From d146dd9d123a999e40307a93403239b81b04bffc Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:52:23 -0400 Subject: settings,general: Rename non-confirming enums --- src/common/settings.cpp | 6 +++--- src/common/settings.h | 40 ++++++++++++++++++++++++---------------- src/common/settings_enums.h | 37 ++++++++++++++++++------------------- 3 files changed, 45 insertions(+), 38 deletions(-) (limited to 'src/common') diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 8bfda5667..0a8729b5a 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -122,12 +122,12 @@ void SetConfiguringGlobal(bool is_global) { } bool IsGPULevelExtreme() { - return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme; + return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme; } bool IsGPULevelHigh() { - return values.gpu_accuracy.GetValue() == GPUAccuracy::Extreme || - values.gpu_accuracy.GetValue() == GPUAccuracy::High; + return values.gpu_accuracy.GetValue() == GpuAccuracy::Extreme || + values.gpu_accuracy.GetValue() == GpuAccuracy::High; } bool IsFastmemEnabled() { diff --git a/src/common/settings.h b/src/common/settings.h index a9ce113ef..141408d3e 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -91,6 +91,7 @@ public: return {}; } virtual void LoadString(const std::string& load) = 0; + virtual std::string Canonicalize() const = 0; virtual const std::string& GetLabel() const = 0; virtual std::string DefaultToString() const = 0; virtual bool Save() const = 0; @@ -102,7 +103,7 @@ public: virtual std::string MinVal() const = 0; virtual std::string MaxVal() const = 0; virtual bool UsingGlobal() const { - return false; + return true; } }; @@ -245,7 +246,7 @@ protected: } else if constexpr (std::is_same()) { return value_ ? "true" : "false"; } else if (std::is_same()) { - return TranslateEnum(value_); + return CanonicalizeEnum(value_); } else { return std::to_string(static_cast(value_)); } @@ -321,6 +322,13 @@ public: } } + [[nodiscard]] std::string constexpr Canonicalize() const override { + if constexpr (std::is_enum::value) { + return CanonicalizeEnum(this->GetValue()); + } + return ToString(this->GetValue()); + } + /** * Returns the save preference of the setting i.e. when saving or reading the setting from a * frontend, whether this setting should be skipped. @@ -560,8 +568,8 @@ struct Values { linkage, false, "use_unsafe_extended_memory_layout", Category::Core}; // Cpu - SwitchableSetting cpu_accuracy{linkage, CPUAccuracy::Auto, - CPUAccuracy::Auto, CPUAccuracy::Paranoid, + SwitchableSetting cpu_accuracy{linkage, CpuAccuracy::Auto, + CpuAccuracy::Auto, CpuAccuracy::Paranoid, "cpu_accuracy", Category::Cpu}; // TODO: remove cpu_accuracy_first_time, migration setting added 8 July 2021 Setting cpu_accuracy_first_time{linkage, true, "cpu_accuracy_first_time", Category::Cpu}; @@ -657,28 +665,28 @@ struct Values { 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, + 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, + SwitchableSetting nvdec_emulation{linkage, NvdecEmulation::Gpu, "nvdec_emulation", Category::Renderer}; SwitchableSetting accelerate_astc{linkage, - AstcDecodeMode::CPU, - AstcDecodeMode::CPU, - AstcDecodeMode::CPUAsynchronous, + AstcDecodeMode::Cpu, + AstcDecodeMode::Cpu, + AstcDecodeMode::CpuAsynchronous, "accelerate_astc", Category::Renderer}; Setting vsync_mode{linkage, - VSyncMode::FIFO, + VSyncMode::Fifo, VSyncMode::Immediate, - VSyncMode::FIFORelaxed, + VSyncMode::FifoRelaxed, "use_vsync", Category::Renderer, true, @@ -686,7 +694,7 @@ struct Values { SwitchableSetting use_reactive_flushing{linkage, true, "use_reactive_flushing", Category::RendererAdvanced}; SwitchableSetting shader_backend{ - linkage, ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV, + linkage, ShaderBackend::Glsl, ShaderBackend::Glsl, ShaderBackend::SpirV, "shader_backend", Category::Renderer}; SwitchableSetting use_asynchronous_shaders{linkage, false, "use_asynchronous_shaders", Category::RendererAdvanced}; @@ -730,7 +738,7 @@ struct Values { Language::PortugueseBrazilian, "language_index", Category::System}; - SwitchableSetting region_index{linkage, Region::USA, Region::Japan, + SwitchableSetting region_index{linkage, Region::Usa, Region::Japan, Region::Taiwan, "region_index", Category::System}; SwitchableSetting time_zone_index{linkage, TimeZone::Auto, TimeZone::Auto, TimeZone::Zulu, diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index f48fb7bd4..6cd2ac28b 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -47,7 +47,7 @@ enum class Language : u32 { enum class Region : u32 { Japan, - USA, + Usa, Europe, Australia, China, @@ -114,9 +114,9 @@ enum class AnisotropyMode : u32 { }; enum class AstcDecodeMode : u32 { - CPU = 0, - GPU = 1, - CPUAsynchronous = 2, + Cpu = 0, + Gpu = 1, + CpuAsynchronous = 2, }; enum class AstcRecompression : u32 { @@ -128,8 +128,8 @@ enum class AstcRecompression : u32 { enum class VSyncMode : u32 { Immediate = 0, Mailbox = 1, - FIFO = 2, - FIFORelaxed = 3, + Fifo = 2, + FifoRelaxed = 3, }; enum class RendererBackend : u32 { @@ -139,19 +139,18 @@ enum class RendererBackend : u32 { }; enum class ShaderBackend : u32 { - GLSL = 0, - GLASM = 1, - SPIRV = 2, + Glsl = 0, + Glasm = 1, + SpirV = 2, }; -enum class GPUAccuracy : u32 { +enum class GpuAccuracy : u32 { Normal = 0, High = 1, Extreme = 2, - MaxEnum = 3, }; -enum class CPUAccuracy : u32 { +enum class CpuAccuracy : u32 { Auto = 0, Accurate = 1, Unsafe = 2, @@ -165,8 +164,8 @@ enum class FullscreenMode : u32 { enum class NvdecEmulation : u32 { Off = 0, - CPU = 1, - GPU = 2, + Cpu = 1, + Gpu = 2, }; enum class ResolutionSetup : u32 { @@ -220,18 +219,18 @@ static std::map> translations = { static std::string empty_string{}; template -const std::string& TranslateEnum(Type id) { - auto& group = translations.at(typeid(Type)); +const std::string& CanonicalizeEnum(Type id) { + auto& group = canonicalizations.at(typeid(Type)); for (auto& [name, value] : group) { if (static_cast(value) == id) { return name; } } - return empty_string; + return invalid_string; } template -static Type ToEnum(const std::string& text) { - return static_cast(translations.at(typeid(Type)).at(text)); +static Type ToEnum(const std::string& canonicalization) { + return static_cast(canonicalizations.at(typeid(Type)).at(canonicalization)); } } // namespace Settings -- cgit v1.2.3