From 47d870b11f86e8af43c32f762aa2eedfd51ed7b0 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Fri, 9 Jun 2023 19:52:59 -0400 Subject: [PATCH] shared_translation: Populate combobox enums with macro --- src/yuzu/configuration/shared_translation.cpp | 326 +++++++++--------- 1 file changed, 158 insertions(+), 168 deletions(-) diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index cf5d74c832..1787a35fff 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp @@ -175,207 +175,197 @@ std::unique_ptr ComboboxEnumeration(QWidget* parent) { std::make_unique(); const auto& tr = [&](const char* text) { return parent->tr(text); }; +#define PAIR(ENUM, VALUE, TRANSLATION) \ + { static_cast(Settings::ENUM::VALUE), tr(TRANSLATION) } +#define CTX_PAIR(ENUM, VALUE, TRANSLATION, CONTEXT) \ + { static_cast(Settings::ENUM::VALUE), tr(TRANSLATION, CONTEXT) } + // Intentionally skipping VSyncMode to let the UI fill that one out - translations->insert( - {typeid(Settings::AstcDecodeMode), - { - {static_cast(Settings::AstcDecodeMode::Cpu), tr("CPU")}, - {static_cast(Settings::AstcDecodeMode::Gpu), tr("GPU")}, - {static_cast(Settings::AstcDecodeMode::CpuAsynchronous), tr("CPU Asynchronous")}, - }}); - translations->insert( - {typeid(Settings::AstcRecompression), - { - {static_cast(Settings::AstcRecompression::Uncompressed), - tr("Uncompressed (Best quality)")}, - {static_cast(Settings::AstcRecompression::Bc1), tr("BC1 (Low quality)")}, - {static_cast(Settings::AstcRecompression::Bc3), tr("BC3 (Medium quality)")}, - }}); + translations->insert({typeid(Settings::AstcDecodeMode), + { + PAIR(AstcDecodeMode, Cpu, "CPU"), + PAIR(AstcDecodeMode, Gpu, "GPU"), + PAIR(AstcDecodeMode, CpuAsynchronous, "CPU Asynchronous"), + }}); + translations->insert({typeid(Settings::AstcRecompression), + { + PAIR(AstcRecompression, Uncompressed, "Uncompressed (Best quality)"), + PAIR(AstcRecompression, Bc1, "BC1 (Low quality)"), + PAIR(AstcRecompression, Bc3, "BC3 (Medium quality)"), + }}); translations->insert({typeid(Settings::RendererBackend), { #ifdef HAS_OPENGL - {static_cast(Settings::RendererBackend::OpenGL), tr("OpenGL")}, + PAIR(RendererBackend, OpenGL, "OpenGL"), #endif - {static_cast(Settings::RendererBackend::Vulkan), tr("Vulkan")}, - {static_cast(Settings::RendererBackend::Null), tr("Null")}, + PAIR(RendererBackend, Vulkan, "Vulkan"), + PAIR(RendererBackend, Null, "Null"), }}); translations->insert({typeid(Settings::ShaderBackend), { - {static_cast(Settings::ShaderBackend::Glsl), tr("GLSL")}, - {static_cast(Settings::ShaderBackend::Glasm), - tr("GLASM (Assembly Shaders, NVIDIA Only)")}, - {static_cast(Settings::ShaderBackend::SpirV), - tr("SPIR-V (Experimental, Mesa Only)")}, + PAIR(ShaderBackend, Glsl, "GLSL"), + PAIR(ShaderBackend, Glasm, "GLASM (Assembly Shaders, NVIDIA Only)"), + PAIR(ShaderBackend, SpirV, "SPIR-V (Experimental, Mesa Only)"), }}); translations->insert({typeid(Settings::GpuAccuracy), { - {static_cast(Settings::GpuAccuracy::Normal), tr("Normal")}, - {static_cast(Settings::GpuAccuracy::High), tr("High")}, - {static_cast(Settings::GpuAccuracy::Extreme), tr("Extreme")}, + PAIR(GpuAccuracy, Normal, "Normal"), + PAIR(GpuAccuracy, High, "High"), + PAIR(GpuAccuracy, Extreme, "Extreme"), }}); translations->insert({typeid(Settings::CpuAccuracy), { - {static_cast(Settings::CpuAccuracy::Auto), tr("Auto")}, - {static_cast(Settings::CpuAccuracy::Accurate), tr("Accurate")}, - {static_cast(Settings::CpuAccuracy::Unsafe), tr("Unsafe")}, - {static_cast(Settings::CpuAccuracy::Paranoid), - tr("Paranoid (disables most optimizations)")}, + PAIR(CpuAccuracy, Auto, "Auto"), + PAIR(CpuAccuracy, Accurate, "Accurate"), + PAIR(CpuAccuracy, Unsafe, "Unsafe"), + PAIR(CpuAccuracy, Paranoid, "Paranoid (disables most optimizations)"), + }}); + translations->insert({typeid(Settings::FullscreenMode), + { + PAIR(FullscreenMode, Borderless, "Borderless Windowed"), + PAIR(FullscreenMode, Exclusive, "Exclusive Fullscreen"), + }}); + translations->insert({typeid(Settings::NvdecEmulation), + { + PAIR(NvdecEmulation, Off, "No Video Output"), + PAIR(NvdecEmulation, Cpu, "CPU Video Decoding"), + PAIR(NvdecEmulation, Gpu, "GPU Video Decoding (Default)"), + }}); + translations->insert({typeid(Settings::ResolutionSetup), + { + PAIR(ResolutionSetup, Res1_2X, "0.5X (360p/540p) [EXPERIMENTAL]"), + PAIR(ResolutionSetup, Res3_4X, "0.75X (540p/810p) [EXPERIMENTAL]"), + PAIR(ResolutionSetup, Res1X, "1X (720p/1080p)"), + PAIR(ResolutionSetup, Res3_2X, "1.5X (1080p/1620p) [EXPERIMENTAL]"), + PAIR(ResolutionSetup, Res2X, "2X (1440p/2160p)"), + PAIR(ResolutionSetup, Res3X, "3X (2160p/3240p)"), + PAIR(ResolutionSetup, Res4X, "4X (2880p/4320p)"), + PAIR(ResolutionSetup, Res5X, "5X (3600p/5400p)"), + PAIR(ResolutionSetup, Res6X, "6X (4320p/6480p)"), + PAIR(ResolutionSetup, Res7X, "7X (5040p/7560p)"), + PAIR(ResolutionSetup, Res8X, "8X (5760p/8640p)"), + }}); + translations->insert({typeid(Settings::ScalingFilter), + { + PAIR(ScalingFilter, NearestNeighbor, "Nearest Neighbor"), + PAIR(ScalingFilter, Bilinear, "Bilinear"), + PAIR(ScalingFilter, Bicubic, "Bicubic"), + PAIR(ScalingFilter, Gaussian, "Gaussian"), + PAIR(ScalingFilter, ScaleForce, "ScaleForce"), + PAIR(ScalingFilter, Fsr, "AMD FidelityFX™️ Super Resolution"), }}); - translations->insert( - {typeid(Settings::FullscreenMode), - { - {static_cast(Settings::FullscreenMode::Borderless), tr("Borderless Windowed")}, - {static_cast(Settings::FullscreenMode::Exclusive), tr("Exclusive Fullscreen")}, - }}); - translations->insert( - {typeid(Settings::NvdecEmulation), - { - {static_cast(Settings::NvdecEmulation::Off), tr("No Video Output")}, - {static_cast(Settings::NvdecEmulation::Cpu), tr("CPU Video Decoding")}, - {static_cast(Settings::NvdecEmulation::Gpu), tr("GPU Video Decoding (Default)")}, - }}); - translations->insert( - {typeid(Settings::ResolutionSetup), - { - {static_cast(Settings::ResolutionSetup::Res1_2X), - tr("0.5X (360p/540p) [EXPERIMENTAL]")}, - {static_cast(Settings::ResolutionSetup::Res3_4X), - tr("0.75X (540p/810p) [EXPERIMENTAL]")}, - {static_cast(Settings::ResolutionSetup::Res1X), tr("1X (720p/1080p)")}, - {static_cast(Settings::ResolutionSetup::Res3_2X), - tr("1.5X (1080p/1620p) [EXPERIMENTAL]")}, - {static_cast(Settings::ResolutionSetup::Res2X), tr("2X (1440p/2160p)")}, - {static_cast(Settings::ResolutionSetup::Res3X), tr("3X (2160p/3240p)")}, - {static_cast(Settings::ResolutionSetup::Res4X), tr("4X (2880p/4320p)")}, - {static_cast(Settings::ResolutionSetup::Res5X), tr("5X (3600p/5400p)")}, - {static_cast(Settings::ResolutionSetup::Res6X), tr("6X (4320p/6480p)")}, - {static_cast(Settings::ResolutionSetup::Res7X), tr("7X (5040p/7560p)")}, - {static_cast(Settings::ResolutionSetup::Res8X), tr("8X (5760p/8640p)")}, - }}); - translations->insert( - {typeid(Settings::ScalingFilter), - { - {static_cast(Settings::ScalingFilter::NearestNeighbor), tr("Nearest Neighbor")}, - {static_cast(Settings::ScalingFilter::Bilinear), tr("Bilinear")}, - {static_cast(Settings::ScalingFilter::Bicubic), tr("Bicubic")}, - {static_cast(Settings::ScalingFilter::Gaussian), tr("Gaussian")}, - {static_cast(Settings::ScalingFilter::ScaleForce), tr("ScaleForce")}, - {static_cast(Settings::ScalingFilter::Fsr), - tr("AMD FidelityFX™️ Super Resolution")}, - }}); translations->insert({typeid(Settings::AntiAliasing), { - {static_cast(Settings::AntiAliasing::None), tr("None")}, - {static_cast(Settings::AntiAliasing::Fxaa), tr("FXAA")}, - {static_cast(Settings::AntiAliasing::Smaa), tr("SMAA")}, + PAIR(AntiAliasing, None, "None"), + PAIR(AntiAliasing, Fxaa, "FXAA"), + PAIR(AntiAliasing, Smaa, "SMAA"), + }}); + translations->insert({typeid(Settings::AspectRatio), + { + PAIR(AspectRatio, R16_9, "Default (16:9)"), + PAIR(AspectRatio, R4_3, "Force 4:3"), + PAIR(AspectRatio, R21_9, "Force 21:9"), + PAIR(AspectRatio, R16_10, "Force 16:10"), + PAIR(AspectRatio, Stretch, "Stretch to Window"), + }}); + translations->insert({typeid(Settings::AnisotropyMode), + { + PAIR(AnisotropyMode, Automatic, "Automatic"), + PAIR(AnisotropyMode, Default, "Default"), + PAIR(AnisotropyMode, X2, "2x"), + PAIR(AnisotropyMode, X4, "4x"), + PAIR(AnisotropyMode, X8, "8x"), + PAIR(AnisotropyMode, X16, "16x"), }}); - translations->insert( - {typeid(Settings::AspectRatio), - { - {static_cast(Settings::AspectRatio::R16_9), tr("Default (16:9)")}, - {static_cast(Settings::AspectRatio::R4_3), tr("Force 4:3")}, - {static_cast(Settings::AspectRatio::R21_9), tr("Force 21:9")}, - {static_cast(Settings::AspectRatio::R16_10), tr("Force 16:10")}, - {static_cast(Settings::AspectRatio::Stretch), tr("Stretch to Window")}, - }}); - translations->insert( - {typeid(Settings::AnisotropyMode), - { - {static_cast(Settings::AnisotropyMode::Automatic), tr("Automatic")}, - {static_cast(Settings::AnisotropyMode::Default), tr("Default")}, - {static_cast(Settings::AnisotropyMode::X2), tr("2x")}, - {static_cast(Settings::AnisotropyMode::X4), tr("4x")}, - {static_cast(Settings::AnisotropyMode::X8), tr("8x")}, - {static_cast(Settings::AnisotropyMode::X16), tr("16x")}, - }}); translations->insert( {typeid(Settings::Language), { - {static_cast(Settings::Language::Japanese), tr("Japanese (日本語)")}, - {static_cast(Settings::Language::EnglishAmerican), tr("American English")}, - {static_cast(Settings::Language::French), tr("French (français)")}, - {static_cast(Settings::Language::German), tr("German (Deutsch)")}, - {static_cast(Settings::Language::Italian), tr("Italian (italiano)")}, - {static_cast(Settings::Language::Spanish), tr("Spanish (español)")}, - {static_cast(Settings::Language::Chinese), tr("Chinese")}, - {static_cast(Settings::Language::Korean), tr("Korean (한국어)")}, - {static_cast(Settings::Language::Dutch), tr("Dutch (Nederlands)")}, - {static_cast(Settings::Language::Portuguese), tr("Portuguese (português)")}, - {static_cast(Settings::Language::Russian), tr("Russian (Русский)")}, - {static_cast(Settings::Language::Taiwanese), tr("Taiwanese")}, - {static_cast(Settings::Language::EnglishBritish), tr("British English")}, - {static_cast(Settings::Language::FrenchCanadian), tr("Canadian French")}, - {static_cast(Settings::Language::SpanishLatin), tr("Latin American Spanish")}, - {static_cast(Settings::Language::ChineseSimplified), tr("Simplified Chinese")}, - {static_cast(Settings::Language::ChineseTraditional), - tr("Traditional Chinese (正體中文)")}, - {static_cast(Settings::Language::PortugueseBrazilian), - tr("Brazilian Portuguese (português do Brasil)")}, + PAIR(Language, Japanese, "Japanese (日本語)"), + PAIR(Language, EnglishAmerican, "American English"), + PAIR(Language, French, "French (français)"), + PAIR(Language, German, "German (Deutsch)"), + PAIR(Language, Italian, "Italian (italiano)"), + PAIR(Language, Spanish, "Spanish (español)"), + PAIR(Language, Chinese, "Chinese"), + PAIR(Language, Korean, "Korean (한국어)"), + PAIR(Language, Dutch, "Dutch (Nederlands)"), + PAIR(Language, Portuguese, "Portuguese (português)"), + PAIR(Language, Russian, "Russian (Русский)"), + PAIR(Language, Taiwanese, "Taiwanese"), + PAIR(Language, EnglishBritish, "British English"), + PAIR(Language, FrenchCanadian, "Canadian French"), + PAIR(Language, SpanishLatin, "Latin American Spanish"), + PAIR(Language, ChineseSimplified, "Simplified Chinese"), + PAIR(Language, ChineseTraditional, "Traditional Chinese (正體中文)"), + PAIR(Language, PortugueseBrazilian, "Brazilian Portuguese (português do Brasil)"), }}); translations->insert({typeid(Settings::Region), { - {static_cast(Settings::Region::Japan), tr("Japan")}, - {static_cast(Settings::Region::Usa), tr("USA")}, - {static_cast(Settings::Region::Europe), tr("Europe")}, - {static_cast(Settings::Region::Australia), tr("Australia")}, - {static_cast(Settings::Region::China), tr("China")}, - {static_cast(Settings::Region::Korea), tr("Korea")}, - {static_cast(Settings::Region::Taiwan), tr("Taiwan")}, + PAIR(Region, Japan, "Japan"), + PAIR(Region, Usa, "USA"), + PAIR(Region, Europe, "Europe"), + PAIR(Region, Australia, "Australia"), + PAIR(Region, China, "China"), + PAIR(Region, Korea, "Korea"), + PAIR(Region, Taiwan, "Taiwan"), }}); translations->insert({typeid(Settings::TimeZone), { - {static_cast(Settings::TimeZone::Auto), tr("Auto")}, - {static_cast(Settings::TimeZone::Default), tr("Default")}, - {static_cast(Settings::TimeZone::CET), tr("CET")}, - {static_cast(Settings::TimeZone::CST6CDT), tr("CST6CDT")}, - {static_cast(Settings::TimeZone::Cuba), tr("Cuba")}, - {static_cast(Settings::TimeZone::EET), tr("EET")}, - {static_cast(Settings::TimeZone::Egypt), tr("Egypt")}, - {static_cast(Settings::TimeZone::Eire), tr("Eire")}, - {static_cast(Settings::TimeZone::EST), tr("EST")}, - {static_cast(Settings::TimeZone::EST5EDT), tr("EST5EDT")}, - {static_cast(Settings::TimeZone::GB), tr("GB")}, - {static_cast(Settings::TimeZone::GBEire), tr("GB-Eire")}, - {static_cast(Settings::TimeZone::GMT), tr("GMT")}, - {static_cast(Settings::TimeZone::GMTPlusZero), tr("GMT+0")}, - {static_cast(Settings::TimeZone::GMTMinusZero), tr("GMT-0")}, - {static_cast(Settings::TimeZone::GMTZero), tr("GMT0")}, - {static_cast(Settings::TimeZone::Greenwich), tr("Greenwich")}, - {static_cast(Settings::TimeZone::Hongkong), tr("Hongkong")}, - {static_cast(Settings::TimeZone::HST), tr("HST")}, - {static_cast(Settings::TimeZone::Iceland), tr("Iceland")}, - {static_cast(Settings::TimeZone::Iran), tr("Iran")}, - {static_cast(Settings::TimeZone::Israel), tr("Israel")}, - {static_cast(Settings::TimeZone::Jamaica), tr("Jamaica")}, - {static_cast(Settings::TimeZone::Kwajalein), tr("Kwajalein")}, - {static_cast(Settings::TimeZone::Libya), tr("Libya")}, - {static_cast(Settings::TimeZone::MET), tr("MET")}, - {static_cast(Settings::TimeZone::MST), tr("MST")}, - {static_cast(Settings::TimeZone::MST7MDT), tr("MST7MDT")}, - {static_cast(Settings::TimeZone::Navajo), tr("Navajo")}, - {static_cast(Settings::TimeZone::NZ), tr("NZ")}, - {static_cast(Settings::TimeZone::NZCHAT), tr("NZ-CHAT")}, - {static_cast(Settings::TimeZone::Poland), tr("Poland")}, - {static_cast(Settings::TimeZone::Portugal), tr("Portugal")}, - {static_cast(Settings::TimeZone::PRC), tr("PRC")}, - {static_cast(Settings::TimeZone::PST8PDT), tr("PST8PDT")}, - {static_cast(Settings::TimeZone::ROC), tr("ROC")}, - {static_cast(Settings::TimeZone::ROK), tr("ROK")}, - {static_cast(Settings::TimeZone::Singapore), tr("Singapore")}, - {static_cast(Settings::TimeZone::Turkey), tr("Turkey")}, - {static_cast(Settings::TimeZone::UCT), tr("UCT")}, - {static_cast(Settings::TimeZone::W_SU), tr("W-SU")}, - {static_cast(Settings::TimeZone::WET), tr("WET")}, - {static_cast(Settings::TimeZone::Zulu), tr("Zulu")}, + PAIR(TimeZone, Auto, "Auto"), + PAIR(TimeZone, Default, "Default"), + PAIR(TimeZone, CET, "CET"), + PAIR(TimeZone, CST6CDT, "CST6CDT"), + PAIR(TimeZone, Cuba, "Cuba"), + PAIR(TimeZone, EET, "EET"), + PAIR(TimeZone, Egypt, "Egypt"), + PAIR(TimeZone, Eire, "Eire"), + PAIR(TimeZone, EST, "EST"), + PAIR(TimeZone, EST5EDT, "EST5EDT"), + PAIR(TimeZone, GB, "GB"), + PAIR(TimeZone, GBEire, "GB-Eire"), + PAIR(TimeZone, GMT, "GMT"), + PAIR(TimeZone, GMTPlusZero, "GMT+0"), + PAIR(TimeZone, GMTMinusZero, "GMT-0"), + PAIR(TimeZone, GMTZero, "GMT0"), + PAIR(TimeZone, Greenwich, "Greenwich"), + PAIR(TimeZone, Hongkong, "Hongkong"), + PAIR(TimeZone, HST, "HST"), + PAIR(TimeZone, Iceland, "Iceland"), + PAIR(TimeZone, Iran, "Iran"), + PAIR(TimeZone, Israel, "Israel"), + PAIR(TimeZone, Jamaica, "Jamaica"), + PAIR(TimeZone, Kwajalein, "Kwajalein"), + PAIR(TimeZone, Libya, "Libya"), + PAIR(TimeZone, MET, "MET"), + PAIR(TimeZone, MST, "MST"), + PAIR(TimeZone, MST7MDT, "MST7MDT"), + PAIR(TimeZone, Navajo, "Navajo"), + PAIR(TimeZone, NZ, "NZ"), + PAIR(TimeZone, NZCHAT, "NZ-CHAT"), + PAIR(TimeZone, Poland, "Poland"), + PAIR(TimeZone, Portugal, "Portugal"), + PAIR(TimeZone, PRC, "PRC"), + PAIR(TimeZone, PST8PDT, "PST8PDT"), + PAIR(TimeZone, ROC, "ROC"), + PAIR(TimeZone, ROK, "ROK"), + PAIR(TimeZone, Singapore, "Singapore"), + PAIR(TimeZone, Turkey, "Turkey"), + PAIR(TimeZone, UCT, "UCT"), + PAIR(TimeZone, W_SU, "W-SU"), + PAIR(TimeZone, WET, "WET"), + PAIR(TimeZone, Zulu, "Zulu"), }}); translations->insert({typeid(Settings::AudioMode), { - {static_cast(Settings::AudioMode::Mono), tr("Mono")}, - {static_cast(Settings::AudioMode::Stereo), tr("Stereo")}, - {static_cast(Settings::AudioMode::Surround), tr("Surround")}, + PAIR(AudioMode, Mono, "Mono"), + PAIR(AudioMode, Stereo, "Stereo"), + PAIR(AudioMode, Surround, "Surround"), }}); +#undef PAIR +#undef CTX_PAIR + return translations; } } // namespace ConfigurationShared