1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2025-12-10 06:52:05 +01:00

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.
This commit is contained in:
Peter Nelson
2025-11-27 22:47:07 +00:00
committed by Peter Nelson
parent 91a12a3928
commit 2675295675

View File

@@ -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<NWidgetCore>(widget)->GetString());
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.