More GUI work
This commit is contained in:
@@ -19,6 +19,11 @@ struct MenuItem {
|
|||||||
return ret;
|
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; }
|
void setEnabled(bool v) { enabled = v; }
|
||||||
private:
|
private:
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
|
|||||||
@@ -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) {
|
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());
|
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 = [&]() {
|
emuExitFunc = [&]() {
|
||||||
quit = true;
|
quit = true;
|
||||||
if (emuThread.isRunning) {
|
if (emuThread.isRunning) {
|
||||||
@@ -68,10 +84,10 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 800, 600), core(std::make_sha
|
|||||||
|
|
||||||
void KaizenGui::RenderUI() {
|
void KaizenGui::RenderUI() {
|
||||||
gui::StartFrame();
|
gui::StartFrame();
|
||||||
menuBar.render();
|
|
||||||
about.render();
|
|
||||||
statusBar.render();
|
statusBar.render();
|
||||||
|
menuBar.render();
|
||||||
settingsWindow.render();
|
settingsWindow.render();
|
||||||
|
about.render();
|
||||||
gui::EndFrame();
|
gui::EndFrame();
|
||||||
|
|
||||||
if (core->render) {
|
if (core->render) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
explicit KaizenGui() noexcept;
|
explicit KaizenGui() noexcept;
|
||||||
double fpsCounter = -1.0;
|
double fpsCounter = -1.0;
|
||||||
gui::MenuBar<true> menuBar;
|
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;
|
SettingsWindow settingsWindow;
|
||||||
std::shared_ptr<n64::Core> core;
|
std::shared_ptr<n64::Core> core;
|
||||||
RenderWidget vulkanWidget;
|
RenderWidget vulkanWidget;
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ SettingsWindow::SettingsWindow() : settings{JSONOpenOrCreate("resources/settings
|
|||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if(cancel.render()) {
|
if(ImGui::Button("Cancel")) {
|
||||||
|
popup.setOpened(false);
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class SettingsWindow final {
|
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;
|
nlohmann::json settings;
|
||||||
CPUSettings cpuSettings{settings};
|
CPUSettings cpuSettings{settings};
|
||||||
AudioSettings audioSettings{settings};
|
AudioSettings audioSettings{settings};
|
||||||
|
|||||||
Reference in New Issue
Block a user