From 3b62d75257ea441054157b360c465852c3cf9da1 Mon Sep 17 00:00:00 2001 From: lat9nq Date: Thu, 25 Jun 2020 02:30:30 -0400 Subject: [PATCH] fix more logic errors Fixed the frame limit would set the global setting from the game properties dialog. Also strengthened the Settings::Setting member variables and simplified the logic in config reading (ReadSettingGlobal). --- src/core/settings.cpp | 5 +++++ src/core/settings.h | 6 +++--- src/yuzu/configuration/config.cpp | 17 +++++++---------- src/yuzu/configuration/configure_general.cpp | 19 +++++++++++-------- .../configure_per_game_addons.cpp | 3 +++ src/yuzu/main.cpp | 10 ++++++---- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 41dad4456a..f6259158ed 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -144,6 +144,11 @@ bool IsGPULevelHigh() { } void RestoreGlobalState() { + // If a game is running, DO NOT restore the global settings state + if (!Core::System::GetInstance().IsPoweredOn()) { + return; + } + // Audio Settings::values.enable_audio_stretching.SetGlobal(true); Settings::values.volume.SetGlobal(true); diff --git a/src/core/settings.h b/src/core/settings.h index 85b36b9bde..e526356409 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -423,9 +423,9 @@ public: }; private: - bool use_global; - Type global; - Type local; + bool use_global{}; + Type global{}; + Type local{}; }; struct Values { diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index d35d940bcc..88a5c398a0 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -1263,10 +1263,9 @@ QVariant Config::ReadSetting(const QString& name, const QVariant& default_value) template void Config::ReadSettingGlobal(Settings::Setting& setting, const QString& name) { - bool use_global = - global || qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); - setting.SetGlobal(use_global); - if ((!global && !use_global) || global) { + bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); + setting.SetGlobal(use_global || global); + if (global || !use_global) { setting.SetValue(ReadSetting(name).value()); } } @@ -1274,10 +1273,9 @@ void Config::ReadSettingGlobal(Settings::Setting& setting, const QString& template void Config::ReadSettingGlobal(Settings::Setting& setting, const QString& name, const QVariant& default_value) { - bool use_global = - global || qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); + bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); setting.SetGlobal(use_global); - if ((!global && !use_global) || global) { + if (global || !use_global) { setting.SetValue(ReadSetting(name, default_value).value()); } } @@ -1285,9 +1283,8 @@ void Config::ReadSettingGlobal(Settings::Setting& setting, const QString& template void Config::ReadSettingGlobal(Type& setting, const QString& name, const QVariant& default_value) const { - bool use_global = - global || qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); - if ((!global && !use_global) || global) { + bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); + if (global || !use_global) { setting = ReadSetting(name, default_value).value(); } else { setting = default_value.value(); diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 6f457165f4..ecb8642dcd 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -39,8 +39,10 @@ void ConfigureGeneral::SetConfiguration() { ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); ui->frame_limit->setValue(Settings::values.frame_limit); - if (!Settings::configuring_global && Settings::values.use_frame_limit.UsingGlobal()) { - ui->toggle_frame_limit->setCheckState(Qt::PartiallyChecked); + if (!Settings::configuring_global) { + if (Settings::values.use_frame_limit.UsingGlobal()) { + ui->toggle_frame_limit->setCheckState(Qt::PartiallyChecked); + } } ui->frame_limit->setEnabled(ui->toggle_frame_limit->checkState() == Qt::Checked && @@ -67,12 +69,13 @@ void ConfigureGeneral::ApplyConfiguration() { Settings::values.frame_limit = ui->frame_limit->value(); } } else { - Settings::values.use_frame_limit.SetGlobal(ui->toggle_frame_limit->checkState() == - Qt::PartiallyChecked); - Settings::values.frame_limit.SetGlobal(ui->toggle_frame_limit->checkState() == - Qt::PartiallyChecked); - Settings::values.use_frame_limit = ui->toggle_frame_limit->checkState() == Qt::Checked; - Settings::values.frame_limit = ui->frame_limit->value(); + bool global_frame_limit = ui->toggle_frame_limit->checkState() == Qt::PartiallyChecked; + Settings::values.use_frame_limit.SetGlobal(global_frame_limit); + Settings::values.frame_limit.SetGlobal(global_frame_limit); + if (!global_frame_limit) { + Settings::values.use_frame_limit = ui->toggle_frame_limit->checkState() == Qt::Checked; + Settings::values.frame_limit = ui->frame_limit->value(); + } } } diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp index 3208297ddf..478d5d3a19 100644 --- a/src/yuzu/configuration/configure_per_game_addons.cpp +++ b/src/yuzu/configuration/configure_per_game_addons.cpp @@ -15,6 +15,7 @@ #include "common/common_paths.h" #include "common/file_util.h" +#include "core/core.h" #include "core/file_sys/patch_manager.h" #include "core/file_sys/xts_archive.h" #include "core/loader/loader.h" @@ -57,6 +58,8 @@ ConfigurePerGameAddons::ConfigurePerGameAddons(QWidget* parent) ui->scrollArea->setLayout(layout); + ui->scrollArea->setEnabled(!Core::System::GetInstance().IsPoweredOn()); + connect(item_model, &QStandardItemModel::itemChanged, [] { UISettings::values.is_game_list_reload_pending.exchange(true); }); } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 8f8d0584c9..80adce1071 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1550,11 +1550,13 @@ void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) { game_list->PopulateAsync(UISettings::values.game_dirs); } - config->Save(); - } + // Do not cause the global config to write local settings + Settings::RestoreGlobalState(); - // If a game is running, DO NOT restore the global settings state - if (!Core::System::GetInstance().IsPoweredOn()) { + if (!Core::System::GetInstance().IsPoweredOn()) { + config->Save(); + } + } else { Settings::RestoreGlobalState(); } }