From 35b17fa5e0a69c019852fed9ede9b64f08dd21a0 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sat, 26 Jun 2021 02:45:14 -0400 Subject: configuration: Defer to common/settings for per-game settings defaults Avoids double-setting defaults, and avoids potential accidents when inconsistently setting the default on new settings. --- src/yuzu/configuration/config.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/yuzu/configuration/config.h') diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 3c1de0ac9..62501997c 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -104,14 +104,14 @@ private: QVariant ReadSetting(const QString& name) const; QVariant ReadSetting(const QString& name, const QVariant& default_value) const; + QVariant ReadSetting(const QString& name, Settings::CPUAccuracy default_value) const; + QVariant ReadSetting(const QString& name, Settings::GPUAccuracy default_value) const; + QVariant ReadSetting(const QString& name, Settings::RendererBackend default_value) const; // Templated ReadSettingGlobal functions will also look for the use_global setting and set // both the value and the global state properly template void ReadSettingGlobal(Settings::Setting& setting, const QString& name); template - void ReadSettingGlobal(Settings::Setting& setting, const QString& name, - const QVariant& default_value); - template void ReadSettingGlobal(Type& setting, const QString& name, const QVariant& default_value) const; // Templated WriteSettingGlobal functions will also write the global state if needed and will // skip writing the actual setting if it defers to the global value -- cgit v1.2.3 From b91b76df4fe27d781bd95ddb89b78ff54df57029 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 28 Jun 2021 15:58:16 -0400 Subject: general: Make most settings a BasicSetting Creates a new BasicSettings class in common/settings, and forces setting a default and label for each setting that uses it in common/settings. Moves defaults and labels from both frontends into common settings. Creates a helper function in each frontend to facillitate reading the settings now with the new default and label properties. Settings::Setting is also now a subclass of Settings::BasicSetting. Also adds documentation for both Setting and BasicSetting. --- src/yuzu/configuration/config.h | 75 +++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 14 deletions(-) (limited to 'src/yuzu/configuration/config.h') diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 62501997c..96f9b6de1 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -102,28 +102,75 @@ private: void SaveUILayoutValues(); void SaveWebServiceValues(); + /** + * Reads a setting from the qt_config. + * + * @param name The setting's identifier + * @param default_value The value to use when the setting is not already present in the config + */ QVariant ReadSetting(const QString& name) const; QVariant ReadSetting(const QString& name, const QVariant& default_value) const; - QVariant ReadSetting(const QString& name, Settings::CPUAccuracy default_value) const; - QVariant ReadSetting(const QString& name, Settings::GPUAccuracy default_value) const; - QVariant ReadSetting(const QString& name, Settings::RendererBackend default_value) const; - // Templated ReadSettingGlobal functions will also look for the use_global setting and set - // both the value and the global state properly - template - void ReadSettingGlobal(Settings::Setting& setting, const QString& name); + + /** + * Only reads a setting from the qt_config if the current config is a global config, or if the + * current config is a custom config and the setting is overriding the global setting. Otherwise + * it does nothing. + * + * @param setting The variable to be modified + * @param name The setting's identifier + * @param default_value The value to use when the setting is not already present in the config + */ template void ReadSettingGlobal(Type& setting, const QString& name, const QVariant& default_value) const; - // Templated WriteSettingGlobal functions will also write the global state if needed and will - // skip writing the actual setting if it defers to the global value + + /** + * Writes a setting to the qt_config. + * + * @param name The setting's idetentifier + * @param value Value of the setting + * @param default_value Default of the setting if not present in qt_config + * @param use_global Specifies if the custom or global config should be in use, for custom + * configs + */ void WriteSetting(const QString& name, const QVariant& value); void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value); + void WriteSetting(const QString& name, const QVariant& value, const QVariant& default_value, + bool use_global); + + /** + * Reads a value from the qt_config and applies it to the setting, using its label and default + * value. If the config is a custom config, this will also read the global state of the setting + * and apply that information to it. + * + * @param The setting + */ template - void WriteSettingGlobal(const QString& name, const Settings::Setting& setting); + void ReadGlobalSetting(Settings::Setting& setting); + + /** + * Sets a value to the qt_config using the setting's label and default value. If the config is a + * custom config, it will apply the global state, and the custom value if needed. + * + * @param The setting + */ + template + void WriteGlobalSetting(const Settings::Setting& setting); + + /** + * Reads a value from the qt_config using the setting's label and default value and applies the + * value to the setting. + * + * @param The setting + */ + template + void ReadBasicSetting(Settings::BasicSetting& setting); + + /** Sets a value from the setting in the qt_config using the setting's label and default value. + * + * @param The setting + */ template - void WriteSettingGlobal(const QString& name, const Settings::Setting& setting, - const QVariant& default_value); - void WriteSettingGlobal(const QString& name, const QVariant& value, bool use_global, - const QVariant& default_value); + void WriteBasicSetting(const Settings::BasicSetting& setting); ConfigType type; std::unique_ptr qt_config; -- cgit v1.2.3