From 4b9b26f8af67b395ed74518536919f584de22fa1 Mon Sep 17 00:00:00 2001 From: iris Date: Thu, 4 Jun 2026 17:30:41 +0200 Subject: [PATCH] more work --- CMakeLists.txt | 1 - src/frontend/EmuThread.hpp | 21 +++++------ src/frontend/KaizenGui.cpp | 27 ++++++++------ src/frontend/KaizenGui.hpp | 2 +- src/frontend/RenderWidget.hpp | 1 + src/frontend/Settings/AudioSettings.cpp | 14 ++++--- src/frontend/Settings/AudioSettings.hpp | 4 +- src/frontend/Settings/CPUSettings.cpp | 45 ++++++++++++++++------- src/frontend/Settings/CPUSettings.hpp | 9 ++--- src/frontend/Settings/GeneralSettings.cpp | 28 ++++++++------ src/frontend/Settings/GeneralSettings.hpp | 10 ++--- src/frontend/SettingsWindow.cpp | 12 +++--- src/frontend/SettingsWindow.hpp | 5 ++- 13 files changed, 104 insertions(+), 75 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dff5683..90600d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,6 @@ add_subdirectory(external/parallel-rdp) add_subdirectory(external/unarr) add_subdirectory(external/SDL) add_subdirectory(external/cflags) -add_subdirectory(external/mINI) set(CAPSTONE_ARCHITECTURE_DEFAULT OFF) set(CAPSTONE_MIPS_SUPPORT ON) set(CAPSTONE_X86_SUPPORT ON) diff --git a/src/frontend/EmuThread.hpp b/src/frontend/EmuThread.hpp index 6172867..c4f1bcb 100644 --- a/src/frontend/EmuThread.hpp +++ b/src/frontend/EmuThread.hpp @@ -8,16 +8,15 @@ struct Core; } class EmuThread final { - bool started = false; -public: - explicit EmuThread(double &, SettingsWindow &) noexcept; - ~EmuThread() = default; - void run() const noexcept; - void TogglePause() const noexcept; - void Reset() const noexcept; - void Stop() const noexcept; + bool started = false; - bool interruptionRequested = false, parallelRDPInitialized = false; - SettingsWindow &settings; - double& fps; + public: + explicit EmuThread() noexcept; + ~EmuThread() = default; + void run() const noexcept; + void TogglePause() const noexcept; + void Reset() const noexcept; + void Stop() const noexcept; + + bool interruptionRequested = false, parallelRDPInitialized = false; }; diff --git a/src/frontend/KaizenGui.cpp b/src/frontend/KaizenGui.cpp index dd6700e..f176482 100644 --- a/src/frontend/KaizenGui.cpp +++ b/src/frontend/KaizenGui.cpp @@ -1,23 +1,26 @@ #include #include -#include -#include -#include +#include +#include #include -KaizenGui::KaizenGui() noexcept : - window("Kaizen " KAIZEN_VERSION_STR, 1280, 720), settingsWindow(window), vulkanWidget(window.getHandle()), - emuThread(fpsCounter, settingsWindow) { - gui::Initialize(n64::Core::GetInstance().parallel.wsi, window.getHandle()); +KaizenGui::KaizenGui() noexcept : vulkanWidget(windowHandle()) { SDL_InitSubSystem(SDL_INIT_GAMEPAD); + auto fileMenu = menuBar()->addMenu("File"); + auto open = fileMenu->addMenu("Open"); + auto exit = fileMenu->addMenu("Exit"); + auto emulationMenu = menuBar()->addMenu("Emulation"); + auto settingsMenu = emulationMenu->addMenu("Settings"); + connect(settingsMenu, &QMenu::triggered, this, [&] { settingsWindow.show(); }); - SDL_AddGamepadMapping(gamecontrollerdb_str); + emulationMenu->addSeparator(); + auto pause = emulationMenu->addMenu("Pause"); + auto reset = emulationMenu->addMenu("Reset"); + auto stop = emulationMenu->addMenu("Stop"); + auto helpMenu = menuBar()->addMenu("Help"); } -KaizenGui::~KaizenGui() { - gui::Cleanup(); - SDL_Quit(); -} +KaizenGui::~KaizenGui() { SDL_Quit(); } void KaizenGui::QueryDevices(const SDL_Event &event) { switch (event.type) { diff --git a/src/frontend/KaizenGui.hpp b/src/frontend/KaizenGui.hpp index 4bedf1c..63d8d2d 100644 --- a/src/frontend/KaizenGui.hpp +++ b/src/frontend/KaizenGui.hpp @@ -1,8 +1,8 @@ #pragma once +#include #include #include #include -#include class KaizenGui final : QMainWindow { public: diff --git a/src/frontend/RenderWidget.hpp b/src/frontend/RenderWidget.hpp index 7b4c6f1..c0387d4 100644 --- a/src/frontend/RenderWidget.hpp +++ b/src/frontend/RenderWidget.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include struct InputSettings; diff --git a/src/frontend/Settings/AudioSettings.cpp b/src/frontend/Settings/AudioSettings.cpp index 01b303c..f10938e 100644 --- a/src/frontend/Settings/AudioSettings.cpp +++ b/src/frontend/Settings/AudioSettings.cpp @@ -3,15 +3,17 @@ #include AudioSettings::AudioSettings() { - v.addWidget(&volume); - volume.setRange(0, 100); - volume.setValue(int(Options::GetVolume()) * 100.f); + volume = new QSlider(); + volume->setRange(0, 100); + volume->setValue(int(Options::GetVolume()) * 100.f); QSettings settings; - connect(&volume, &QSlider::valueChanged, this, [&] { - float newValue = float(volume.value()) / 100.f; + connect(volume, &QSlider::valueChanged, this, [&] { + float newValue = float(volume->value()) / 100.f; Options::SetVolume(newValue); settings.setValue("audio/volume", newValue); }); - setLayout(&v); + v = new QVBoxLayout(); + v->addWidget(volume); + setLayout(v); } diff --git a/src/frontend/Settings/AudioSettings.hpp b/src/frontend/Settings/AudioSettings.hpp index 709cdee..3768927 100644 --- a/src/frontend/Settings/AudioSettings.hpp +++ b/src/frontend/Settings/AudioSettings.hpp @@ -4,8 +4,8 @@ #include class AudioSettings final : public QWidget { - QVBoxLayout v; - QSlider volume; + QVBoxLayout *v; + QSlider *volume; public: explicit AudioSettings(); diff --git a/src/frontend/Settings/CPUSettings.cpp b/src/frontend/Settings/CPUSettings.cpp index 15f3f6e..ba998da 100644 --- a/src/frontend/Settings/CPUSettings.cpp +++ b/src/frontend/Settings/CPUSettings.cpp @@ -4,30 +4,47 @@ #include CPUSettings::CPUSettings() { - types.addItems({"Interpreter", "Cached Interpreter"}); + types = new QComboBox(); + idleSkip = new QCheckBox("Idle skipping"); + idleSkip->setToolTip("Whether to enable idle skipping.

