diff --git a/src/frontend/SettingsWindow.cpp b/src/frontend/SettingsWindow.cpp index 8c154cff..b30de1f8 100644 --- a/src/frontend/SettingsWindow.cpp +++ b/src/frontend/SettingsWindow.cpp @@ -10,64 +10,66 @@ bool SettingsWindow::render() { ImVec2 center = ImGui::GetMainViewport()->GetCenter(); ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); - if(ImGui::BeginPopupModal("Settings", &isOpen)) { - if(ImGui::BeginTabBar("SettingsTabBar")) { - if(ImGui::BeginTabItem("General")) { - if(ImGui::Button("Pick...")) { - NFD::Guard guard; - NFD::UniquePath outPath; + if(!ImGui::BeginPopupModal("Settings", &isOpen)) + return false; + + if(!ImGui::BeginTabBar("SettingsTabBar")) + return false; - auto result = NFD::PickFolder(outPath); - if(result == NFD_ERROR) - panic("Error: {}", NFD::GetError()); + if(ImGui::BeginTabItem("General")) { + if(ImGui::Button("Pick...")) { + NFD::Guard guard; + NFD::UniquePath outPath; - if(result != NFD_CANCEL) { - savesPath = outPath.get(); - Options::GetInstance().SetValue("general", "savePath", savesPath); - applyEnabled = true; - } - } - ImGui::SameLine(); - ImGui::BeginDisabled(); - ImGui::InputText("Save Path", (char*)savesPath.c_str(), savesPath.length()); - ImGui::EndDisabled(); - ImGui::EndTabItem(); + auto result = NFD::PickFolder(outPath); + if(result == NFD_ERROR) + panic("Error: {}", NFD::GetError()); + + if(result != NFD_CANCEL) { + savesPath = outPath.get(); + Options::GetInstance().SetValue("general", "savePath", savesPath); + applyEnabled = true; } - - if(ImGui::BeginTabItem("Core")) { - if(cpuSettings.render()) { - if(cpuSettings.getModified()) - applyEnabled = true; - } - ImGui::EndTabItem(); - } - - if(ImGui::BeginTabItem("Audio")) { - if(audioSettings.render()) { - if(audioSettings.getModified()) - applyEnabled = true; - } - ImGui::EndTabItem(); - } - - ImGui::EndTabBar(); } - - ImGui::BeginDisabled(!applyEnabled); - if(ImGui::Button("Apply")) { - applyEnabled = false; - Options::GetInstance().Apply(); - } - ImGui::EndDisabled(); - ImGui::SameLine(); - - if(ImGui::Button("Cancel")) { - isOpen = false; - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); + ImGui::BeginDisabled(); + ImGui::InputText("Save Path", (char*)savesPath.c_str(), savesPath.length()); + ImGui::EndDisabled(); + ImGui::EndTabItem(); } + if(ImGui::BeginTabItem("Core")) { + if(cpuSettings.render()) { + if(cpuSettings.getModified()) + applyEnabled = true; + } + ImGui::EndTabItem(); + } + + if(ImGui::BeginTabItem("Audio")) { + if(audioSettings.render()) { + if(audioSettings.getModified()) + applyEnabled = true; + } + ImGui::EndTabItem(); + } + + ImGui::EndTabBar(); + + ImGui::BeginDisabled(!applyEnabled); + if(ImGui::Button("Apply")) { + applyEnabled = false; + Options::GetInstance().Apply(); + } + ImGui::EndDisabled(); + + ImGui::SameLine(); + + if(ImGui::Button("Cancel")) { + isOpen = false; + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + return true; } \ No newline at end of file