summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-10-14 11:40:38 +0000
committerrubidium <rubidium@openttd.org>2014-10-14 11:40:38 +0000
commitdeca49f4c6a2e759515d51e49ff7a9220daf002e (patch)
tree6ad710bbf6eda2d369c861a44ef22c15cf84ee0e /src
parenta72dd0480c14985d10daaa323dfd1937748f54a4 (diff)
downloadopenttd-deca49f4c6a2e759515d51e49ff7a9220daf002e.tar.xz
(svn r27014) -Fix [FS#6102]: unit number was not always fully shown in depots
Diffstat (limited to 'src')
-rw-r--r--src/depot_gui.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index b2018bd2c..feceeda93 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -231,6 +231,7 @@ struct DepotWindow : Window {
bool generate_list;
VehicleList vehicle_list;
VehicleList wagon_list;
+ uint unitnumber_digits;
uint num_columns; ///< Number of columns.
Scrollbar *hscroll; ///< Only for trains.
Scrollbar *vscroll;
@@ -244,6 +245,7 @@ struct DepotWindow : Window {
this->generate_list = true;
this->type = type;
this->num_columns = 1; // for non-trains this gets set in FinishInitNested()
+ this->unitnumber_digits = 2;
this->CreateNestedTree();
this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : NULL);
@@ -607,7 +609,8 @@ struct DepotWindow : Window {
this->count_width = 0;
}
- Dimension unumber = { GetDigitWidth() * 4, FONT_HEIGHT_NORMAL };
+ SetDParamMaxDigits(0, this->unitnumber_digits);
+ Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
this->flag_width = UnScaleByZoom(spr->width, ZOOM_LVL_GUI) + WD_FRAMERECT_RIGHT;
this->flag_height = UnScaleByZoom(spr->height, ZOOM_LVL_GUI);
@@ -656,6 +659,12 @@ struct DepotWindow : Window {
BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
this->generate_list = false;
DepotSortList(&this->vehicle_list);
+
+ uint new_unitnumber_digits = GetUnitNumberDigits(this->vehicle_list);
+ if (this->unitnumber_digits != new_unitnumber_digits) {
+ this->unitnumber_digits = new_unitnumber_digits;
+ this->ReInit();
+ }
}
/* determine amount of items for scroller */