Changeset - r13600:8268515184a7
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-11-17 09:09:20
rubidium@openttd.org
(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
3 files changed with 24 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/group_gui.cpp
Show inline comments
 
@@ -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"
src/vehicle_gui.cpp
Show inline comments
 
@@ -100,6 +100,22 @@ void BaseVehicleListWindow::BuildVehicle
 

	
 
	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::DrawVehicleL
 
	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;
 

	
src/vehicle_gui_base.h
Show inline comments
 
@@ -20,6 +20,7 @@ struct BaseVehicleListWindow: public Win
 
	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[];
0 comments (0 inline, 0 general)