From 5ccfaf0517ed365e64458783b30f521d3ed21c78 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 4 May 2023 03:44:53 -0400 Subject: settings: Pool SetGlobal functions --- src/common/settings.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/common/settings.h') diff --git a/src/common/settings.h b/src/common/settings.h index b8ab34f7f..61d15467d 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -5,6 +5,8 @@ #include #include +#include +#include #include #include #include @@ -125,6 +127,8 @@ struct ResolutionScalingInfo { } }; +static std::forward_list> global_reset_registry; + /** The Setting class is a simple resource manager. It defines a label and default value alongside * the actual value of the setting for simpler and less-error prone use with frontend * configurations. Specifying a default value and label is required. A minimum and maximum range can @@ -255,7 +259,9 @@ public: */ explicit SwitchableSetting(const Type& default_val, const std::string& name) requires(!ranged) - : Setting{default_val, name} {} + : Setting{default_val, name} { + global_reset_registry.push_front([this]() { this->SetGlobal(true); }); + } virtual ~SwitchableSetting() = default; /** @@ -269,7 +275,9 @@ public: explicit SwitchableSetting(const Type& default_val, const Type& min_val, const Type& max_val, const std::string& name) requires(ranged) - : Setting{default_val, min_val, max_val, name} {} + : Setting{default_val, min_val, max_val, name} { + global_reset_registry.push_front([this]() { this->SetGlobal(true); }); + } /** * Tells this setting to represent either the global or custom setting when other member -- cgit v1.2.3