diff options
Diffstat (limited to '')
| -rw-r--r-- | src/common/settings.h | 67 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 16 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.h | 16 | ||||
| -rw-r--r-- | src/yuzu/configuration/configuration_shared.h | 10 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 4 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.h | 4 |
6 files changed, 59 insertions, 58 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index 3583a2e70..368046e87 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -106,7 +106,7 @@ struct ResolutionScalingInfo { | |||
| 106 | * configurations. Specifying a default value and label is required. A minimum and maximum range can | 106 | * configurations. Specifying a default value and label is required. A minimum and maximum range can |
| 107 | * be specified for sanitization. | 107 | * be specified for sanitization. |
| 108 | */ | 108 | */ |
| 109 | template <typename Type> | 109 | template <typename Type, bool ranged = false> |
| 110 | class Setting { | 110 | class Setting { |
| 111 | protected: | 111 | protected: |
| 112 | Setting() = default; | 112 | Setting() = default; |
| @@ -126,8 +126,8 @@ public: | |||
| 126 | * @param default_val Intial value of the setting, and default value of the setting | 126 | * @param default_val Intial value of the setting, and default value of the setting |
| 127 | * @param name Label for the setting | 127 | * @param name Label for the setting |
| 128 | */ | 128 | */ |
| 129 | explicit Setting(const Type& default_val, const std::string& name) | 129 | explicit Setting(const Type& default_val, const std::string& name) requires(!ranged) |
| 130 | : value{default_val}, default_value{default_val}, ranged{false}, label{name} {} | 130 | : value{default_val}, default_value{default_val}, label{name} {} |
| 131 | virtual ~Setting() = default; | 131 | virtual ~Setting() = default; |
| 132 | 132 | ||
| 133 | /** | 133 | /** |
| @@ -139,9 +139,9 @@ public: | |||
| 139 | * @param name Label for the setting | 139 | * @param name Label for the setting |
| 140 | */ | 140 | */ |
| 141 | explicit Setting(const Type& default_val, const Type& min_val, const Type& max_val, | 141 | explicit Setting(const Type& default_val, const Type& min_val, const Type& max_val, |
| 142 | const std::string& name) | 142 | const std::string& name) requires(ranged) |
| 143 | : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, | 143 | : value{default_val}, |
| 144 | ranged{true}, label{name} {} | 144 | default_value{default_val}, maximum{max_val}, minimum{min_val}, label{name} {} |
| 145 | 145 | ||
| 146 | /** | 146 | /** |
| 147 | * Returns a reference to the setting's value. | 147 | * Returns a reference to the setting's value. |
| @@ -158,7 +158,7 @@ public: | |||
| 158 | * @param val The desired value | 158 | * @param val The desired value |
| 159 | */ | 159 | */ |
| 160 | virtual void SetValue(const Type& val) { | 160 | virtual void SetValue(const Type& val) { |
| 161 | Type temp{(ranged) ? std::clamp(val, minimum, maximum) : val}; | 161 | Type temp{ranged ? std::clamp(val, minimum, maximum) : val}; |
| 162 | std::swap(value, temp); | 162 | std::swap(value, temp); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| @@ -188,7 +188,7 @@ public: | |||
| 188 | * @returns A reference to the setting | 188 | * @returns A reference to the setting |
| 189 | */ | 189 | */ |
| 190 | virtual const Type& operator=(const Type& val) { | 190 | virtual const Type& operator=(const Type& val) { |
| 191 | Type temp{(ranged) ? std::clamp(val, minimum, maximum) : val}; | 191 | Type temp{ranged ? std::clamp(val, minimum, maximum) : val}; |
| 192 | std::swap(value, temp); | 192 | std::swap(value, temp); |
| 193 | return value; | 193 | return value; |
| 194 | } | 194 | } |
| @@ -207,7 +207,6 @@ protected: | |||
| 207 | const Type default_value{}; ///< The default value | 207 | const Type default_value{}; ///< The default value |
| 208 | const Type maximum{}; ///< Maximum allowed value of the setting | 208 | const Type maximum{}; ///< Maximum allowed value of the setting |
| 209 | const Type minimum{}; ///< Minimum allowed value of the setting | 209 | const Type minimum{}; ///< Minimum allowed value of the setting |
| 210 | const bool ranged; ///< The setting has sanitization ranges | ||
| 211 | const std::string label{}; ///< The setting's label | 210 | const std::string label{}; ///< The setting's label |
| 212 | }; | 211 | }; |
| 213 | 212 | ||
| @@ -219,8 +218,8 @@ protected: | |||
| 219 | * | 218 | * |
| 220 | * By default, the global setting is used. | 219 | * By default, the global setting is used. |
| 221 | */ | 220 | */ |
| 222 | template <typename Type> | 221 | template <typename Type, bool ranged = false> |
| 223 | class SwitchableSetting : virtual public Setting<Type> { | 222 | class SwitchableSetting : virtual public Setting<Type, ranged> { |
| 224 | public: | 223 | public: |
| 225 | /** | 224 | /** |
| 226 | * Sets a default value, label, and setting value. | 225 | * Sets a default value, label, and setting value. |
| @@ -228,7 +227,7 @@ public: | |||
| 228 | * @param default_val Intial value of the setting, and default value of the setting | 227 | * @param default_val Intial value of the setting, and default value of the setting |
| 229 | * @param name Label for the setting | 228 | * @param name Label for the setting |
| 230 | */ | 229 | */ |
| 231 | explicit SwitchableSetting(const Type& default_val, const std::string& name) | 230 | explicit SwitchableSetting(const Type& default_val, const std::string& name) requires(!ranged) |
| 232 | : Setting<Type>{default_val, name} {} | 231 | : Setting<Type>{default_val, name} {} |
| 233 | virtual ~SwitchableSetting() = default; | 232 | virtual ~SwitchableSetting() = default; |
| 234 | 233 | ||
| @@ -241,8 +240,8 @@ public: | |||
| 241 | * @param name Label for the setting | 240 | * @param name Label for the setting |
| 242 | */ | 241 | */ |
| 243 | explicit SwitchableSetting(const Type& default_val, const Type& min_val, const Type& max_val, | 242 | explicit SwitchableSetting(const Type& default_val, const Type& min_val, const Type& max_val, |
| 244 | const std::string& name) | 243 | const std::string& name) requires(ranged) |
| 245 | : Setting<Type>{default_val, min_val, max_val, name} {} | 244 | : Setting<Type, true>{default_val, min_val, max_val, name} {} |
| 246 | 245 | ||
| 247 | /** | 246 | /** |
| 248 | * Tells this setting to represent either the global or custom setting when other member | 247 | * Tells this setting to represent either the global or custom setting when other member |
| @@ -290,7 +289,7 @@ public: | |||
| 290 | * @param val The new value | 289 | * @param val The new value |
| 291 | */ | 290 | */ |
| 292 | void SetValue(const Type& val) override { | 291 | void SetValue(const Type& val) override { |
| 293 | Type temp{(this->ranged) ? std::clamp(val, this->minimum, this->maximum) : val}; | 292 | Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; |
| 294 | if (use_global) { | 293 | if (use_global) { |
| 295 | std::swap(this->value, temp); | 294 | std::swap(this->value, temp); |
| 296 | } else { | 295 | } else { |
| @@ -306,7 +305,7 @@ public: | |||
| 306 | * @returns A reference to the current setting value | 305 | * @returns A reference to the current setting value |
| 307 | */ | 306 | */ |
| 308 | const Type& operator=(const Type& val) override { | 307 | const Type& operator=(const Type& val) override { |
| 309 | Type temp{(this->ranged) ? std::clamp(val, this->minimum, this->maximum) : val}; | 308 | Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; |
| 310 | if (use_global) { | 309 | if (use_global) { |
| 311 | std::swap(this->value, temp); | 310 | std::swap(this->value, temp); |
| 312 | return this->value; | 311 | return this->value; |
| @@ -374,15 +373,15 @@ struct Values { | |||
| 374 | Setting<std::string> audio_device_id{"auto", "output_device"}; | 373 | Setting<std::string> audio_device_id{"auto", "output_device"}; |
| 375 | Setting<std::string> sink_id{"auto", "output_engine"}; | 374 | Setting<std::string> sink_id{"auto", "output_engine"}; |
| 376 | Setting<bool> audio_muted{false, "audio_muted"}; | 375 | Setting<bool> audio_muted{false, "audio_muted"}; |
| 377 | SwitchableSetting<u8> volume{100, 0, 100, "volume"}; | 376 | SwitchableSetting<u8, true> volume{100, 0, 100, "volume"}; |
| 378 | 377 | ||
| 379 | // Core | 378 | // Core |
| 380 | SwitchableSetting<bool> use_multi_core{true, "use_multi_core"}; | 379 | SwitchableSetting<bool> use_multi_core{true, "use_multi_core"}; |
| 381 | SwitchableSetting<bool> use_extended_memory_layout{false, "use_extended_memory_layout"}; | 380 | SwitchableSetting<bool> use_extended_memory_layout{false, "use_extended_memory_layout"}; |
| 382 | 381 | ||
| 383 | // Cpu | 382 | // Cpu |
| 384 | SwitchableSetting<CPUAccuracy> cpu_accuracy{CPUAccuracy::Auto, CPUAccuracy::Auto, | 383 | SwitchableSetting<CPUAccuracy, true> cpu_accuracy{CPUAccuracy::Auto, CPUAccuracy::Auto, |
| 385 | CPUAccuracy::Paranoid, "cpu_accuracy"}; | 384 | CPUAccuracy::Paranoid, "cpu_accuracy"}; |
| 386 | // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021 | 385 | // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021 |
| 387 | Setting<bool> cpu_accuracy_first_time{true, "cpu_accuracy_first_time"}; | 386 | Setting<bool> cpu_accuracy_first_time{true, "cpu_accuracy_first_time"}; |
| 388 | Setting<bool> cpu_debug_mode{false, "cpu_debug_mode"}; | 387 | Setting<bool> cpu_debug_mode{false, "cpu_debug_mode"}; |
| @@ -409,7 +408,7 @@ struct Values { | |||
| 409 | true, "cpuopt_unsafe_ignore_global_monitor"}; | 408 | true, "cpuopt_unsafe_ignore_global_monitor"}; |
| 410 | 409 | ||
| 411 | // Renderer | 410 | // Renderer |
| 412 | SwitchableSetting<RendererBackend> renderer_backend{ | 411 | SwitchableSetting<RendererBackend, true> renderer_backend{ |
| 413 | RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Vulkan, "backend"}; | 412 | RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Vulkan, "backend"}; |
| 414 | Setting<bool> renderer_debug{false, "debug"}; | 413 | Setting<bool> renderer_debug{false, "debug"}; |
| 415 | Setting<bool> renderer_shader_feedback{false, "shader_feedback"}; | 414 | Setting<bool> renderer_shader_feedback{false, "shader_feedback"}; |
| @@ -423,28 +422,28 @@ struct Values { | |||
| 423 | SwitchableSetting<AntiAliasing> anti_aliasing{AntiAliasing::None, "anti_aliasing"}; | 422 | SwitchableSetting<AntiAliasing> anti_aliasing{AntiAliasing::None, "anti_aliasing"}; |
| 424 | // *nix platforms may have issues with the borderless windowed fullscreen mode. | 423 | // *nix platforms may have issues with the borderless windowed fullscreen mode. |
| 425 | // Default to exclusive fullscreen on these platforms for now. | 424 | // Default to exclusive fullscreen on these platforms for now. |
| 426 | SwitchableSetting<FullscreenMode> fullscreen_mode{ | 425 | SwitchableSetting<FullscreenMode, true> fullscreen_mode{ |
| 427 | #ifdef _WIN32 | 426 | #ifdef _WIN32 |
| 428 | FullscreenMode::Borderless, | 427 | FullscreenMode::Borderless, |
| 429 | #else | 428 | #else |
| 430 | FullscreenMode::Exclusive, | 429 | FullscreenMode::Exclusive, |
| 431 | #endif | 430 | #endif |
| 432 | FullscreenMode::Borderless, FullscreenMode::Exclusive, "fullscreen_mode"}; | 431 | FullscreenMode::Borderless, FullscreenMode::Exclusive, "fullscreen_mode"}; |
| 433 | SwitchableSetting<int> aspect_ratio{0, 0, 3, "aspect_ratio"}; | 432 | SwitchableSetting<int, true> aspect_ratio{0, 0, 3, "aspect_ratio"}; |
| 434 | SwitchableSetting<int> max_anisotropy{0, 0, 5, "max_anisotropy"}; | 433 | SwitchableSetting<int, true> max_anisotropy{0, 0, 5, "max_anisotropy"}; |
| 435 | SwitchableSetting<bool> use_speed_limit{true, "use_speed_limit"}; | 434 | SwitchableSetting<bool> use_speed_limit{true, "use_speed_limit"}; |
| 436 | SwitchableSetting<u16> speed_limit{100, 0, 9999, "speed_limit"}; | 435 | SwitchableSetting<u16, true> speed_limit{100, 0, 9999, "speed_limit"}; |
| 437 | SwitchableSetting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"}; | 436 | SwitchableSetting<bool> use_disk_shader_cache{true, "use_disk_shader_cache"}; |
| 438 | SwitchableSetting<GPUAccuracy> gpu_accuracy{GPUAccuracy::High, GPUAccuracy::Normal, | 437 | SwitchableSetting<GPUAccuracy, true> gpu_accuracy{GPUAccuracy::High, GPUAccuracy::Normal, |
| 439 | GPUAccuracy::Extreme, "gpu_accuracy"}; | 438 | GPUAccuracy::Extreme, "gpu_accuracy"}; |
| 440 | SwitchableSetting<bool> use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"}; | 439 | SwitchableSetting<bool> use_asynchronous_gpu_emulation{true, "use_asynchronous_gpu_emulation"}; |
| 441 | SwitchableSetting<NvdecEmulation> nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"}; | 440 | SwitchableSetting<NvdecEmulation> nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"}; |
| 442 | SwitchableSetting<bool> accelerate_astc{true, "accelerate_astc"}; | 441 | SwitchableSetting<bool> accelerate_astc{true, "accelerate_astc"}; |
| 443 | SwitchableSetting<bool> use_vsync{true, "use_vsync"}; | 442 | SwitchableSetting<bool> use_vsync{true, "use_vsync"}; |
| 444 | SwitchableSetting<u16> fps_cap{1000, 1, 1000, "fps_cap"}; | 443 | SwitchableSetting<u16, true> fps_cap{1000, 1, 1000, "fps_cap"}; |
| 445 | Setting<bool> disable_fps_limit{false, "disable_fps_limit"}; | 444 | Setting<bool> disable_fps_limit{false, "disable_fps_limit"}; |
| 446 | SwitchableSetting<ShaderBackend> shader_backend{ShaderBackend::GLASM, ShaderBackend::GLSL, | 445 | SwitchableSetting<ShaderBackend, true> shader_backend{ShaderBackend::GLASM, ShaderBackend::GLSL, |
| 447 | ShaderBackend::SPIRV, "shader_backend"}; | 446 | ShaderBackend::SPIRV, "shader_backend"}; |
| 448 | SwitchableSetting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"}; | 447 | SwitchableSetting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"}; |
| 449 | SwitchableSetting<bool> use_fast_gpu_time{true, "use_fast_gpu_time"}; | 448 | SwitchableSetting<bool> use_fast_gpu_time{true, "use_fast_gpu_time"}; |
| 450 | 449 | ||
| @@ -460,10 +459,10 @@ struct Values { | |||
| 460 | s64 custom_rtc_differential; | 459 | s64 custom_rtc_differential; |
| 461 | 460 | ||
| 462 | Setting<s32> current_user{0, "current_user"}; | 461 | Setting<s32> current_user{0, "current_user"}; |
| 463 | SwitchableSetting<s32> language_index{1, 0, 17, "language_index"}; | 462 | SwitchableSetting<s32, true> language_index{1, 0, 17, "language_index"}; |
| 464 | SwitchableSetting<s32> region_index{1, 0, 6, "region_index"}; | 463 | SwitchableSetting<s32, true> region_index{1, 0, 6, "region_index"}; |
| 465 | SwitchableSetting<s32> time_zone_index{0, 0, 45, "time_zone_index"}; | 464 | SwitchableSetting<s32, true> time_zone_index{0, 0, 45, "time_zone_index"}; |
| 466 | SwitchableSetting<s32> sound_index{1, 0, 2, "sound_index"}; | 465 | SwitchableSetting<s32, true> sound_index{1, 0, 2, "sound_index"}; |
| 467 | 466 | ||
| 468 | // Controls | 467 | // Controls |
| 469 | InputSetting<std::array<PlayerInput, 10>> players; | 468 | InputSetting<std::array<PlayerInput, 10>> players; |
| @@ -485,7 +484,7 @@ struct Values { | |||
| 485 | Setting<bool> tas_loop{false, "tas_loop"}; | 484 | Setting<bool> tas_loop{false, "tas_loop"}; |
| 486 | 485 | ||
| 487 | Setting<bool> mouse_panning{false, "mouse_panning"}; | 486 | Setting<bool> mouse_panning{false, "mouse_panning"}; |
| 488 | Setting<u8> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; | 487 | Setting<u8, true> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; |
| 489 | Setting<bool> mouse_enabled{false, "mouse_enabled"}; | 488 | Setting<bool> mouse_enabled{false, "mouse_enabled"}; |
| 490 | 489 | ||
| 491 | Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"}; | 490 | Setting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"}; |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 9686412d0..a57b2e019 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -143,8 +143,8 @@ void Config::ReadBasicSetting(Settings::Setting<std::string>& setting) { | |||
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | template <typename Type> | 146 | template <typename Type, bool ranged> |
| 147 | void Config::ReadBasicSetting(Settings::Setting<Type>& setting) { | 147 | void Config::ReadBasicSetting(Settings::Setting<Type, ranged>& setting) { |
| 148 | const QString name = QString::fromStdString(setting.GetLabel()); | 148 | const QString name = QString::fromStdString(setting.GetLabel()); |
| 149 | const Type default_value = setting.GetDefault(); | 149 | const Type default_value = setting.GetDefault(); |
| 150 | if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) { | 150 | if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) { |
| @@ -164,16 +164,16 @@ void Config::WriteBasicSetting(const Settings::Setting<std::string>& setting) { | |||
| 164 | qt_config->setValue(name, QString::fromStdString(value)); | 164 | qt_config->setValue(name, QString::fromStdString(value)); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | template <typename Type> | 167 | template <typename Type, bool ranged> |
| 168 | void Config::WriteBasicSetting(const Settings::Setting<Type>& setting) { | 168 | void Config::WriteBasicSetting(const Settings::Setting<Type, ranged>& setting) { |
| 169 | const QString name = QString::fromStdString(setting.GetLabel()); | 169 | const QString name = QString::fromStdString(setting.GetLabel()); |
| 170 | const Type value = setting.GetValue(); | 170 | const Type value = setting.GetValue(); |
| 171 | qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault()); | 171 | qt_config->setValue(name + QStringLiteral("/default"), value == setting.GetDefault()); |
| 172 | qt_config->setValue(name, value); | 172 | qt_config->setValue(name, value); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | template <typename Type> | 175 | template <typename Type, bool ranged> |
| 176 | void Config::WriteGlobalSetting(const Settings::SwitchableSetting<Type>& setting) { | 176 | void Config::WriteGlobalSetting(const Settings::SwitchableSetting<Type, ranged>& setting) { |
| 177 | const QString name = QString::fromStdString(setting.GetLabel()); | 177 | const QString name = QString::fromStdString(setting.GetLabel()); |
| 178 | const Type& value = setting.GetValue(global); | 178 | const Type& value = setting.GetValue(global); |
| 179 | if (!global) { | 179 | if (!global) { |
| @@ -1421,8 +1421,8 @@ QVariant Config::ReadSetting(const QString& name, const QVariant& default_value) | |||
| 1421 | return result; | 1421 | return result; |
| 1422 | } | 1422 | } |
| 1423 | 1423 | ||
| 1424 | template <typename Type> | 1424 | template <typename Type, bool ranged> |
| 1425 | void Config::ReadGlobalSetting(Settings::SwitchableSetting<Type>& setting) { | 1425 | void Config::ReadGlobalSetting(Settings::SwitchableSetting<Type, ranged>& setting) { |
| 1426 | QString name = QString::fromStdString(setting.GetLabel()); | 1426 | QString name = QString::fromStdString(setting.GetLabel()); |
| 1427 | const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); | 1427 | const bool use_global = qt_config->value(name + QStringLiteral("/use_global"), true).toBool(); |
| 1428 | setting.SetGlobal(use_global); | 1428 | setting.SetGlobal(use_global); |
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 9ca878d23..d511b3dbd 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -159,8 +159,8 @@ private: | |||
| 159 | * | 159 | * |
| 160 | * @param The setting | 160 | * @param The setting |
| 161 | */ | 161 | */ |
| 162 | template <typename Type> | 162 | template <typename Type, bool ranged> |
| 163 | void ReadGlobalSetting(Settings::SwitchableSetting<Type>& setting); | 163 | void ReadGlobalSetting(Settings::SwitchableSetting<Type, ranged>& setting); |
| 164 | 164 | ||
| 165 | /** | 165 | /** |
| 166 | * Sets a value to the qt_config using the setting's label and default value. If the config is a | 166 | * Sets a value to the qt_config using the setting's label and default value. If the config is a |
| @@ -168,8 +168,8 @@ private: | |||
| 168 | * | 168 | * |
| 169 | * @param The setting | 169 | * @param The setting |
| 170 | */ | 170 | */ |
| 171 | template <typename Type> | 171 | template <typename Type, bool ranged> |
| 172 | void WriteGlobalSetting(const Settings::SwitchableSetting<Type>& setting); | 172 | void WriteGlobalSetting(const Settings::SwitchableSetting<Type, ranged>& setting); |
| 173 | 173 | ||
| 174 | /** | 174 | /** |
| 175 | * Reads a value from the qt_config using the setting's label and default value and applies the | 175 | * Reads a value from the qt_config using the setting's label and default value and applies the |
| @@ -177,15 +177,15 @@ private: | |||
| 177 | * | 177 | * |
| 178 | * @param The setting | 178 | * @param The setting |
| 179 | */ | 179 | */ |
| 180 | template <typename Type> | 180 | template <typename Type, bool ranged> |
| 181 | void ReadBasicSetting(Settings::Setting<Type>& setting); | 181 | void ReadBasicSetting(Settings::Setting<Type, ranged>& setting); |
| 182 | 182 | ||
| 183 | /** Sets a value from the setting in the qt_config using the setting's label and default value. | 183 | /** Sets a value from the setting in the qt_config using the setting's label and default value. |
| 184 | * | 184 | * |
| 185 | * @param The setting | 185 | * @param The setting |
| 186 | */ | 186 | */ |
| 187 | template <typename Type> | 187 | template <typename Type, bool ranged> |
| 188 | void WriteBasicSetting(const Settings::Setting<Type>& setting); | 188 | void WriteBasicSetting(const Settings::Setting<Type, ranged>& setting); |
| 189 | 189 | ||
| 190 | ConfigType type; | 190 | ConfigType type; |
| 191 | std::unique_ptr<QSettings> qt_config; | 191 | std::unique_ptr<QSettings> qt_config; |
diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h index 77802a367..56800b6ff 100644 --- a/src/yuzu/configuration/configuration_shared.h +++ b/src/yuzu/configuration/configuration_shared.h | |||
| @@ -27,8 +27,9 @@ enum class CheckState { | |||
| 27 | // ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting | 27 | // ApplyPerGameSetting, given a Settings::Setting and a Qt UI element, properly applies a Setting |
| 28 | void ApplyPerGameSetting(Settings::SwitchableSetting<bool>* setting, const QCheckBox* checkbox, | 28 | void ApplyPerGameSetting(Settings::SwitchableSetting<bool>* setting, const QCheckBox* checkbox, |
| 29 | const CheckState& tracker); | 29 | const CheckState& tracker); |
| 30 | template <typename Type> | 30 | template <typename Type, bool ranged> |
| 31 | void ApplyPerGameSetting(Settings::SwitchableSetting<Type>* setting, const QComboBox* combobox) { | 31 | void ApplyPerGameSetting(Settings::SwitchableSetting<Type, ranged>* setting, |
| 32 | const QComboBox* combobox) { | ||
| 32 | if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) { | 33 | if (Settings::IsConfiguringGlobal() && setting->UsingGlobal()) { |
| 33 | setting->SetValue(static_cast<Type>(combobox->currentIndex())); | 34 | setting->SetValue(static_cast<Type>(combobox->currentIndex())); |
| 34 | } else if (!Settings::IsConfiguringGlobal()) { | 35 | } else if (!Settings::IsConfiguringGlobal()) { |
| @@ -45,8 +46,9 @@ void ApplyPerGameSetting(Settings::SwitchableSetting<Type>* setting, const QComb | |||
| 45 | // Sets a Qt UI element given a Settings::Setting | 46 | // Sets a Qt UI element given a Settings::Setting |
| 46 | void SetPerGameSetting(QCheckBox* checkbox, const Settings::SwitchableSetting<bool>* setting); | 47 | void SetPerGameSetting(QCheckBox* checkbox, const Settings::SwitchableSetting<bool>* setting); |
| 47 | 48 | ||
| 48 | template <typename Type> | 49 | template <typename Type, bool ranged> |
| 49 | void SetPerGameSetting(QComboBox* combobox, const Settings::SwitchableSetting<Type>* setting) { | 50 | void SetPerGameSetting(QComboBox* combobox, |
| 51 | const Settings::SwitchableSetting<Type, ranged>* setting) { | ||
| 50 | combobox->setCurrentIndex(setting->UsingGlobal() ? ConfigurationShared::USE_GLOBAL_INDEX | 52 | combobox->setCurrentIndex(setting->UsingGlobal() ? ConfigurationShared::USE_GLOBAL_INDEX |
| 51 | : static_cast<int>(setting->GetValue()) + | 53 | : static_cast<int>(setting->GetValue()) + |
| 52 | ConfigurationShared::USE_GLOBAL_OFFSET); | 54 | ConfigurationShared::USE_GLOBAL_OFFSET); |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 903e02297..9db7115a2 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -99,8 +99,8 @@ void Config::ReadSetting(const std::string& group, Settings::Setting<bool>& sett | |||
| 99 | setting = sdl2_config->GetBoolean(group, setting.GetLabel(), setting.GetDefault()); | 99 | setting = sdl2_config->GetBoolean(group, setting.GetLabel(), setting.GetDefault()); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | template <typename Type> | 102 | template <typename Type, bool ranged> |
| 103 | void Config::ReadSetting(const std::string& group, Settings::Setting<Type>& setting) { | 103 | void Config::ReadSetting(const std::string& group, Settings::Setting<Type, ranged>& setting) { |
| 104 | setting = static_cast<Type>(sdl2_config->GetInteger(group, setting.GetLabel(), | 104 | setting = static_cast<Type>(sdl2_config->GetInteger(group, setting.GetLabel(), |
| 105 | static_cast<long>(setting.GetDefault()))); | 105 | static_cast<long>(setting.GetDefault()))); |
| 106 | } | 106 | } |
diff --git a/src/yuzu_cmd/config.h b/src/yuzu_cmd/config.h index ccf77d668..32c03075f 100644 --- a/src/yuzu_cmd/config.h +++ b/src/yuzu_cmd/config.h | |||
| @@ -33,6 +33,6 @@ private: | |||
| 33 | * @param group The name of the INI group | 33 | * @param group The name of the INI group |
| 34 | * @param setting The yuzu setting to modify | 34 | * @param setting The yuzu setting to modify |
| 35 | */ | 35 | */ |
| 36 | template <typename Type> | 36 | template <typename Type, bool ranged> |
| 37 | void ReadSetting(const std::string& group, Settings::Setting<Type>& setting); | 37 | void ReadSetting(const std::string& group, Settings::Setting<Type, ranged>& setting); |
| 38 | }; | 38 | }; |