fix: imgui.ini file being created in the working directory sometimes
Fixes #450
This commit is contained in:
parent
75bd7805c9
commit
bdb2ac3a0b
@ -52,6 +52,8 @@ namespace hex {
|
|||||||
|
|
||||||
std::list<std::string> m_popupsToOpen;
|
std::list<std::string> m_popupsToOpen;
|
||||||
std::vector<int> m_pressedKeys;
|
std::vector<int> m_pressedKeys;
|
||||||
|
|
||||||
|
fs::path m_imguiSettingsPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -720,14 +720,16 @@ namespace hex {
|
|||||||
handler.UserData = this;
|
handler.UserData = this;
|
||||||
ImGui::GetCurrentContext()->SettingsHandlers.push_back(handler);
|
ImGui::GetCurrentContext()->SettingsHandlers.push_back(handler);
|
||||||
|
|
||||||
static std::string iniFileName;
|
|
||||||
for (const auto &dir : hex::getPath(ImHexPath::Config)) {
|
for (const auto &dir : hex::getPath(ImHexPath::Config)) {
|
||||||
if (std::filesystem::exists(dir)) {
|
if (std::filesystem::exists(dir)) {
|
||||||
iniFileName = (dir / "interface.ini").string();
|
this->m_imguiSettingsPath = dir / "interface.ini";
|
||||||
break;
|
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);
|
ImGui_ImplGlfw_InitForOpenGL(this->m_window, true);
|
||||||
|
|
||||||
@ -748,6 +750,8 @@ namespace hex {
|
|||||||
ImNodes::PopAttributeFlag();
|
ImNodes::PopAttributeFlag();
|
||||||
ImNodes::PopAttributeFlag();
|
ImNodes::PopAttributeFlag();
|
||||||
|
|
||||||
|
ImGui::SaveIniSettingsToDisk(this->m_imguiSettingsPath.string().c_str());
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfw_Shutdown();
|
||||||
ImNodes::DestroyContext();
|
ImNodes::DestroyContext();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user