From c7cea0a37fadd83a959099ae590b29516a00b5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sat, 15 Apr 2023 10:42:05 +0200 Subject: [PATCH] Fix incorrect chat background rect width calculation The calculation of `m_LongestLineWidth` was adjusted in bf1e757581e7b37c7de493ae48b074ccb6a9eff5 so it's really the width of the line and not the X position of the end of the line. This caused the background rects of chat messages to be rendered incorrectly. --- src/game/client/components/chat.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index d4d26f064..0b0e11f18 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -1021,11 +1021,11 @@ void CChat::OnPrepareLines() } CTextCursor AppendCursor = Cursor; - + AppendCursor.m_LongestLineWidth = 0.0f; if(!IsScoreBoardOpen && !g_Config.m_ClChatOld) { AppendCursor.m_StartX = Cursor.m_X; - AppendCursor.m_LineWidth -= (Cursor.m_LongestLineWidth - Cursor.m_StartX); + AppendCursor.m_LineWidth -= Cursor.m_LongestLineWidth; } TextRender()->TextEx(&AppendCursor, m_aLines[r].m_aText, -1); @@ -1113,10 +1113,13 @@ void CChat::OnPrepareLines() TextRender()->TextColor(Color); CTextCursor AppendCursor = Cursor; + AppendCursor.m_LongestLineWidth = 0.0f; + float OriginalWidth = 0.0f; if(!IsScoreBoardOpen && !g_Config.m_ClChatOld) { - AppendCursor.m_LineWidth -= (Cursor.m_LongestLineWidth - Cursor.m_StartX); AppendCursor.m_StartX = Cursor.m_X; + AppendCursor.m_LineWidth -= Cursor.m_LongestLineWidth; + OriginalWidth = Cursor.m_LongestLineWidth; } TextRender()->CreateOrAppendTextContainer(m_aLines[r].m_TextContainerIndex, &AppendCursor, m_aLines[r].m_aText); @@ -1125,7 +1128,7 @@ void CChat::OnPrepareLines() { float Height = m_aLines[r].m_aYOffset[OffsetType]; Graphics()->SetColor(1, 1, 1, 1); - m_aLines[r].m_QuadContainerIndex = Graphics()->CreateRectQuadContainer(Begin, y, (AppendCursor.m_LongestLineWidth - TextBegin) + RealMsgPaddingX * 1.5f, Height, MESSAGE_ROUNDING, IGraphics::CORNER_ALL); + m_aLines[r].m_QuadContainerIndex = Graphics()->CreateRectQuadContainer(Begin, y, OriginalWidth + AppendCursor.m_LongestLineWidth + RealMsgPaddingX * 1.5f, Height, MESSAGE_ROUNDING, IGraphics::CORNER_ALL); } TextRender()->SetRenderFlags(CurRenderFlags);