More GUI work
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -68,7 +68,8 @@ SettingsWindow::SettingsWindow() : settings{JSONOpenOrCreate("resources/settings
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if(cancel.render()) {
|
||||
if(ImGui::Button("Cancel")) {
|
||||
popup.setOpened(false);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in New Issue
Block a user