diff --git a/Source/Core/Core/PowerPC/PowerPC.cpp b/Source/Core/Core/PowerPC/PowerPC.cpp index 30c9cb2b14..a2a890d5bc 100644 --- a/Source/Core/Core/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/PowerPC/PowerPC.cpp @@ -236,9 +236,9 @@ void PowerPCManager::InitializeCPUCore(CPUCore cpu_core) m_mode = m_cpu_core_base == &interpreter ? CoreMode::Interpreter : CoreMode::JIT; } -const std::vector& AvailableCPUCores() +std::span AvailableCPUCores() { - static const std::vector cpu_cores = { + static constexpr auto cpu_cores = { #ifdef _M_X86_64 CPUCore::JIT64, #elif defined(_M_ARM_64) diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h index 42545f2c1f..ffaa3630d7 100644 --- a/Source/Core/Core/PowerPC/PowerPC.h +++ b/Source/Core/Core/PowerPC/PowerPC.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -238,7 +239,7 @@ static_assert(offsetof(PowerPC::PowerPCState, above_fits_in_first_0x100) <= 0x10 #endif #endif -const std::vector& AvailableCPUCores(); +std::span AvailableCPUCores(); CPUCore DefaultCPUCore(); class PowerPCManager diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp index 62e234219d..af50a3f7e9 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp @@ -22,6 +22,8 @@ #include "Core/HW/SystemTimers.h" #include "Core/PowerPC/PowerPC.h" +#include "DolphinQt/Config/ConfigControls/ConfigBool.h" +#include "DolphinQt/QtUtils/SignalBlocking.h" #include "DolphinQt/Settings.h" static const std::map CPU_CORE_NAMES = { @@ -63,21 +65,25 @@ void AdvancedPane::CreateLayout() m_cpu_emulation_engine_combobox->addItem(tr(CPU_CORE_NAMES.at(cpu_core))); } - m_enable_mmu_checkbox = new QCheckBox(tr("Enable MMU")); - m_enable_mmu_checkbox->setToolTip(tr( - "Enables the Memory Management Unit, needed for some games. (ON = Compatible, OFF = Fast)")); + m_enable_mmu_checkbox = new ConfigBool(tr("Enable MMU"), Config::MAIN_MMU); + m_enable_mmu_checkbox->SetDescription( + tr("Enables the Memory Management Unit, needed for some games. (ON = Compatible, OFF = " + "Fast)

If unsure, leave this unchecked.")); cpu_options_group_layout->addWidget(m_enable_mmu_checkbox); - m_pause_on_panic_checkbox = new QCheckBox(tr("Pause on Panic")); - m_pause_on_panic_checkbox->setToolTip( - tr("Pauses the emulation if a Read/Write or Unknown Instruction panic occurs.\nEnabling will " - "affect performance.\nThe performance impact is the same as having Enable MMU on.")); + m_pause_on_panic_checkbox = new ConfigBool(tr("Pause on Panic"), Config::MAIN_PAUSE_ON_PANIC); + m_pause_on_panic_checkbox->SetDescription( + tr("Pauses the emulation if a Read/Write or Unknown Instruction panic occurs.
Enabling " + "will affect performance.
The performance impact is the same as having Enable MMU " + "on.

If unsure, leave this unchecked.")); cpu_options_group_layout->addWidget(m_pause_on_panic_checkbox); - m_accurate_cpu_cache_checkbox = new QCheckBox(tr("Enable Write-Back Cache (slow)")); - m_accurate_cpu_cache_checkbox->setToolTip( - tr("Enables emulation of the CPU write-back cache.\nEnabling will have a significant impact " - "on performance.\nThis should be left disabled unless absolutely needed.")); + m_accurate_cpu_cache_checkbox = + new ConfigBool(tr("Enable Write-Back Cache (slow)"), Config::MAIN_ACCURATE_CPU_CACHE); + m_accurate_cpu_cache_checkbox->SetDescription( + tr("Enables emulation of the CPU write-back cache.
Enabling will have a significant " + "impact on performance.
This should be left disabled unless absolutely " + "needed.

If unsure, leave this unchecked.")); cpu_options_group_layout->addWidget(m_accurate_cpu_cache_checkbox); auto* clock_override = new QGroupBox(tr("Clock Override")); @@ -184,21 +190,13 @@ void AdvancedPane::CreateLayout() void AdvancedPane::ConnectLayout() { - connect(m_cpu_emulation_engine_combobox, - static_cast(&QComboBox::currentIndexChanged), [](int index) { - Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[index]); + connect(m_cpu_emulation_engine_combobox, qOverload(&QComboBox::currentIndexChanged), + [](int index) { + const auto cpu_cores = PowerPC::AvailableCPUCores(); + if (index >= 0 && static_cast(index) < cpu_cores.size()) + Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, cpu_cores[index]); }); - connect(m_enable_mmu_checkbox, &QCheckBox::toggled, this, - [](bool checked) { Config::SetBaseOrCurrent(Config::MAIN_MMU, checked); }); - - connect(m_pause_on_panic_checkbox, &QCheckBox::toggled, this, - [](bool checked) { Config::SetBaseOrCurrent(Config::MAIN_PAUSE_ON_PANIC, checked); }); - - connect(m_accurate_cpu_cache_checkbox, &QCheckBox::toggled, this, - [](bool checked) { Config::SetBaseOrCurrent(Config::MAIN_ACCURATE_CPU_CACHE, checked); }); - - m_cpu_clock_override_checkbox->setChecked(Config::Get(Config::MAIN_OVERCLOCK_ENABLE)); connect(m_cpu_clock_override_checkbox, &QCheckBox::toggled, [this](bool enable_clock_override) { Config::SetBaseOrCurrent(Config::MAIN_OVERCLOCK_ENABLE, enable_clock_override); Update(); @@ -211,7 +209,6 @@ void AdvancedPane::ConnectLayout() Update(); }); - m_ram_override_checkbox->setChecked(Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE)); connect(m_ram_override_checkbox, &QCheckBox::toggled, [this](bool enable_ram_override) { Config::SetBaseOrCurrent(Config::MAIN_RAM_OVERRIDE_ENABLE, enable_ram_override); Update(); @@ -229,15 +226,11 @@ void AdvancedPane::ConnectLayout() Update(); }); - m_custom_rtc_checkbox->setChecked(Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE)); connect(m_custom_rtc_checkbox, &QCheckBox::toggled, [this](bool enable_custom_rtc) { Config::SetBaseOrCurrent(Config::MAIN_CUSTOM_RTC_ENABLE, enable_custom_rtc); Update(); }); - QDateTime initial_date_time; - initial_date_time.setSecsSinceEpoch(Config::Get(Config::MAIN_CUSTOM_RTC_VALUE)); - m_custom_rtc_datetime->setDateTime(initial_date_time); connect(m_custom_rtc_datetime, &QDateTimeEdit::dateTimeChanged, [this](QDateTime date_time) { Config::SetBaseOrCurrent(Config::MAIN_CUSTOM_RTC_VALUE, static_cast(date_time.toSecsSinceEpoch())); @@ -252,7 +245,7 @@ void AdvancedPane::Update() const bool enable_ram_override_widgets = Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE); const bool enable_custom_rtc_widgets = Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE) && !running; - const std::vector& available_cpu_cores = PowerPC::AvailableCPUCores(); + const auto available_cpu_cores = PowerPC::AvailableCPUCores(); const auto cpu_core = Config::Get(Config::MAIN_CPU_CORE); for (size_t i = 0; i < available_cpu_cores.size(); ++i) { @@ -260,21 +253,19 @@ void AdvancedPane::Update() m_cpu_emulation_engine_combobox->setCurrentIndex(int(i)); } m_cpu_emulation_engine_combobox->setEnabled(!running); - - m_enable_mmu_checkbox->setChecked(Config::Get(Config::MAIN_MMU)); m_enable_mmu_checkbox->setEnabled(!running); - - m_pause_on_panic_checkbox->setChecked(Config::Get(Config::MAIN_PAUSE_ON_PANIC)); m_pause_on_panic_checkbox->setEnabled(!running); - - m_accurate_cpu_cache_checkbox->setChecked(Config::Get(Config::MAIN_ACCURATE_CPU_CACHE)); m_accurate_cpu_cache_checkbox->setEnabled(!running); - QFont bf = font(); - bf.setBold(Config::GetActiveLayerForConfig(Config::MAIN_OVERCLOCK_ENABLE) != - Config::LayerType::Base); - m_cpu_clock_override_checkbox->setFont(bf); - m_cpu_clock_override_checkbox->setChecked(enable_cpu_clock_override_widgets); + { + QFont bf = font(); + bf.setBold(Config::GetActiveLayerForConfig(Config::MAIN_OVERCLOCK_ENABLE) != + Config::LayerType::Base); + + const QSignalBlocker blocker(m_cpu_clock_override_checkbox); + m_cpu_clock_override_checkbox->setFont(bf); + m_cpu_clock_override_checkbox->setChecked(enable_cpu_clock_override_widgets); + } m_cpu_clock_override_slider->setEnabled(enable_cpu_clock_override_widgets); m_cpu_clock_override_slider_label->setEnabled(enable_cpu_clock_override_widgets); @@ -293,6 +284,7 @@ void AdvancedPane::Update() }()); m_ram_override_checkbox->setEnabled(!running); + SignalBlocking(m_ram_override_checkbox)->setChecked(enable_ram_override_widgets); m_mem1_override_slider->setEnabled(enable_ram_override_widgets && !running); m_mem1_override_slider_label->setEnabled(enable_ram_override_widgets && !running); @@ -323,5 +315,10 @@ void AdvancedPane::Update() }()); m_custom_rtc_checkbox->setEnabled(!running); + SignalBlocking(m_custom_rtc_checkbox)->setChecked(Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE)); + + QDateTime initial_date_time; + initial_date_time.setSecsSinceEpoch(Config::Get(Config::MAIN_CUSTOM_RTC_VALUE)); m_custom_rtc_datetime->setEnabled(enable_custom_rtc_widgets); + SignalBlocking(m_custom_rtc_datetime)->setDateTime(initial_date_time); } diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.h b/Source/Core/DolphinQt/Settings/AdvancedPane.h index b4fdb141cd..1607c1b3c0 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.h +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.h @@ -7,6 +7,7 @@ #include +class ConfigBool; class QCheckBox; class QComboBox; class QLabel; @@ -31,9 +32,9 @@ private: void Update(); QComboBox* m_cpu_emulation_engine_combobox; - QCheckBox* m_enable_mmu_checkbox; - QCheckBox* m_pause_on_panic_checkbox; - QCheckBox* m_accurate_cpu_cache_checkbox; + ConfigBool* m_enable_mmu_checkbox; + ConfigBool* m_pause_on_panic_checkbox; + ConfigBool* m_accurate_cpu_cache_checkbox; QCheckBox* m_cpu_clock_override_checkbox; QSlider* m_cpu_clock_override_slider; QLabel* m_cpu_clock_override_slider_label;