From cdb5dea26959001f9cf7448fcdb612475045a313 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 9 May 2023 16:21:24 -0400 Subject: settings: Move runtime and save to parameters These don't need to be whole new types. --- src/common/settings.h | 148 +++++++++++++++----------- src/yuzu/configuration/configuration_shared.h | 9 +- 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: * configurations. Specifying a default value and label is required. A minimum and maximum range * can be specified for sanitization. */ -template +template class Setting : public BasicSetting { protected: Setting() = default; @@ -245,10 +245,10 @@ public: * @param category_ Category of the setting AKA INI group */ explicit Setting(Linkage& linkage, const Type& default_val, const std::string& name, - enum Category category_) + enum Category category_, bool save_ = true, bool runtime_modifiable_ = false) requires(!ranged) - : value{default_val}, - default_value{default_val}, label{name}, category{category_}, id{linkage.count} { + : value{default_val}, default_value{default_val}, label{name}, category{category_}, + id{linkage.count}, save{save_}, runtime_modifiable{runtime_modifiable_} { linkage.by_category[category].push_front(this); linkage.count++; } @@ -265,10 +265,12 @@ public: * @param category_ Category of the setting AKA INI group */ explicit Setting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, enum Category category_) + const Type& max_val, const std::string& name, enum Category category_, + bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) : value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val}, - label{name}, category{category_}, id{linkage.count} { + label{name}, category{category_}, id{linkage.count}, save{save_}, + runtime_modifiable{runtime_modifiable_} { linkage.by_category[category].push_front(this); linkage.count++; } @@ -455,6 +457,8 @@ protected: const std::string label{}; ///< The setting's label const enum Category category; ///< The setting's category AKA INI group const u32 id; + bool save; + bool runtime_modifiable; }; /** @@ -465,8 +469,8 @@ protected: * * By default, the global setting is used. */ -template -class SwitchableSetting : virtual public Setting { +template +class SwitchableSetting : virtual public Setting { public: /** * Sets a default value, label, and setting value. @@ -477,9 +481,9 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category) + Category category, bool save = true, bool runtime_modifiable = false) requires(!ranged) - : Setting{linkage, default_val, name, category} { + : Setting{linkage, default_val, name, category, save, runtime_modifiable} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -495,10 +499,11 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, Category category) + const Type& max_val, const std::string& name, Category category, + bool save = true, bool runtime_modifiable = false) requires(ranged) - : Setting{linkage, default_val, min_val, - max_val, name, category} { + : Setting{linkage, default_val, min_val, max_val, + name, category, save, runtime_modifiable} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } @@ -642,10 +647,10 @@ struct Values { Setting sink_id{linkage, "auto", "output_engine", Category::Audio}; Setting audio_output_device_id{linkage, "auto", "output_device", Category::Audio}; Setting audio_input_device_id{linkage, "auto", "input_device", Category::Audio}; - Setting audio_muted{linkage, false, "audio_muted", Category::Audio}; + Setting audio_muted{linkage, false, "audio_muted", Category::Audio, false}; SwitchableSetting volume{linkage, 100, 0, 200, "volume", Category::Audio}; - Setting dump_audio_commands{linkage, false, "dump_audio_commands", - Category::Audio}; + Setting dump_audio_commands{linkage, false, "dump_audio_commands", Category::Audio, + false}; // Core SwitchableSetting use_multi_core{linkage, true, "use_multi_core", Category::Core}; @@ -713,38 +718,51 @@ struct Values { ResolutionScalingInfo resolution_info{}; SwitchableSetting resolution_setup{linkage, ResolutionSetup::Res1X, "resolution_setup", Category::Renderer}; - SwitchableSetting scaling_filter{ - linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer}; - SwitchableSetting fsr_sharpening_slider{ - linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer}; - SwitchableSetting anti_aliasing{ - linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer}; + SwitchableSetting scaling_filter{ + linkage, ScalingFilter::Bilinear, "scaling_filter", Category::Renderer, true, true}; + SwitchableSetting fsr_sharpening_slider{ + linkage, 25, 0, 200, "fsr_sharpening_slider", Category::Renderer, true, true}; + SwitchableSetting anti_aliasing{ + linkage, AntiAliasing::None, "anti_aliasing", Category::Renderer, true, true}; // *nix platforms may have issues with the borderless windowed fullscreen mode. // Default to exclusive fullscreen on these platforms for now. - SwitchableSetting fullscreen_mode{linkage, + SwitchableSetting fullscreen_mode{linkage, #ifdef _WIN32 - FullscreenMode::Borderless, + FullscreenMode::Borderless, #else - FullscreenMode::Exclusive, + FullscreenMode::Exclusive, #endif - FullscreenMode::Borderless, - FullscreenMode::Exclusive, - "fullscreen_mode", - Category::Renderer}; - SwitchableSetting aspect_ratio{ - linkage, 0, 0, 4, "aspect_ratio", Category::Renderer}; + FullscreenMode::Borderless, + FullscreenMode::Exclusive, + "fullscreen_mode", + Category::Renderer, + true, + true}; + SwitchableSetting aspect_ratio{linkage, + AspectRatio::R16_9, + AspectRatio::R16_9, + AspectRatio::Stretch, + "aspect_ratio", + Category::Renderer, + true, + true}; SwitchableSetting max_anisotropy{ linkage, AnisotropyMode::Automatic, AnisotropyMode::Automatic, AnisotropyMode::X16, "max_anisotropy", Category::RendererAdvanced}; - SwitchableSetting use_speed_limit{linkage, true, "use_speed_limit", - Category::Renderer}; - SwitchableSetting speed_limit{ - linkage, 100, 0, 9999, "speed_limit", Category::Renderer}; + SwitchableSetting use_speed_limit{ + linkage, true, "use_speed_limit", Category::Renderer, false, true}; + SwitchableSetting speed_limit{ + linkage, 100, 0, 9999, "speed_limit", Category::Renderer, true, true}; SwitchableSetting use_disk_shader_cache{linkage, true, "use_disk_shader_cache", Category::Renderer}; - SwitchableSetting gpu_accuracy{ - linkage, GPUAccuracy::High, GPUAccuracy::Normal, GPUAccuracy::Extreme, - "gpu_accuracy", Category::RendererAdvanced}; + SwitchableSetting gpu_accuracy{linkage, + GPUAccuracy::High, + GPUAccuracy::Normal, + GPUAccuracy::Extreme, + "gpu_accuracy", + Category::RendererAdvanced, + true, + true}; SwitchableSetting use_asynchronous_gpu_emulation{ linkage, true, "use_asynchronous_gpu_emulation", Category::Renderer}; SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::GPU, @@ -755,9 +773,14 @@ struct Values { AstcDecodeMode::CPUAsynchronous, "accelerate_astc", Category::Renderer}; - Setting vsync_mode{ - linkage, VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::FIFORelaxed, - "use_vsync", Category::Renderer}; + Setting vsync_mode{linkage, + VSyncMode::FIFO, + VSyncMode::Immediate, + VSyncMode::FIFORelaxed, + "use_vsync", + Category::Renderer, + true, + true}; SwitchableSetting use_reactive_flushing{linkage, true, "use_reactive_flushing", Category::RendererAdvanced}; SwitchableSetting shader_backend{ @@ -765,10 +788,10 @@ struct Values { "shader_backend", Category::Renderer}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; - SwitchableSetting use_fast_gpu_time{linkage, true, "use_fast_gpu_time", - Category::RendererAdvanced}; - SwitchableSetting use_vulkan_driver_pipeline_cache{ - linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced}; + SwitchableSetting use_fast_gpu_time{ + linkage, true, "use_fast_gpu_time", Category::RendererAdvanced, true, true}; + SwitchableSetting use_vulkan_driver_pipeline_cache{ + linkage, true, "use_vulkan_driver_pipeline_cache", Category::RendererAdvanced, true, true}; SwitchableSetting enable_compute_pipelines{linkage, false, "enable_compute_pipelines", Category::RendererAdvanced}; SwitchableSetting astc_recompression{linkage, @@ -782,9 +805,9 @@ struct Values { SwitchableSetting barrier_feedback_loops{linkage, true, "barrier_feedback_loops", Category::RendererAdvanced}; - SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer}; - SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer}; - SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer}; + SwitchableSetting bg_red{linkage, 0, "bg_red", Category::Renderer, true, true}; + SwitchableSetting bg_green{linkage, 0, "bg_green", Category::Renderer, true, true}; + SwitchableSetting bg_blue{linkage, 0, "bg_blue", Category::Renderer, true, true}; // System SwitchableSetting rng_seed_enabled{linkage, false, "rng_seed_enabled", Category::System}; @@ -809,15 +832,14 @@ struct Values { // Controls InputSetting> players; - Setting enable_raw_input{linkage, false, "enable_raw_input", Category::Controls, // Only read/write enable_raw_input on Windows platforms #ifdef _WIN32 - true + true #else - false + false #endif - > - enable_raw_input{linkage, false, "enable_raw_input", Category::Controls}; + }; Setting controller_navigation{linkage, true, "controller_navigation", Category::Controls}; Setting enable_joycon_driver{linkage, true, "enable_joycon_driver", Category::Controls}; Setting enable_procon_driver{linkage, false, "enable_procon_driver", Category::Controls}; @@ -837,7 +859,7 @@ struct Values { Setting tas_enable{linkage, false, "tas_enable", Category::Controls}; Setting tas_loop{linkage, false, "tas_loop", Category::Controls}; - Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls}; + Setting mouse_panning{linkage, false, "mouse_panning", Category::Controls, false}; Setting mouse_panning_sensitivity{ linkage, 50, 1, 100, "mouse_panning_sensitivity", Category::Controls}; Setting mouse_enabled{linkage, false, "mouse_enabled", Category::Controls}; @@ -893,22 +915,22 @@ struct Values { Setting program_args{linkage, std::string(), "program_args", Category::Debugging}; Setting dump_exefs{linkage, false, "dump_exefs", Category::Debugging}; Setting dump_nso{linkage, false, "dump_nso", Category::Debugging}; - Setting dump_shaders{linkage, false, "dump_shaders", - Category::DebuggingGraphics}; - Setting dump_macros{linkage, false, "dump_macros", - Category::DebuggingGraphics}; + Setting dump_shaders{linkage, false, "dump_shaders", Category::DebuggingGraphics, + false}; + Setting dump_macros{linkage, false, "dump_macros", Category::DebuggingGraphics, + false}; Setting enable_fs_access_log{linkage, false, "enable_fs_access_log", Category::Debugging}; - Setting reporting_services{linkage, false, "reporting_services", - Category::Debugging}; + Setting reporting_services{linkage, false, "reporting_services", + Category::Debugging, false}; Setting quest_flag{linkage, false, "quest_flag", Category::Debugging}; Setting disable_macro_jit{linkage, false, "disable_macro_jit", Category::DebuggingGraphics}; Setting disable_macro_hle{linkage, false, "disable_macro_hle", Category::DebuggingGraphics}; - Setting extended_logging{linkage, false, "extended_logging", - Category::Debugging}; + Setting extended_logging{linkage, false, "extended_logging", Category::Debugging, + false}; Setting use_debug_asserts{linkage, false, "use_debug_asserts", Category::Debugging}; - Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging}; + Setting use_auto_stub{linkage, false, "use_auto_stub", Category::Debugging, false}; Setting enable_all_controllers{linkage, false, "enable_all_controllers", Category::Debugging}; Setting 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, void SetHighlight(QWidget* widget, bool highlighted); // Sets up a QCheckBox like a tristate one, given a Setting -template -void SetColoredTristate( - QCheckBox* checkbox, - const Settings::SwitchableSetting& setting, - CheckState& tracker) { +template +void SetColoredTristate(QCheckBox* checkbox, + const Settings::SwitchableSetting& setting, + CheckState& tracker) { if (setting.UsingGlobal()) { tracker = CheckState::Global; } else { -- cgit v1.2.3