autostart + more cleanup
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "Util.h"
|
||||
#include "AudioApi.h"
|
||||
#include "Settings.h"
|
||||
#include "resource.h"
|
||||
#include "AsuroTool.h"
|
||||
|
||||
@@ -41,7 +42,7 @@ int main()
|
||||
callbacks.drawFunc = std::bind(draw, std::placeholders::_1, std::ref(applicationData));
|
||||
callbacks.cleanupFunc = std::bind(cleanup, std::placeholders::_1, std::ref(applicationData));
|
||||
|
||||
startImgui(callbacks, "Asuro's Tool", 600, 400);
|
||||
startImgui(callbacks, "Audio Thingy", 600, 400);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK trayIconEventHandler(int code, WPARAM wParam, LPARAM lParam)
|
||||
@@ -132,15 +133,7 @@ void init(DrawData& drawData, ApplicationData& appData)
|
||||
});
|
||||
|
||||
// Load settings
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "ApplicationSettings";
|
||||
ini_handler.TypeHash = ImHashStr("ApplicationSettings");
|
||||
ini_handler.ReadOpenFn = settingsReadOpen;
|
||||
ini_handler.ReadLineFn = settingsReadLine;
|
||||
ini_handler.WriteAllFn = settingsWriteAll;
|
||||
GImGui->SettingsHandlers.push_back(ini_handler);
|
||||
ImGui::LoadIniSettingsFromDisk("imgui.ini");
|
||||
updateSettings(drawData, appData);
|
||||
initSettings(drawData, appData);
|
||||
|
||||
// Set up audio device api
|
||||
HRESULT audioResult;
|
||||
@@ -228,6 +221,12 @@ ImVec2 menuBar(DrawData& drawData, ApplicationData& appData)
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Show Disabled Devices", &appData.settings.showDisabledDevices);
|
||||
|
||||
if (ImGui::Checkbox("Autostart", &appData.settings.autostart))
|
||||
{
|
||||
setAutostart(appData.settings.autostart);
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
@@ -334,11 +333,11 @@ ImVec2 audioDeviceWindow(ApplicationData& appData, std::vector<AudioDevice>& dev
|
||||
ImVec2 cursorPos = ImGui::GetCursorScreenPos();
|
||||
ImVec2 space = ImGui::GetContentRegionAvail();
|
||||
float lineY = cursorPos.y + ImGui::GetTextLineHeight() / 2. + 2.;
|
||||
|
||||
|
||||
const float linePaddingX = 3.;
|
||||
cursorPos.x += linePaddingX;
|
||||
|
||||
drawList->AddLine(ImVec2(cursorPos.x, lineY), ImVec2(cursorPos.x + (space.x - 2. * linePaddingX) , lineY), IM_COL32(120, 120, 120, 255), 2.);
|
||||
drawList->AddLine(ImVec2(cursorPos.x, lineY), ImVec2(cursorPos.x + (space.x - 2. * linePaddingX), lineY), IM_COL32(120, 120, 120, 255), 2.);
|
||||
drawList->AddLine(ImVec2(cursorPos.x, lineY), ImVec2(cursorPos.x + (space.x - 2. * linePaddingX) * meterValue, lineY), IM_COL32(200, 200, 255, 255), 3.);
|
||||
|
||||
float volume = getVolume(dev.volumeInterface);
|
||||
@@ -401,43 +400,3 @@ void drawCircle(float radius, ImU32 color)
|
||||
ImVec2 windowPos = ImGui::GetWindowPos();
|
||||
drawList->AddCircleFilled(ImVec2(cursorPos.x + windowPos.x, cursorPos.y + windowPos.y + ImGui::GetTextLineHeight() / 2.), radius, color);
|
||||
}
|
||||
|
||||
void updateSettings(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
updateDocked(drawData, appData);
|
||||
}
|
||||
|
||||
void updateDocked(DrawData& drawData, ApplicationData& appData)
|
||||
{
|
||||
justDocked = true;
|
||||
|
||||
glfwSetWindowAttrib(drawData.window, GLFW_DECORATED, !appData.settings.docked);
|
||||
ShowWindow(drawData.window_handle, SW_HIDE);
|
||||
SetWindowLongPtr(drawData.window_handle, GWL_EXSTYLE, appData.settings.docked ? WS_EX_TOOLWINDOW : 0);
|
||||
ShowWindow(drawData.window_handle, SW_SHOW);
|
||||
}
|
||||
|
||||
void* settingsReadOpen(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name)
|
||||
{
|
||||
ApplicationSettings* settings = &hackyAppData->settings;
|
||||
*settings = ApplicationSettings();
|
||||
return (void*)settings;
|
||||
}
|
||||
|
||||
void settingsReadLine(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line)
|
||||
{
|
||||
ApplicationSettings* settings = (ApplicationSettings*)entry;
|
||||
|
||||
int docked;
|
||||
if (sscanf_s(line, "docked=%i", &docked))
|
||||
{
|
||||
settings->docked = (bool)docked;
|
||||
}
|
||||
}
|
||||
|
||||
void settingsWriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* outBuf)
|
||||
{
|
||||
outBuf->appendf("[%s][%s]\n", "ApplicationSettings", "ApplicationSettings");
|
||||
outBuf->appendf("docked=%i\n", (int)hackyAppData->settings.docked);
|
||||
outBuf->append("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user