" + "Note: idle skipping is a technique used in emulators
" + "that enables skipping the execution of certain blocks of guest code
" + "when it's determined that the aforementioned is used to wait on a certain
" + "event to occur; the code gets skipped, the event is executed immediately by
" + "the emulator so that the game never actually waits, progressing immediately
" + "and making emulation much faster.

" + "This feature is not available when the pure interpreter is selected
" + "because the information regarding instructions would be too limited to perform
" + "the evaluation above described."); + v = new QVBoxLayout(); + h = new QHBoxLayout(); + + types->addItems({"Interpreter", "Cached Interpreter"}); QSettings settings; - connect(&types, &QComboBox::currentIndexChanged, this, [&] { - int index = types.currentIndex(); + connect(types, &QComboBox::currentIndexChanged, this, [&] { + int index = types->currentIndex(); QString newValue{}; - if (index == 0) + if (index == 0) { + idleSkip->hide(); newValue = "interpreter"; - if (index == 1) + } + if (index == 1) { + idleSkip->show(); newValue = "cached_interpreter"; + } Options::SetCpuType(newValue.toStdString()); settings.setValue("cpu/type", newValue); }); - idleSkipLabel.setText("Idle skip:"); - connect(&idleSkip, &QCheckBox::checkStateChanged, this, [&] { - Options::SetIdleSkip(idleSkip.checkState()); - settings.setValue("cpu/idle_skip", idleSkip.checkState()); + connect(idleSkip, &QCheckBox::checkStateChanged, this, [&] { + Options::SetIdleSkip(idleSkip->checkState()); + settings.setValue("cpu/idle_skip", idleSkip->checkState()); }); - h.addWidget(&idleSkipLabel); - h.addWidget(&idleSkip); - v.addWidget(&types); - v.addLayout(&h); - setLayout(&v); + h->addWidget(idleSkip); + v->addWidget(types); + v->addLayout(h); + setLayout(v); } diff --git a/src/frontend/Settings/CPUSettings.hpp b/src/frontend/Settings/CPUSettings.hpp index d26de16..94dee75 100644 --- a/src/frontend/Settings/CPUSettings.hpp +++ b/src/frontend/Settings/CPUSettings.hpp @@ -6,11 +6,10 @@ #include class CPUSettings final : public QWidget { - QComboBox types; - QCheckBox idleSkip; - QVBoxLayout v; - QHBoxLayout h; - QLabel idleSkipLabel; + QComboBox *types; + QCheckBox *idleSkip; + QVBoxLayout *v; + QHBoxLayout *h; public: explicit CPUSettings(); diff --git a/src/frontend/Settings/GeneralSettings.cpp b/src/frontend/Settings/GeneralSettings.cpp index 0be96c5..8161a48 100644 --- a/src/frontend/Settings/GeneralSettings.cpp +++ b/src/frontend/Settings/GeneralSettings.cpp @@ -7,21 +7,27 @@ GeneralSettings::GeneralSettings() { QSettings settings; - description.setText("Saves path:"); - selectedFolderLabel.setDisabled(true); - selectedFolderLabel.setText(Options::GetSavesPath().c_str()); - folderSelectButton.setText("Choose..."); - connect(&folderSelectButton, &QPushButton::clicked, this, [&] { + description = new QLabel("Path:"); + description->setToolTip("Path where game saves are stored."); + selectedFolderLabel = new QLabel(Options::GetSavesPath().c_str()); + selectedFolderLabel->setDisabled(true); + folderSelectButton = new QPushButton("Choose..."); + + connect(folderSelectButton, &QPushButton::clicked, this, [&] { auto dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), QCoreApplication::applicationDirPath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - selectedFolderLabel.setText(dir); + selectedFolderLabel->setText(dir); Options::SetSavesPath(dir.toStdString()); settings.setValue("general/saves_path", dir); }); - h.addWidget(&description); - h.addWidget(&selectedFolderLabel); - h.addWidget(&folderSelectButton); - v.addLayout(&h); - setLayout(&v); + h = new QHBoxLayout(this); + + h->addWidget(description); + h->addWidget(selectedFolderLabel); + h->addWidget(folderSelectButton); + + v = new QVBoxLayout(this); + v->addLayout(h); + setLayout(v); } diff --git a/src/frontend/Settings/GeneralSettings.hpp b/src/frontend/Settings/GeneralSettings.hpp index a9716f4..38ccf6c 100644 --- a/src/frontend/Settings/GeneralSettings.hpp +++ b/src/frontend/Settings/GeneralSettings.hpp @@ -5,11 +5,11 @@ #include class GeneralSettings final : public QWidget { - QLabel description; - QPushButton folderSelectButton; - QLabel selectedFolderLabel; - QVBoxLayout v; - QHBoxLayout h; + QLabel *description; + QPushButton *folderSelectButton; + QLabel *selectedFolderLabel; + QVBoxLayout *v; + QHBoxLayout *h; public: explicit GeneralSettings(); diff --git a/src/frontend/SettingsWindow.cpp b/src/frontend/SettingsWindow.cpp index dcfdc40..db0111a 100644 --- a/src/frontend/SettingsWindow.cpp +++ b/src/frontend/SettingsWindow.cpp @@ -5,10 +5,12 @@ SettingsWindow::SettingsWindow() { hide(); QSettings settings; - categories.addTab(&general, "General"); - categories.addTab(&cpu, "MIPS VR4300i"); - categories.addTab(&audio, "Audio"); + categories = new QTabWidget(this); + categories->addTab(&general, "General"); + categories->addTab(&cpu, "MIPS VR4300i"); + categories->addTab(&audio, "Audio"); - v.addWidget(&categories); - setLayout(&v); + v = new QVBoxLayout(this); + v->addWidget(categories); + setLayout(v); } diff --git a/src/frontend/SettingsWindow.hpp b/src/frontend/SettingsWindow.hpp index 837d19f..31853a6 100644 --- a/src/frontend/SettingsWindow.hpp +++ b/src/frontend/SettingsWindow.hpp @@ -8,12 +8,13 @@ #include class SettingsWindow final : QWidget { - QTabWidget categories; + QTabWidget *categories; GeneralSettings general; AudioSettings audio; CPUSettings cpu; - QVBoxLayout v; + QVBoxLayout *v; public: SettingsWindow(); + void show() { QWidget::show(); } };