From 233aea0110dcc51e56baf59bb15e61d8760f5121 Mon Sep 17 00:00:00 2001 From: Zero <128979226+lux-zero-161@users.noreply.github.com> Date: Fri, 12 Jun 2026 15:46:22 +0200 Subject: [PATCH] Revert "Refresh localized text on gainFocus for RmlUI menus" This reverts commit 6399a965d60e777f4f96b58e313e1936f22c3575. --- .../Common/UI/UIScene_HelpAndOptionsMenu.cpp | 36 +----------- .../Common/UI/UIScene_HelpAndOptionsMenu.h | 2 - .../Common/UI/UIScene_PauseMenu.cpp | 57 ++----------------- .../Common/UI/UIScene_PauseMenu.h | 3 - .../Common/UI/UIScene_SettingsMenu.cpp | 36 ------------ .../Common/UI/UIScene_SettingsMenu.h | 2 - 6 files changed, 7 insertions(+), 129 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp index 64392f0b..e2f0f85a 100644 --- a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.cpp @@ -20,18 +20,6 @@ #pragma pop_macro("GetNextSibling") #pragma pop_macro("byte") -static std::string WStringToUTF8(LPCWSTR wstr) -{ - if (!wstr) return {}; - size_t wlen = wcslen(wstr); - if (wlen == 0) return {}; - int len = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)wlen, nullptr, 0, nullptr, nullptr); - if (len <= 0) return {}; - std::string result(len, '\0'); - WideCharToMultiByte(CP_UTF8, 0, wstr, (int)wlen, &result[0], len, nullptr, nullptr); - return result; -} - UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) , m_document(nullptr) @@ -48,7 +36,7 @@ UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void *initData, { m_document->Show(); - UpdateLocalizedText(); + bool bNotInGame = (Minecraft::GetInstance()->level == nullptr); // Change Skin: hide if not full version if (!ProfileManager.IsFullVersion()) @@ -72,8 +60,7 @@ UIScene_HelpAndOptionsMenu::UIScene_HelpAndOptionsMenu(int iPad, void *initData, m_document->GetElementById("credits")->AddEventListener(Rml::EventId::Click, this); // Focus first visible button - auto* elFirst = m_document->GetElementById("change_skin"); - if (elFirst) elFirst->Focus(); + m_document->GetElementById("change_skin")->Focus(); } else { @@ -213,27 +200,8 @@ void UIScene_HelpAndOptionsMenu::updateTooltips() { } -void UIScene_HelpAndOptionsMenu::UpdateLocalizedText() -{ - if (!m_document) - return; - - auto setText = [this](const Rml::String& id, int ids) { - auto* el = m_document->GetElementById(id); - if (el) el->SetInnerRML(WStringToUTF8(app.GetString(ids))); - }; - - setText("change_skin", IDS_CHANGE_SKIN); - setText("how_to_play", IDS_HOW_TO_PLAY); - setText("controls", IDS_CONTROLS); - setText("settings", IDS_SETTINGS); - setText("credits", IDS_CREDITS); -} - void UIScene_HelpAndOptionsMenu::updateComponents() { - UpdateLocalizedText(); - bool bNotInGame = (Minecraft::GetInstance()->level == nullptr); if (bNotInGame) { diff --git a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.h b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.h index bb3076b4..a8c720d4 100644 --- a/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_HelpAndOptionsMenu.h @@ -48,8 +48,6 @@ protected: void OnSettings(); void OnCredits(); - void UpdateLocalizedText(); - private: Rml::ElementDocument* m_document; }; diff --git a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp index e038fe3f..e15c9217 100644 --- a/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_PauseMenu.cpp @@ -21,18 +21,6 @@ #pragma pop_macro("GetNextSibling") #pragma pop_macro("byte") -static std::string WStringToUTF8(LPCWSTR wstr) -{ - if (!wstr) return {}; - size_t wlen = wcslen(wstr); - if (wlen == 0) return {}; - int len = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)wlen, nullptr, 0, nullptr, nullptr); - if (len <= 0) return {}; - std::string result(len, '\0'); - WideCharToMultiByte(CP_UTF8, 0, wstr, (int)wlen, &result[0], len, nullptr, nullptr); - return result; -} - UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) , m_document(nullptr) @@ -54,9 +42,6 @@ UIScene_PauseMenu::UIScene_PauseMenu(int iPad, void *initData, UILayer *parentLa m_document->Show(); app.DebugPrintf("[RmlPauseMenu] Document shown, visible=%d, context docs=%d\n", m_document->IsVisible(), ctx->GetNumDocuments()); - - UpdateLocalizedText(); - m_document->GetElementById("resume")->AddEventListener(Rml::EventId::Click, this); m_document->GetElementById("help_options")->AddEventListener(Rml::EventId::Click, this); m_document->GetElementById("achievements")->AddEventListener(Rml::EventId::Click, this); @@ -263,32 +248,6 @@ void UIScene_PauseMenu::ProcessEvent(Rml::Event& event) } } -void UIScene_PauseMenu::UpdateLocalizedText() -{ - if (!m_document) - return; - - auto setText = [this](const Rml::String& id, int ids) { - auto* el = m_document->GetElementById(id); - if (el) el->SetInnerRML(WStringToUTF8(app.GetString(ids))); - }; - - setText("resume", IDS_RESUME_GAME); - setText("help_options", IDS_HELP_AND_OPTIONS); - setText("achievements", IDS_ACHIEVEMENTS); - setText("save_game", IDS_SAVE_GAME); - setText("exit_game", IDS_EXIT_GAME); - setText("exit_save", IDS_EXIT_GAME_SAVE); - setText("exit_nosave", IDS_EXIT_GAME_NO_SAVE); - setText("exit_cancel", IDS_CANCEL); - setText("save_cancel", IDS_CANCEL); -} - -void UIScene_PauseMenu::updateComponents() -{ - UpdateLocalizedText(); -} - void UIScene_PauseMenu::ShowScene(bool show) { if (m_document) @@ -351,7 +310,6 @@ void UIScene_PauseMenu::ShowSaveDialog(bool show) if (saveText) saveText->SetInnerRML("Overwrite existing save?"); } - m_document->GetElementById("save_cancel")->SetInnerRML(WStringToUTF8(app.GetString(IDS_CANCEL))); m_document->GetElementById("save_cancel")->Focus(); m_bSaveDialog = true; } @@ -429,23 +387,19 @@ void UIScene_PauseMenu::ShowExitDialog(bool show) auto* exitCancel = m_document->GetElementById("exit_cancel"); auto* exitText = m_document->GetElementById("exit_text"); - if (exitSave) exitSave->SetInnerRML(WStringToUTF8(app.GetString(IDS_EXIT_GAME_SAVE))); - if (exitCancel) exitCancel->SetInnerRML(WStringToUTF8(app.GetString(IDS_CANCEL))); - if (ProfileManager.IsFullVersion() && m_iPad == ProfileManager.GetPrimaryPad()) { // Full version primary pad: show Save & Exit + Exit without Saving + Cancel if (exitSave) exitSave->SetProperty("display", "inline-block"); if (exitNosave) exitNosave->SetProperty("display", "inline-block"); - if (exitNosave) exitNosave->SetInnerRML(WStringToUTF8(app.GetString(IDS_EXIT_GAME_NO_SAVE))); if (g_NetworkManager.GetPlayerCount() > 1) { - if (exitText) exitText->SetInnerRML(WStringToUTF8(app.GetString(IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE))); + if (exitText) exitText->SetInnerRML("Exit Game (disconnect other players)?"); } else { - if (exitText) exitText->SetInnerRML(WStringToUTF8(app.GetString(IDS_CONFIRM_EXIT_GAME))); + if (exitText) exitText->SetInnerRML("Exit Game?"); } if (exitCancel) exitCancel->Focus(); } @@ -454,8 +408,8 @@ void UIScene_PauseMenu::ShowExitDialog(bool show) // Trial version: simple OK/Cancel, "progress will be lost" if (exitSave) exitSave->SetProperty("display", "none"); if (exitNosave) exitNosave->SetProperty("display", "inline-block"); - if (exitNosave) exitNosave->SetInnerRML(WStringToUTF8(app.GetString(IDS_YES))); - if (exitText) exitText->SetInnerRML(WStringToUTF8(app.GetString(IDS_CONFIRM_EXIT_GAME_PROGRESS_LOST))); + if (exitNosave) exitNosave->SetInnerRML("Yes"); + if (exitText) exitText->SetInnerRML("Exit Game (progress will be lost)?"); if (exitCancel) exitCancel->Focus(); } @@ -470,8 +424,7 @@ void UIScene_PauseMenu::ShowExitDialog(bool show) auto* exitSave = m_document->GetElementById("exit_save"); auto* exitNosave = m_document->GetElementById("exit_nosave"); if (exitSave) exitSave->SetProperty("display", "inline-block"); - if (exitSave) exitSave->SetInnerRML(WStringToUTF8(app.GetString(IDS_EXIT_GAME_SAVE))); - if (exitNosave) exitNosave->SetInnerRML(WStringToUTF8(app.GetString(IDS_EXIT_GAME_NO_SAVE))); + if (exitNosave) exitNosave->SetInnerRML("Exit without Saving"); if (exitNosave) exitNosave->SetProperty("display", "inline-block"); m_document->GetElementById("exit_game")->Focus(); diff --git a/Minecraft.Client/Common/UI/UIScene_PauseMenu.h b/Minecraft.Client/Common/UI/UIScene_PauseMenu.h index 96413ecd..9d67f593 100644 --- a/Minecraft.Client/Common/UI/UIScene_PauseMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_PauseMenu.h @@ -38,7 +38,6 @@ protected: virtual wstring getMoviePath() { return L""; } virtual void handleLoseFocus() override; - virtual void updateComponents() override; void ShowScene(bool show) override; void SetIgnoreInput(bool ignoreInput) override { m_bIgnoreInput = ignoreInput; } @@ -59,8 +58,6 @@ protected: void ShowExitDialog(bool show); void ShowSaveDialog(bool show); - void UpdateLocalizedText(); - private: Rml::ElementDocument* m_document; bool m_bIgnoreInput; diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp index 0f1205b8..6af780cc 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.cpp @@ -20,18 +20,6 @@ #pragma pop_macro("GetNextSibling") #pragma pop_macro("byte") -static std::string WStringToUTF8(LPCWSTR wstr) -{ - if (!wstr) return {}; - size_t wlen = wcslen(wstr); - if (wlen == 0) return {}; - int len = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)wlen, nullptr, 0, nullptr, nullptr); - if (len <= 0) return {}; - std::string result(len, '\0'); - WideCharToMultiByte(CP_UTF8, 0, wstr, (int)wlen, &result[0], len, nullptr, nullptr); - return result; -} - UIScene_SettingsMenu::UIScene_SettingsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) , m_document(nullptr) @@ -61,8 +49,6 @@ UIScene_SettingsMenu::UIScene_SettingsMenu(int iPad, void *initData, UILayer *pa if (elGraphics) elGraphics->SetProperty("display", "none"); } - UpdateLocalizedText(); - // Register button click listeners m_document->GetElementById("options")->AddEventListener(Rml::EventId::Click, this); m_document->GetElementById("audio")->AddEventListener(Rml::EventId::Click, this); @@ -132,30 +118,8 @@ void UIScene_SettingsMenu::updateTooltips() { } -void UIScene_SettingsMenu::UpdateLocalizedText() -{ - if (!m_document) - return; - - auto setText = [this](const Rml::String& id, int ids) { - auto* el = m_document->GetElementById(id); - if (el) el->SetInnerRML(WStringToUTF8(app.GetString(ids))); - }; - - setText("options", IDS_OPTIONS); - setText("audio", IDS_AUDIO); - setText("controls", IDS_CONTROLS); - setText("graphics", IDS_GRAPHICS); - setText("ui", IDS_USER_INTERFACE); - setText("reset_defaults", IDS_RESET_TO_DEFAULTS); - setText("confirm_yes", IDS_YES); - setText("confirm_no", IDS_NO); -} - void UIScene_SettingsMenu::updateComponents() { - UpdateLocalizedText(); - bool bNotInGame = (Minecraft::GetInstance()->level == nullptr); if (bNotInGame) diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.h b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.h index 15a4116b..f63ebb32 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_SettingsMenu.h @@ -53,8 +53,6 @@ protected: void ShowConfirmDialog(bool show); - void UpdateLocalizedText(); - private: Rml::ElementDocument* m_document; bool m_bConfirmDialog;