From 6624df1e8cef23018d140b6b6189bcdec5eef28d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 29 Jan 2020 00:01:44 +1000 Subject: [PATCH] Qt: Add CPU settings/emulation speed to console settings --- src/duckstation-qt/consolesettingswidget.cpp | 21 ++ src/duckstation-qt/consolesettingswidget.h | 2 + src/duckstation-qt/consolesettingswidget.ui | 257 +++++++++++++------ 3 files changed, 199 insertions(+), 81 deletions(-) diff --git a/src/duckstation-qt/consolesettingswidget.cpp b/src/duckstation-qt/consolesettingswidget.cpp index 43391ce40..d62d8aa0e 100644 --- a/src/duckstation-qt/consolesettingswidget.cpp +++ b/src/duckstation-qt/consolesettingswidget.cpp @@ -9,6 +9,9 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW { m_ui.setupUi(this); + for (u32 i = 0; i < static_cast(CPUExecutionMode::Count); i++) + m_ui.cpuExecutionMode->addItem(tr(Settings::GetCPUExecutionModeDisplayName(static_cast(i)))); + SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, "Console/Region", &Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName); SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, m_ui.biosPath, "BIOS/Path"); @@ -16,9 +19,17 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.fastBoot, "BIOS/PatchFastBoot"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableSpeedLimiter, "General/SpeedLimiterEnabled"); + SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.emulationSpeed, "General/EmulationSpeed"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pauseOnStart, "General/StartPaused"); connect(m_ui.biosPathBrowse, &QPushButton::pressed, this, &ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked); + + connect(m_ui.enableSpeedLimiter, &QCheckBox::stateChanged, this, + &ConsoleSettingsWidget::onEnableSpeedLimiterStateChanged); + connect(m_ui.emulationSpeed, &QSlider::valueChanged, this, &ConsoleSettingsWidget::onEmulationSpeedValueChanged); + + onEnableSpeedLimiterStateChanged(); + onEmulationSpeedValueChanged(m_ui.emulationSpeed->value()); } ConsoleSettingsWidget::~ConsoleSettingsWidget() = default; @@ -34,3 +45,13 @@ void ConsoleSettingsWidget::onBrowseBIOSPathButtonClicked() m_host_interface->putSettingValue("BIOS/Path", path); m_host_interface->applySettings(); } + +void ConsoleSettingsWidget::onEnableSpeedLimiterStateChanged() +{ + m_ui.emulationSpeed->setDisabled(!m_ui.enableSpeedLimiter->isChecked()); +} + +void ConsoleSettingsWidget::onEmulationSpeedValueChanged(int value) +{ + m_ui.emulationSpeedLabel->setText(tr("%1%").arg(value)); +} diff --git a/src/duckstation-qt/consolesettingswidget.h b/src/duckstation-qt/consolesettingswidget.h index dd8fba125..a4f56c5ab 100644 --- a/src/duckstation-qt/consolesettingswidget.h +++ b/src/duckstation-qt/consolesettingswidget.h @@ -16,6 +16,8 @@ public: private Q_SLOTS: void onBrowseBIOSPathButtonClicked(); + void onEnableSpeedLimiterStateChanged(); + void onEmulationSpeedValueChanged(int value); private: Ui::ConsoleSettingsWidget m_ui; diff --git a/src/duckstation-qt/consolesettingswidget.ui b/src/duckstation-qt/consolesettingswidget.ui index 252af2543..ff105c40b 100644 --- a/src/duckstation-qt/consolesettingswidget.ui +++ b/src/duckstation-qt/consolesettingswidget.ui @@ -7,13 +7,13 @@ 0 0 502 - 308 + 358 Form - + 0 @@ -23,89 +23,184 @@ 0 - - - - - - Region: - - - - - - + + 0 + + + + + Console + + + + - Auto-Detect + Region: - - - - NTSC-J (Japan) - - - - - NTSC-U (US) - - - - - PAL (Europe, Australia) - - - - - - - - BIOS Path: - - - - - - - - - - + + + + + - ... + Auto-Detect - - - - - - - - Enable TTY Output - - - - - - - Fast Boot - - - - - - - Enable Speed Limiter - - - - - - - Pause On Start - - - - + + + + NTSC-J (Japan) + + + + + NTSC-U (US) + + + + + PAL (Europe, Australia) + + + + + + + + BIOS Image Path: + + + + + + + Fast Boot + + + + + + + Enable TTY Output + + + + + + + + + + + + ... + + + + + + + + + + + + Behaviour + + + + + + Emulation Speed: + + + + + + + + + 25 + + + 500 + + + 25 + + + 25 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + + + + 100% + + + + + + + + + Enable Speed Limiter + + + + + + + Pause On Start + + + + + + + + + + CPU Emulation + + + + + + Execution Mode: + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + +