Settings widget mostly works
This commit is contained in:
4
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
4
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
@@ -7,6 +7,7 @@
|
|||||||
#include <resources/frag.spv.h>
|
#include <resources/frag.spv.h>
|
||||||
#include <KaizenGui.hpp>
|
#include <KaizenGui.hpp>
|
||||||
#include <imgui_impl_vulkan.h>
|
#include <imgui_impl_vulkan.h>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
using namespace Vulkan;
|
using namespace Vulkan;
|
||||||
using namespace RDP;
|
using namespace RDP;
|
||||||
@@ -158,7 +159,10 @@ void ParallelRDP::DrawFullscreenTexturedQuad(Util::IntrusivePtr<Image> image,
|
|||||||
cmd->draw(3, 1);
|
cmd->draw(3, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::mutex coreM;
|
||||||
|
|
||||||
void ParallelRDP::UpdateScreen(Util::IntrusivePtr<Image> image) const {
|
void ParallelRDP::UpdateScreen(Util::IntrusivePtr<Image> image) const {
|
||||||
|
std::lock_guard<std::mutex> coreLock(coreM);
|
||||||
wsi->begin_frame();
|
wsi->begin_frame();
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
|
|||||||
@@ -20,4 +20,6 @@ bool CPUSettings::render() {
|
|||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return modified;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
struct ComboItem {
|
struct ComboItem {
|
||||||
ComboItem(std::string label, bool enabled = true) : enabled(enabled) {}
|
ComboItem(const std::string& label, bool enabled = true) : enabled(enabled), label(label) {}
|
||||||
|
|
||||||
bool render(bool is_selected) {
|
bool render(bool is_selected) {
|
||||||
ImGui::BeginDisabled(!enabled);
|
ImGui::BeginDisabled(!enabled);
|
||||||
@@ -22,7 +22,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Combobox {
|
struct Combobox {
|
||||||
Combobox(std::string label, std::vector<ComboItem> items, std::string preview = "", bool enabled = true) : label(label), items(items), preview(preview), enabled(enabled) {}
|
Combobox(const std::string& label, const std::vector<ComboItem>& items, const std::string& preview = "", bool enabled = true) : label(label), items(items), preview(preview), enabled(enabled) {}
|
||||||
|
|
||||||
void addItem(const ComboItem& item) {
|
void addItem(const ComboItem& item) {
|
||||||
if(std::find_if(items.begin(), items.end(),
|
if(std::find_if(items.begin(), items.end(),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
struct TabItem {
|
struct TabItem {
|
||||||
TabItem(std::string label, std::function<void()>&& func, bool enabled = true) : exec(std::move(func)), enabled(enabled) {}
|
TabItem(const std::string& label, std::function<void()>&& func, bool enabled = true) : exec(std::move(func)), enabled(enabled), label(label) {}
|
||||||
|
|
||||||
bool render() {
|
bool render() {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@@ -28,7 +28,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct TabBar {
|
struct TabBar {
|
||||||
TabBar(std::string label, const std::vector<TabItem>& items = {}) : label(label), tabs(items) {}
|
TabBar(const std::string& label, const std::vector<TabItem>& items = {}) : label(label), tabs(items) {}
|
||||||
void addTab(TabItem tabItem) { tabs.push_back(tabItem); }
|
void addTab(TabItem tabItem) { tabs.push_back(tabItem); }
|
||||||
|
|
||||||
bool render() {
|
bool render() {
|
||||||
|
|||||||
@@ -3,8 +3,10 @@
|
|||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
InputSettings::InputSettings(nlohmann::json &settings) : settings(settings) {
|
InputSettings::InputSettings(nlohmann::json &settings) : settings(settings) {
|
||||||
|
int i = 0;
|
||||||
for(auto& kb : kbButtons) {
|
for(auto& kb : kbButtons) {
|
||||||
kb.setLabel(JSONGetField<std::string>(settings, "input", kb.getName()));
|
auto field = JSONGetField<std::string>(settings, "input", kb.getName());
|
||||||
|
kb.setLabel(field != "" ? field : "##unsetButton" + std::to_string(i++));
|
||||||
}
|
}
|
||||||
|
|
||||||
devices.addItem({"Keyboard/Mouse"});
|
devices.addItem({"Keyboard/Mouse"});
|
||||||
@@ -33,13 +35,13 @@ bool InputSettings::render() {
|
|||||||
QueryDevices();
|
QueryDevices();
|
||||||
PollGamepad();
|
PollGamepad();
|
||||||
|
|
||||||
if(i % 2 != 0) // only go down every 2 buttons... just... i like it this way
|
if((i % 2 == 0) || i == 0) // only go down every 2 buttons... just... i like it this way
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<SDL_Keycode, 18> InputSettings::GetMappedKeys() {
|
std::array<SDL_Keycode, 18> InputSettings::GetMappedKeys() {
|
||||||
|
|||||||
@@ -4,10 +4,15 @@
|
|||||||
#include <ImGuiImpl/StatusBar.hpp>
|
#include <ImGuiImpl/StatusBar.hpp>
|
||||||
#include <ImGuiImpl/GUI.hpp>
|
#include <ImGuiImpl/GUI.hpp>
|
||||||
|
|
||||||
KaizenGui::KaizenGui() noexcept : window("Kaizen", 1280, 720), 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());
|
||||||
|
|
||||||
emuExitFunc = [&]() {
|
emuExitFunc = [&]() {
|
||||||
|
quit = true;
|
||||||
|
if (emuThread.isRunning) {
|
||||||
|
emuThread.requestInterruption();
|
||||||
|
while (emuThread.isRunning) {}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
about.setFunc([&]() {
|
about.setFunc([&]() {
|
||||||
@@ -17,6 +22,7 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 1280, 720), core(std::make_sh
|
|||||||
ImGui::Text("Nintendo 64 is a registered trademark of Nintendo Co., Ltd.");
|
ImGui::Text("Nintendo 64 is a registered trademark of Nintendo Co., Ltd.");
|
||||||
if(ImGui::Button("OK")) {
|
if(ImGui::Button("OK")) {
|
||||||
about.setOpened(false);
|
about.setOpened(false);
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -49,7 +55,6 @@ KaizenGui::KaizenGui() noexcept : window("Kaizen", 1280, 720), core(std::make_sh
|
|||||||
actionReset,
|
actionReset,
|
||||||
{"Settings", [&]() {
|
{"Settings", [&]() {
|
||||||
settingsWindow.popup.setOpened(true);
|
settingsWindow.popup.setOpened(true);
|
||||||
settingsWindow.render();
|
|
||||||
}},
|
}},
|
||||||
}});
|
}});
|
||||||
|
|
||||||
@@ -66,6 +71,7 @@ void KaizenGui::RenderUI() {
|
|||||||
menuBar.render();
|
menuBar.render();
|
||||||
about.render();
|
about.render();
|
||||||
statusBar.render();
|
statusBar.render();
|
||||||
|
settingsWindow.render();
|
||||||
gui::EndFrame();
|
gui::EndFrame();
|
||||||
|
|
||||||
if (core->render) {
|
if (core->render) {
|
||||||
@@ -85,25 +91,10 @@ void KaizenGui::LoadROM(const std::string &path) noexcept {
|
|||||||
Util::RPC::GetInstance().Update(Util::RPC::Playing, gameNameDB);
|
Util::RPC::GetInstance().Update(Util::RPC::Playing, gameNameDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KaizenGui::handleEvents() {
|
|
||||||
SDL_Event e;
|
|
||||||
while(SDL_PollEvent(&e)) {
|
|
||||||
switch(e.type) {
|
|
||||||
case SDL_EVENT_QUIT:
|
|
||||||
emuExitFunc();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int KaizenGui::run() {
|
int KaizenGui::run() {
|
||||||
while(!quit) {
|
while(!quit) {
|
||||||
if(vulkanWidget.wsiPlatform->quitRequested) {
|
if(vulkanWidget.wsiPlatform->quitRequested) {
|
||||||
quit = true;
|
emuExitFunc();
|
||||||
if (emuThread.isRunning) {
|
|
||||||
emuThread.requestInterruption();
|
|
||||||
while (emuThread.isRunning) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderUI();
|
RenderUI();
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ SettingsWindow::SettingsWindow() : settings{JSONOpenOrCreate("resources/settings
|
|||||||
file << settings;
|
file << settings;
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
if(cancel.render()) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class SettingsWindow final {
|
|||||||
AudioSettings audioSettings{settings};
|
AudioSettings audioSettings{settings};
|
||||||
InputSettings inputSettings{settings};
|
InputSettings inputSettings{settings};
|
||||||
public:
|
public:
|
||||||
gui::PopupWindow popup{"Settings"};
|
gui::PopupWindow popup{"Emulator Settings"};
|
||||||
bool render();
|
bool render();
|
||||||
SettingsWindow();
|
SettingsWindow();
|
||||||
[[nodiscard]] float getVolumeL() const { return audioSettings.volumeL.getValue() / 100.f; }
|
[[nodiscard]] float getVolumeL() const { return audioSettings.volumeL.getValue() / 100.f; }
|
||||||
|
|||||||
Reference in New Issue
Block a user