diff options
| -rw-r--r-- | src/common/settings.h | 21 | ||||
| -rw-r--r-- | src/common/settings_common.cpp | 9 | ||||
| -rw-r--r-- | src/common/settings_common.h | 11 | ||||
| -rw-r--r-- | src/common/settings_setting.h | 29 |
4 files changed, 49 insertions, 21 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index c78dd85c8..b87301d4e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -150,9 +150,16 @@ struct Values { | |||
| 150 | linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; | 150 | linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; |
| 151 | SwitchableSetting<bool> use_speed_limit{ | 151 | SwitchableSetting<bool> use_speed_limit{ |
| 152 | linkage, true, "use_speed_limit", Category::Core, Specialization::Paired, false, true}; | 152 | linkage, true, "use_speed_limit", Category::Core, Specialization::Paired, false, true}; |
| 153 | SwitchableSetting<u16, true> speed_limit{ | 153 | SwitchableSetting<u16, true> speed_limit{linkage, |
| 154 | linkage, 100, 0, 9999, "speed_limit", Category::Core, Specialization::Countable, | 154 | 100, |
| 155 | true, true}; | 155 | 0, |
| 156 | 9999, | ||
| 157 | "speed_limit", | ||
| 158 | Category::Core, | ||
| 159 | Specialization::Countable, | ||
| 160 | true, | ||
| 161 | true, | ||
| 162 | &use_speed_limit}; | ||
| 156 | 163 | ||
| 157 | // Cpu | 164 | // Cpu |
| 158 | SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto, | 165 | SwitchableSetting<CpuAccuracy, true> cpu_accuracy{linkage, CpuAccuracy::Auto, |
| @@ -339,13 +346,15 @@ struct Values { | |||
| 339 | SwitchableSetting<bool> custom_rtc_enabled{ | 346 | SwitchableSetting<bool> custom_rtc_enabled{ |
| 340 | linkage, false, "custom_rtc_enabled", Category::System, Specialization::Paired, true, true}; | 347 | linkage, false, "custom_rtc_enabled", Category::System, Specialization::Paired, true, true}; |
| 341 | SwitchableSetting<s64> custom_rtc{ | 348 | SwitchableSetting<s64> custom_rtc{ |
| 342 | linkage, 0, "custom_rtc", Category::System, Specialization::Time, true, true}; | 349 | linkage, 0, "custom_rtc", Category::System, Specialization::Time, |
| 350 | true, true, &custom_rtc_enabled}; | ||
| 343 | // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` | 351 | // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` |
| 344 | s64 custom_rtc_differential; | 352 | s64 custom_rtc_differential; |
| 345 | SwitchableSetting<bool> rng_seed_enabled{ | 353 | SwitchableSetting<bool> rng_seed_enabled{ |
| 346 | linkage, false, "rng_seed_enabled", Category::System, Specialization::Paired, true, true}; | 354 | linkage, false, "rng_seed_enabled", Category::System, Specialization::Paired, true, true}; |
| 347 | SwitchableSetting<u32> rng_seed{linkage, 0, "rng_seed", Category::System, Specialization::Hex, | 355 | SwitchableSetting<u32> rng_seed{ |
| 348 | true, true}; | 356 | linkage, 0, "rng_seed", Category::System, Specialization::Hex, |
| 357 | true, true, &rng_seed_enabled}; | ||
| 349 | Setting<std::string> device_name{ | 358 | Setting<std::string> device_name{ |
| 350 | linkage, "yuzu", "device_name", Category::System, Specialization::Default, true, true}; | 359 | linkage, "yuzu", "device_name", Category::System, Specialization::Default, true, true}; |
| 351 | 360 | ||
diff --git a/src/common/settings_common.cpp b/src/common/settings_common.cpp index 3e86c7347..53d4548f5 100644 --- a/src/common/settings_common.cpp +++ b/src/common/settings_common.cpp | |||
| @@ -8,9 +8,10 @@ namespace Settings { | |||
| 8 | 8 | ||
| 9 | BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, | 9 | BasicSetting::BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, |
| 10 | bool save_, bool runtime_modifiable_, | 10 | bool save_, bool runtime_modifiable_, |
| 11 | enum Specialization specialization_) | 11 | enum Specialization specialization_, BasicSetting* other_setting_) |
| 12 | : label{name}, category{category_}, id{linkage.count}, save{save_}, | 12 | : label{name}, category{category_}, id{linkage.count}, save{save_}, |
| 13 | runtime_modifiable{runtime_modifiable_}, specialization{specialization_} { | 13 | runtime_modifiable{runtime_modifiable_}, specialization{specialization_}, |
| 14 | other_setting{other_setting_} { | ||
| 14 | linkage.by_category[category].push_front(this); | 15 | linkage.by_category[category].push_front(this); |
| 15 | linkage.count++; | 16 | linkage.count++; |
| 16 | } | 17 | } |
| @@ -43,6 +44,10 @@ Specialization BasicSetting::Specialization() const { | |||
| 43 | return specialization; | 44 | return specialization; |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 47 | BasicSetting* BasicSetting::PairedSetting() const { | ||
| 48 | return other_setting; | ||
| 49 | } | ||
| 50 | |||
| 46 | const std::string& BasicSetting::GetLabel() const { | 51 | const std::string& BasicSetting::GetLabel() const { |
| 47 | return label; | 52 | return label; |
| 48 | } | 53 | } |
diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 664c807f1..ad005ca4e 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h | |||
| @@ -75,7 +75,8 @@ public: | |||
| 75 | class BasicSetting { | 75 | class BasicSetting { |
| 76 | protected: | 76 | protected: |
| 77 | explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, | 77 | explicit BasicSetting(Linkage& linkage, const std::string& name, enum Category category_, |
| 78 | bool save_, bool runtime_modifiable_, Specialization spec); | 78 | bool save_, bool runtime_modifiable_, Specialization spec, |
| 79 | BasicSetting* other_setting); | ||
| 79 | 80 | ||
| 80 | public: | 81 | public: |
| 81 | virtual ~BasicSetting(); | 82 | virtual ~BasicSetting(); |
| @@ -197,6 +198,11 @@ public: | |||
| 197 | [[nodiscard]] enum Specialization Specialization() const; | 198 | [[nodiscard]] enum Specialization Specialization() const; |
| 198 | 199 | ||
| 199 | /** | 200 | /** |
| 201 | * @returns Another BasicSetting if one is paired, or nullptr otherwise. | ||
| 202 | */ | ||
| 203 | [[nodiscard]] BasicSetting* PairedSetting() const; | ||
| 204 | |||
| 205 | /** | ||
| 200 | * Returns the label this setting was created with. | 206 | * Returns the label this setting was created with. |
| 201 | * | 207 | * |
| 202 | * @returns A reference to the label | 208 | * @returns A reference to the label |
| @@ -236,7 +242,8 @@ private: | |||
| 236 | const bool | 242 | const bool |
| 237 | runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running | 243 | runtime_modifiable; ///< Suggests if the setting can be modified while a guest is running |
| 238 | const enum Specialization | 244 | const enum Specialization |
| 239 | specialization; ///< Extra data to identify representation of a setting | 245 | specialization; ///< Extra data to identify representation of a setting |
| 246 | BasicSetting* const other_setting; ///< A paired setting | ||
| 240 | }; | 247 | }; |
| 241 | 248 | ||
| 242 | } // namespace Settings | 249 | } // namespace Settings |
diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 9805a5b5d..dd91250a1 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h | |||
| @@ -37,9 +37,11 @@ public: | |||
| 37 | explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, | 37 | explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, |
| 38 | enum Category category_, | 38 | enum Category category_, |
| 39 | enum Specialization specialization = Specialization::Default, | 39 | enum Specialization specialization = Specialization::Default, |
| 40 | bool save_ = true, bool runtime_modifiable_ = false) | 40 | bool save_ = true, bool runtime_modifiable_ = false, |
| 41 | BasicSetting* other_setting = nullptr) | ||
| 41 | requires(!ranged) | 42 | requires(!ranged) |
| 42 | : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization), | 43 | : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization, |
| 44 | other_setting), | ||
| 43 | value{default_val}, default_value{default_val} {} | 45 | value{default_val}, default_value{default_val} {} |
| 44 | virtual ~Setting() = default; | 46 | virtual ~Setting() = default; |
| 45 | 47 | ||
| @@ -56,9 +58,11 @@ public: | |||
| 56 | explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, | 58 | explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, |
| 57 | const Type& max_val, const std::string& name, enum Category category_, | 59 | const Type& max_val, const std::string& name, enum Category category_, |
| 58 | enum Specialization specialization = Specialization::Default, | 60 | enum Specialization specialization = Specialization::Default, |
| 59 | bool save_ = true, bool runtime_modifiable_ = false) | 61 | bool save_ = true, bool runtime_modifiable_ = false, |
| 62 | BasicSetting* other_setting = nullptr) | ||
| 60 | requires(ranged) | 63 | requires(ranged) |
| 61 | : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization), | 64 | : BasicSetting(linkage, name, category_, save_, runtime_modifiable_, specialization, |
| 65 | other_setting), | ||
| 62 | value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val} {} | 66 | value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val} {} |
| 63 | 67 | ||
| 64 | /** | 68 | /** |
| @@ -235,10 +239,12 @@ public: | |||
| 235 | explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, | 239 | explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, |
| 236 | Category category_, | 240 | Category category_, |
| 237 | enum Specialization specialization = Specialization::Default, | 241 | enum Specialization specialization = Specialization::Default, |
| 238 | bool save_ = true, bool runtime_modifiable_ = false) | 242 | bool save_ = true, bool runtime_modifiable_ = false, |
| 243 | BasicSetting* other_setting = nullptr) | ||
| 239 | requires(!ranged) | 244 | requires(!ranged) |
| 240 | : Setting<Type, false>{linkage, default_val, name, category_, specialization, | 245 | : Setting<Type, false>{ |
| 241 | save_, runtime_modifiable_} { | 246 | linkage, default_val, name, category_, specialization, |
| 247 | save_, runtime_modifiable_, other_setting} { | ||
| 242 | linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); | 248 | linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); |
| 243 | } | 249 | } |
| 244 | virtual ~SwitchableSetting() = default; | 250 | virtual ~SwitchableSetting() = default; |
| @@ -256,11 +262,12 @@ public: | |||
| 256 | explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, | 262 | explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, |
| 257 | const Type& max_val, const std::string& name, Category category_, | 263 | const Type& max_val, const std::string& name, Category category_, |
| 258 | enum Specialization specialization = Specialization::Default, | 264 | enum Specialization specialization = Specialization::Default, |
| 259 | bool save_ = true, bool runtime_modifiable_ = false) | 265 | bool save_ = true, bool runtime_modifiable_ = false, |
| 266 | BasicSetting* other_setting = nullptr) | ||
| 260 | requires(ranged) | 267 | requires(ranged) |
| 261 | : Setting<Type, true>{linkage, default_val, min_val, | 268 | : Setting<Type, true>{ |
| 262 | max_val, name, category_, | 269 | linkage, default_val, min_val, max_val, name, category_, specialization, |
| 263 | specialization, save_, runtime_modifiable_} { | 270 | save_, runtime_modifiable_, other_setting} { |
| 264 | linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); | 271 | linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); |
| 265 | } | 272 | } |
| 266 | 273 | ||