diff options
-rw-r--r-- | src/vehicle_gui.cpp | 9 | ||||
-rw-r--r-- | src/vehicle_gui_base.h | 2 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index d4cd7212e..830c022b5 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -110,11 +110,11 @@ void BaseVehicleListWindow::BuildVehicleList(Owner owner, uint16 index, uint16 w * wider numbers to determine the width instead of just * the random number that it seems to be. */ if (unitnumber >= 1000) { - this->max_unitnumber = 9999; + this->unitnumber_digits = 4; } else if (unitnumber >= 100) { - this->max_unitnumber = 999; + this->unitnumber_digits = 3; } else { - this->max_unitnumber = 99; + this->unitnumber_digits = 2; } this->vehicles.RebuildDone(); @@ -908,8 +908,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int int width = right - left; bool rtl = _dynlang.text_dir == TD_RTL; - SetDParam(0, this->max_unitnumber); - int text_offset = GetStringBoundingBox(STR_JUST_INT).width + WD_FRAMERECT_RIGHT; + int text_offset = GetDigitWidth() * this->unitnumber_digits + WD_FRAMERECT_RIGHT; int text_left = left + (rtl ? 0 : text_offset); int text_right = right - (rtl ? text_offset : 0); diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h index 09d63bd30..72dd8bcc3 100644 --- a/src/vehicle_gui_base.h +++ b/src/vehicle_gui_base.h @@ -20,7 +20,7 @@ struct BaseVehicleListWindow : public Window { GUIVehicleList vehicles; ///< The list of vehicles Listing *sorting; ///< Pointer to the vehicle type related sorting. VehicleType vehicle_type; ///< The vehicle type that is sorted - UnitID max_unitnumber; ///< The maximum UnitID + byte unitnumber_digits; ///< The number of digits of the highest unit number static const StringID vehicle_sorter_names[]; static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[]; |