From 26752956757c4855a10d78b6ce576caeefb8f9de Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 27 Nov 2025 22:47:07 +0000 Subject: [PATCH] Fix #8062: (Try to) ensure enough room for profit in vehicle group window. Width of group info panel previously relied entirely on the size of other widgets. --- src/group_gui.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 1b0dc461d0..c123176165 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -468,6 +468,22 @@ public: size.height = this->tiny_step_height; break; + case WID_GL_INFO: { + uint left_side = 0; + for (const StringID &label : {STR_GROUP_PROFIT_THIS_PERIOD, STR_GROUP_PROFIT_THIS_YEAR, STR_GROUP_PROFIT_LAST_PERIOD, STR_GROUP_PROFIT_LAST_YEAR, STR_GROUP_OCCUPANCY}) { + left_side = std::max(left_side, GetStringBoundingBox(label).width); + } + + /* Guestimate that 12 digits is reasonable*/ + uint right_side = std::max( + GetStringBoundingBox(GetString(STR_GROUP_OCCUPANCY_VALUE, GetParamMaxDigits(3))).width, + GetStringBoundingBox(GetString(STR_JUST_CURRENCY_LONG, GetParamMaxDigits(12))).width + ); + + size.width = left_side + WidgetDimensions::scaled.hsep_wide + right_side + padding.width; + break; + } + case WID_GL_SORT_BY_ORDER: { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->GetString()); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.