summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-09 22:25:12 +0000
committerrubidium <rubidium@openttd.org>2009-12-09 22:25:12 +0000
commit826fad03fb31645bcd0a53e8476e3a7d6cd4cf27 (patch)
tree5eb09c0f6884007b368a06cf5fb6df9e471fe22d /src
parent8ecf4bdd561d92152d674e48106ece8e9916ea3b (diff)
downloadopenttd-826fad03fb31645bcd0a53e8476e3a7d6cd4cf27.tar.xz
(svn r18450) -Fix [FS#3363]: initial size of the vehicle detail windows would occasionally be too small (although it could be resized)
Diffstat (limited to 'src')
-rw-r--r--src/vehicle_gui.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index be308c410..012475d21 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1353,9 +1353,25 @@ struct VehicleDetailsWindow : Window {
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
- case VLD_WIDGET_TOP_DETAILS:
+ case VLD_WIDGET_TOP_DETAILS: {
+ Dimension dim = { 0, 0 };
size->height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
- break;
+
+ for (uint i = 0; i < 4; i++) SetDParam(i, INT16_MAX);
+ static const StringID info_strings[] = {
+ STR_VEHICLE_INFO_MAX_SPEED,
+ STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED,
+ STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE,
+ STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR,
+ STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS
+ };
+ for (uint i = 0; i < lengthof(info_strings); i++) {
+ dim = maxdim(dim, GetStringBoundingBox(info_strings[i]));
+ }
+ SetDParam(0, STR_VEHICLE_INFO_AGE);
+ dim = maxdim(dim, GetStringBoundingBox(STR_VEHICLE_INFO_AGE_RUNNING_COST_YR));
+ size->width = dim.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
+ } break;
case VLD_WIDGET_MIDDLE_DETAILS: {
const Vehicle *v = Vehicle::Get(this->window_number);