From ade830b30cc10d949845ef1411930f116c0a7986 Mon Sep 17 00:00:00 2001 From: Vantha Date: Sat, 9 May 2026 12:48:31 +0200 Subject: [PATCH] Fix brief text misalignment in GUI text objects The issue was introduced by 8a2a450686. It affected GUI text objects (CText) with `scrollbar` set to true; when their caption was long enough for a scrollbar to be visible and then the size changed (got bigger) so that no scrollbar was needed anymore, then for a single frame the text was completely misaligned. This happened because in `CText::Draw` the scrollbar wasn't updated yet, so the newly added `GetScrollBar(0).IsVisible()` check still returned true, even though it wouldn't end up being rendered anyway -- it was updated in `IGUITextOwner::DrawText` eventually. This happened to the tutorial info panel in the starting economy walkthrough, for example. Note: in that case the scrollbar wasn't ever drawn, but it was temporarily set visible within a frame by the JS object resizing logic. --- source/gui/ObjectTypes/CText.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/gui/ObjectTypes/CText.cpp b/source/gui/ObjectTypes/CText.cpp index 41ece6474c..ff9d448b9b 100644 --- a/source/gui/ObjectTypes/CText.cpp +++ b/source/gui/ObjectTypes/CText.cpp @@ -181,6 +181,9 @@ void CText::Draw(CCanvas2D& canvas) { m_pGUI.DrawSprite(m_Sprite, canvas, GetActualSize(), m_VisibleArea); + // Ensure the scrollbars are up-to-date. + UpdateText(); + float scroll = 0.f; if (m_ScrollBar) scroll = GetScrollBar(0).GetPos();