From 51270dd3904236cabfe22af2548d78e971fff68e Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 4 Jun 2024 10:52:30 +0200 Subject: [PATCH] Store imgui.ini and user.imstyle in dhewm3 config dir instead of $PWD --- neo/sys/imgui_savestyle.cpp | 3 ++- neo/sys/sys_imgui.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/neo/sys/imgui_savestyle.cpp b/neo/sys/imgui_savestyle.cpp index 93734fce..46cbe660 100644 --- a/neo/sys/imgui_savestyle.cpp +++ b/neo/sys/imgui_savestyle.cpp @@ -313,7 +313,8 @@ bool ReadImGuiStyle( ImGuiStyle& s, const char* filename ) { FILE* f = DG_IMSAVESTYLE_FOPEN( filename, "r" ); // TODO: "rt" on Windows? if ( f == nullptr ) { - warnPrintf( "Couldn't open '%s' for reading\n", filename ); + // DG: shut up this warning, user don't *have* to write their own style + //warnPrintf( "Couldn't open '%s' for reading\n", filename ); return false; } diff --git a/neo/sys/sys_imgui.cpp b/neo/sys/sys_imgui.cpp index 1babc55b..18102dc7 100644 --- a/neo/sys/sys_imgui.cpp +++ b/neo/sys/sys_imgui.cpp @@ -73,8 +73,9 @@ static ImVec2 warningOverlayStartPos; idStr GetUserStyleFilename() { - // TODO: put this into the config dir - return idStr( "user.imstyle" ); + idStr ret( cvarSystem->GetCVarString( "fs_configpath" ) ); + ret += "/user.imstyle"; + return ret; } static void UpdateWarningOverlay() @@ -227,10 +228,15 @@ bool Init(void* _sdlWindow, void* sdlGlContext) common->Warning( "Failed to create ImGui Context!\n" ); return false; } - ImGuiIO& io = ImGui::GetIO(); (void)io; + ImGuiIO& io = ImGui::GetIO(); io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls + static idStr iniPath; + iniPath = cvarSystem->GetCVarString( "fs_configpath" ); + iniPath += "/imgui.ini"; + io.IniFilename = iniPath.c_str(); + SetImGuiStyle( Style::Dhewm3 ); userStyle = ImGui::GetStyle(); // set dhewm3 style as default, in case the user style is missing values if ( DG::ReadImGuiStyle( userStyle, GetUserStyleFilename() ) && imgui_style.GetInteger() == 2 ) {