summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar lat9nq2023-05-09 16:21:24 -0400
committerGravatar lat9nq2023-07-21 10:56:07 -0400
commitcdb5dea26959001f9cf7448fcdb612475045a313 (patch)
tree12a712073047a2dfe65832a585aacb7c49f510d5
parentgraphics: Set speed limit to spinbox (diff)
downloadyuzu-cdb5dea26959001f9cf7448fcdb612475045a313.tar.gz
yuzu-cdb5dea26959001f9cf7448fcdb612475045a313.tar.xz
yuzu-cdb5dea26959001f9cf7448fcdb612475045a313.zip
settings: Move runtime and save to parameters
These don't need to be whole new types.
-rw-r--r--src/common/settings.h148
-rw-r--r--src/yuzu/configuration/configuration_shared.h9
2 files changed, 89 insertions, 68 deletions
diff --git a/src/common/settings.h b/src/common/settings.h
index e60105059..fdadb06a1 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -222,7 +222,7 @@ public:
222 * configurations. Specifying a default value and label is required. A minimum and maximum range 222 * configurations. Specifying a default value and label is required. A minimum and maximum range
223 * can be specified for sanitization. 223 * can be specified for sanitization.
224 */ 224 */
225template <typename Type, bool ranged = false, bool save = true, bool runtime_modifiable = false> 225template <typename Type, bool ranged = false>
226class Setting : public BasicSetting { 226class Setting : public BasicSetting {
227protected: 227protected:
228 Setting() = default; 228 Setting() = default;
@@ -245,10 +245,10 @@ public:
245 * @param category_ Category of the setting AKA INI group 245 * @param category_ Category of the setting AKA INI group
246 */ 246 */
247 explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, 247 explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name,
248 enum Category category_) 248 enum Category category_, bool save_ = true, bool runtime_modifiable_ = false)
249 requires(!ranged) 249 requires(!ranged)
250 : value{default_val}, 250 : value{default_val}, default_value{default_val}, label{name}, category{category_},
251 default_value{default_val}, label{name}, category{category_}, id{linkage.count} { 251 id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_} {
252 linkage.by_category[category].push_front(this); 252 linkage.by_category[category].push_front(this);
253 linkage.count++; 253 linkage.count++;
254 } 254 }
@@ -265,10 +265,12 @@ public:
265 * @param category_ Category of the setting AKA INI group 265 * @param category_ Category of the setting AKA INI group
266 */ 266 */
267 explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, 267 explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val,
268 const Type& max_val, const std::string& name, enum Category category_) 268 const Type& max_val, const std::string& name, enum Category category_,
269 bool save_ = true, bool runtime_modifiable_ = false)
269 requires(ranged) 270 requires(ranged)
270 : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, 271 : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val},
271 label{name}, category{category_}, id{linkage.count} { 272 label{name}, category{category_}, id{linkage.count}, save{save_},
273 runtime_modifiable{runtime_modifiable_} {
272 linkage.by_category[category].push_front(this); 274 linkage.by_category[category].push_front(this);
273 linkage.count++; 275 linkage.count++;
274 } 276 }
@@ -455,6 +457,8 @@ protected:
455 const std::string label{}; ///< The setting's label 457 const std::string label{}; ///< The setting's label
456 const enum Category category; ///< The setting's category AKA INI group 458 const enum Category category; ///< The setting's category AKA INI group
457 const u32 id; 459 const u32 id;
460 bool save;
461 bool runtime_modifiable;
458}; 462};
459 463
460/** 464/**
@@ -465,8 +469,8 @@ protected:
465 * 469 *
466 * By default, the global setting is used. 470 * By default, the global setting is used.
467 */ 471 */
468template <typename Type, bool ranged = false, bool save = true, bool runtime_modifiable = false> 472template <typename Type, bool ranged = false>
469class SwitchableSetting : virtual public Setting<Type, ranged, save, runtime_modifiable> { 473class SwitchableSetting : virtual public Setting<Type, ranged> {
470public: 474public:
471 /** 475 /**
472 * Sets a default value, label, and setting value. 476 * Sets a default value, label, and setting value.
@@ -477,9 +481,9 @@ public:
477 * @param category_ Category of the setting AKA INI group 481 * @param category_ Category of the setting AKA INI group
478 */ 482 */
479 explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, 483 explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name,
480 Category category) 484 Category category, bool save = true, bool runtime_modifiable = false)
481 requires(!ranged) 485 requires(!ranged)
482 : Setting<Type, false, save, runtime_modifiable>{linkage, default_val, name, category} { 486 : Setting<Type, false>{linkage, default_val, name, category, save, runtime_modifiable} {
483 linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); 487 linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); });
484 } 488 }
485 virtual ~SwitchableSetting() = default; 489 virtual ~SwitchableSetting() = default;
@@ -495,10 +499,11 @@ public:
495 * @param category_ Category of the setting AKA INI group 499 * @param category_ Category of the setting AKA INI group
496 */ 500 */
497 explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, 501 explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val,
498 const Type& max_val, const std::string& name, Category category) 502 const Type& max_val, const std::string& name, Category category,
503 bool save = true, bool runtime_modifiable = false)
499 requires(ranged) 504 requires(ranged)
500 : Setting<Type, true, save, runtime_modifiable>{linkage, default_val, min_val, 505 : Setting<Type, true>{linkage, default_val, min_val, max_val,
501 max_val, name, category} { 506 name, category, save, runtime_modifiable} {
502 linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); 507 linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); });
503 } 508 }
504 509
@@ -642,10 +647,10 @@ struct Values {
642 Setting<std::string> sink_id{linkage, "auto", "output_engine", Category::Audio}; 647 Setting<std::string> sink_id{linkage, "auto", "output_engine", Category::Audio};
643 Setting<std::string> audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; 648 Setting<std::string> audio_output_device_id{linkage, "auto", "output_device", Category::Audio};
644 Setting<std::string> audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; 649 Setting<std::string> audio_input_device_id{linkage, "auto", "input_device", Category::Audio};
645 Setting<bool, false, false> audio_muted{linkage, false, "audio_muted", Category::Audio}; 650 Setting<bool, false> audio_muted{linkage, false, "audio_muted", Category::Audio, false};
646 SwitchableSetting<u8, true> volume{linkage, 100, 0, 200, "volume", Category::Audio}; 651 SwitchableSetting<u8, true> volume{linkage, 100, 0, 200, "volume", Category::Audio};
647 Setting<bool, false, false> dump_audio_commands{linkage, false, "dump_audio_commands", 652 Setting<bool, false> dump_audio_commands{linkage, false, "dump_audio_commands", Category::Audio,
648 Category::Audio}; 653 false};
649 654
650 // Core 655 // Core
651 SwitchableSetting<bool> use_multi_core{linkage, true, "use_multi_core", Category::Core}; 656 SwitchableSetting<bool> use_multi_core{linkage, true, "use_multi_core", Category::Core};
@@ -713,38 +718,51 @@ struct Values {
713 ResolutionScalingInfo resolution_info{}; 718 ResolutionScalingInfo resolution_info{};
714 SwitchableSetting<ResolutionSetup> resolution_setup{linkage, ResolutionSetup::Res1X, 719 SwitchableSetting<ResolutionSetup> resolution_setup{linkage, ResolutionSetup::Res1X,
715 "resolution_setup", Category::Renderer}; 720 "resolution_setup", Category::Renderer};
716 SwitchableSetting<ScalingFilter, false, true, true> scaling_filter{ 721 SwitchableSetting<ScalingFilter, false> scaling_filter{
717 linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer}; 722 linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer, true, true};
718 SwitchableSetting<int, true, true, true> fsr_sharpening_slider{ 723 SwitchableSetting<int, true> fsr_sharpening_slider{
719 linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer}; 724 linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, true, true};
720 SwitchableSetting<AntiAliasing, false, true, true> anti_aliasing{ 725 SwitchableSetting<AntiAliasing, false> anti_aliasing{
721 linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer}; 726 linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer, true, true};
722 // *nix platforms may have issues with the borderless windowed fullscreen mode. 727 // *nix platforms may have issues with the borderless windowed fullscreen mode.
723 // Default to exclusive fullscreen on these platforms for now. 728 // Default to exclusive fullscreen on these platforms for now.
724 SwitchableSetting<FullscreenMode, true, true, true> fullscreen_mode{linkage, 729 SwitchableSetting<FullscreenMode, true> fullscreen_mode{linkage,
725#ifdef _WIN32 730#ifdef _WIN32
726 FullscreenMode::Borderless, 731 FullscreenMode::Borderless,
727#else 732#else
728 FullscreenMode::Exclusive, 733 FullscreenMode::Exclusive,
729#endif 734#endif
730 FullscreenMode::Borderless, 735 FullscreenMode::Borderless,
731 FullscreenMode::Exclusive, 736 FullscreenMode::Exclusive,
732 "fullscreen_mode", 737 "fullscreen_mode",
733 Category::Renderer}; 738 Category::Renderer,
734 SwitchableSetting<int, true, true, true> aspect_ratio{ 739 true,
735 linkage, 0, 0, 4, "aspect_ratio", Category::Renderer}; 740 true};
741 SwitchableSetting<AspectRatio, true> aspect_ratio{linkage,
742 AspectRatio::R16_9,
743 AspectRatio::R16_9,
744 AspectRatio::Stretch,
745 "aspect_ratio",
746 Category::Renderer,
747 true,
748 true};
736 SwitchableSetting<AnisotropyMode, true> max_anisotropy{ 749 SwitchableSetting<AnisotropyMode, true> max_anisotropy{
737 linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16, 750 linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16,
738 "max_anisotropy", Category::RendererAdvanced}; 751 "max_anisotropy", Category::RendererAdvanced};
739 SwitchableSetting<bool, false, false, true> use_speed_limit{linkage, true, "use_speed_limit", 752 SwitchableSetting<bool, false> use_speed_limit{
740 Category::Renderer}; 753 linkage, true, "use_speed_limit", Category::Renderer, false, true};
741 SwitchableSetting<u16, true, true, true> speed_limit{ 754 SwitchableSetting<u16, true> speed_limit{
742 linkage, 100, 0, 9999, "speed_limit", Category::Renderer}; 755 linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true};
743 SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache", 756 SwitchableSetting<bool> use_disk_shader_cache{linkage, true, "use_disk_shader_cache",
744 Category::Renderer}; 757 Category::Renderer};
745 SwitchableSetting<GPUAccuracy, true, true, true> gpu_accuracy{ 758 SwitchableSetting<GPUAccuracy, true> gpu_accuracy{linkage,
746 linkage, GPUAccuracy::High, GPUAccuracy::Normal, GPUAccuracy::Extreme, 759 GPUAccuracy::High,
747 "gpu_accuracy", Category::RendererAdvanced}; 760 GPUAccuracy::Normal,
761 GPUAccuracy::Extreme,
762 "gpu_accuracy",
763 Category::RendererAdvanced,
764 true,
765 true};
748 SwitchableSetting<bool> use_asynchronous_gpu_emulation{ 766 SwitchableSetting<bool> use_asynchronous_gpu_emulation{
749 linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; 767 linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer};
750 SwitchableSetting<NvdecEmulation> nvdec_emulation{linkage, NvdecEmulation::GPU, 768 SwitchableSetting<NvdecEmulation> nvdec_emulation{linkage, NvdecEmulation::GPU,
@@ -755,9 +773,14 @@ struct Values {
755 AstcDecodeMode::CPUAsynchronous, 773 AstcDecodeMode::CPUAsynchronous,
756 "accelerate_astc", 774 "accelerate_astc",
757 Category::Renderer}; 775 Category::Renderer};
758 Setting<VSyncMode, true, true, true> vsync_mode{ 776 Setting<VSyncMode, true> vsync_mode{linkage,
759 linkage, VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::FIFORelaxed, 777 VSyncMode::FIFO,
760 "use_vsync", Category::Renderer}; 778 VSyncMode::Immediate,
779 VSyncMode::FIFORelaxed,
780 "use_vsync",
781 Category::Renderer,
782 true,
783 true};
761 SwitchableSetting<bool> use_reactive_flushing{linkage, true, "use_reactive_flushing", 784 SwitchableSetting<bool> use_reactive_flushing{linkage, true, "use_reactive_flushing",
762 Category::RendererAdvanced}; 785 Category::RendererAdvanced};
763 SwitchableSetting<ShaderBackend, true> shader_backend{ 786 SwitchableSetting<ShaderBackend, true> shader_backend{
@@ -765,10 +788,10 @@ struct Values {
765 "shader_backend", Category::Renderer}; 788 "shader_backend", Category::Renderer};
766 SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", 789 SwitchableSetting<bool> use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders",
767 Category::RendererAdvanced}; 790 Category::RendererAdvanced};
768 SwitchableSetting<bool, false, true, true> use_fast_gpu_time{linkage, true, "use_fast_gpu_time", 791 SwitchableSetting<bool, false> use_fast_gpu_time{
769 Category::RendererAdvanced}; 792 linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, true, true};
770 SwitchableSetting<bool, false, true, true> use_vulkan_driver_pipeline_cache{ 793 SwitchableSetting<bool, false> use_vulkan_driver_pipeline_cache{
771 linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced}; 794 linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced, true, true};
772 SwitchableSetting<bool> enable_compute_pipelines{linkage, false, "enable_compute_pipelines", 795 SwitchableSetting<bool> enable_compute_pipelines{linkage, false, "enable_compute_pipelines",
773 Category::RendererAdvanced}; 796 Category::RendererAdvanced};
774 SwitchableSetting<AstcRecompression, true> astc_recompression{linkage, 797 SwitchableSetting<AstcRecompression, true> astc_recompression{linkage,
@@ -782,9 +805,9 @@ struct Values {
782 SwitchableSetting<bool> barrier_feedback_loops{linkage, true, "barrier_feedback_loops", 805 SwitchableSetting<bool> barrier_feedback_loops{linkage, true, "barrier_feedback_loops",
783 Category::RendererAdvanced}; 806 Category::RendererAdvanced};
784 807
785 SwitchableSetting<u8, false, true, true> bg_red{linkage, 0, "bg_red", Category::Renderer}; 808 SwitchableSetting<u8, false> bg_red{linkage, 0, "bg_red", Category::Renderer, true, true};
786 SwitchableSetting<u8, false, true, true> bg_green{linkage, 0, "bg_green", Category::Renderer}; 809 SwitchableSetting<u8, false> bg_green{linkage, 0, "bg_green", Category::Renderer, true, true};
787 SwitchableSetting<u8, false, true, true> bg_blue{linkage, 0, "bg_blue", Category::Renderer}; 810 SwitchableSetting<u8, false> bg_blue{linkage, 0, "bg_blue", Category::Renderer, true, true};
788 811
789 // System 812 // System
790 SwitchableSetting<bool> rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System}; 813 SwitchableSetting<bool> rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System};
@@ -809,15 +832,14 @@ struct Values {
809 // Controls 832 // Controls
810 InputSetting<std::array<PlayerInput, 10>> players; 833 InputSetting<std::array<PlayerInput, 10>> players;
811 834
812 Setting<bool, false, 835 Setting<bool, false> enable_raw_input{linkage, false, "enable_raw_input", Category::Controls,
813// Only read/write enable_raw_input on Windows platforms 836// Only read/write enable_raw_input on Windows platforms
814#ifdef _WIN32 837#ifdef _WIN32
815 true 838 true
816#else 839#else
817 false 840 false
818#endif 841#endif
819 > 842 };
820 enable_raw_input{linkage, false, "enable_raw_input", Category::Controls};
821 Setting<bool> controller_navigation{linkage, true, "controller_navigation", Category::Controls}; 843 Setting<bool> controller_navigation{linkage, true, "controller_navigation", Category::Controls};
822 Setting<bool> enable_joycon_driver{linkage, true, "enable_joycon_driver", Category::Controls}; 844 Setting<bool> enable_joycon_driver{linkage, true, "enable_joycon_driver", Category::Controls};
823 Setting<bool> enable_procon_driver{linkage, false, "enable_procon_driver", Category::Controls}; 845 Setting<bool> enable_procon_driver{linkage, false, "enable_procon_driver", Category::Controls};
@@ -837,7 +859,7 @@ struct Values {
837 Setting<bool> tas_enable{linkage, false, "tas_enable", Category::Controls}; 859 Setting<bool> tas_enable{linkage, false, "tas_enable", Category::Controls};
838 Setting<bool> tas_loop{linkage, false, "tas_loop", Category::Controls}; 860 Setting<bool> tas_loop{linkage, false, "tas_loop", Category::Controls};
839 861
840 Setting<bool, false, false> mouse_panning{linkage, false, "mouse_panning", Category::Controls}; 862 Setting<bool, false> mouse_panning{linkage, false, "mouse_panning", Category::Controls, false};
841 Setting<u8, true> mouse_panning_sensitivity{ 863 Setting<u8, true> mouse_panning_sensitivity{
842 linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; 864 linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls};
843 Setting<bool> mouse_enabled{linkage, false, "mouse_enabled", Category::Controls}; 865 Setting<bool> mouse_enabled{linkage, false, "mouse_enabled", Category::Controls};
@@ -893,22 +915,22 @@ struct Values {
893 Setting<std::string> program_args{linkage, std::string(), "program_args", Category::Debugging}; 915 Setting<std::string> program_args{linkage, std::string(), "program_args", Category::Debugging};
894 Setting<bool> dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; 916 Setting<bool> dump_exefs{linkage, false, "dump_exefs", Category::Debugging};
895 Setting<bool> dump_nso{linkage, false, "dump_nso", Category::Debugging}; 917 Setting<bool> dump_nso{linkage, false, "dump_nso", Category::Debugging};
896 Setting<bool, false, false> dump_shaders{linkage, false, "dump_shaders", 918 Setting<bool, false> dump_shaders{linkage, false, "dump_shaders", Category::DebuggingGraphics,
897 Category::DebuggingGraphics}; 919 false};
898 Setting<bool, false, false> dump_macros{linkage, false, "dump_macros", 920 Setting<bool, false> dump_macros{linkage, false, "dump_macros", Category::DebuggingGraphics,
899 Category::DebuggingGraphics}; 921 false};
900 Setting<bool> enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; 922 Setting<bool> enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging};
901 Setting<bool, false, false> reporting_services{linkage, false, "reporting_services", 923 Setting<bool, false> reporting_services{linkage, false, "reporting_services",
902 Category::Debugging}; 924 Category::Debugging, false};
903 Setting<bool> quest_flag{linkage, false, "quest_flag", Category::Debugging}; 925 Setting<bool> quest_flag{linkage, false, "quest_flag", Category::Debugging};
904 Setting<bool> disable_macro_jit{linkage, false, "disable_macro_jit", 926 Setting<bool> disable_macro_jit{linkage, false, "disable_macro_jit",
905 Category::DebuggingGraphics}; 927 Category::DebuggingGraphics};
906 Setting<bool> disable_macro_hle{linkage, false, "disable_macro_hle", 928 Setting<bool> disable_macro_hle{linkage, false, "disable_macro_hle",
907 Category::DebuggingGraphics}; 929 Category::DebuggingGraphics};
908 Setting<bool, false, false> extended_logging{linkage, false, "extended_logging", 930 Setting<bool, false> extended_logging{linkage, false, "extended_logging", Category::Debugging,
909 Category::Debugging}; 931 false};
910 Setting<bool> use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; 932 Setting<bool> use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging};
911 Setting<bool, false, false> use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging}; 933 Setting<bool, false> use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging, false};
912 Setting<bool> enable_all_controllers{linkage, false, "enable_all_controllers", 934 Setting<bool> enable_all_controllers{linkage, false, "enable_all_controllers",
913 Category::Debugging}; 935 Category::Debugging};
914 Setting<bool> create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging}; 936 Setting<bool> create_crash_dumps{linkage, false, "create_crash_dumps", Category::Debugging};
diff --git a/src/yuzu/configuration/configuration_shared.h b/src/yuzu/configuration/configuration_shared.h
index 0a0a92ae5..83a0dd574 100644
--- a/src/yuzu/configuration/configuration_shared.h
+++ b/src/yuzu/configuration/configuration_shared.h
@@ -77,11 +77,10 @@ void SetPerGameSetting(QComboBox* combobox,
77void SetHighlight(QWidget* widget, bool highlighted); 77void SetHighlight(QWidget* widget, bool highlighted);
78 78
79// Sets up a QCheckBox like a tristate one, given a Setting 79// Sets up a QCheckBox like a tristate one, given a Setting
80template <bool ranged, bool save, bool runtime_modifiable> 80template <bool ranged>
81void SetColoredTristate( 81void SetColoredTristate(QCheckBox* checkbox,
82 QCheckBox* checkbox, 82 const Settings::SwitchableSetting<bool, ranged>& setting,
83 const Settings::SwitchableSetting<bool, ranged, save, runtime_modifiable>& setting, 83 CheckState& tracker) {
84 CheckState& tracker) {
85 if (setting.UsingGlobal()) { 84 if (setting.UsingGlobal()) {
86 tracker = CheckState::Global; 85 tracker = CheckState::Global;
87 } else { 86 } else {