Moved CPU Emulation Engine options to the Advanced tab

This commit is contained in:
Ethan Roseman 2019-10-08 14:48:43 -04:00
parent a1405f70a2
commit 1ce566f9fd
4 changed files with 65 additions and 56 deletions

View File

@ -9,6 +9,7 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QRadioButton>
#include <QSignalBlocker>
#include <QSlider>
#include <QVBoxLayout>
@ -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<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)
{
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<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);
}
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);
}

View File

@ -4,13 +4,21 @@
#pragma once
#include <vector>
#include <QWidget>
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<QRadioButton*> m_cpu_cores;
};

View File

@ -12,7 +12,6 @@
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
#include <QRadioButton>
#include <QSlider>
#include <QVBoxLayout>
#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_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)
{
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<void (QComboBox::*)(int)>(&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<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)
@ -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();
}

View File

@ -4,8 +4,6 @@
#pragma once
#include <vector>
#include <QWidget>
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<QRadioButton*> m_cpu_cores;
// Analytics related
#if defined(USE_ANALYTICS) && USE_ANALYTICS
void CreateAnalytics();