From cf527cafd432d49d6cd5a08bb9983d8d2b2f30d6 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 1 May 2020 15:03:42 +0200 Subject: [PATCH] DolphinQt: Split Config > Advanced into Misc and Advanced It has gotten too tall. --- Source/Core/DolphinQt/CMakeLists.txt | 2 + .../Core/DolphinQt/Config/SettingsWindow.cpp | 2 + Source/Core/DolphinQt/DolphinQt.vcxproj | 2 + .../Core/DolphinQt/Settings/AdvancedPane.cpp | 101 ------------- Source/Core/DolphinQt/Settings/AdvancedPane.h | 14 -- Source/Core/DolphinQt/Settings/MiscPane.cpp | 142 ++++++++++++++++++ Source/Core/DolphinQt/Settings/MiscPane.h | 29 ++++ 7 files changed, 177 insertions(+), 115 deletions(-) create mode 100644 Source/Core/DolphinQt/Settings/MiscPane.cpp create mode 100644 Source/Core/DolphinQt/Settings/MiscPane.h diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 9ae47143177f..1511c69e7c9b 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -289,6 +289,8 @@ add_executable(dolphin-emu Settings/GeneralPane.h Settings/InterfacePane.cpp Settings/InterfacePane.h + Settings/MiscPane.cpp + Settings/MiscPane.h Settings/PathPane.cpp Settings/PathPane.h Settings/WiiPane.cpp diff --git a/Source/Core/DolphinQt/Config/SettingsWindow.cpp b/Source/Core/DolphinQt/Config/SettingsWindow.cpp index 7faf712a55ed..ea458e2506c0 100644 --- a/Source/Core/DolphinQt/Config/SettingsWindow.cpp +++ b/Source/Core/DolphinQt/Config/SettingsWindow.cpp @@ -15,6 +15,7 @@ #include "DolphinQt/Settings/GameCubePane.h" #include "DolphinQt/Settings/GeneralPane.h" #include "DolphinQt/Settings/InterfacePane.h" +#include "DolphinQt/Settings/MiscPane.h" #include "DolphinQt/Settings/PathPane.h" #include "DolphinQt/Settings/WiiPane.h" @@ -39,6 +40,7 @@ SettingsWindow::SettingsWindow(QWidget* parent) : QDialog(parent) m_tab_widget->addTab(GetWrappedWidget(new PathPane, this, 125, 100), tr("Paths")); m_tab_widget->addTab(GetWrappedWidget(new GameCubePane, this, 125, 100), tr("GameCube")); m_tab_widget->addTab(GetWrappedWidget(new WiiPane, this, 125, 100), tr("Wii")); + m_tab_widget->addTab(GetWrappedWidget(new MiscPane, this, 125, 200), tr("Misc")); m_tab_widget->addTab(GetWrappedWidget(new AdvancedPane, this, 125, 200), tr("Advanced")); // Dialog box buttons diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 18a838896edf..ea033488519d 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -178,6 +178,7 @@ + @@ -341,6 +342,7 @@ + diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp index 34bb0491dcad..56f858f02935 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.cpp +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.cpp @@ -4,9 +4,6 @@ #include "DolphinQt/Settings/AdvancedPane.h" #include -#include -#include -#include #include #include #include @@ -20,17 +17,9 @@ #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 for x86-64 (recommended)")}, - {PowerPC::CPUCore::JITARM64, QT_TR_NOOP("JIT Recompiler for ARM64 (recommended)")}, -}; - AdvancedPane::AdvancedPane(QWidget* parent) : QWidget(parent) { CreateLayout(); @@ -46,27 +35,6 @@ void AdvancedPane::CreateLayout() auto* main_layout = new QVBoxLayout(); setLayout(main_layout); - auto* cpu_options = new QGroupBox(tr("CPU Options")); - auto* cpu_options_layout = new QVBoxLayout(); - cpu_options->setLayout(cpu_options_layout); - 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); - - 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)")); - cpu_options_layout->addWidget(m_enable_mmu_checkbox); - auto* clock_override = new QGroupBox(tr("Clock Override")); auto* clock_override_layout = new QVBoxLayout(); clock_override->setLayout(clock_override_layout); @@ -135,51 +103,11 @@ void AdvancedPane::CreateLayout() ram_override_description->setWordWrap(true); ram_override_layout->addWidget(ram_override_description); - auto* rtc_options = new QGroupBox(tr("Custom RTC Options")); - rtc_options->setLayout(new QVBoxLayout()); - main_layout->addWidget(rtc_options); - - m_custom_rtc_checkbox = new QCheckBox(tr("Enable Custom RTC")); - rtc_options->layout()->addWidget(m_custom_rtc_checkbox); - - m_custom_rtc_datetime = new QDateTimeEdit(); - - // Show seconds - m_custom_rtc_datetime->setDisplayFormat(m_custom_rtc_datetime->displayFormat().replace( - QStringLiteral("mm"), QStringLiteral("mm:ss"))); - - if (!m_custom_rtc_datetime->displayFormat().contains(QStringLiteral("yyyy"))) - { - // Always show the full year, no matter what the locale specifies. Otherwise, two-digit years - // will always be interpreted as in the 21st century. - m_custom_rtc_datetime->setDisplayFormat(m_custom_rtc_datetime->displayFormat().replace( - QStringLiteral("yy"), QStringLiteral("yyyy"))); - } - m_custom_rtc_datetime->setDateTimeRange(QDateTime({2000, 1, 1}, {0, 0, 0}, Qt::UTC), - QDateTime({2099, 12, 31}, {23, 59, 59}, Qt::UTC)); - m_custom_rtc_datetime->setTimeSpec(Qt::UTC); - rtc_options->layout()->addWidget(m_custom_rtc_datetime); - - auto* custom_rtc_description = - new QLabel(tr("This setting allows you to set a custom real time clock (RTC) separate from " - "your current system time.\n\nIf unsure, leave this unchecked.")); - custom_rtc_description->setWordWrap(true); - rtc_options->layout()->addWidget(custom_rtc_description); - main_layout->addStretch(1); } void AdvancedPane::ConnectLayout() { - connect(m_cpu_emulation_engine_combobox, - static_cast(&QComboBox::currentIndexChanged), [](int index) { - SConfig::GetInstance().cpu_core = PowerPC::AvailableCPUCores()[index]; - Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[index]); - }); - - connect(m_enable_mmu_checkbox, &QCheckBox::toggled, this, - [](bool checked) { SConfig::GetInstance().bMMU = checked; }); - 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; @@ -212,20 +140,6 @@ void AdvancedPane::ConnectLayout() Config::SetBaseOrCurrent(Config::MAIN_MEM2_SIZE, mem2_size); Update(); }); - - m_custom_rtc_checkbox->setChecked(SConfig::GetInstance().bEnableCustomRTC); - connect(m_custom_rtc_checkbox, &QCheckBox::toggled, [this](bool enable_custom_rtc) { - SConfig::GetInstance().bEnableCustomRTC = enable_custom_rtc; - Update(); - }); - - QDateTime initial_date_time; - initial_date_time.setSecsSinceEpoch(SConfig::GetInstance().m_customRTCValue); - m_custom_rtc_datetime->setDateTime(initial_date_time); - connect(m_custom_rtc_datetime, &QDateTimeEdit::dateTimeChanged, [this](QDateTime date_time) { - SConfig::GetInstance().m_customRTCValue = static_cast(date_time.toSecsSinceEpoch()); - Update(); - }); } void AdvancedPane::Update() @@ -233,18 +147,6 @@ void AdvancedPane::Update() const bool running = Core::GetState() != Core::State::Uninitialized; const bool enable_cpu_clock_override_widgets = SConfig::GetInstance().m_OCEnable; const bool enable_ram_override_widgets = Config::Get(Config::MAIN_RAM_OVERRIDE_ENABLE); - 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_emulation_engine_combobox->setCurrentIndex(int(i)); - } - m_cpu_emulation_engine_combobox->setEnabled(!running); - - m_enable_mmu_checkbox->setChecked(SConfig::GetInstance().bMMU); - m_enable_mmu_checkbox->setEnabled(!running); QFont bf = font(); bf.setBold(Config::GetActiveLayerForConfig(Config::MAIN_OVERCLOCK_ENABLE) != @@ -297,7 +199,4 @@ void AdvancedPane::Update() const u32 mem2_size = Config::Get(Config::MAIN_MEM2_SIZE) / 0x100000; return tr("%1MB (MEM2)").arg(QString::number(mem2_size)); }()); - - m_custom_rtc_checkbox->setEnabled(!running); - m_custom_rtc_datetime->setEnabled(enable_custom_rtc_widgets); } diff --git a/Source/Core/DolphinQt/Settings/AdvancedPane.h b/Source/Core/DolphinQt/Settings/AdvancedPane.h index 726ce93bc1e4..2ca13ea1fe6b 100644 --- a/Source/Core/DolphinQt/Settings/AdvancedPane.h +++ b/Source/Core/DolphinQt/Settings/AdvancedPane.h @@ -3,21 +3,12 @@ #pragma once -#include - #include class QCheckBox; -class QComboBox; class QLabel; class QRadioButton; class QSlider; -class QDateTimeEdit; - -namespace Core -{ -enum class State; -} class AdvancedPane final : public QWidget { @@ -30,16 +21,11 @@ class AdvancedPane final : public QWidget void ConnectLayout(); void Update(); - QComboBox* m_cpu_emulation_engine_combobox; - QCheckBox* m_enable_mmu_checkbox; QCheckBox* m_cpu_clock_override_checkbox; QSlider* m_cpu_clock_override_slider; QLabel* m_cpu_clock_override_slider_label; QLabel* m_cpu_clock_override_description; - QCheckBox* m_custom_rtc_checkbox; - QDateTimeEdit* m_custom_rtc_datetime; - QCheckBox* m_ram_override_checkbox; QSlider* m_mem1_override_slider; QLabel* m_mem1_override_slider_label; diff --git a/Source/Core/DolphinQt/Settings/MiscPane.cpp b/Source/Core/DolphinQt/Settings/MiscPane.cpp new file mode 100644 index 000000000000..09c6d984fa45 --- /dev/null +++ b/Source/Core/DolphinQt/Settings/MiscPane.cpp @@ -0,0 +1,142 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/Settings/MiscPane.h" + +#include +#include +#include +#include +#include +#include + +#include "Core/Config/MainSettings.h" +#include "Core/ConfigManager.h" +#include "Core/Core.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 for x86-64 (recommended)")}, + {PowerPC::CPUCore::JITARM64, QT_TR_NOOP("JIT Recompiler for ARM64 (recommended)")}, +}; + +MiscPane::MiscPane(QWidget* parent) : QWidget(parent) +{ + CreateLayout(); + Update(); + + ConnectLayout(); + + connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, &MiscPane::Update); +} + +void MiscPane::CreateLayout() +{ + auto* main_layout = new QVBoxLayout(); + setLayout(main_layout); + + auto* cpu_options = new QGroupBox(tr("CPU Options")); + auto* cpu_options_layout = new QVBoxLayout(); + cpu_options->setLayout(cpu_options_layout); + 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); + + 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)")); + cpu_options_layout->addWidget(m_enable_mmu_checkbox); + + auto* rtc_options = new QGroupBox(tr("Custom RTC Options")); + rtc_options->setLayout(new QVBoxLayout()); + main_layout->addWidget(rtc_options); + + m_custom_rtc_checkbox = new QCheckBox(tr("Enable Custom RTC")); + rtc_options->layout()->addWidget(m_custom_rtc_checkbox); + + m_custom_rtc_datetime = new QDateTimeEdit(); + + // Show seconds + m_custom_rtc_datetime->setDisplayFormat(m_custom_rtc_datetime->displayFormat().replace( + QStringLiteral("mm"), QStringLiteral("mm:ss"))); + + if (!m_custom_rtc_datetime->displayFormat().contains(QStringLiteral("yyyy"))) + { + // Always show the full year, no matter what the locale specifies. Otherwise, two-digit years + // will always be interpreted as in the 21st century. + m_custom_rtc_datetime->setDisplayFormat(m_custom_rtc_datetime->displayFormat().replace( + QStringLiteral("yy"), QStringLiteral("yyyy"))); + } + m_custom_rtc_datetime->setDateTimeRange(QDateTime({2000, 1, 1}, {0, 0, 0}, Qt::UTC), + QDateTime({2099, 12, 31}, {23, 59, 59}, Qt::UTC)); + m_custom_rtc_datetime->setTimeSpec(Qt::UTC); + rtc_options->layout()->addWidget(m_custom_rtc_datetime); + + auto* custom_rtc_description = + new QLabel(tr("This setting allows you to set a custom real time clock (RTC) separate from " + "your current system time.\n\nIf unsure, leave this unchecked.")); + custom_rtc_description->setWordWrap(true); + rtc_options->layout()->addWidget(custom_rtc_description); + + main_layout->addStretch(1); +} + +void MiscPane::ConnectLayout() +{ + connect(m_cpu_emulation_engine_combobox, + static_cast(&QComboBox::currentIndexChanged), [](int index) { + SConfig::GetInstance().cpu_core = PowerPC::AvailableCPUCores()[index]; + Config::SetBaseOrCurrent(Config::MAIN_CPU_CORE, PowerPC::AvailableCPUCores()[index]); + }); + + connect(m_enable_mmu_checkbox, &QCheckBox::toggled, this, + [](bool checked) { SConfig::GetInstance().bMMU = checked; }); + + m_custom_rtc_checkbox->setChecked(SConfig::GetInstance().bEnableCustomRTC); + connect(m_custom_rtc_checkbox, &QCheckBox::toggled, [this](bool enable_custom_rtc) { + SConfig::GetInstance().bEnableCustomRTC = enable_custom_rtc; + Update(); + }); + + QDateTime initial_date_time; + initial_date_time.setSecsSinceEpoch(SConfig::GetInstance().m_customRTCValue); + m_custom_rtc_datetime->setDateTime(initial_date_time); + connect(m_custom_rtc_datetime, &QDateTimeEdit::dateTimeChanged, [this](QDateTime date_time) { + SConfig::GetInstance().m_customRTCValue = static_cast(date_time.toSecsSinceEpoch()); + Update(); + }); +} + +void MiscPane::Update() +{ + const bool running = Core::GetState() != Core::State::Uninitialized; + 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_emulation_engine_combobox->setCurrentIndex(int(i)); + } + m_cpu_emulation_engine_combobox->setEnabled(!running); + + m_enable_mmu_checkbox->setChecked(SConfig::GetInstance().bMMU); + m_enable_mmu_checkbox->setEnabled(!running); + + m_custom_rtc_checkbox->setEnabled(!running); + m_custom_rtc_datetime->setEnabled(enable_custom_rtc_widgets); +} diff --git a/Source/Core/DolphinQt/Settings/MiscPane.h b/Source/Core/DolphinQt/Settings/MiscPane.h new file mode 100644 index 000000000000..a657465677ba --- /dev/null +++ b/Source/Core/DolphinQt/Settings/MiscPane.h @@ -0,0 +1,29 @@ +// Copyright 2020 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include + +class QCheckBox; +class QComboBox; +class QDateTimeEdit; + +class MiscPane final : public QWidget +{ + Q_OBJECT +public: + explicit MiscPane(QWidget* parent = nullptr); + +private: + void CreateLayout(); + void ConnectLayout(); + void Update(); + + QComboBox* m_cpu_emulation_engine_combobox; + QCheckBox* m_enable_mmu_checkbox; + + QCheckBox* m_custom_rtc_checkbox; + QDateTimeEdit* m_custom_rtc_datetime; +};