mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r18134) -Codechange: scale the offset of the text/vehicle in the vehicle lists based on the font and the unit numbers in the list
This commit is contained in:
parent
a808623b24
commit
bdb118aa69
|
@ -15,7 +15,6 @@
|
|||
#include "textbuf_gui.h"
|
||||
#include "command_func.h"
|
||||
#include "vehicle_gui.h"
|
||||
#include "vehicle_gui_base.h"
|
||||
#include "vehicle_base.h"
|
||||
#include "group.h"
|
||||
#include "strings_func.h"
|
||||
|
@ -27,6 +26,7 @@
|
|||
#include "widgets/dropdown_type.h"
|
||||
#include "widgets/dropdown_func.h"
|
||||
#include "tilehighlight_func.h"
|
||||
#include "vehicle_gui_base.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
#include "table/sprites.h"
|
||||
|
|
|
@ -100,6 +100,22 @@ void BaseVehicleListWindow::BuildVehicleList(Owner owner, uint16 index, uint16 w
|
|||
|
||||
GenerateVehicleSortList(&this->vehicles, this->vehicle_type, owner, index, window_type);
|
||||
|
||||
uint unitnumber = 0;
|
||||
for (const Vehicle **v = this->vehicles.Begin(); v != this->vehicles.End(); v++) {
|
||||
unitnumber = max<uint>(unitnumber, (*v)->unitnumber);
|
||||
}
|
||||
|
||||
/* Because 111 is much less wide than e.g. 999 we use the
|
||||
* wider numbers to determine the width instead of just
|
||||
* the random number that it seems to be. */
|
||||
if (unitnumber >= 1000) {
|
||||
this->max_unitnumber = 9999;
|
||||
} else if (unitnumber >= 100) {
|
||||
this->max_unitnumber = 999;
|
||||
} else {
|
||||
this->max_unitnumber = 99;
|
||||
}
|
||||
|
||||
this->vehicles.RebuildDone();
|
||||
this->vscroll.SetCount(this->vehicles.Length());
|
||||
}
|
||||
|
@ -827,11 +843,13 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
|
|||
int right = r.right - WD_MATRIX_RIGHT;
|
||||
bool rtl = _dynlang.text_dir == TD_RTL;
|
||||
|
||||
int text_left = left + (rtl ? 0 : 19);
|
||||
int text_right = right - (rtl ? 19 : 0);
|
||||
SetDParam(0, this->max_unitnumber);
|
||||
int text_offset = GetStringBoundingBox(STR_JUST_INT).width + WD_FRAMERECT_RIGHT;
|
||||
int text_left = left + (rtl ? 0 : text_offset);
|
||||
int text_right = right - (rtl ? text_offset : 0);
|
||||
|
||||
int orderlist_left = left + (rtl ? 0 : 138);
|
||||
int orderlist_right = right - (rtl ? 138 : 0);
|
||||
int orderlist_left = left + (rtl ? 0 : 120 + text_offset);
|
||||
int orderlist_right = right - (rtl ? 120 + text_offset : 0);
|
||||
|
||||
int vehicle_button_x = rtl ? right - 8 : left;
|
||||
|
||||
|
|
|
@ -20,6 +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
|
||||
|
||||
static const StringID vehicle_sorter_names[];
|
||||
static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[];
|
||||
|
|
Loading…
Reference in New Issue