Next try to make the settings modal work
This commit is contained in:
@@ -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;
|
||||
|
||||
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));
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ struct PushButton {
|
||||
|
||||
bool render() {
|
||||
if(name != "") {
|
||||
ImGui::Text(name.c_str());
|
||||
ImGui::Text("%s", name.c_str());
|
||||
ImGui::SameLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 1280, 720), core(std::make_sh
|
||||
actionStop,
|
||||
actionReset,
|
||||
{"Settings", [&]() {
|
||||
settingsWindow.popup.setOpened(true);
|
||||
settingsWindow.render();
|
||||
}},
|
||||
}});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user