Qt6 frontend

Reviewed-on: #1
Co-authored-by: iris <iris.kaizen@pm.me>
Co-committed-by: iris <iris.kaizen@pm.me>
This commit was merged in pull request #1.
This commit is contained in:
2026-06-09 17:14:08 +02:00
committed by iris
parent 3080d4d45a
commit 430139dc9f
315 changed files with 860 additions and 140860 deletions
+44 -45
View File
@@ -1,56 +1,55 @@
#include <CPUSettings.hpp>
#include <Options.hpp>
#include <log.hpp>
#include <imgui.h>
#include <Core.hpp>
CPUSettings::CPUSettings() {
auto selectedCpuType = Options::GetInstance().GetValue<std::string>("cpu", "type");
if (selectedCpuType == "cached_interpreter") {
selectedCpuTypeIndex = 1;
CPUSettings::CPUSettings() : settings(QSettings::UserScope) {
types = new QComboBox();
idleSkip = new QCheckBox("Idle skipping");
idleSkip->setToolTip("Whether to enable idle skipping.<br><br>"
"Note: idle skipping is a technique used in emulators<br>"
"that enables skipping the execution of certain blocks of guest code<br>"
"when it's determined that the aforementioned is used to wait on a certain<br>"
"event to occur; the code gets skipped, the event is executed immediately by<br>"
"the emulator so that the game never actually waits, progressing immediately and making "
"emulation much faster.<br><br>"
"This feature is not available when the pure interpreter is selected<br>"
"because the information regarding instructions would be too limited to<br>"
"perform the evaluation described above.");
idleSkip->setChecked(settings.value("cpu/idle_skip", false).value<bool>());
v = new QVBoxLayout();
h = new QHBoxLayout();
types->addItems({"Interpreter", "Cached Interpreter"});
if (Options::GetCpuType() == 0) {
idleSkip->hide();
} else {
selectedCpuTypeIndex = 0;
idleSkip->show();
}
types->setCurrentIndex(Options::GetCpuType());
idleSkip = Options::GetInstance().GetValue<bool>("cpu", "idleSkip");
}
connect(types, &QComboBox::currentIndexChanged, this, [&] {
int index = types->currentIndex();
if (index == 0)
idleSkip->hide();
else
idleSkip->show();
void CPUSettings::render() {
const char *items[] = {"Interpreter", "Cached Interpreter"};
Options::SetCpuType(index);
settings.setValue("cpu/type", index);
settings.sync();
emit cpuTypeChanged();
});
const char *combo_preview_value = items[selectedCpuTypeIndex];
if (ImGui::BeginCombo("CPU Type", combo_preview_value)) {
for (int n = 0; n < IM_ARRAYSIZE(items); n++) {
const bool is_selected = (selectedCpuTypeIndex == n);
if (ImGui::Selectable(items[n], is_selected)) {
selectedCpuTypeIndex = n;
modified = true;
}
connect(idleSkip, &QCheckBox::checkStateChanged, this, [&] {
Options::SetIdleSkip(idleSkip->checkState());
settings.setValue("cpu/idle_skip", idleSkip->checkState());
settings.sync();
emit idleSkipChanged();
});
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
bool showIdleSkipping = std::string(items[selectedCpuTypeIndex]) == "Cached Interpreter";
if (showIdleSkipping)
if (ImGui::Checkbox("Idle skipping", &idleSkip))
modified = true;
if (modified) {
if (selectedCpuTypeIndex == 0) {
Options::GetInstance().SetValue<std::string>("cpu", "type", "interpreter");
idleSkip = false;
Options::GetInstance().SetValue<bool>("cpu", "idleSkip", idleSkip);
n64::Core::GetInstance().cpuType = n64::Core::PlainInterpreter;
n64::Core::GetInstance().idleSkip = idleSkip;
} else {
Options::GetInstance().SetValue<std::string>("cpu", "type", "cached_interpreter");
Options::GetInstance().SetValue<bool>("cpu", "idleSkip", idleSkip);
n64::Core::GetInstance().cpuType = n64::Core::CachedInterpreter;
n64::Core::GetInstance().idleSkip = idleSkip;
}
}
h->addWidget(idleSkip);
v->addWidget(types);
v->addLayout(h);
setLayout(v);
}