Structure settings better

This commit is contained in:
irisz64
2025-12-15 09:37:10 +01:00
parent 9a1089b70e
commit 8f787522bb
9 changed files with 60 additions and 55 deletions

View File

@@ -4,38 +4,6 @@
#include <imgui.h>
#include <ranges>
void GeneralTab::render() {
if(ImGui::Button("Pick...")) {
SDL_ShowOpenFolderDialog([](void *userdata, const char * const *filelist, int _) {
auto* general = static_cast<GeneralTab*>(userdata);
auto& settings = general->settingsWindow;
if (!filelist) {
panic("An error occurred: {}", SDL_GetError());
}
if (!*filelist) {
warn("The user did not select any file.");
warn("Most likely, the dialog was canceled.");
general->modified = false;
return;
}
settings.savesPath = *filelist;
Options::GetInstance().SetValue<std::string>("general", "savePath", settings.savesPath);
general->modified = true;
}, this, settingsWindow.window.getHandle(), nullptr, false);
}
ImGui::SameLine();
ImGui::BeginDisabled();
ImGui::InputText("Save Path", const_cast<char*>(settingsWindow.savesPath.c_str()), settingsWindow.savesPath.length());
ImGui::EndDisabled();
}
SettingsWindow::SettingsWindow(gui::NativeWindow& window) : window(window) {
savesPath = Options::GetInstance().GetValue<std::string>("general", "savePath");
}
bool SettingsWindow::render() {
const ImVec2 center = ImGui::GetMainViewport()->GetCenter();
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));