Revert "Refresh localized text on gainFocus for RmlUI menus"

This reverts commit 6399a965d6.
This commit is contained in:
Zero
2026-06-12 15:46:22 +02:00
parent 6399a965d6
commit 233aea0110
6 changed files with 7 additions and 129 deletions

View File

@@ -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();