Skip to content

Commit

Permalink
Reset text containers on language change
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Robyt3 committed Aug 14, 2023
1 parent b935588 commit f90e908
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/engine/client/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2341,8 +2341,6 @@ class CTextRender : public IEngineTextRender
}

dbg_assert(!HasNonEmptyTextContainer, "text container was not empty");

m_pGlyphMap->Clear();
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/game/client/gameclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 0 additions & 5 deletions src/game/client/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ void CUI::OnWindowResize()
OnElementsReset();
}

void CUI::OnLanguageChange()
{
OnElementsReset();
}

void CUI::OnCursorMove(float X, float Y)
{
if(!CheckMouseLock())
Expand Down
1 change: 0 additions & 1 deletion src/game/client/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ class CUI
void AddUIElement(CUIElement *pElement);
void OnElementsReset();
void OnWindowResize();
void OnLanguageChange();
void OnCursorMove(float X, float Y);

void SetEnabled(bool Enabled) { m_Enabled = Enabled; }
Expand Down

0 comments on commit f90e908

Please sign in to comment.