From 1b3c91e2f31449162d81a7a1940f471d9e9c8c44 Mon Sep 17 00:00:00 2001 From: SutandoTsukai181 <52977072+SutandoTsukai181@users.noreply.github.com> Date: Sat, 2 May 2020 03:27:08 +0300 Subject: [PATCH] Rewrite to keep only a single QSpinBox * Second rewrite * set Unthrottled to 0 in the Qspinbox * Hotkey for Unthrottle --- src/citra/config.cpp | 2 +- src/citra/default_ini.h | 13 ++++---- src/citra_qt/configuration/config.cpp | 7 ++-- .../configuration/configure_general.cpp | 29 ++++++++-------- .../configuration/configure_general.ui | 33 +++++-------------- src/citra_qt/main.cpp | 32 +++++------------- src/core/perf_stats.cpp | 2 +- src/core/settings.cpp | 2 +- src/core/settings.h | 2 +- src/core/telemetry_session.cpp | 4 +-- 10 files changed, 47 insertions(+), 79 deletions(-) diff --git a/src/citra/config.cpp b/src/citra/config.cpp index a986c11a9..3505f6e6a 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -123,7 +123,7 @@ void Config::ReadValues() { Settings::values.use_shader_jit = sdl2_config->GetBoolean("Renderer", "use_shader_jit", true); Settings::values.resolution_factor = static_cast(sdl2_config->GetInteger("Renderer", "resolution_factor", 1)); - Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); + Settings::values.unthrottled = sdl2_config->GetBoolean("Renderer", "unthrottled", false); Settings::values.use_disk_shader_cache = sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", true); Settings::values.frame_limit = diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index 13d6fc3d4..720749fda 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -135,16 +135,17 @@ resolution_factor = # Texture filter name texture_filter_name = -# Turns on the frame limiter, which will limit frames output to the target game speed -# 0: Off, 1: On (default) -use_frame_limit = +# Turns off the frame limiter, which will make the game speed go as high as it can. +# 0: Off (default), 1: On +unthrottled = -# Limits the speed of the game to run no faster than this value as a percentage of target speed +# Limits the speed of the game to run no faster than this value as a percentage of target speed. +# Will not have an effect if unthrottled is enabled. # 1 - 9999: Speed limit as a percentage of target game speed. 100 (default) frame_limit = -# Overrides the frame limiter to use frame_limit_alternate instead of frame_limit. Will only have -# an effect if use_frame_limit is enabled +# Overrides the frame limiter to use frame_limit_alternate instead of frame_limit. Will not have an +# effect if unthrottled is enabled. # 0: Off (default), 1: On use_frame_limit_alternate = diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 842ec66b7..71043e756 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -78,7 +78,7 @@ const std::array default_hotkeys{ {QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, {QStringLiteral("Toggle Frame Advancing"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+A"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Screen Layout"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::WindowShortcut}}, - {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}, + {QStringLiteral("Unthrottle"), QStringLiteral("Main Window"), {QStringLiteral("Tab"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Alternate Speed"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+X"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}}, {QStringLiteral("Toggle Texture Dumping"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+D"), Qt::ApplicationShortcut}}}}; @@ -446,8 +446,7 @@ void Config::ReadRendererValues() { Settings::values.use_vsync_new = ReadSetting(QStringLiteral("use_vsync_new"), true).toBool(); Settings::values.resolution_factor = static_cast(ReadSetting(QStringLiteral("resolution_factor"), 1).toInt()); - Settings::values.use_frame_limit = - ReadSetting(QStringLiteral("use_frame_limit"), true).toBool(); + Settings::values.unthrottled = ReadSetting(QStringLiteral("unthrottled"), false).toBool(); Settings::values.frame_limit = ReadSetting(QStringLiteral("frame_limit"), 100).toInt(); Settings::values.use_frame_limit_alternate = ReadSetting(QStringLiteral("use_frame_limit_alternate"), false).toBool(); @@ -934,7 +933,7 @@ void Config::SaveRendererValues() { WriteSetting(QStringLiteral("use_shader_jit"), Settings::values.use_shader_jit, true); WriteSetting(QStringLiteral("use_vsync_new"), Settings::values.use_vsync_new, true); WriteSetting(QStringLiteral("resolution_factor"), Settings::values.resolution_factor, 1); - WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true); + WriteSetting(QStringLiteral("unthrottled"), Settings::values.unthrottled, false); WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); WriteSetting(QStringLiteral("use_frame_limit_alternate"), Settings::values.use_frame_limit_alternate, false); diff --git a/src/citra_qt/configuration/configure_general.cpp b/src/citra_qt/configuration/configure_general.cpp index b966ac20a..94e57a8b0 100644 --- a/src/citra_qt/configuration/configure_general.cpp +++ b/src/citra_qt/configuration/configure_general.cpp @@ -15,11 +15,6 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent) ui->setupUi(this); SetConfiguration(); - connect(ui->toggle_frame_limit, &QCheckBox::toggled, ui->frame_limit, &QSpinBox::setEnabled); - - connect(ui->toggle_alternate_speed, &QCheckBox::toggled, ui->frame_limit_alternate, - &QSpinBox::setEnabled); - ui->updateBox->setVisible(UISettings::values.updater_found); connect(ui->button_reset_defaults, &QPushButton::clicked, this, &ConfigureGeneral::ResetDefaults); @@ -38,14 +33,14 @@ void ConfigureGeneral::SetConfiguration() { // The first item is "auto-select" with actual value -1, so plus one here will do the trick ui->region_combobox->setCurrentIndex(Settings::values.region_value + 1); - ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); - ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); - ui->frame_limit->setValue(Settings::values.frame_limit); - ui->toggle_alternate_speed->setChecked(Settings::values.use_frame_limit_alternate); - ui->frame_limit_alternate->setEnabled(ui->toggle_alternate_speed->isChecked()); - ui->frame_limit_alternate->setValue(Settings::values.frame_limit_alternate); + if (Settings::values.unthrottled) { + ui->frame_limit_alternate->setValue(0); + } else { + ui->frame_limit_alternate->setValue(Settings::values.frame_limit_alternate); + } } + void ConfigureGeneral::ResetDefaults() { QMessageBox::StandardButton answer = QMessageBox::question( @@ -70,11 +65,15 @@ void ConfigureGeneral::ApplyConfiguration() { Settings::values.region_value = ui->region_combobox->currentIndex() - 1; - Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); - Settings::values.frame_limit = ui->frame_limit->value(); - Settings::values.use_frame_limit_alternate = ui->toggle_alternate_speed->isChecked(); - Settings::values.frame_limit_alternate = ui->frame_limit_alternate->value(); + if (!ui->toggle_alternate_speed->isChecked()) { + if (ui->frame_limit_alternate->value() == 0) + Settings::values.unthrottled = true; + } else { + Settings::values.unthrottled = false; + if (!ui->frame_limit_alternate->value() == 0) + Settings::values.frame_limit_alternate = ui->frame_limit_alternate->value(); + } } void ConfigureGeneral::RetranslateUI() { diff --git a/src/citra_qt/configuration/configure_general.ui b/src/citra_qt/configuration/configure_general.ui index 9581d202d..6b7b4f7bc 100644 --- a/src/citra_qt/configuration/configure_general.ui +++ b/src/citra_qt/configuration/configure_general.ui @@ -76,16 +76,9 @@ - - - Limit Speed Percent - - - - - Alternate Speed Limit + Alternate Speed Percent @@ -141,28 +134,12 @@ - - - % - - - 1 - - - 9999 - - - 100 - - - - % - 1 + 0 9999 @@ -170,6 +147,12 @@ 200 + + 5 + + + Unthrottled + diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index fa48ba984..d9ab35858 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -491,9 +491,9 @@ void GMainWindow::InitializeHotkeys() { ToggleFullscreen(); } }); - connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Speed Limit"), this), + connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Unthrottle"), this), &QShortcut::activated, this, [&] { - Settings::values.use_frame_limit = !Settings::values.use_frame_limit; + Settings::values.unthrottled = !Settings::values.unthrottled; UpdateStatusBar(); }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Alternate Speed"), this), @@ -510,30 +510,16 @@ void GMainWindow::InitializeHotkeys() { static constexpr u16 SPEED_LIMIT_STEP = 5; connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Increase Speed Limit"), this), &QShortcut::activated, this, [&] { - if (Settings::values.use_frame_limit_alternate) { - if (Settings::values.frame_limit_alternate < 9999 - SPEED_LIMIT_STEP) { - Settings::values.frame_limit_alternate += SPEED_LIMIT_STEP; - UpdateStatusBar(); - } - } else { - if (Settings::values.frame_limit < 9999 - SPEED_LIMIT_STEP) { - Settings::values.frame_limit += SPEED_LIMIT_STEP; - UpdateStatusBar(); - } + if (Settings::values.frame_limit_alternate < 9999 - SPEED_LIMIT_STEP) { + Settings::values.frame_limit_alternate += SPEED_LIMIT_STEP; + UpdateStatusBar(); } }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Decrease Speed Limit"), this), &QShortcut::activated, this, [&] { - if (Settings::values.use_frame_limit_alternate) { - if (Settings::values.frame_limit_alternate > SPEED_LIMIT_STEP) { - Settings::values.frame_limit_alternate -= SPEED_LIMIT_STEP; - UpdateStatusBar(); - } - } else { - if (Settings::values.frame_limit > SPEED_LIMIT_STEP) { - Settings::values.frame_limit -= SPEED_LIMIT_STEP; - UpdateStatusBar(); - } + if (Settings::values.frame_limit_alternate > SPEED_LIMIT_STEP) { + Settings::values.frame_limit_alternate -= SPEED_LIMIT_STEP; + UpdateStatusBar(); } }); connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Frame Advancing"), this), @@ -2041,7 +2027,7 @@ void GMainWindow::UpdateStatusBar() { auto results = Core::System::GetInstance().GetAndResetPerfStats(); - if (Settings::values.use_frame_limit) { + if (!Settings::values.unthrottled) { if (Settings::values.use_frame_limit_alternate) { emu_speed_label->setText(tr("Speed: %1% / %2%") diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index db3d781e5..bafa7f7e7 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -133,7 +133,7 @@ void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) { return; } - if (!Settings::values.use_frame_limit) { + if (Settings::values.unthrottled) { return; } diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 55e18d67e..8f3e70598 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -81,7 +81,7 @@ void LogSettings() { LogSetting("Renderer_ShadersAccurateMul", Settings::values.shaders_accurate_mul); LogSetting("Renderer_UseShaderJit", Settings::values.use_shader_jit); LogSetting("Renderer_UseResolutionFactor", Settings::values.resolution_factor); - LogSetting("Renderer_UseFrameLimit", Settings::values.use_frame_limit); + LogSetting("Renderer_Unthrottled", Settings::values.unthrottled); LogSetting("Renderer_FrameLimit", Settings::values.frame_limit); LogSetting("Renderer_UseFrameLimitAlternate", Settings::values.use_frame_limit_alternate); LogSetting("Renderer_FrameLimitAlternate", Settings::values.frame_limit_alternate); diff --git a/src/core/settings.h b/src/core/settings.h index c882c0346..940c9ffa8 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -146,7 +146,7 @@ struct Values { bool shaders_accurate_mul; bool use_shader_jit; u16 resolution_factor; - bool use_frame_limit; + bool unthrottled; bool use_frame_limit_alternate; u16 frame_limit; u16 frame_limit_alternate; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 525518dde..83d1bfd10 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -165,8 +165,8 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader) { AddField(Telemetry::FieldType::UserConfig, "Core_UseCpuJit", Settings::values.use_cpu_jit); AddField(Telemetry::FieldType::UserConfig, "Renderer_ResolutionFactor", Settings::values.resolution_factor); - AddField(Telemetry::FieldType::UserConfig, "Renderer_UseFrameLimit", - Settings::values.use_frame_limit); + AddField(Telemetry::FieldType::UserConfig, "Renderer_Unthrottled", + Settings::values.unthrottled); AddField(Telemetry::FieldType::UserConfig, "Renderer_FrameLimit", Settings::values.frame_limit); AddField(Telemetry::FieldType::UserConfig, "Renderer_UseFrameLimitAlternate", Settings::values.use_frame_limit_alternate);