diff --git a/src/duckstation-qt/CMakeLists.txt b/src/duckstation-qt/CMakeLists.txt index 6cff98996..d75e7af07 100644 --- a/src/duckstation-qt/CMakeLists.txt +++ b/src/duckstation-qt/CMakeLists.txt @@ -37,6 +37,9 @@ set(SRCS displaysettingswidget.cpp displaysettingswidget.h displaysettingswidget.ui + emulationsettingswidget.cpp + emulationsettingswidget.h + emulationsettingswidget.ui enhancementsettingswidget.cpp enhancementsettingswidget.h enhancementsettingswidget.ui diff --git a/src/duckstation-qt/consolesettingswidget.cpp b/src/duckstation-qt/consolesettingswidget.cpp index 258496bca..6163ab4a9 100644 --- a/src/duckstation-qt/consolesettingswidget.cpp +++ b/src/duckstation-qt/consolesettingswidget.cpp @@ -25,8 +25,6 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, "Console", "Region", &Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName, Settings::DEFAULT_CONSOLE_REGION); - SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToHostRefreshRate, "Main", - "SyncToHostRefreshRate", false); SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.cpuExecutionMode, "CPU", "ExecutionMode", &Settings::ParseCPUExecutionMode, &Settings::GetCPUExecutionModeName, Settings::DEFAULT_CPU_EXECUTION_MODE); @@ -37,28 +35,6 @@ 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 " @@ -67,24 +43,6 @@ 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"), tr("User Preference"), - 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"), tr("User Preference"), - tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled. Turboing will take " - "priority over fast forwarding if both hotkeys are pressed/toggled.")); - dialog->registerWidgetHelp( - m_ui.syncToHostRefreshRate, tr("Sync To Host Refresh Rate"), tr("Unchecked"), - tr("Adjusts the emulation speed so the console's refresh rate matches the host's refresh rate when both VSync and " - "Audio Resampling settings are enabled. This results in the smoothest animations possible, at the cost of " - "potentially increasing the emulation speed by less than 1%. Sync To Host Refresh Rate will not take effect if " - "the console's refresh rate is too far from the host's refresh rate. Users with variable refresh rate displays " - "should disable this option.")); m_ui.cpuClockSpeed->setEnabled(m_ui.enableCPUClockSpeedControl->checkState() == Qt::Checked); m_ui.cdromReadSpeedup->setCurrentIndex(m_host_interface->GetIntSettingValue("CDROM", "ReadSpeedup", 1) - 1); @@ -160,27 +118,3 @@ 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 1946aa44c..3d9248928 100644 --- a/src/duckstation-qt/consolesettingswidget.h +++ b/src/duckstation-qt/consolesettingswidget.h @@ -20,9 +20,6 @@ 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 a2da17111..f71e7d805 100644 --- a/src/duckstation-qt/consolesettingswidget.ui +++ b/src/duckstation-qt/consolesettingswidget.ui @@ -45,52 +45,6 @@ - - - - Speed Control - - - - - - Emulation Speed: - - - - - - - - - - Fast Forward Speed: - - - - - - - - - - Turbo Speed: - - - - - - - - - - Sync To Host Refresh Rate - - - - - - diff --git a/src/duckstation-qt/duckstation-qt.vcxproj b/src/duckstation-qt/duckstation-qt.vcxproj index b46cdf395..0f80f8689 100644 --- a/src/duckstation-qt/duckstation-qt.vcxproj +++ b/src/duckstation-qt/duckstation-qt.vcxproj @@ -59,6 +59,7 @@ + @@ -118,6 +119,7 @@ + @@ -164,6 +166,9 @@ Document + + Document + Document @@ -219,6 +224,7 @@ + diff --git a/src/duckstation-qt/emulationsettingswidget.cpp b/src/duckstation-qt/emulationsettingswidget.cpp new file mode 100644 index 000000000..77b607b99 --- /dev/null +++ b/src/duckstation-qt/emulationsettingswidget.cpp @@ -0,0 +1,83 @@ +#include "emulationsettingswidget.h" +#include "core/system.h" +#include "qtutils.h" +#include "settingsdialog.h" +#include "settingwidgetbinder.h" +#include + +EmulationSettingsWidget::EmulationSettingsWidget(QtHostInterface* host_interface, QWidget* parent, + SettingsDialog* dialog) + : QWidget(parent), m_host_interface(host_interface) +{ + m_ui.setupUi(this); + + SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToHostRefreshRate, "Main", + "SyncToHostRefreshRate", 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, + &EmulationSettingsWidget::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, + &EmulationSettingsWidget::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, + &EmulationSettingsWidget::onTurboSpeedIndexChanged); + + 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"), tr("User Preference"), + 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"), tr("User Preference"), + tr("Sets the turbo speed. This speed will be used when the turbo hotkey is pressed/toggled. Turboing will take " + "priority over fast forwarding if both hotkeys are pressed/toggled.")); + dialog->registerWidgetHelp( + m_ui.syncToHostRefreshRate, tr("Sync To Host Refresh Rate"), tr("Unchecked"), + tr("Adjusts the emulation speed so the console's refresh rate matches the host's refresh rate when both VSync and " + "Audio Resampling settings are enabled. This results in the smoothest animations possible, at the cost of " + "potentially increasing the emulation speed by less than 1%. Sync To Host Refresh Rate will not take effect if " + "the console's refresh rate is too far from the host's refresh rate. Users with variable refresh rate displays " + "should disable this option.")); +} + +EmulationSettingsWidget::~EmulationSettingsWidget() = default; + +void EmulationSettingsWidget::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 EmulationSettingsWidget::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 EmulationSettingsWidget::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/emulationsettingswidget.h b/src/duckstation-qt/emulationsettingswidget.h new file mode 100644 index 000000000..ab10831ed --- /dev/null +++ b/src/duckstation-qt/emulationsettingswidget.h @@ -0,0 +1,28 @@ +#pragma once + +#include + +#include "ui_emulationsettingswidget.h" + +class QtHostInterface; +class SettingsDialog; + +class EmulationSettingsWidget : public QWidget +{ + Q_OBJECT + +public: + explicit EmulationSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog); + ~EmulationSettingsWidget(); + +private Q_SLOTS: + void onEmulationSpeedIndexChanged(int index); + void onFastForwardSpeedIndexChanged(int index); + void onTurboSpeedIndexChanged(int index); + +private: + + Ui::EmulationSettingsWidget m_ui; + + QtHostInterface* m_host_interface; +}; diff --git a/src/duckstation-qt/emulationsettingswidget.ui b/src/duckstation-qt/emulationsettingswidget.ui new file mode 100644 index 000000000..9db54fa67 --- /dev/null +++ b/src/duckstation-qt/emulationsettingswidget.ui @@ -0,0 +1,94 @@ + + + EmulationSettingsWidget + + + + 0 + 0 + 648 + 456 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Speed Control + + + + + + Emulation Speed: + + + + + + + + + + Fast Forward Speed: + + + + + + + + + + Turbo Speed: + + + + + + + + + + Sync To Host Refresh Rate + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 48f2d3ab6..a9f6ca4be 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -969,6 +969,8 @@ void MainWindow::connectSignals() [this]() { doSettings(SettingsDialog::Category::BIOSSettings); }); connect(m_ui.actionConsoleSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::ConsoleSettings); }); + connect(m_ui.actionEmulationSettings, &QAction::triggered, + [this]() { doSettings(SettingsDialog::Category::EmulationSettings); }); connect(m_ui.actionGameListSettings, &QAction::triggered, [this]() { doSettings(SettingsDialog::Category::GameListSettings); }); connect(m_ui.actionHotkeySettings, &QAction::triggered, diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index 62100ee30..1128386e9 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -119,6 +119,7 @@ + @@ -375,6 +376,15 @@ C&onsole Settings... + + + + :/icons/applications-other.png:/icons/applications-other.png + + + E&mulation Settings... + + @@ -387,7 +397,7 @@ - :/icons/applications-other.png:/icons/applications-other.png + :/icons/preferences-desktop-keyboard-shortcuts.png:/icons/preferences-desktop-keyboard-shortcuts.png &Hotkey Settings... diff --git a/src/duckstation-qt/settingsdialog.cpp b/src/duckstation-qt/settingsdialog.cpp index 92d29165d..6a6028e95 100644 --- a/src/duckstation-qt/settingsdialog.cpp +++ b/src/duckstation-qt/settingsdialog.cpp @@ -5,6 +5,7 @@ #include "consolesettingswidget.h" #include "controllersettingswidget.h" #include "displaysettingswidget.h" +#include "emulationsettingswidget.h" #include "enhancementsettingswidget.h" #include "gamelistsettingswidget.h" #include "generalsettingswidget.h" @@ -27,6 +28,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent m_general_settings = new GeneralSettingsWidget(host_interface, m_ui.settingsContainer, this); m_bios_settings = new BIOSSettingsWidget(host_interface, m_ui.settingsContainer, this); m_console_settings = new ConsoleSettingsWidget(host_interface, m_ui.settingsContainer, this); + m_emulation_settings = new EmulationSettingsWidget(host_interface, m_ui.settingsContainer, this); m_game_list_settings = new GameListSettingsWidget(host_interface, m_ui.settingsContainer); m_hotkey_settings = new HotkeySettingsWidget(host_interface, m_ui.settingsContainer); m_controller_settings = new ControllerSettingsWidget(host_interface, m_ui.settingsContainer); @@ -40,6 +42,7 @@ SettingsDialog::SettingsDialog(QtHostInterface* host_interface, QWidget* parent m_ui.settingsContainer->insertWidget(static_cast(Category::GeneralSettings), m_general_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::BIOSSettings), m_bios_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::ConsoleSettings), m_console_settings); + m_ui.settingsContainer->insertWidget(static_cast(Category::EmulationSettings), m_emulation_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::GameListSettings), m_game_list_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::HotkeySettings), m_hotkey_settings); m_ui.settingsContainer->insertWidget(static_cast(Category::ControllerSettings), m_controller_settings); diff --git a/src/duckstation-qt/settingsdialog.h b/src/duckstation-qt/settingsdialog.h index cdd0aea92..5ff28b0d3 100644 --- a/src/duckstation-qt/settingsdialog.h +++ b/src/duckstation-qt/settingsdialog.h @@ -12,6 +12,7 @@ class BIOSSettingsWidget; class GameListSettingsWidget; class HotkeySettingsWidget; class ConsoleSettingsWidget; +class EmulationSettingsWidget; class ControllerSettingsWidget; class MemoryCardSettingsWidget; class DisplaySettingsWidget; @@ -30,6 +31,7 @@ public: GeneralSettings, BIOSSettings, ConsoleSettings, + EmulationSettings, GameListSettings, HotkeySettings, ControllerSettings, @@ -48,6 +50,7 @@ public: GeneralSettingsWidget* getGeneralSettingsWidget() const { return m_general_settings; } BIOSSettingsWidget* getBIOSSettingsWidget() const { return m_bios_settings; } ConsoleSettingsWidget* getConsoleSettingsWidget() const { return m_console_settings; } + EmulationSettingsWidget* getEmulationSettingsWidget() const { return m_emulation_settings; } GameListSettingsWidget* getGameListSettingsWidget() const { return m_game_list_settings; } HotkeySettingsWidget* getHotkeySettingsWidget() const { return m_hotkey_settings; } ControllerSettingsWidget* getControllerSettingsWidget() const { return m_controller_settings; } @@ -77,6 +80,7 @@ private: GeneralSettingsWidget* m_general_settings = nullptr; BIOSSettingsWidget* m_bios_settings = nullptr; ConsoleSettingsWidget* m_console_settings = nullptr; + EmulationSettingsWidget* m_emulation_settings = nullptr; GameListSettingsWidget* m_game_list_settings = nullptr; HotkeySettingsWidget* m_hotkey_settings = nullptr; ControllerSettingsWidget* m_controller_settings = nullptr; diff --git a/src/duckstation-qt/settingsdialog.ui b/src/duckstation-qt/settingsdialog.ui index 5531f7bfc..e279d53c0 100644 --- a/src/duckstation-qt/settingsdialog.ui +++ b/src/duckstation-qt/settingsdialog.ui @@ -80,6 +80,15 @@ :/icons/utilities-system-monitor.png:/icons/utilities-system-monitor.png + + + Emulation Settings + + + + :/icons/applications-other.png:/icons/applications-other.png + + Game List Settings