From fdeef65676031b9c090258a36682406f33071891 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 11 Jan 2021 02:12:20 +1000 Subject: [PATCH] Qt: Move emulation speed settings to console settings --- src/duckstation-qt/consolesettingswidget.cpp | 56 ++++++ src/duckstation-qt/consolesettingswidget.h | 3 + src/duckstation-qt/consolesettingswidget.ui | 190 +++++++++++-------- src/duckstation-qt/generalsettingswidget.cpp | 57 ------ src/duckstation-qt/generalsettingswidget.h | 5 - src/duckstation-qt/generalsettingswidget.ui | 39 ---- 6 files changed, 173 insertions(+), 177 deletions(-) diff --git a/src/duckstation-qt/consolesettingswidget.cpp b/src/duckstation-qt/consolesettingswidget.cpp index 2923e447f..f241878d0 100644 --- a/src/duckstation-qt/consolesettingswidget.cpp +++ b/src/duckstation-qt/consolesettingswidget.cpp @@ -35,6 +35,28 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromLoadImageToRAM, "CDROM", "LoadImageToRAM", false); + QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed); + const int emulation_speed_index = + m_ui.emulationSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "EmulationSpeed", 1.0f))); + if (emulation_speed_index >= 0) + m_ui.emulationSpeed->setCurrentIndex(emulation_speed_index); + connect(m_ui.emulationSpeed, QOverload::of(&QComboBox::currentIndexChanged), this, + &ConsoleSettingsWidget::onEmulationSpeedIndexChanged); + QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.fastForwardSpeed); + const int fast_forward_speed_index = + m_ui.fastForwardSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "FastForwardSpeed", 0.0f))); + if (fast_forward_speed_index >= 0) + m_ui.fastForwardSpeed->setCurrentIndex(fast_forward_speed_index); + connect(m_ui.fastForwardSpeed, QOverload::of(&QComboBox::currentIndexChanged), this, + &ConsoleSettingsWidget::onFastForwardSpeedIndexChanged); + QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.turboSpeed); + const int turbo_speed_index = + m_ui.turboSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "TurboSpeed", 0.0f))); + if (turbo_speed_index >= 0) + m_ui.turboSpeed->setCurrentIndex(turbo_speed_index); + connect(m_ui.turboSpeed, QOverload::of(&QComboBox::currentIndexChanged), this, + &ConsoleSettingsWidget::onTurboSpeedIndexChanged); + dialog->registerWidgetHelp( m_ui.cdromLoadImageToRAM, tr("Preload Image to RAM"), tr("Unchecked"), tr("Loads the game image into RAM. Useful for network paths that may become unreliable during gameplay. In some " @@ -43,6 +65,16 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW m_ui.cdromReadSpeedup, tr("CDROM Read Speedup"), tr("None (Double Speed"), tr("Speeds up CD-ROM reads by the specified factor. Only applies to double-speed reads, and is ignored when audio " "is playing. May improve loading speeds in some games, at the cost of breaking others.")); + dialog->registerWidgetHelp( + m_ui.emulationSpeed, tr("Emulation Speed"), "100%", + tr("Sets the target emulation speed. It is not guaranteed that this speed will be reached, " + "and if not, the emulator will run as fast as it can manage.")); + dialog->registerWidgetHelp( + m_ui.fastForwardSpeed, tr("Fast Forward Speed"), "100%", + tr("Sets the fast forward speed. This speed will be used when the fast forward hotkey is pressed/toggled.")); + dialog->registerWidgetHelp( + m_ui.turboSpeed, tr("Turbo Speed"), "100%", + tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled.")); m_ui.cpuClockSpeed->setEnabled(m_ui.enableCPUClockSpeedControl->checkState() == Qt::Checked); m_ui.cdromReadSpeedup->setCurrentIndex(m_host_interface->GetIntSettingValue("CDROM", "ReadSpeedup", 1) - 1); @@ -118,3 +150,27 @@ void ConsoleSettingsWidget::calculateCPUClockValue() m_ui.cpuClockSpeed->setValue(static_cast(percent)); updateCPUClockSpeedLabel(); } + +void ConsoleSettingsWidget::onEmulationSpeedIndexChanged(int index) +{ + bool okay; + const float value = m_ui.emulationSpeed->currentData().toFloat(&okay); + m_host_interface->SetFloatSettingValue("Main", "EmulationSpeed", okay ? value : 1.0f); + m_host_interface->applySettings(); +} + +void ConsoleSettingsWidget::onFastForwardSpeedIndexChanged(int index) +{ + bool okay; + const float value = m_ui.fastForwardSpeed->currentData().toFloat(&okay); + m_host_interface->SetFloatSettingValue("Main", "FastForwardSpeed", okay ? value : 0.0f); + m_host_interface->applySettings(); +} + +void ConsoleSettingsWidget::onTurboSpeedIndexChanged(int index) +{ + bool okay; + const float value = m_ui.turboSpeed->currentData().toFloat(&okay); + m_host_interface->SetFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f); + m_host_interface->applySettings(); +} diff --git a/src/duckstation-qt/consolesettingswidget.h b/src/duckstation-qt/consolesettingswidget.h index 3d9248928..1946aa44c 100644 --- a/src/duckstation-qt/consolesettingswidget.h +++ b/src/duckstation-qt/consolesettingswidget.h @@ -20,6 +20,9 @@ private Q_SLOTS: void onCPUClockSpeedValueChanged(int value); void updateCPUClockSpeedLabel(); void onCDROMReadSpeedupValueChanged(int value); + void onEmulationSpeedIndexChanged(int index); + void onFastForwardSpeedIndexChanged(int index); + void onTurboSpeedIndexChanged(int index); private: void calculateCPUClockValue(); diff --git a/src/duckstation-qt/consolesettingswidget.ui b/src/duckstation-qt/consolesettingswidget.ui index cb70f6ac8..51044c53e 100644 --- a/src/duckstation-qt/consolesettingswidget.ui +++ b/src/duckstation-qt/consolesettingswidget.ui @@ -7,7 +7,7 @@ 0 0 648 - 401 + 456 @@ -45,12 +45,51 @@ + + + + Speed Control + + + + + + Emulation Speed: + + + + + + + + + + Fast Forward Speed: + + + + + + + + + + Turbo Speed: + + + + + + + + + CPU Emulation - + @@ -61,71 +100,66 @@ - - - - - - - CPU Clock Speed Control - - - - + + - - - Enable Clock Speed Control (Overclocking/Underclocking) - - + + + + + Enable Clock Speed Control (Overclocking/Underclocking) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 100% (effective 33.3mhz) + + + Qt::AlignCenter + + + + - + + + 10 + + + 1000 + + + 100 + Qt::Horizontal - - - 40 - 20 - + + QSlider::TicksBothSides - - - - - - 100% (effective 33.3mhz) - - - Qt::AlignCenter + + 50 - - - - 10 - - - 1000 - - - 100 - - - Qt::Horizontal - - - QSlider::TicksBothSides - - - 50 - - - @@ -135,27 +169,6 @@ CD-ROM Emulation - - - - Use Read Thread (Asynchronous) - - - - - - - Enable Region Check - - - - - - - Preload Image To RAM - - - @@ -217,6 +230,31 @@ + + + + + + Use Read Thread (Asynchronous) + + + + + + + Enable Region Check + + + + + + + Preload Image To RAM + + + + + diff --git a/src/duckstation-qt/generalsettingswidget.cpp b/src/duckstation-qt/generalsettingswidget.cpp index eac6130ed..a9d56c227 100644 --- a/src/duckstation-qt/generalsettingswidget.cpp +++ b/src/duckstation-qt/generalsettingswidget.cpp @@ -38,29 +38,6 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW m_host_interface, m_ui.controllerBackend, "Main", "ControllerBackend", &ControllerInterface::ParseBackendName, &ControllerInterface::GetBackendName, ControllerInterface::GetDefaultBackend()); - QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.emulationSpeed); - const int emulation_speed_index = - m_ui.emulationSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "EmulationSpeed", 1.0f))); - if (emulation_speed_index >= 0) - m_ui.emulationSpeed->setCurrentIndex(emulation_speed_index); - connect(m_ui.emulationSpeed, QOverload::of(&QComboBox::currentIndexChanged), this, - &GeneralSettingsWidget::onEmulationSpeedIndexChanged); - - QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.fastForwardSpeed); - const int fast_forward_speed_index = - m_ui.fastForwardSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "FastForwardSpeed", 0.0f))); - if (fast_forward_speed_index >= 0) - m_ui.fastForwardSpeed->setCurrentIndex(fast_forward_speed_index); - connect(m_ui.fastForwardSpeed, QOverload::of(&QComboBox::currentIndexChanged), this, - &GeneralSettingsWidget::onFastForwardSpeedIndexChanged); - QtUtils::FillComboBoxWithEmulationSpeeds(m_ui.turboSpeed); - const int turbo_speed_index = - m_ui.turboSpeed->findData(QVariant(m_host_interface->GetFloatSettingValue("Main", "TurboSpeed", 0.0f))); - if (turbo_speed_index >= 0) - m_ui.turboSpeed->setCurrentIndex(turbo_speed_index); - connect(m_ui.turboSpeed, QOverload::of(&QComboBox::currentIndexChanged), this, - &GeneralSettingsWidget::onTurboSpeedIndexChanged); - dialog->registerWidgetHelp( m_ui.confirmPowerOff, tr("Confirm Power Off"), tr("Checked"), tr("Determines whether a prompt will be displayed to confirm shutting down the emulator/game " @@ -90,16 +67,6 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW m_ui.applyGameSettings, tr("Apply Per-Game Settings"), tr("Checked"), tr("When enabled, per-game settings will be applied, and incompatible enhancements will be disabled. You should " "leave this option enabled except when testing enhancements with incompatible games.")); - dialog->registerWidgetHelp( - m_ui.emulationSpeed, tr("Emulation Speed"), "100%", - tr("Sets the target emulation speed. It is not guaranteed that this speed will be reached, " - "and if not, the emulator will run as fast as it can manage.")); - dialog->registerWidgetHelp( - m_ui.fastForwardSpeed, tr("Fast Forward Speed"), "100%", - tr("Sets the fast forward speed. This speed will be used when the fast forward hotkey is pressed/toggled.")); - dialog->registerWidgetHelp( - m_ui.turboSpeed, tr("Turbo Speed"), "100%", - tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled.")); dialog->registerWidgetHelp(m_ui.controllerBackend, tr("Controller Backend"), qApp->translate("ControllerInterface", ControllerInterface::GetBackendName( ControllerInterface::GetDefaultBackend())), @@ -149,27 +116,3 @@ GeneralSettingsWidget::GeneralSettingsWidget(QtHostInterface* host_interface, QW } GeneralSettingsWidget::~GeneralSettingsWidget() = default; - -void GeneralSettingsWidget::onEmulationSpeedIndexChanged(int index) -{ - bool okay; - const float value = m_ui.emulationSpeed->currentData().toFloat(&okay); - m_host_interface->SetFloatSettingValue("Main", "EmulationSpeed", okay ? value : 1.0f); - m_host_interface->applySettings(); -} - -void GeneralSettingsWidget::onFastForwardSpeedIndexChanged(int index) -{ - bool okay; - const float value = m_ui.fastForwardSpeed->currentData().toFloat(&okay); - m_host_interface->SetFloatSettingValue("Main", "FastForwardSpeed", okay ? value : 0.0f); - m_host_interface->applySettings(); -} - -void GeneralSettingsWidget::onTurboSpeedIndexChanged(int index) -{ - bool okay; - const float value = m_ui.turboSpeed->currentData().toFloat(&okay); - m_host_interface->SetFloatSettingValue("Main", "TurboSpeed", okay ? value : 0.0f); - m_host_interface->applySettings(); -} diff --git a/src/duckstation-qt/generalsettingswidget.h b/src/duckstation-qt/generalsettingswidget.h index e168251af..e26d16d94 100644 --- a/src/duckstation-qt/generalsettingswidget.h +++ b/src/duckstation-qt/generalsettingswidget.h @@ -15,11 +15,6 @@ public: explicit GeneralSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog); ~GeneralSettingsWidget(); -private Q_SLOTS: - void onEmulationSpeedIndexChanged(int index); - void onFastForwardSpeedIndexChanged(int index); - void onTurboSpeedIndexChanged(int index); - private: Ui::GeneralSettingsWidget m_ui; diff --git a/src/duckstation-qt/generalsettingswidget.ui b/src/duckstation-qt/generalsettingswidget.ui index 49d5d0785..d252f9542 100644 --- a/src/duckstation-qt/generalsettingswidget.ui +++ b/src/duckstation-qt/generalsettingswidget.ui @@ -105,45 +105,6 @@ - - - - Speed Control - - - - - - Emulation Speed: - - - - - - - - - - Fast Forward Speed: - - - - - - - - - - Turbo Speed: - - - - - - - - -