summaryrefslogtreecommitdiff
path: root/src/common/settings_setting.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/settings_setting.h')
-rw-r--r--src/common/settings_setting.h86
1 files changed, 11 insertions, 75 deletions
diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h
index 99a4bad01..1ca3acf18 100644
--- a/src/common/settings_setting.h
+++ b/src/common/settings_setting.h
@@ -1,3 +1,6 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
1#pragma once 4#pragma once
2 5
3#include <map> 6#include <map>
@@ -21,16 +24,6 @@ class Setting : public BasicSetting {
21protected: 24protected:
22 Setting() = default; 25 Setting() = default;
23 26
24 /**
25 * Only sets the setting to the given initializer, leaving the other members to their default
26 * initializers.
27 *
28 * @param global_val Initial value of the setting
29 */
30 explicit Setting(const Type& val)
31 : value{val},
32 default_value{}, maximum{}, minimum{}, label{}, category{Category::Miscellaneous}, id{} {}
33
34public: 27public:
35 /** 28 /**
36 * Sets a default value, label, and setting value. 29 * Sets a default value, label, and setting value.
@@ -43,11 +36,8 @@ public:
43 explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, 36 explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name,
44 enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) 37 enum Category category_, bool save_ = true, bool runtime_modifiable_ = false)
45 requires(!ranged) 38 requires(!ranged)
46 : value{default_val}, default_value{default_val}, label{name}, category{category_}, 39 : BasicSetting(linkage, name, category_, save_, runtime_modifiable_), value{default_val},
47 id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_} { 40 default_value{default_val} {}
48 linkage.by_category[category].push_front(this);
49 linkage.count++;
50 }
51 virtual ~Setting() = default; 41 virtual ~Setting() = default;
52 42
53 /** 43 /**
@@ -64,12 +54,8 @@ public:
64 const Type& max_val, const std::string& name, enum Category category_, 54 const Type& max_val, const std::string& name, enum Category category_,
65 bool save_ = true, bool runtime_modifiable_ = false) 55 bool save_ = true, bool runtime_modifiable_ = false)
66 requires(ranged) 56 requires(ranged)
67 : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, 57 : BasicSetting(linkage, name, category_, save_, runtime_modifiable_), value{default_val},
68 label{name}, category{category_}, id{linkage.count}, save{save_}, 58 default_value{default_val}, maximum{max_val}, minimum{min_val} {}
69 runtime_modifiable{runtime_modifiable_} {
70 linkage.by_category[category].push_front(this);
71 linkage.count++;
72 }
73 59
74 /** 60 /**
75 * Returns a reference to the setting's value. 61 * Returns a reference to the setting's value.
@@ -99,41 +85,10 @@ public:
99 return default_value; 85 return default_value;
100 } 86 }
101 87
102 /**
103 * Returns the label this setting was created with.
104 *
105 * @returns A reference to the label
106 */
107 [[nodiscard]] const std::string& GetLabel() const override {
108 return label;
109 }
110
111 /**
112 * Returns the setting's category AKA INI group.
113 *
114 * @returns The setting's category
115 */
116 [[nodiscard]] enum Category Category() const override {
117 return category;
118 }
119
120 [[nodiscard]] bool RuntimeModfiable() const override {
121 return runtime_modifiable;
122 }
123
124 [[nodiscard]] constexpr bool IsEnum() const override { 88 [[nodiscard]] constexpr bool IsEnum() const override {
125 return std::is_enum<Type>::value; 89 return std::is_enum<Type>::value;
126 } 90 }
127 91
128 /**
129 * Returns whether the current setting is Switchable.
130 *
131 * @returns If the setting is a SwitchableSetting
132 */
133 [[nodiscard]] virtual constexpr bool Switchable() const override {
134 return false;
135 }
136
137protected: 92protected:
138 std::string ToString(const Type& value_) const { 93 std::string ToString(const Type& value_) const {
139 if constexpr (std::is_same<Type, std::string>()) { 94 if constexpr (std::is_same<Type, std::string>()) {
@@ -228,16 +183,6 @@ public:
228 } 183 }
229 184
230 /** 185 /**
231 * Returns the save preference of the setting i.e. when saving or reading the setting from a
232 * frontend, whether this setting should be skipped.
233 *
234 * @returns The save preference
235 */
236 virtual bool Save() const override {
237 return save;
238 }
239
240 /**
241 * Gives us another way to identify the setting without having to go through a string. 186 * Gives us another way to identify the setting without having to go through a string.
242 * 187 *
243 * @returns the type_index of the setting's type 188 * @returns the type_index of the setting's type
@@ -246,10 +191,6 @@ public:
246 return std::type_index(typeid(Type)); 191 return std::type_index(typeid(Type));
247 } 192 }
248 193
249 virtual constexpr u32 Id() const override {
250 return id;
251 }
252
253 virtual std::string MinVal() const override { 194 virtual std::string MinVal() const override {
254 return this->ToString(minimum); 195 return this->ToString(minimum);
255 } 196 }
@@ -258,15 +199,10 @@ public:
258 } 199 }
259 200
260protected: 201protected:
261 Type value{}; ///< The setting 202 Type value{}; ///< The setting
262 const Type default_value{}; ///< The default value 203 const Type default_value{}; ///< The default value
263 const Type maximum{}; ///< Maximum allowed value of the setting 204 const Type maximum{}; ///< Maximum allowed value of the setting
264 const Type minimum{}; ///< Minimum allowed value of the setting 205 const Type minimum{}; ///< Minimum allowed value of the setting
265 const std::string label{}; ///< The setting's label
266 const enum Category category; ///< The setting's category AKA INI group
267 const u32 id;
268 bool save;
269 bool runtime_modifiable;
270}; 206};
271 207
272/** 208/**