diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-05-04 03:44:53 -0400 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-07-21 10:56:07 -0400 |
commit | 5ccfaf0517ed365e64458783b30f521d3ed21c78 (patch) | |
tree | 236082bbd35dd53021f68b4580e4309d42f157d4 /src/common/settings.h | |
parent | 5cffa342884df531d911555f7b3db9d2f6d1d1f0 (diff) |
settings: Pool SetGlobal functions
Diffstat (limited to 'src/common/settings.h')
-rw-r--r-- | src/common/settings.h | 12 |
1 files changed, 10 insertions, 2 deletions
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 <algorithm> #include <array> +#include <forward_list> +#include <functional> #include <map> #include <optional> #include <string> @@ -125,6 +127,8 @@ struct ResolutionScalingInfo { } }; +static std::forward_list<std::function<void()>> 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<Type>{default_val, name} {} + : Setting<Type>{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<Type, true>{default_val, min_val, max_val, name} {} + : Setting<Type, true>{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 |