From 1ce566f9fd25d78c033a1b6ac57b127f45f130b7 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Tue, 8 Oct 2019 14:48:43 -0400 Subject: [PATCH] Moved CPU Emulation Engine options to the Advanced tab --- .../Core/DolphinQt/Settings/AdvancedPane.cpp | 54 +++++++++++++++++++ Source/Core/DolphinQt/Settings/AdvancedPane.h | 11 ++++ .../Core/DolphinQt/Settings/GeneralPane.cpp | 51 ------------------ Source/Core/DolphinQt/Settings/GeneralPane.h | 5 -- 4 files changed, 65 insertions(+), 56 deletions(-) diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp index d8ae447237..55f146c93a 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -18,9 +19,17 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/SystemTimers.h" +#include "Core/PowerPC/PowerPC.h" #include "DolphinQt/Settings.h" +static const std::map CPU_CORE_NAMES = { + {PowerPC::CPUCore::Interpreter, QT_TR_NOOP("Interpreter (slowest)")}, + {PowerPC::CPUCore::CachedInterpreter, QT_TR_NOOP("Cached Interpreter (slower)")}, + {PowerPC::CPUCore::JIT64, QT_TR_NOOP("JIT Recompiler (recommended)")}, + {PowerPC::CPUCore::JITARM64, QT_TR_NOOP("JIT Arm64 (experimental)")}, +}; + AdvancedPane::AdvancedPane(QWidget* parent) : QWidget(parent) { CreateLayout(); @@ -29,6 +38,8 @@ AdvancedPane::AdvancedPane(QWidget* parent) : QWidget(parent) ConnectLayout(); connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &AdvancedPane::Update); + connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, + &AdvancedPane::OnEmulationStateChanged); } void AdvancedPane::CreateLayout() @@ -41,6 +52,18 @@ void AdvancedPane::CreateLayout() cpu_options->setLayout(cpu_options_layout); main_layout->addWidget(cpu_options); + auto* engine_group = new QGroupBox(tr("CPU Emulation Engine")); + auto* engine_group_layout = new QVBoxLayout; + engine_group->setLayout(engine_group_layout); + + for (PowerPC::CPUCore cpu_core : PowerPC::AvailableCPUCores()) + { + m_cpu_cores.emplace_back(new QRadioButton(tr(CPU_CORE_NAMES.at(cpu_core)))); + engine_group_layout->addWidget(m_cpu_cores.back()); + } + + cpu_options_layout->addWidget(engine_group); + m_cpu_clock_override_checkbox = new QCheckBox(tr("Enable Emulated CPU Clock Override")); cpu_options_layout->addWidget(m_cpu_clock_override_checkbox); @@ -100,6 +123,22 @@ void AdvancedPane::CreateLayout() void AdvancedPane::ConnectLayout() { + for (QRadioButton* radio_button : m_cpu_cores) + { + connect(radio_button, &QRadioButton::toggled, [this](bool toggled) { + for (size_t i = 0; i < m_cpu_cores.size(); ++i) + { + if (m_cpu_cores[i]->isChecked()) + { + SConfig::GetInstance().cpu_core = PowerPC::AvailableCPUCores()[i]; + Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[i]); + break; + } + } + Update(); + }); + } + m_cpu_clock_override_checkbox->setChecked(SConfig::GetInstance().m_OCEnable); connect(m_cpu_clock_override_checkbox, &QCheckBox::toggled, [this](bool enable_clock_override) { SConfig::GetInstance().m_OCEnable = enable_clock_override; @@ -136,6 +175,13 @@ void AdvancedPane::Update() const bool enable_cpu_clock_override_widgets = SConfig::GetInstance().m_OCEnable; const bool enable_custom_rtc_widgets = SConfig::GetInstance().bEnableCustomRTC && !running; + const std::vector& available_cpu_cores = PowerPC::AvailableCPUCores(); + for (size_t i = 0; i < available_cpu_cores.size(); ++i) + { + if (available_cpu_cores[i] == SConfig::GetInstance().cpu_core) + m_cpu_cores[i]->setChecked(true); + } + QFont bf = font(); bf.setBold(Config::GetActiveLayerForConfig(Config::MAIN_OVERCLOCK_ENABLE) != Config::LayerType::Base); @@ -161,3 +207,11 @@ void AdvancedPane::Update() m_custom_rtc_checkbox->setEnabled(!running); m_custom_rtc_datetime->setEnabled(enable_custom_rtc_widgets); } + +void AdvancedPane::OnEmulationStateChanged(Core::State state) +{ + const bool running = state != Core::State::Uninitialized; + + for (QRadioButton* radio_button : m_cpu_cores) + radio_button->setEnabled(!running); +} diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.h b/Source/Core/DolphinQt/Settings/AdvancedPane.h index 2e7120ae62..d15ba02266 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.h +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.h @@ -4,13 +4,21 @@ #pragma once +#include + #include class QCheckBox; class QLabel; +class QRadioButton; class QSlider; class QDateTimeEdit; +namespace Core +{ +enum class State; +} + class AdvancedPane final : public QWidget { Q_OBJECT @@ -21,6 +29,7 @@ private: void CreateLayout(); void ConnectLayout(); void Update(); + void OnEmulationStateChanged(Core::State state); QCheckBox* m_cpu_clock_override_checkbox; QSlider* m_cpu_clock_override_slider; @@ -29,4 +38,6 @@ private: QCheckBox* m_custom_rtc_checkbox; QDateTimeEdit* m_custom_rtc_datetime; + + std::vector m_cpu_cores; }; diff --git a/Source/Core/DolphinQt/Settings/GeneralPane.cpp b/Source/Core/DolphinQt/Settings/GeneralPane.cpp index 2bed590f8b..c1140cf98f 100644 --- a/Source/Core/DolphinQt/Settings/GeneralPane.cpp +++ b/Source/Core/DolphinQt/Settings/GeneralPane.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -42,13 +41,6 @@ constexpr const char* AUTO_UPDATE_STABLE_STRING = "stable"; constexpr const char* AUTO_UPDATE_BETA_STRING = "beta"; constexpr const char* AUTO_UPDATE_DEV_STRING = "dev"; -static const std::map CPU_CORE_NAMES = { - {PowerPC::CPUCore::Interpreter, QT_TR_NOOP("Interpreter (slowest)")}, - {PowerPC::CPUCore::CachedInterpreter, QT_TR_NOOP("Cached Interpreter (slower)")}, - {PowerPC::CPUCore::JIT64, QT_TR_NOOP("JIT Recompiler (recommended)")}, - {PowerPC::CPUCore::JITARM64, QT_TR_NOOP("JIT Arm64 (experimental)")}, -}; - GeneralPane::GeneralPane(QWidget* parent) : QWidget(parent) { CreateLayout(); @@ -72,7 +64,6 @@ void GeneralPane::CreateLayout() #if defined(USE_ANALYTICS) && USE_ANALYTICS CreateAnalytics(); #endif - CreateAdvanced(); m_main_layout->addStretch(1); setLayout(m_main_layout); @@ -88,9 +79,6 @@ void GeneralPane::OnEmulationStateChanged(Core::State state) #ifdef USE_DISCORD_PRESENCE m_checkbox_discord_presence->setEnabled(!running); #endif - - for (QRadioButton* radio_button : m_cpu_cores) - radio_button->setEnabled(!running); } void GeneralPane::ConnectLayout() @@ -117,8 +105,6 @@ void GeneralPane::ConnectLayout() connect(m_combobox_speedlimit, static_cast(&QComboBox::currentIndexChanged), [this]() { OnSaveConfig(); }); - for (QRadioButton* radio_button : m_cpu_cores) - connect(radio_button, &QRadioButton::toggled, this, &GeneralPane::OnSaveConfig); #if defined(USE_ANALYTICS) && USE_ANALYTICS connect(&Settings::Instance(), &Settings::AnalyticsToggled, this, &GeneralPane::LoadConfig); @@ -208,26 +194,6 @@ void GeneralPane::CreateAnalytics() } #endif -void GeneralPane::CreateAdvanced() -{ - auto* advanced_group = new QGroupBox(tr("Advanced Settings")); - auto* advanced_group_layout = new QVBoxLayout; - advanced_group->setLayout(advanced_group_layout); - m_main_layout->addWidget(advanced_group); - - // Speed Limit - auto* engine_group = new QGroupBox(tr("CPU Emulation Engine")); - auto* engine_group_layout = new QVBoxLayout; - engine_group->setLayout(engine_group_layout); - advanced_group_layout->addWidget(engine_group); - - for (PowerPC::CPUCore cpu_core : PowerPC::AvailableCPUCores()) - { - m_cpu_cores.emplace_back(new QRadioButton(tr(CPU_CORE_NAMES.at(cpu_core)))); - engine_group_layout->addWidget(m_cpu_cores.back()); - } -} - void GeneralPane::LoadConfig() { if (AutoUpdateChecker::SystemSupportsAutoUpdates()) @@ -258,13 +224,6 @@ void GeneralPane::LoadConfig() if (selection < m_combobox_speedlimit->count()) m_combobox_speedlimit->setCurrentIndex(selection); m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread); - - const std::vector& available_cpu_cores = PowerPC::AvailableCPUCores(); - for (size_t i = 0; i < available_cpu_cores.size(); ++i) - { - if (available_cpu_cores[i] == SConfig::GetInstance().cpu_core) - m_cpu_cores[i]->setChecked(true); - } } static QString UpdateTrackFromIndex(int index) @@ -319,16 +278,6 @@ void GeneralPane::OnSaveConfig() Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, m_checkbox_cheats->isChecked()); settings.m_EmulationSpeed = m_combobox_speedlimit->currentIndex() * 0.1f; - for (size_t i = 0; i < m_cpu_cores.size(); ++i) - { - if (m_cpu_cores[i]->isChecked()) - { - settings.cpu_core = PowerPC::AvailableCPUCores()[i]; - Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[i]); - break; - } - } - settings.SaveSettings(); } diff --git a/Source/Core/DolphinQt/Settings/GeneralPane.h b/Source/Core/DolphinQt/Settings/GeneralPane.h index 6aa9fc1e1a..8106672bcd 100644 --- a/Source/Core/DolphinQt/Settings/GeneralPane.h +++ b/Source/Core/DolphinQt/Settings/GeneralPane.h @@ -4,8 +4,6 @@ #pragma once -#include - #include class QCheckBox; @@ -32,7 +30,6 @@ private: void ConnectLayout(); void CreateBasic(); void CreateAutoUpdate(); - void CreateAdvanced(); void LoadConfig(); void OnSaveConfig(); @@ -51,8 +48,6 @@ private: #endif QLabel* m_label_speedlimit; - std::vector m_cpu_cores; - // Analytics related #if defined(USE_ANALYTICS) && USE_ANALYTICS void CreateAnalytics();