From f90e908c9d4e336048728c296457249084f96628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Mon, 14 Aug 2023 18:52:45 +0200 Subject: [PATCH] Reset text containers on language change Fix text containers rendering broken text after the language is changed, as this cleared the glyph atlas without clearing the references to the glyph positions in the text containers. Now `OnWindowResize` is also called on language change to reset all text containers. However, the glyph atlas is not cleared on normal window resize anymore, because this seems to be unnecessary. --- src/engine/client/text.cpp | 2 -- src/game/client/gameclient.cpp | 3 ++- src/game/client/ui.cpp | 5 ----- src/game/client/ui.h | 1 - 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index 0f870e83f..9360bc761 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -2341,8 +2341,6 @@ public: } dbg_assert(!HasNonEmptyTextContainer, "text container was not empty"); - - m_pGlyphMap->Clear(); } }; diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index aeead0a24..19ef1ca3a 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -990,7 +990,8 @@ void CGameClient::HandleLanguageChanged() g_Localization.Load(g_Config.m_ClLanguagefile, Storage(), Console()); TextRender()->SetFontLanguageVariant(g_Config.m_ClLanguagefile); - UI()->OnLanguageChange(); + // Clear all text containers + OnWindowResize(); } void CGameClient::RenderShutdownMessage() diff --git a/src/game/client/ui.cpp b/src/game/client/ui.cpp index 1fafd7de7..14dc6a752 100644 --- a/src/game/client/ui.cpp +++ b/src/game/client/ui.cpp @@ -174,11 +174,6 @@ void CUI::OnWindowResize() OnElementsReset(); } -void CUI::OnLanguageChange() -{ - OnElementsReset(); -} - void CUI::OnCursorMove(float X, float Y) { if(!CheckMouseLock()) diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 1313cf951..5a5b51bcb 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -390,7 +390,6 @@ public: void AddUIElement(CUIElement *pElement); void OnElementsReset(); void OnWindowResize(); - void OnLanguageChange(); void OnCursorMove(float X, float Y); void SetEnabled(bool Enabled) { m_Enabled = Enabled; }