mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Merge #3069
3069: Recreate score hud when any score changed r=Learath2 a=def- Fixes problem with too long strings because we display the score centered Thanks to ExP for report: ![screenshot_2020-10-11_17-18-45](https://user-images.githubusercontent.com/2335377/95682429-7a2b3380-0be5-11eb-8186-c1dbf922b960.png) Fixed: ![screenshot-20201011@171419](https://user-images.githubusercontent.com/2335377/95682443-88794f80-0be5-11eb-9d10-79ea5df785c0.png) ![screenshot-20201011@171423](https://user-images.githubusercontent.com/2335377/95682441-857e5f00-0be5-11eb-805a-8312e43f5ba1.png) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
1d961a262f
|
@ -357,12 +357,12 @@ void CHud::RenderScoreHud()
|
||||||
aScore[t][0] = 0;
|
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;
|
bool RecreateRect = ForceScoreInfoInit;
|
||||||
for(int t = 0; t < 2; t++)
|
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);
|
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));
|
mem_copy(m_aScoreInfo[t].m_aScoreText, aScore[t], sizeof(m_aScoreInfo[t].m_aScoreText));
|
||||||
|
@ -414,13 +414,13 @@ void CHud::RenderScoreHud()
|
||||||
if(m_aScoreInfo[t].m_RoundRectQuadContainerIndex != -1)
|
if(m_aScoreInfo[t].m_RoundRectQuadContainerIndex != -1)
|
||||||
Graphics()->RenderQuadContainer(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)
|
if(m_aScoreInfo[t].m_TextScoreContainerIndex != -1)
|
||||||
TextRender()->DeleteTextContainer(m_aScoreInfo[t].m_TextScoreContainerIndex);
|
TextRender()->DeleteTextContainer(m_aScoreInfo[t].m_TextScoreContainerIndex);
|
||||||
|
|
||||||
CTextCursor Cursor;
|
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;
|
Cursor.m_LineWidth = -1;
|
||||||
m_aScoreInfo[t].m_TextScoreContainerIndex = TextRender()->CreateTextContainer(&Cursor, aScore[t]);
|
m_aScoreInfo[t].m_TextScoreContainerIndex = TextRender()->CreateTextContainer(&Cursor, aScore[t]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue