diff --git a/main/include/window.hpp b/main/include/window.hpp index ee6efbf51..1c5901e14 100644 --- a/main/include/window.hpp +++ b/main/include/window.hpp @@ -52,6 +52,8 @@ namespace hex { std::list m_popupsToOpen; std::vector m_pressedKeys; + + fs::path m_imguiSettingsPath; }; } \ No newline at end of file diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index f1a7db83f..350626a7c 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -720,14 +720,16 @@ namespace hex { handler.UserData = this; ImGui::GetCurrentContext()->SettingsHandlers.push_back(handler); - static std::string iniFileName; for (const auto &dir : hex::getPath(ImHexPath::Config)) { if (std::filesystem::exists(dir)) { - iniFileName = (dir / "interface.ini").string(); + this->m_imguiSettingsPath = dir / "interface.ini"; break; } } - io.IniFilename = iniFileName.c_str(); + io.IniFilename = nullptr; + + if (!this->m_imguiSettingsPath.empty() && fs::exists(this->m_imguiSettingsPath)) + ImGui::LoadIniSettingsFromDisk(this->m_imguiSettingsPath.string().c_str()); ImGui_ImplGlfw_InitForOpenGL(this->m_window, true); @@ -748,6 +750,8 @@ namespace hex { ImNodes::PopAttributeFlag(); ImNodes::PopAttributeFlag(); + ImGui::SaveIniSettingsToDisk(this->m_imguiSettingsPath.string().c_str()); + ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); ImNodes::DestroyContext();