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".
This commit is contained in:
SutandoTsukai181 2020-04-29 03:34:09 +03:00
parent 98fe5f82c5
commit 9de6a0cb3a
5 changed files with 32 additions and 12 deletions

View file

@ -126,7 +126,8 @@ void Config::ReadValues() {
Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true);
Settings::values.use_disk_shader_cache = Settings::values.use_disk_shader_cache =
sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", true); sdl2_config->GetBoolean("Renderer", "use_disk_shader_cache", true);
Settings::values.frame_limit = Settings::values.frame_limit = 100;
Settings::values.frame_limit_custom =
static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100)); static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100));
Settings::values.use_vsync_new = Settings::values.use_vsync_new =
static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync_new", 1)); static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync_new", 1));

View file

@ -57,7 +57,7 @@ const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> Config:
// This must be in alphabetical order according to action name as it must have the same order as // This must be in alphabetical order according to action name as it must have the same order as
// UISetting::values.shortcuts, which is alphabetically ordered. // UISetting::values.shortcuts, which is alphabetically ordered.
// clang-format off // clang-format off
const std::array<UISettings::Shortcut, 23> default_hotkeys{ const std::array<UISettings::Shortcut, 24> default_hotkeys{
{{QStringLiteral("Advance Frame"), QStringLiteral("Main Window"), {QStringLiteral("\\"), Qt::ApplicationShortcut}}, {{QStringLiteral("Advance Frame"), QStringLiteral("Main Window"), {QStringLiteral("\\"), Qt::ApplicationShortcut}},
{QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::ApplicationShortcut}}, {QStringLiteral("Capture Screenshot"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+P"), Qt::ApplicationShortcut}},
{QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}}, {QStringLiteral("Continue/Pause Emulation"), QStringLiteral("Main Window"), {QStringLiteral("F4"), Qt::WindowShortcut}},
@ -78,9 +78,10 @@ const std::array<UISettings::Shortcut, 23> default_hotkeys{
{QStringLiteral("Toggle Filter Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+F"), Qt::WindowShortcut}}, {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 Frame Advancing"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+A"), Qt::ApplicationShortcut}},
{QStringLiteral("Toggle Screen Layout"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::WindowShortcut}}, {QStringLiteral("Toggle Screen Layout"), QStringLiteral("Main Window"), {QStringLiteral("F10"), Qt::WindowShortcut}},
{QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}, {QStringLiteral("Toggle Speed Limit"), QStringLiteral("Main Window"), {QStringLiteral("Backspace"), Qt::ApplicationShortcut}},
{QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}}, {QStringLiteral("Toggle Status Bar"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+S"), Qt::WindowShortcut}},
{QStringLiteral("Toggle Texture Dumping"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+D"), Qt::ApplicationShortcut}}}}; {QStringLiteral("Toggle Texture Dumping"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+D"), Qt::ApplicationShortcut}},
{QStringLiteral("Unthrottle"), QStringLiteral("Main Window"), {QStringLiteral("Ctrl+Z"), Qt::ApplicationShortcut}}}};
// clang-format on // clang-format on
void Config::ReadValues() { void Config::ReadValues() {
@ -447,7 +448,8 @@ void Config::ReadRendererValues() {
static_cast<u16>(ReadSetting(QStringLiteral("resolution_factor"), 1).toInt()); static_cast<u16>(ReadSetting(QStringLiteral("resolution_factor"), 1).toInt());
Settings::values.use_frame_limit = Settings::values.use_frame_limit =
ReadSetting(QStringLiteral("use_frame_limit"), true).toBool(); ReadSetting(QStringLiteral("use_frame_limit"), true).toBool();
Settings::values.frame_limit = ReadSetting(QStringLiteral("frame_limit"), 100).toInt(); Settings::values.frame_limit = 100;
Settings::values.frame_limit_custom = ReadSetting(QStringLiteral("frame_limit"), 100).toInt();
Settings::values.bg_red = ReadSetting(QStringLiteral("bg_red"), 0.0).toFloat(); Settings::values.bg_red = ReadSetting(QStringLiteral("bg_red"), 0.0).toFloat();
Settings::values.bg_green = ReadSetting(QStringLiteral("bg_green"), 0.0).toFloat(); Settings::values.bg_green = ReadSetting(QStringLiteral("bg_green"), 0.0).toFloat();
@ -930,7 +932,7 @@ void Config::SaveRendererValues() {
WriteSetting(QStringLiteral("use_vsync_new"), Settings::values.use_vsync_new, true); WriteSetting(QStringLiteral("use_vsync_new"), Settings::values.use_vsync_new, true);
WriteSetting(QStringLiteral("resolution_factor"), Settings::values.resolution_factor, 1); WriteSetting(QStringLiteral("resolution_factor"), Settings::values.resolution_factor, 1);
WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true); WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true);
WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit_custom, 100);
// Cast to double because Qt's written float values are not human-readable // Cast to double because Qt's written float values are not human-readable
WriteSetting(QStringLiteral("bg_red"), (double)Settings::values.bg_red, 0.0); WriteSetting(QStringLiteral("bg_red"), (double)Settings::values.bg_red, 0.0);

View file

@ -37,7 +37,7 @@ void ConfigureGeneral::SetConfiguration() {
ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked());
ui->frame_limit->setValue(Settings::values.frame_limit); ui->frame_limit->setValue(Settings::values.frame_limit_custom);
} }
void ConfigureGeneral::ResetDefaults() { void ConfigureGeneral::ResetDefaults() {
@ -64,7 +64,7 @@ void ConfigureGeneral::ApplyConfiguration() {
Settings::values.region_value = ui->region_combobox->currentIndex() - 1; Settings::values.region_value = ui->region_combobox->currentIndex() - 1;
Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked();
Settings::values.frame_limit = ui->frame_limit->value(); Settings::values.frame_limit_custom = ui->frame_limit->value();
} }
void ConfigureGeneral::RetranslateUI() { void ConfigureGeneral::RetranslateUI() {

View file

@ -492,6 +492,16 @@ void GMainWindow::InitializeHotkeys() {
} }
}); });
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Speed Limit"), this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Speed Limit"), this),
&QShortcut::activated, this, [&] {
if (Settings::values.frame_limit != 100) {
Settings::values.frame_limit = 100;
UpdateStatusBar();
} else {
Settings::values.frame_limit = Settings::values.frame_limit_custom;
UpdateStatusBar();
}
});
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Unthrottle"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
Settings::values.use_frame_limit = !Settings::values.use_frame_limit; Settings::values.use_frame_limit = !Settings::values.use_frame_limit;
UpdateStatusBar(); UpdateStatusBar();
@ -504,15 +514,21 @@ void GMainWindow::InitializeHotkeys() {
static constexpr u16 SPEED_LIMIT_STEP = 5; static constexpr u16 SPEED_LIMIT_STEP = 5;
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Increase Speed Limit"), this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Increase Speed Limit"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
if (Settings::values.frame_limit < 9999 - SPEED_LIMIT_STEP) { if (Settings::values.frame_limit_custom < 9999 - SPEED_LIMIT_STEP) {
Settings::values.frame_limit += SPEED_LIMIT_STEP; Settings::values.frame_limit_custom += SPEED_LIMIT_STEP;
if (Settings::values.frame_limit != 100) {
Settings::values.frame_limit = Settings::values.frame_limit_custom;
}
UpdateStatusBar(); UpdateStatusBar();
} }
}); });
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Decrease Speed Limit"), this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Decrease Speed Limit"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
if (Settings::values.frame_limit > SPEED_LIMIT_STEP) { if (Settings::values.frame_limit_custom > SPEED_LIMIT_STEP) {
Settings::values.frame_limit -= SPEED_LIMIT_STEP; Settings::values.frame_limit_custom -= SPEED_LIMIT_STEP;
if (Settings::values.frame_limit != 100) {
Settings::values.frame_limit = Settings::values.frame_limit_custom;
}
UpdateStatusBar(); UpdateStatusBar();
} }
}); });

View file

@ -148,6 +148,7 @@ struct Values {
u16 resolution_factor; u16 resolution_factor;
bool use_frame_limit; bool use_frame_limit;
u16 frame_limit; u16 frame_limit;
u16 frame_limit_custom;
std::string texture_filter_name; std::string texture_filter_name;
LayoutOption layout_option; LayoutOption layout_option;