citra-qt: Add an "Alternative Speed Limit" with its hotkey (#5281)

* Change "Toggle Speed Limit" to toggle between 100% and a custom value

This will change the shortcut for "Toggle Speed Limit" to make it swap between 100% and the value of "Limit Speed Percent" in the config. Old functionality is still there, but renamed to "Unthrottle".

* Complete reimplementation of the function

* Fix something that didn't get saved correctly

* Fix missing indentation

* Rewrite to keep only a single QSpinBox

* Second rewrite

* set Unthrottled to 0 in the Qspinbox

* Hotkey for Unthrottle

* minor improvements to the design

* Apply suggestions from code review

Co-authored-by: Ben <bene_thomas@web.de>

* Default slider values

* clang-format fixes

* Prevent the speed slider from changing size

...when an element in its row has variable width.

* Change "Game Speed" to "Emulation Speed"

* Apply suggestions from code review

`game_speed` to` emulation_speed`

Co-authored-by: Valentin Vanelslande <vvanelslandedev@gmail.com>

* Fix for QSliders

* Revert "Prevent the speed slider from changing size"

This reverts commit ddaca2004484f1e024f49d2e6dc99ef5e261f64d.

* clang-format

...doesn't seem to stick to a choice

* Fix 2 for QSliders

Co-authored-by: B3n30 <benediktthomas@gmail.com>
Co-authored-by: Ben <bene_thomas@web.de>
Co-authored-by: Valentin Vanelslande <vvanelslandedev@gmail.com>
This commit is contained in:
SutandoTsukai181 2020-06-20 21:52:14 +03:00 committed by GitHub
parent 6d65319c85
commit 485d64ae73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 259 additions and 61 deletions

View file

@ -491,9 +491,10 @@ void GMainWindow::InitializeHotkeys() {
ToggleFullscreen();
}
});
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Speed Limit"), this),
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Alternate Speed"), this),
&QShortcut::activated, this, [&] {
Settings::values.use_frame_limit = !Settings::values.use_frame_limit;
Settings::values.use_frame_limit_alternate =
!Settings::values.use_frame_limit_alternate;
UpdateStatusBar();
});
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Texture Dumping"), this),
@ -504,17 +505,44 @@ 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.frame_limit < 9999 - SPEED_LIMIT_STEP) {
Settings::values.frame_limit += SPEED_LIMIT_STEP;
UpdateStatusBar();
if (Settings::values.use_frame_limit_alternate) {
if (Settings::values.frame_limit_alternate == 0) {
return;
}
if (Settings::values.frame_limit_alternate < 995 - SPEED_LIMIT_STEP) {
Settings::values.frame_limit_alternate += SPEED_LIMIT_STEP;
} else {
Settings::values.frame_limit_alternate = 0;
}
} else {
if (Settings::values.frame_limit == 0) {
return;
}
if (Settings::values.frame_limit < 995 - SPEED_LIMIT_STEP) {
Settings::values.frame_limit += SPEED_LIMIT_STEP;
} else {
Settings::values.frame_limit = 0;
}
}
UpdateStatusBar();
});
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Decrease Speed Limit"), this),
&QShortcut::activated, this, [&] {
if (Settings::values.frame_limit > SPEED_LIMIT_STEP) {
Settings::values.frame_limit -= SPEED_LIMIT_STEP;
UpdateStatusBar();
if (Settings::values.use_frame_limit_alternate) {
if (Settings::values.frame_limit_alternate == 0) {
Settings::values.frame_limit_alternate = 995;
} else if (Settings::values.frame_limit_alternate > SPEED_LIMIT_STEP) {
Settings::values.frame_limit_alternate -= SPEED_LIMIT_STEP;
}
} else {
if (Settings::values.frame_limit == 0) {
Settings::values.frame_limit = 995;
} else if (Settings::values.frame_limit > SPEED_LIMIT_STEP) {
Settings::values.frame_limit -= SPEED_LIMIT_STEP;
UpdateStatusBar();
}
}
UpdateStatusBar();
});
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Frame Advancing"), this),
&QShortcut::activated, ui.action_Enable_Frame_Advancing, &QAction::trigger);
@ -2019,12 +2047,22 @@ void GMainWindow::UpdateStatusBar() {
auto results = Core::System::GetInstance().GetAndResetPerfStats();
if (Settings::values.use_frame_limit) {
if (Settings::values.use_frame_limit_alternate) {
if (Settings::values.frame_limit_alternate == 0) {
emu_speed_label->setText(
tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0));
} else {
emu_speed_label->setText(tr("Speed: %1% / %2%")
.arg(results.emulation_speed * 100.0, 0, 'f', 0)
.arg(Settings::values.frame_limit_alternate));
}
} else if (Settings::values.frame_limit == 0) {
emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0));
} else {
emu_speed_label->setText(tr("Speed: %1% / %2%")
.arg(results.emulation_speed * 100.0, 0, 'f', 0)
.arg(Settings::values.frame_limit));
} else {
emu_speed_label->setText(tr("Speed: %1%").arg(results.emulation_speed * 100.0, 0, 'f', 0));
}
game_fps_label->setText(tr("Game: %1 FPS").arg(results.game_fps, 0, 'f', 0));
emu_frametime_label->setText(tr("Frame: %1 ms").arg(results.frametime * 1000.0, 0, 'f', 2));