From dd22ec6fa7e15ff43c346f0dce7cb10c6bda7c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 5 Dec 2022 12:07:07 +0100 Subject: [PATCH] Show the name of the chosen language on the choice button. Looks weird not to. --- Core/Config.cpp | 4 ++-- UI/GameSettingsScreen.cpp | 12 +++++++++++- UI/MiscScreens.h | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 24497fc89a..ebc731cbd2 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1294,8 +1294,8 @@ void Config::LoadLangValuesMapping() { langCodeMapping["CHINESE_TRADITIONAL"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL; langCodeMapping["CHINESE_SIMPLIFIED"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED; - Section *langRegionNames = mapping.GetOrCreateSection("LangRegionNames"); - Section *systemLanguage = mapping.GetOrCreateSection("SystemLanguage"); + const Section *langRegionNames = mapping.GetOrCreateSection("LangRegionNames"); + const Section *systemLanguage = mapping.GetOrCreateSection("SystemLanguage"); for (size_t i = 0; i < keys.size(); i++) { std::string langName; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 1219c43236..15d1987f02 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -846,7 +846,17 @@ void GameSettingsScreen::CreateViews() { LinearLayout *systemSettings = AddTab("GameSettingsSystem", ms->T("System")); systemSettings->Add(new ItemHeader(sy->T("UI"))); - systemSettings->Add(new Choice(sy->T("Language")))->OnClick.Add([&](UI::EventParams &e) { + + auto langCodeToName = [](const char *value) -> std::string { + auto &mapping = g_Config.GetLangValuesMapping(); + auto iter = mapping.find(value); + if (iter != mapping.end()) { + return iter->second.first; + } + return value; + }; + + systemSettings->Add(new ChoiceWithValueDisplay(&g_Config.sLanguageIni, sy->T("Language"), langCodeToName))->OnClick.Add([&](UI::EventParams &e) { auto sy = GetI18NCategory("System"); auto langScreen = new NewLanguageScreen(sy->T("Language")); langScreen->OnChoice.Add([&](UI::EventParams &e) { diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 6166fdb94a..f0eca81ff5 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -106,7 +106,6 @@ public: private: void OnCompleted(DialogResult result) override; bool ShowButtons() const override { return true; } - std::map titleCodeMapping; std::vector langs_; };