From 8c17a945f71b8532b0a4c3903b00a09d99ff0d6c Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:53:05 -0400 Subject: [PATCH] settings_enums: Cannonicalize settings names Gives every option of the enums a string literal via a macro. --- src/common/settings_enums.h | 165 +++++++++++++++++++++++++++++++++++- 1 file changed, 163 insertions(+), 2 deletions(-) diff --git a/src/common/settings_enums.h b/src/common/settings_enums.h index 6cd2ac28b..d820bc48e 100644 --- a/src/common/settings_enums.h +++ b/src/common/settings_enums.h @@ -207,16 +207,177 @@ enum class AspectRatio : u32 { Stretch, }; -static std::map> translations = { +#define X(ENUM, NAME) \ + { (#NAME), static_cast(ENUM::NAME) } + +static std::map> canonicalizations = { {typeid(AudioEngine), { {"auto", static_cast(AudioEngine::Auto)}, {"cubeb", static_cast(AudioEngine::Cubeb)}, {"sdl2", static_cast(AudioEngine::Sdl2)}, {"null", static_cast(AudioEngine::Null)}, + }}, + {typeid(AudioMode), + { + X(AudioMode, Mono), + X(AudioMode, Stereo), + X(AudioMode, Surround), + }}, + {typeid(Language), + { + X(Language, Japanese), + X(Language, EnglishAmerican), + X(Language, French), + X(Language, German), + X(Language, Italian), + X(Language, Spanish), + X(Language, Chinese), + X(Language, Korean), + X(Language, Dutch), + X(Language, Portuguese), + X(Language, Russian), + X(Language, Taiwanese), + X(Language, EnglishBritish), + X(Language, FrenchCanadian), + X(Language, SpanishLatin), + X(Language, ChineseSimplified), + X(Language, ChineseTraditional), + X(Language, PortugueseBrazilian), + }}, + {typeid(Region), + { + X(Region, Japan), + X(Region, Usa), + X(Region, Europe), + X(Region, Australia), + X(Region, China), + X(Region, Korea), + X(Region, Taiwan), + }}, + {typeid(TimeZone), + { + X(TimeZone, Auto), X(TimeZone, Default), X(TimeZone, CET), + X(TimeZone, CST6CDT), X(TimeZone, Cuba), X(TimeZone, EET), + X(TimeZone, Egypt), X(TimeZone, Eire), X(TimeZone, EST5EDT), + X(TimeZone, GB), X(TimeZone, GBEire), X(TimeZone, GMT), + X(TimeZone, GMTPlusZero), X(TimeZone, GMTMinusZero), X(TimeZone, GMTZero), + X(TimeZone, Greenwich), X(TimeZone, Hongkong), X(TimeZone, HST), + X(TimeZone, Iceland), X(TimeZone, Iran), X(TimeZone, Israel), + X(TimeZone, Jamaica), X(TimeZone, Japan), X(TimeZone, Kwajalein), + X(TimeZone, Libya), X(TimeZone, MET), X(TimeZone, MST), + X(TimeZone, MST7MDT), X(TimeZone, Navajo), X(TimeZone, NZ), + X(TimeZone, NZCHAT), X(TimeZone, Poland), X(TimeZone, Portugal), + X(TimeZone, PRC), X(TimeZone, ROC), X(TimeZone, ROK), + X(TimeZone, Singapore), X(TimeZone, Turkey), X(TimeZone, UCT), + X(TimeZone, Universal), X(TimeZone, UTC), X(TimeZone, W_SU), + X(TimeZone, WET), X(TimeZone, Zulu), + }}, + {typeid(AnisotropyMode), + { + X(AnisotropyMode, Automatic), + X(AnisotropyMode, Default), + X(AnisotropyMode, X2), + X(AnisotropyMode, X4), + X(AnisotropyMode, X8), + X(AnisotropyMode, X16), + }}, + {typeid(AstcDecodeMode), + { + X(AstcDecodeMode, Cpu), + X(AstcDecodeMode, Gpu), + X(AstcDecodeMode, CpuAsynchronous), + }}, + {typeid(AstcRecompression), + { + X(AstcRecompression, Uncompressed), + X(AstcRecompression, Bc1), + X(AstcRecompression, Bc3), + }}, + {typeid(VSyncMode), + { + X(VSyncMode, Immediate), + X(VSyncMode, Mailbox), + X(VSyncMode, Fifo), + X(VSyncMode, FifoRelaxed), + }}, + {typeid(RendererBackend), + { + X(RendererBackend, OpenGL), + X(RendererBackend, Vulkan), + X(RendererBackend, Null), + }}, + {typeid(ShaderBackend), + { + X(ShaderBackend, Glsl), + X(ShaderBackend, Glasm), + X(ShaderBackend, SpirV), + }}, + {typeid(GpuAccuracy), + { + X(GpuAccuracy, Normal), + X(GpuAccuracy, High), + X(GpuAccuracy, Extreme), + }}, + {typeid(CpuAccuracy), + { + X(CpuAccuracy, Auto), + X(CpuAccuracy, Accurate), + X(CpuAccuracy, Unsafe), + X(CpuAccuracy, Paranoid), + }}, + {typeid(FullscreenMode), + { + X(FullscreenMode, Borderless), + X(FullscreenMode, Exclusive), + }}, + {typeid(NvdecEmulation), + { + X(NvdecEmulation, Off), + X(NvdecEmulation, Cpu), + X(NvdecEmulation, Gpu), + }}, + {typeid(ResolutionSetup), + { + X(ResolutionSetup, Res1_2X), + X(ResolutionSetup, Res3_4X), + X(ResolutionSetup, Res1X), + X(ResolutionSetup, Res3_2X), + X(ResolutionSetup, Res2X), + X(ResolutionSetup, Res3X), + X(ResolutionSetup, Res4X), + X(ResolutionSetup, Res5X), + X(ResolutionSetup, Res6X), + X(ResolutionSetup, Res7X), + X(ResolutionSetup, Res8X), + }}, + {typeid(ScalingFilter), + { + X(ScalingFilter, NearestNeighbor), + X(ScalingFilter, Bilinear), + X(ScalingFilter, Bicubic), + X(ScalingFilter, Gaussian), + X(ScalingFilter, ScaleForce), + X(ScalingFilter, Fsr), + }}, + {typeid(AntiAliasing), + { + X(AntiAliasing, None), + X(AntiAliasing, Fxaa), + X(AntiAliasing, Smaa), + }}, + {typeid(AspectRatio), + { + X(AspectRatio, R16_9), + X(AspectRatio, R4_3), + X(AspectRatio, R21_9), + X(AspectRatio, R16_10), + X(AspectRatio, Stretch), }}}; -static std::string empty_string{}; +#undef X + +static std::string invalid_string{"(invalid setting)"}; template const std::string& CanonicalizeEnum(Type id) {