Merge pull request #8408 from ethteck/move-cpu-emulation-engine-options

Qt: Move CPU Emulation Engine options to the Advanced tab
This commit is contained in:
Anthony 2019-10-17 12:56:50 -07:00 committed by GitHub
commit acf9bd5ebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 60 deletions

View File

@ -47,7 +47,7 @@ SettingsWindow::SettingsWindow(QWidget* parent) : QDialog(parent)
wii_pane->OnEmulationStateChanged(state != Core::State::Uninitialized); wii_pane->OnEmulationStateChanged(state != Core::State::Uninitialized);
}); });
m_tab_widget->addTab(new AdvancedPane(), tr("Advanced")); m_tab_widget->addTab(GetWrappedWidget(new AdvancedPane, this, 125, 200), tr("Advanced"));
// Dialog box buttons // Dialog box buttons
QDialogButtonBox* close_box = new QDialogButtonBox(QDialogButtonBox::Close); QDialogButtonBox* close_box = new QDialogButtonBox(QDialogButtonBox::Close);

View File

@ -5,10 +5,13 @@
#include "DolphinQt/Settings/AdvancedPane.h" #include "DolphinQt/Settings/AdvancedPane.h"
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox>
#include <QDateTimeEdit> #include <QDateTimeEdit>
#include <QFormLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
#include <QRadioButton>
#include <QSignalBlocker> #include <QSignalBlocker>
#include <QSlider> #include <QSlider>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -18,9 +21,17 @@
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/HW/SystemTimers.h" #include "Core/HW/SystemTimers.h"
#include "Core/PowerPC/PowerPC.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
static const std::map<PowerPC::CPUCore, const char*> 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) AdvancedPane::AdvancedPane(QWidget* parent) : QWidget(parent)
{ {
CreateLayout(); CreateLayout();
@ -29,6 +40,8 @@ AdvancedPane::AdvancedPane(QWidget* parent) : QWidget(parent)
ConnectLayout(); ConnectLayout();
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &AdvancedPane::Update); connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &AdvancedPane::Update);
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
&AdvancedPane::OnEmulationStateChanged);
} }
void AdvancedPane::CreateLayout() void AdvancedPane::CreateLayout()
@ -41,12 +54,28 @@ void AdvancedPane::CreateLayout()
cpu_options->setLayout(cpu_options_layout); cpu_options->setLayout(cpu_options_layout);
main_layout->addWidget(cpu_options); main_layout->addWidget(cpu_options);
QGridLayout* cpu_emulation_layout = new QGridLayout();
QLabel* cpu_emulation_engine_label = new QLabel(tr("CPU Emulation Engine:"));
m_cpu_emulation_engine_combobox = new QComboBox(this);
for (PowerPC::CPUCore cpu_core : PowerPC::AvailableCPUCores())
{
m_cpu_emulation_engine_combobox->addItem(tr(CPU_CORE_NAMES.at(cpu_core)));
}
cpu_emulation_layout->addWidget(cpu_emulation_engine_label, 0, 0);
cpu_emulation_layout->addWidget(m_cpu_emulation_engine_combobox, 0, 1, Qt::AlignLeft);
cpu_options_layout->addLayout(cpu_emulation_layout);
auto* clock_override = new QGroupBox(tr("Clock Override"));
auto* clock_override_layout = new QVBoxLayout();
clock_override->setLayout(clock_override_layout);
main_layout->addWidget(clock_override);
m_cpu_clock_override_checkbox = new QCheckBox(tr("Enable Emulated CPU Clock Override")); m_cpu_clock_override_checkbox = new QCheckBox(tr("Enable Emulated CPU Clock Override"));
cpu_options_layout->addWidget(m_cpu_clock_override_checkbox); clock_override_layout->addWidget(m_cpu_clock_override_checkbox);
auto* cpu_clock_override_slider_layout = new QHBoxLayout(); auto* cpu_clock_override_slider_layout = new QHBoxLayout();
cpu_clock_override_slider_layout->setContentsMargins(0, 0, 0, 0); cpu_clock_override_slider_layout->setContentsMargins(0, 0, 0, 0);
cpu_options_layout->addLayout(cpu_clock_override_slider_layout); clock_override_layout->addLayout(cpu_clock_override_slider_layout);
m_cpu_clock_override_slider = new QSlider(Qt::Horizontal); m_cpu_clock_override_slider = new QSlider(Qt::Horizontal);
m_cpu_clock_override_slider->setRange(0, 150); m_cpu_clock_override_slider->setRange(0, 150);
@ -64,7 +93,7 @@ void AdvancedPane::CreateLayout()
"break games and cause glitches. Do so at your own risk. " "break games and cause glitches. Do so at your own risk. "
"Please do not report bugs that occur with a non-default clock.")); "Please do not report bugs that occur with a non-default clock."));
cpu_clock_override_description->setWordWrap(true); cpu_clock_override_description->setWordWrap(true);
cpu_options_layout->addWidget(cpu_clock_override_description); clock_override_layout->addWidget(cpu_clock_override_description);
auto* rtc_options = new QGroupBox(tr("Custom RTC Options")); auto* rtc_options = new QGroupBox(tr("Custom RTC Options"));
rtc_options->setLayout(new QVBoxLayout()); rtc_options->setLayout(new QVBoxLayout());
@ -100,6 +129,14 @@ void AdvancedPane::CreateLayout()
void AdvancedPane::ConnectLayout() void AdvancedPane::ConnectLayout()
{ {
connect(m_cpu_emulation_engine_combobox,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this](int index) {
SConfig::GetInstance().cpu_core = PowerPC::AvailableCPUCores()[index];
Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[index]);
Update();
});
m_cpu_clock_override_checkbox->setChecked(SConfig::GetInstance().m_OCEnable); m_cpu_clock_override_checkbox->setChecked(SConfig::GetInstance().m_OCEnable);
connect(m_cpu_clock_override_checkbox, &QCheckBox::toggled, [this](bool enable_clock_override) { connect(m_cpu_clock_override_checkbox, &QCheckBox::toggled, [this](bool enable_clock_override) {
SConfig::GetInstance().m_OCEnable = enable_clock_override; SConfig::GetInstance().m_OCEnable = enable_clock_override;
@ -136,6 +173,13 @@ void AdvancedPane::Update()
const bool enable_cpu_clock_override_widgets = SConfig::GetInstance().m_OCEnable; const bool enable_cpu_clock_override_widgets = SConfig::GetInstance().m_OCEnable;
const bool enable_custom_rtc_widgets = SConfig::GetInstance().bEnableCustomRTC && !running; const bool enable_custom_rtc_widgets = SConfig::GetInstance().bEnableCustomRTC && !running;
const std::vector<PowerPC::CPUCore>& available_cpu_cores = PowerPC::AvailableCPUCores();
for (int i = 0; i < available_cpu_cores.size(); ++i)
{
if (available_cpu_cores[i] == SConfig::GetInstance().cpu_core)
m_cpu_emulation_engine_combobox->setCurrentIndex(i);
}
QFont bf = font(); QFont bf = font();
bf.setBold(Config::GetActiveLayerForConfig(Config::MAIN_OVERCLOCK_ENABLE) != bf.setBold(Config::GetActiveLayerForConfig(Config::MAIN_OVERCLOCK_ENABLE) !=
Config::LayerType::Base); Config::LayerType::Base);
@ -161,3 +205,9 @@ void AdvancedPane::Update()
m_custom_rtc_checkbox->setEnabled(!running); m_custom_rtc_checkbox->setEnabled(!running);
m_custom_rtc_datetime->setEnabled(enable_custom_rtc_widgets); m_custom_rtc_datetime->setEnabled(enable_custom_rtc_widgets);
} }
void AdvancedPane::OnEmulationStateChanged(Core::State state)
{
const bool running = state != Core::State::Uninitialized;
m_cpu_emulation_engine_combobox->setEnabled(!running);
}

View File

@ -4,13 +4,22 @@
#pragma once #pragma once
#include <vector>
#include <QWidget> #include <QWidget>
class QCheckBox; class QCheckBox;
class QComboBox;
class QLabel; class QLabel;
class QRadioButton;
class QSlider; class QSlider;
class QDateTimeEdit; class QDateTimeEdit;
namespace Core
{
enum class State;
}
class AdvancedPane final : public QWidget class AdvancedPane final : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -21,7 +30,9 @@ private:
void CreateLayout(); void CreateLayout();
void ConnectLayout(); void ConnectLayout();
void Update(); void Update();
void OnEmulationStateChanged(Core::State state);
QComboBox* m_cpu_emulation_engine_combobox;
QCheckBox* m_cpu_clock_override_checkbox; QCheckBox* m_cpu_clock_override_checkbox;
QSlider* m_cpu_clock_override_slider; QSlider* m_cpu_clock_override_slider;
QLabel* m_cpu_clock_override_slider_label; QLabel* m_cpu_clock_override_slider_label;

View File

@ -12,7 +12,6 @@
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QRadioButton>
#include <QSlider> #include <QSlider>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
@ -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_BETA_STRING = "beta";
constexpr const char* AUTO_UPDATE_DEV_STRING = "dev"; constexpr const char* AUTO_UPDATE_DEV_STRING = "dev";
static const std::map<PowerPC::CPUCore, const char*> 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) GeneralPane::GeneralPane(QWidget* parent) : QWidget(parent)
{ {
CreateLayout(); CreateLayout();
@ -72,7 +64,6 @@ void GeneralPane::CreateLayout()
#if defined(USE_ANALYTICS) && USE_ANALYTICS #if defined(USE_ANALYTICS) && USE_ANALYTICS
CreateAnalytics(); CreateAnalytics();
#endif #endif
CreateAdvanced();
m_main_layout->addStretch(1); m_main_layout->addStretch(1);
setLayout(m_main_layout); setLayout(m_main_layout);
@ -88,9 +79,6 @@ void GeneralPane::OnEmulationStateChanged(Core::State state)
#ifdef USE_DISCORD_PRESENCE #ifdef USE_DISCORD_PRESENCE
m_checkbox_discord_presence->setEnabled(!running); m_checkbox_discord_presence->setEnabled(!running);
#endif #endif
for (QRadioButton* radio_button : m_cpu_cores)
radio_button->setEnabled(!running);
} }
void GeneralPane::ConnectLayout() void GeneralPane::ConnectLayout()
@ -117,8 +105,6 @@ void GeneralPane::ConnectLayout()
connect(m_combobox_speedlimit, connect(m_combobox_speedlimit,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this]() { OnSaveConfig(); }); [this]() { OnSaveConfig(); });
for (QRadioButton* radio_button : m_cpu_cores)
connect(radio_button, &QRadioButton::toggled, this, &GeneralPane::OnSaveConfig);
#if defined(USE_ANALYTICS) && USE_ANALYTICS #if defined(USE_ANALYTICS) && USE_ANALYTICS
connect(&Settings::Instance(), &Settings::AnalyticsToggled, this, &GeneralPane::LoadConfig); connect(&Settings::Instance(), &Settings::AnalyticsToggled, this, &GeneralPane::LoadConfig);
@ -208,26 +194,6 @@ void GeneralPane::CreateAnalytics()
} }
#endif #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() void GeneralPane::LoadConfig()
{ {
if (AutoUpdateChecker::SystemSupportsAutoUpdates()) if (AutoUpdateChecker::SystemSupportsAutoUpdates())
@ -258,13 +224,6 @@ void GeneralPane::LoadConfig()
if (selection < m_combobox_speedlimit->count()) if (selection < m_combobox_speedlimit->count())
m_combobox_speedlimit->setCurrentIndex(selection); m_combobox_speedlimit->setCurrentIndex(selection);
m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread); m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread);
const std::vector<PowerPC::CPUCore>& 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) static QString UpdateTrackFromIndex(int index)
@ -319,16 +278,6 @@ void GeneralPane::OnSaveConfig()
Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, m_checkbox_cheats->isChecked()); Config::SetBaseOrCurrent(Config::MAIN_ENABLE_CHEATS, m_checkbox_cheats->isChecked());
settings.m_EmulationSpeed = m_combobox_speedlimit->currentIndex() * 0.1f; 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(); settings.SaveSettings();
} }

View File

@ -4,8 +4,6 @@
#pragma once #pragma once
#include <vector>
#include <QWidget> #include <QWidget>
class QCheckBox; class QCheckBox;
@ -32,7 +30,6 @@ private:
void ConnectLayout(); void ConnectLayout();
void CreateBasic(); void CreateBasic();
void CreateAutoUpdate(); void CreateAutoUpdate();
void CreateAdvanced();
void LoadConfig(); void LoadConfig();
void OnSaveConfig(); void OnSaveConfig();
@ -51,8 +48,6 @@ private:
#endif #endif
QLabel* m_label_speedlimit; QLabel* m_label_speedlimit;
std::vector<QRadioButton*> m_cpu_cores;
// Analytics related // Analytics related
#if defined(USE_ANALYTICS) && USE_ANALYTICS #if defined(USE_ANALYTICS) && USE_ANALYTICS
void CreateAnalytics(); void CreateAnalytics();