diff --git a/AsuroTool/ApplicationData.cpp b/AsuroTool/ApplicationData.cpp index 4f9c70f..a6b26fb 100644 --- a/AsuroTool/ApplicationData.cpp +++ b/AsuroTool/ApplicationData.cpp @@ -26,7 +26,11 @@ AudioDevice::AudioDevice(IMMDevice* device, LPCWSTR deviceId) : device(device) err = device->Activate(__uuidof(IAudioMeterInformation), CLSCTX_INPROC_SERVER, NULL, (LPVOID*)&meterInterface); isError(err, "Failed to get audio meter interface: "); - getVolumeLimit(volumeInterface, &minVolumeDb, &maxVolumeDb); + if (volumeInterface != nullptr && meterInterface != nullptr) + { + getVolumeLimit(volumeInterface, &minVolumeDb, &maxVolumeDb); + isInitialized = true; + } if (propertyStore) { diff --git a/AsuroTool/ApplicationData.h b/AsuroTool/ApplicationData.h index 93d9f7e..2123cc9 100644 --- a/AsuroTool/ApplicationData.h +++ b/AsuroTool/ApplicationData.h @@ -12,6 +12,7 @@ class AudioDevice { public: + bool isInitialized = false; IMMDevice* device = nullptr; IAudioEndpointVolume* volumeInterface = nullptr; IAudioMeterInformation* meterInterface = nullptr; @@ -52,6 +53,7 @@ public: std::vector taskNames = {}; std::unordered_map> tasks = {}; std::vector baseStationMacAdresses = {}; + bool baseStationShowConsole; float timerDuration = 5.f * 60.f; float timerRepeatDuration = 2.f * 60.f; bool timerRepeating = false; diff --git a/AsuroTool/AsuroTool.cpp b/AsuroTool/AsuroTool.cpp index e558df2..56f8353 100644 --- a/AsuroTool/AsuroTool.cpp +++ b/AsuroTool/AsuroTool.cpp @@ -363,7 +363,6 @@ ImVec2 timerWindow(DrawData& drawData, ApplicationData& appData) ImGui::OpenPopup(SETTINGS_POPUP_NAME); } - float timerDisplayMinutes = appData.settings.timerDuration / 60.f; if (timerData.isTimerActive) @@ -529,7 +528,7 @@ ImVec2 checklistWindow(ApplicationData& appData, const char* title) double timeDiffSeconds = difftime(today, getDayStartOf(mostRecentDoneDate)); int timeDiffDays = timeDiffSeconds / (60 * 60 * 24); - bool highlightButton = timeDiffDays >= appData.checklistHighlightDurationDays; + bool highlightButton = timeDiffDays > appData.checklistHighlightDurationDays; if (highlightButton) { ImGui::PushStyleColor(ImGuiCol_FrameBg, { .5f, .2f, .15f, 0.54f }); @@ -580,7 +579,7 @@ ImVec2 checklistWindow(ApplicationData& appData, const char* title) return size; } -void startBaseStationProc(const char* args) +void startBaseStationProc(const char* args, DWORD flags = 0) { // additional information STARTUPINFOA si; @@ -592,11 +591,7 @@ void startBaseStationProc(const char* args) ZeroMemory(&pi, sizeof(pi)); // start the program up - DWORD creationFlags = 0; -#ifdef _DEBUG - creationFlags = CREATE_NEW_CONSOLE; -#endif - CreateProcessA("lighthouse-v2-manager.exe", const_cast(args), NULL, NULL, FALSE, creationFlags, NULL, NULL, &si, &pi); + CreateProcessA("lighthouse-v2-manager.exe", const_cast(args), NULL, NULL, FALSE, flags, NULL, NULL, &si, &pi); // Close process and thread handles. CloseHandle(pi.hProcess); @@ -620,7 +615,7 @@ ImVec2 baseStationWindow(ApplicationData& appData) params.append(" "); params.append(mac.c_str()); } - startBaseStationProc(params.c_str()); + startBaseStationProc(params.c_str(), appData.settings.baseStationShowConsole ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW); } ImGui::SameLine(); if (ImGui::Button("Shutdown")) @@ -631,12 +626,13 @@ ImVec2 baseStationWindow(ApplicationData& appData) params.append(" "); params.append(mac.c_str()); } - startBaseStationProc(params.c_str()); + startBaseStationProc(params.c_str(), appData.settings.baseStationShowConsole ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW); } } if (ImGui::BeginPopup(SETTINGS_POPUP_NAME)) { + ImGui::Checkbox("Show Console", &appData.settings.baseStationShowConsole); if (ImGui::Button("Search")) { startBaseStationProc("discover"); diff --git a/AsuroTool/AudioApi.cpp b/AsuroTool/AudioApi.cpp index 205edb3..1816adb 100644 --- a/AsuroTool/AudioApi.cpp +++ b/AsuroTool/AudioApi.cpp @@ -92,7 +92,10 @@ void loadAudioDevices(AudioData& audioData, std::vector& deviceList audioDevice.isDefaultCommunication = wcscmp(defaultCommunicationId, deviceId) == 0; } - deviceList.push_back(std::move(audioDevice)); + if (audioDevice.isInitialized) + { + deviceList.push_back(std::move(audioDevice)); + } } CoTaskMemFree(deviceId); diff --git a/AsuroTool/Settings.cpp b/AsuroTool/Settings.cpp index 438b8e6..02a29a6 100644 --- a/AsuroTool/Settings.cpp +++ b/AsuroTool/Settings.cpp @@ -76,6 +76,13 @@ void settingsReadLine(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* en settings->baseStationMacAdresses.push_back(baseStationMac); } + // baseStationShowConsole + int baseStationShowConsole; + if (sscanf_s(line, "baseStationShowConsole=%i", &baseStationShowConsole)) + { + settings->baseStationShowConsole = (bool)baseStationShowConsole; + } + float timerDuration; if (sscanf_s(line, "timerDuration=%f", &timerDuration)) { diff --git a/AsuroTool/WindowsShell.cpp b/AsuroTool/WindowsShell.cpp index 89bbdce..fd9ff41 100644 --- a/AsuroTool/WindowsShell.cpp +++ b/AsuroTool/WindowsShell.cpp @@ -84,13 +84,15 @@ void initShell(DrawData& drawData) void showToastNotification(TimerToastHandler* handler, const wchar_t* title, const wchar_t* text) { - WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText02); + WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageAndText01); + templ.setScenario(WinToastTemplate::Scenario::Alarm); templ.setImagePath(L"E:\\Code\\AsuroImgui\\x64\\Debug\\kaiju.ico"); templ.setTextField(title, WinToastTemplate::FirstLine); - templ.setTextField(text, WinToastTemplate::SecondLine); + templ.setAttributionText(text); templ.addAction(L"Stop"); + templ.addAction(L"Dismiss"); if (!WinToast::instance()->showToast(templ, handler)) { - OutputDebugString(L"Error: Could not launch your toast notification!\n"); + OutputDebugString(L"Error: Could not launch toast!\n"); } }