From 2a06b3ccb5bd5ae4729da6cc1a6786ce679cc29b Mon Sep 17 00:00:00 2001 From: def Date: Sun, 11 Oct 2020 17:14:32 +0200 Subject: [PATCH 1/2] Recreate score hud when any score changed Fixes problem with too long strings because we display the score centered Thanks to ExP for report --- src/game/client/components/hud.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 77c834564..cd3de0004 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -357,12 +357,12 @@ void CHud::RenderScoreHud() aScore[t][0] = 0; } - bool RecreateScore[2] = {str_comp(aScore[0], m_aScoreInfo[0].m_aScoreText) != 0, str_comp(aScore[1], m_aScoreInfo[1].m_aScoreText) != 0}; + bool RecreateScores = str_comp(aScore[0], m_aScoreInfo[0].m_aScoreText) != 0 || str_comp(aScore[1], m_aScoreInfo[1].m_aScoreText) != 0; bool RecreateRect = ForceScoreInfoInit; for(int t = 0; t < 2; t++) { - if(RecreateScore[t]) + if(RecreateScores) { m_aScoreInfo[t].m_ScoreTextWidth = TextRender()->TextWidth(0, 14.0f, aScore[t], -1, -1.0f); mem_copy(m_aScoreInfo[t].m_aScoreText, aScore[t], sizeof(m_aScoreInfo[t].m_aScoreText)); @@ -414,7 +414,7 @@ void CHud::RenderScoreHud() if(m_aScoreInfo[t].m_RoundRectQuadContainerIndex != -1) Graphics()->RenderQuadContainer(m_aScoreInfo[t].m_RoundRectQuadContainerIndex, -1); - if(RecreateScore[t]) + if(RecreateScores) { if(m_aScoreInfo[t].m_TextScoreContainerIndex != -1) TextRender()->DeleteTextContainer(m_aScoreInfo[t].m_TextScoreContainerIndex); From d0005d3866ccc03e89e6fbda5b006ed145f5bca9 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 11 Oct 2020 17:27:55 +0200 Subject: [PATCH 2/2] Right-align hud scores --- src/game/client/components/hud.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index cd3de0004..4bec05fb4 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -420,7 +420,7 @@ void CHud::RenderScoreHud() TextRender()->DeleteTextContainer(m_aScoreInfo[t].m_TextScoreContainerIndex); CTextCursor Cursor; - TextRender()->SetCursor(&Cursor, Whole - ScoreWidthMax + (ScoreWidthMax - m_aScoreInfo[t].m_ScoreTextWidth) / 2 - Split, StartY + t * 20 + (18.f - 14.f) / 2.f, 14.0f, TEXTFLAG_RENDER); + TextRender()->SetCursor(&Cursor, Whole - ScoreWidthMax + (ScoreWidthMax - m_aScoreInfo[t].m_ScoreTextWidth) - Split, StartY + t * 20 + (18.f - 14.f) / 2.f, 14.0f, TEXTFLAG_RENDER); Cursor.m_LineWidth = -1; m_aScoreInfo[t].m_TextScoreContainerIndex = TextRender()->CreateTextContainer(&Cursor, aScore[t]); }