changeset 12720:d83074ac9bcb draft

(svn r17185) -Codechange: Tweak depot gui and vehicle lists, so text overlaps less with vehicle images.
author frosch <frosch@openttd.org>
date Sat, 15 Aug 2009 11:47:11 +0000
parents deb337e930ca
children bd4dc8fe32f1
files src/depot_gui.cpp src/group_gui.cpp src/train_gui.cpp src/vehicle_gui.cpp src/vehicle_gui_base.h
diffstat 5 files changed, 18 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -271,7 +271,7 @@
 				free_wagon = u->IsFreeWagon();
 
 				uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
-				DrawTrainImage(u, x + 21 + x_space, sprite_y, this->sel, this->hscroll.cap + 4 - x_space, this->hscroll.pos);
+				DrawTrainImage(u, x + 24 + x_space, sprite_y - 1, this->sel, this->hscroll.cap - x_space, this->hscroll.pos);
 
 				/* Number of wagons relative to a standard length wagon (rounded up) */
 				SetDParam(0, (u->tcache.cached_total_length + 7) / 8);
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -322,7 +322,6 @@
 	virtual void OnPaint()
 	{
 		const Owner owner = (Owner)GB(this->window_number, 0, 8);
-		int x = this->widget[GRP_WIDGET_LIST_VEHICLE].left + 2;
 		int y1 = PLY_WND_PRC__OFFSET_TOP_WIDGET + 2;
 		int max;
 		int i;
@@ -422,7 +421,7 @@
 
 		this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
-		this->DrawVehicleListItems(x, this->vehicle_sel);
+		this->DrawVehicleListItems(this->vehicle_sel);
 	}
 
 	virtual void OnClick(Point pt, int widget)
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -70,7 +70,7 @@
 	int highlight_l = 0;
 	int highlight_r = 0;
 
-	if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, max_width + 1, 14)) return;
+	if (!FillDrawPixelInfo(&tmp_dpi, x, y, max_width, 14)) return;
 
 	old_dpi = _cur_dpi;
 	_cur_dpi = &tmp_dpi;
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -793,11 +793,12 @@
 
 /**
  * Draw all the vehicle list items.
- * @param x the position from where to draw the items.
  * @param selected_vehicle the vehicle that is to be selected
  */
-void BaseVehicleListWindow::DrawVehicleListItems(int x, VehicleID selected_vehicle)
+void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle)
 {
+	int left = this->widget[VLW_WIDGET_LIST].left + WD_MATRIX_LEFT;
+	int right = this->widget[VLW_WIDGET_LIST].right - WD_MATRIX_RIGHT;
 	int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
 	uint max = min(this->vscroll.pos + this->vscroll.cap, this->vehicles.Length());
 	for (uint i = this->vscroll.pos; i < max; ++i) {
@@ -807,20 +808,20 @@
 		SetDParam(0, v->GetDisplayProfitThisYear());
 		SetDParam(1, v->GetDisplayProfitLastYear());
 
-		DrawVehicleImage(v, x + 19, y + 6, selected_vehicle, this->widget[VLW_WIDGET_LIST].right - this->widget[VLW_WIDGET_LIST].left - 20, 0);
-		DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y + this->resize.step_height - 8, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
+		DrawVehicleImage(v, left + 19, y + 5, selected_vehicle, right - left + 1 - 19, 0);
+		DrawString(left + 19, right, y + this->resize.step_height - 8, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
 
 		if (v->name != NULL) {
 			/* The vehicle got a name so we will print it */
 			SetDParam(0, v->index);
-			DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y, STR_TINY_BLACK_VEHICLE);
+			DrawString(left + 19, right, y, STR_TINY_BLACK_VEHICLE);
 		} else if (v->group_id != DEFAULT_GROUP) {
 			/* The vehicle has no name, but is member of a group, so print group name */
 			SetDParam(0, v->group_id);
-			DrawString(x + 19, this->widget[VLW_WIDGET_LIST].right, y, STR_TINT_GROUP, TC_BLACK);
+			DrawString(left + 19, right, y, STR_TINT_GROUP, TC_BLACK);
 		}
 
-		if (this->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, x + 138, this->widget[VLW_WIDGET_LIST].right, y);
+		if (this->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, left + 138, right, y);
 
 		if (v->IsInDepot()) {
 			str = STR_BLUE_COMMA;
@@ -829,9 +830,9 @@
 		}
 
 		SetDParam(0, v->unitnumber);
-		DrawString(x, this->widget[VLW_WIDGET_LIST].right, y + 2, str);
+		DrawString(left, right, y + 2, str);
 
-		DrawVehicleProfitButton(v, x, y + 13);
+		DrawVehicleProfitButton(v, left, y + 13);
 
 		y += this->resize.step_height;
 	}
@@ -911,7 +912,6 @@
 
 	virtual void OnPaint()
 	{
-		int x = 2;
 		const Owner owner = this->owner;
 		const uint16 window_type = this->window_number & VLW_MASK;
 		const uint16 index = GB(this->window_number, 16, 16);
@@ -991,7 +991,7 @@
 		/* draw arrow pointing up/down for ascending/descending sorting */
 		this->DrawSortButtonState(VLW_WIDGET_SORT_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
 
-		this->DrawVehicleListItems(x,  INVALID_VEHICLE);
+		this->DrawVehicleListItems(INVALID_VEHICLE);
 	}
 
 	virtual void OnClick(Point pt, int widget)
--- a/src/vehicle_gui_base.h
+++ b/src/vehicle_gui_base.h
@@ -10,9 +10,9 @@
 /** Start of functions regarding vehicle list windows */
 enum {
 	PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
-	PLY_WND_PRC__SIZE_OF_ROW_TINY  = 13,
-	PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
-	PLY_WND_PRC__SIZE_OF_ROW_BIG   = 39,
+	PLY_WND_PRC__SIZE_OF_ROW_TINY  = 13,  ///< Height of rows in group list
+	PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,  ///< Height of rows in train/roadvehicle list
+	PLY_WND_PRC__SIZE_OF_ROW_BIG   = 39,  ///< Height of rows in ship/aircraft list
 };
 
 typedef GUIList<const Vehicle*> GUIVehicleList;
@@ -30,7 +30,7 @@
 		this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs);
 	}
 
-	void DrawVehicleListItems(int x, VehicleID selected_vehicle);
+	void DrawVehicleListItems(VehicleID selected_vehicle);
 	void SortVehicleList();
 	void BuildVehicleList(Owner owner, uint16 index, uint16 window_type);
 };