Fix localisation not updating in real-time for button guides (#322)

This commit is contained in:
Hyper 2025-02-08 20:17:53 +00:00 committed by GitHub
parent fff96a8528
commit fcd1673cfc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 17 deletions

View file

@ -163,7 +163,7 @@ PPC_FUNC(sub_824B0930)
if (*SWA::SGlobals::ms_IsRenderHud && pHudPause->m_IsShown && !pHudPause->m_Submenu && pHudPause->m_Transition == SWA::eTransitionType_Undefined)
{
ButtonGuide::Open(Button(Localise("Achievements_Name"), EButtonIcon::Back, EButtonAlignment::Left, EFontQuality::Low));
ButtonGuide::Open(Button("Achievements_Name", EButtonIcon::Back, EButtonAlignment::Left, EFontQuality::Low));
g_isClosed = false;
}
else if (!g_isClosed)

View file

@ -778,7 +778,7 @@ void AchievementMenu::Open()
return std::get<1>(a) > std::get<1>(b);
});
ButtonGuide::Open(Button(Localise("Common_Back"), EButtonIcon::B));
ButtonGuide::Open(Button("Common_Back", EButtonIcon::B));
ResetSelection();
Game_PlaySound("sys_actstg_pausewinopen");

View file

@ -260,9 +260,10 @@ void ButtonGuide::Draw()
if (btn.Visibility && !*btn.Visibility)
continue;
auto str = Localise(btn.Name.c_str()).c_str();
auto iconWidth = Scale(g_iconWidths[btn.Icon]);
auto iconHeight = Scale(g_iconHeights[btn.Icon]);
auto textSize = g_fntNewRodin->CalcTextSizeA(fontSize, FLT_MAX, 0, btn.Name.c_str());
auto textSize = g_fntNewRodin->CalcTextSizeA(fontSize, FLT_MAX, 0, str);
if (i > 0)
offsetLeft += textSize.x + iconWidth + textMarginX;
@ -270,7 +271,7 @@ void ButtonGuide::Draw()
ImVec2 iconMin = { regionMin.x + offsetLeft - iconWidth - iconMarginX, regionMin.y };
ImVec2 iconMax = { regionMin.x + offsetLeft - iconMarginX, regionMin.y + iconHeight };
DrawGuide(&offsetLeft, regionMin, regionMax, btn.Icon, btn.Alignment, iconMin, iconMax, btn.FontQuality, textSize, fontSize, btn.Name.c_str());
DrawGuide(&offsetLeft, regionMin, regionMax, btn.Icon, btn.Alignment, iconMin, iconMax, btn.FontQuality, textSize, fontSize, str);
}
// Draw right aligned icons.
@ -284,9 +285,10 @@ void ButtonGuide::Draw()
if (btn.Visibility && !*btn.Visibility)
continue;
auto str = Localise(btn.Name.c_str()).c_str();
auto iconWidth = Scale(g_iconWidths[btn.Icon]);
auto iconHeight = Scale(g_iconHeights[btn.Icon]);
auto textSize = g_fntNewRodin->CalcTextSizeA(fontSize, FLT_MAX, 0, btn.Name.c_str());
auto textSize = g_fntNewRodin->CalcTextSizeA(fontSize, FLT_MAX, 0, str);
if (i < g_buttons.size() - 1)
offsetRight += textSize.x + iconWidth + textMarginX;
@ -294,7 +296,7 @@ void ButtonGuide::Draw()
ImVec2 iconMin = { regionMax.x - offsetRight - iconWidth - iconMarginX, regionMin.y };
ImVec2 iconMax = { regionMax.x - offsetRight - iconMarginX, regionMin.y + iconHeight };
DrawGuide(&offsetRight, regionMin, regionMax, btn.Icon, btn.Alignment, iconMin, iconMax, btn.FontQuality, textSize, fontSize, btn.Name.c_str());
DrawGuide(&offsetRight, regionMin, regionMax, btn.Icon, btn.Alignment, iconMin, iconMax, btn.FontQuality, textSize, fontSize, str);
}
}

View file

@ -863,7 +863,7 @@ static void DrawDescriptionContainer()
if (g_currentPage == WizardPage::InstallSucceeded && textAlpha >= 1.0)
{
ButtonGuide::Open(Button(Localise("Common_Select"), selectIcon));
ButtonGuide::Open(Button("Common_Select", selectIcon));
}
else if (g_currentPage != WizardPage::Installing && textAlpha >= 1.0)
{
@ -875,15 +875,15 @@ static void DrawDescriptionContainer()
std::array<Button, 2> buttons =
{
Button(Localise("Common_Select"), selectIcon),
Button(Localise(backKey), backIcon)
Button("Common_Select", selectIcon),
Button(backKey, backIcon)
};
ButtonGuide::Open(buttons);
}
else if (g_currentPage == WizardPage::Installing)
{
ButtonGuide::Open(Button(Localise("Common_Cancel"), backIcon));
ButtonGuide::Open(Button("Common_Cancel", backIcon));
}
else
{

View file

@ -245,7 +245,7 @@ void DrawNextButtonGuide(bool isController, bool isKeyboard)
if (App::s_isInit)
icon = EButtonIcon::A;
ButtonGuide::Open(Button(Localise("Common_Next"), icon));
ButtonGuide::Open(Button("Common_Next", icon));
}
static void ResetSelection()
@ -425,8 +425,8 @@ void MessageWindow::Draw()
std::array<Button, 2> buttons =
{
Button(Localise("Common_Select"), selectIcon),
Button(Localise("Common_Back"), backIcon),
Button("Common_Select", selectIcon),
Button("Common_Back", backIcon),
};
ButtonGuide::Open(buttons);

View file

@ -1737,10 +1737,10 @@ void OptionsMenu::Open(bool isPause, SWA::EMenuType pauseMenuType)
std::array<Button, 4> buttons =
{
Button(Localise("Common_Switch"), EButtonIcon::LBRB, EButtonAlignment::Left, &g_isControlsVisible),
Button(Localise("Common_Reset"), EButtonIcon::X, &g_canReset),
Button(Localise("Common_Select"), EButtonIcon::A, &g_isControlsVisible),
Button(Localise("Common_Back"), EButtonIcon::B, &g_isControlsVisible)
Button("Common_Switch", EButtonIcon::LBRB, EButtonAlignment::Left, &g_isControlsVisible),
Button("Common_Reset", EButtonIcon::X, &g_canReset),
Button("Common_Select", EButtonIcon::A, &g_isControlsVisible),
Button("Common_Back", EButtonIcon::B, &g_isControlsVisible)
};
ButtonGuide::Open(buttons);