This commit is contained in:
2026-03-23 12:11:07 +01:00
commit e64eb40b38
4573 changed files with 3117439 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
#include <AudioSettings.hpp>
#include <imgui.h>
#include <Options.hpp>
AudioSettings::AudioSettings() {
lockChannels = Options::GetInstance().GetValue<bool>("audio", "lock");
volumeL = Options::GetInstance().GetValue<float>("audio", "volumeL") * 100;
volumeR = Options::GetInstance().GetValue<float>("audio", "volumeR") * 100;
}
void AudioSettings::render() {
if(ImGui::Checkbox("Lock channels:", &lockChannels)) {
Options::GetInstance().SetValue("audio", "lock", lockChannels);
if(lockChannels) {
volumeR = volumeL;
Options::GetInstance().SetValue("audio", "volumeR", volumeR / 100.f);
}
modified = true;
}
if(ImGui::SliderFloat("Volume L", &volumeL, 0.f, 100.f, "%.2f")) {
Options::GetInstance().SetValue("audio", "volumeL", volumeL / 100.f);
if (lockChannels) {
volumeR = volumeL;
Options::GetInstance().SetValue("audio", "volumeR", volumeR / 100.f);
}
modified = true;
}
ImGui::BeginDisabled(lockChannels);
if(ImGui::SliderFloat("Volume R", &volumeR, 0.f, 100.f, "%.2f")) {
Options::GetInstance().SetValue("audio", "volumeR", volumeR / 100.f);
modified = true;
}
ImGui::EndDisabled();
}
+11
View File
@@ -0,0 +1,11 @@
#pragma once
#include <SettingsTab.hpp>
struct AudioSettings final : SettingsTab {
bool lockChannels = false;
float volumeL{};
float volumeR{};
explicit AudioSettings();
void render() override;
};
+43
View File
@@ -0,0 +1,43 @@
#include <CPUSettings.hpp>
#include <Options.hpp>
#include <log.hpp>
#include <imgui.h>
CPUSettings::CPUSettings() {
if (Options::GetInstance().GetValue<std::string>("cpu", "type") == "jit") {
selectedCpuTypeIndex = 1;
} else {
selectedCpuTypeIndex = 0;
}
}
void CPUSettings::render() {
const char* items[] = {
"Interpreter",
"Dynamic Recompiler"
};
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;
}
// Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
if(modified) {
if(selectedCpuTypeIndex == 0) {
Options::GetInstance().SetValue<std::string>("cpu", "type", "interpreter");
} else {
Options::GetInstance().SetValue<std::string>("cpu", "type", "jit");
}
}
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
#include <SettingsTab.hpp>
struct CPUSettings final : SettingsTab {
int selectedCpuTypeIndex = 0;
void render() override;
explicit CPUSettings();
};
+35
View File
@@ -0,0 +1,35 @@
#include <GeneralSettings.hpp>
#include <Options.hpp>
#include <imgui.h>
#include <log.hpp>
GeneralSettings::GeneralSettings(gui::NativeWindow& window) : window(window) {
savesPath = Options::GetInstance().GetValue<std::string>("general", "savePath");
}
void GeneralSettings::render() {
if(ImGui::Button("Pick...")) {
SDL_ShowOpenFolderDialog([](void *userdata, const char * const *filelist, int _) {
auto* general = static_cast<GeneralSettings*>(userdata);
if (!filelist) {
panic("An error occurred: {}", SDL_GetError());
}
if (!*filelist) {
warn("The user did not select any file.");
warn("Most likely, the dialog was canceled.");
general->modified = false;
return;
}
general->savesPath = fs::absolute(*filelist).string();
Options::GetInstance().SetValue<std::string>("general", "savePath", general->savesPath);
general->modified = true;
}, this, window.getHandle(), nullptr, false);
}
ImGui::SameLine();
ImGui::BeginDisabled();
ImGui::InputText("Save Path", const_cast<char*>(savesPath.c_str()), savesPath.length());
ImGui::EndDisabled();
}
+11
View File
@@ -0,0 +1,11 @@
#pragma once
#include <SettingsTab.hpp>
#include <NativeWindow.hpp>
struct GeneralSettings final : SettingsTab {
void render() override;
explicit GeneralSettings(gui::NativeWindow&);
private:
gui::NativeWindow& window;
std::string savesPath;
};