More GUI work

This commit is contained in:
irisz64
2025-05-23 15:57:49 +02:00
parent 3b28de6afc
commit 2152a73cce
5 changed files with 27 additions and 5 deletions

View File

@@ -19,6 +19,11 @@ struct MenuItem {
return ret;
}
void setLabel(const std::string& label) { this->label = label; }
const std::string& getLabel() { return label; }
void setFunc(std::function<void()>&& func) { exec = func; }
void setEnabled(bool v) { enabled = v; }
private:
bool enabled = true;

View File

@@ -7,6 +7,22 @@
KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_shared<n64::Core>()), vulkanWidget(core, window.getHandle()), emuThread(core, fpsCounter, vulkanWidget, settingsWindow) {
gui::Initialize(core->parallel.wsi, window.getHandle());
actionPause.setFunc([&]() {
if(ImGui::IsItemClicked()) {
actionPause.setLabel(actionPause.getLabel() == "Pause" ? "Resume" : "Pause");
core->TogglePause();
}
});
actionStop.setFunc([&]() {
if(ImGui::IsItemClicked()) {
actionStop.setEnabled(false);
actionPause.setEnabled(false);
actionReset.setEnabled(false);
core->Stop();
}
});
emuExitFunc = [&]() {
quit = true;
if (emuThread.isRunning) {
@@ -68,10 +84,10 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_sha
void KaizenGui::RenderUI() {
gui::StartFrame();
menuBar.render();
about.render();
statusBar.render();
menuBar.render();
settingsWindow.render();
about.render();
gui::EndFrame();
if (core->render) {

View File

@@ -13,7 +13,7 @@ public:
explicit KaizenGui() noexcept;
double fpsCounter = -1.0;
gui::MenuBar<true> menuBar;
gui::MenuItem actionPause{"Pause"}, actionStop{"Stop"}, actionReset{"Reset"};
gui::MenuItem actionPause{"Pause", nullptr, false}, actionStop{"Stop", nullptr, false}, actionReset{"Reset", nullptr, false};
SettingsWindow settingsWindow;
std::shared_ptr<n64::Core> core;
RenderWidget vulkanWidget;

View File

@@ -68,7 +68,8 @@ SettingsWindow::SettingsWindow() : settings{JSONOpenOrCreate("resources/settings
ImGui::SameLine();
if(cancel.render()) {
if(ImGui::Button("Cancel")) {
popup.setOpened(false);
ImGui::CloseCurrentPopup();
}
});

View File

@@ -8,7 +8,7 @@
#include <memory>
class SettingsWindow final {
gui::PushButton cancel{"Cancel"}, apply{"Apply", "", false}, savesFolder{"Open", "Save path: {}"};
gui::PushButton apply{"Apply", "", false}, savesFolder{"Open", "Save path: {}"};
nlohmann::json settings;
CPUSettings cpuSettings{settings};
AudioSettings audioSettings{settings};