Next try to make the settings modal work

This commit is contained in:
SimoZ64
2025-05-22 23:39:05 +02:00
parent ca21e57835
commit 1de29dd76d
5 changed files with 10 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
#include <imgui.h>
#include <string>
#include <functional>
#include <utils/log.hpp>
namespace gui {
struct PopupWindow {
@@ -15,7 +16,10 @@ struct PopupWindow {
bool render() {
if(!opened)
return false;
ImGui::OpenPopup(title.c_str());
if (!ImGui::IsPopupOpen(title.c_str()))
ImGui::OpenPopup(title.c_str());
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));

View File

@@ -8,7 +8,7 @@ struct PushButton {
bool render() {
if(name != "") {
ImGui::Text(name.c_str());
ImGui::Text("%s", name.c_str());
ImGui::SameLine();
}

View File

@@ -48,6 +48,7 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 1280, 720), core(std::make_sh
actionStop,
actionReset,
{"Settings", [&]() {
settingsWindow.popup.setOpened(true);
settingsWindow.render();
}},
}});

View File

@@ -52,7 +52,7 @@ SettingsWindow::SettingsWindow() : settings{JSONOpenOrCreate("resources/settings
apply.setEnabled(false);
canvas.setFunc([&]() {
popup.setFunc([&]() {
tabs.render();
if(apply.render()) {
@@ -69,7 +69,7 @@ SettingsWindow::SettingsWindow() : settings{JSONOpenOrCreate("resources/settings
}
bool SettingsWindow::render() {
if(canvas.render())
if(popup.render())
return true;
return false;

View File

@@ -9,12 +9,12 @@
class SettingsWindow final {
gui::PushButton cancel{"Cancel"}, apply{"Apply", "", false}, savesFolder{"Open", "Save path: {}"};
gui::PopupWindow canvas{"Settings"};
nlohmann::json settings;
CPUSettings cpuSettings{settings};
AudioSettings audioSettings{settings};
InputSettings inputSettings{settings};
public:
gui::PopupWindow popup{"Settings"};
bool render();
SettingsWindow();
[[nodiscard]] float getVolumeL() const { return audioSettings.volumeL.getValue() / 100.f; }