Changeset - r26554:8202c0b49c1d
[Not reviewed]
master
0 5 0
Peter Nelson - 2 years ago 2022-10-18 12:52:22
peter1138@openttd.org
Change: Use Rect for drawing vehicle details.
5 files changed with 84 insertions and 91 deletions:
0 comments (0 inline, 0 general)
src/aircraft_gui.cpp
Show inline comments
 
@@ -25,47 +25,48 @@
 
 * Draw the details for the given vehicle at the given position
 
 *
 
 * @param v     current vehicle
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
 
 * @param y     The y coordinate
 
 * @param r     the Rect to draw within
 
 */
 
void DrawAircraftDetails(const Aircraft *v, int left, int right, int y)
 
void DrawAircraftDetails(const Aircraft *v, const Rect &r)
 
{
 
	int y_offset = (v->Next()->cargo_cap != 0) ? -(FONT_HEIGHT_NORMAL + 1): 0;
 
	Money feeder_share = 0;
 

	
 
	int y = r.top;
 
	for (const Aircraft *u = v; u != nullptr; u = u->Next()) {
 
		if (u->IsNormalAircraft()) {
 
			SetDParam(0, u->engine_type);
 
			SetDParam(1, u->build_year);
 
			SetDParam(2, u->value);
 
			DrawString(left, right, y, STR_VEHICLE_INFO_BUILT_VALUE);
 
			DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE);
 
			y += FONT_HEIGHT_NORMAL;
 

	
 
			SetDParam(0, u->cargo_type);
 
			SetDParam(1, u->cargo_cap);
 
			SetDParam(2, u->Next()->cargo_type);
 
			SetDParam(3, u->Next()->cargo_cap);
 
			SetDParam(4, GetCargoSubtypeText(u));
 
			DrawString(left, right, y + FONT_HEIGHT_NORMAL, (u->Next()->cargo_cap != 0) ? STR_VEHICLE_INFO_CAPACITY_CAPACITY : STR_VEHICLE_INFO_CAPACITY);
 
			DrawString(r.left, r.right, y, (u->Next()->cargo_cap != 0) ? STR_VEHICLE_INFO_CAPACITY_CAPACITY : STR_VEHICLE_INFO_CAPACITY);
 
			y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
		}
 

	
 
		if (u->cargo_cap != 0) {
 
			uint cargo_count = u->cargo.StoredCount();
 

	
 
			y_offset += FONT_HEIGHT_NORMAL + 1;
 
			if (cargo_count != 0) {
 
				/* Cargo names (fix pluralness) */
 
				SetDParam(0, u->cargo_type);
 
				SetDParam(1, cargo_count);
 
				SetDParam(2, u->cargo.Source());
 
				DrawString(left, right, y + 2 * FONT_HEIGHT_NORMAL + 1 + y_offset, STR_VEHICLE_DETAILS_CARGO_FROM);
 
				DrawString(r.left, r.right, y, STR_VEHICLE_DETAILS_CARGO_FROM);
 
				y += FONT_HEIGHT_NORMAL;
 
				feeder_share += u->cargo.FeederShare();
 
			}
 
		}
 
	}
 

	
 
	y += WD_PAR_VSEP_NORMAL;
 
	SetDParam(0, feeder_share);
 
	DrawString(left, right, y + 3 * FONT_HEIGHT_NORMAL + 3 + y_offset, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
	DrawString(r.left, r.right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
}
 

	
 

	
src/roadveh_gui.cpp
Show inline comments
 
@@ -23,20 +23,19 @@
 
 * Draw the details for the given vehicle at the given position
 
 *
 
 * @param v     current vehicle
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
 
 * @param y     The y coordinate
 
 * @param r     the Rect to draw within
 
 */
 
void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
 
void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
 
{
 
	uint y_offset = v->HasArticulatedPart() ? ScaleGUITrad(15) : 0; // Draw the first line below the sprite of an articulated RV instead of after it.
 
	int y = r.top + (v->HasArticulatedPart() ? ScaleGUITrad(15) : 0); // Draw the first line below the sprite of an articulated RV instead of after it.
 
	StringID str;
 
	Money feeder_share = 0;
 

	
 
	SetDParam(0, v->engine_type);
 
	SetDParam(1, v->build_year);
 
	SetDParam(2, v->value);
 
	DrawString(left, right, y + y_offset, STR_VEHICLE_INFO_BUILT_VALUE);
 
	DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE);
 
	y += FONT_HEIGHT_NORMAL;
 

	
 
	if (v->HasArticulatedPart()) {
 
		CargoArray max_cargo;
 
@@ -76,7 +75,8 @@ void DrawRoadVehDetails(const Vehicle *v
 
			}
 
		}
 

	
 
		DrawString(left, right, y + FONT_HEIGHT_NORMAL + y_offset, capacity, TC_BLUE);
 
		DrawString(r.left, r.right, y, capacity, TC_BLUE);
 
		y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 

	
 
		for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
 
			if (u->cargo_cap == 0) continue;
 
@@ -89,17 +89,16 @@ void DrawRoadVehDetails(const Vehicle *v
 
				str = STR_VEHICLE_DETAILS_CARGO_FROM;
 
				feeder_share += u->cargo.FeederShare();
 
			}
 
			DrawString(left, right, y + 2 * FONT_HEIGHT_NORMAL + 1 + y_offset, str);
 

	
 
			y_offset += FONT_HEIGHT_NORMAL + 1;
 
			DrawString(r.left, r.right, y, str);
 
			y += FONT_HEIGHT_NORMAL;
 
		}
 

	
 
		y_offset -= FONT_HEIGHT_NORMAL + 1;
 
		y += WD_PAR_VSEP_NORMAL;
 
	} else {
 
		SetDParam(0, v->cargo_type);
 
		SetDParam(1, v->cargo_cap);
 
		SetDParam(4, GetCargoSubtypeText(v));
 
		DrawString(left, right, y + FONT_HEIGHT_NORMAL + y_offset, STR_VEHICLE_INFO_CAPACITY);
 
		DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
 
		y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 

	
 
		str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
 
		if (v->cargo.StoredCount() > 0) {
 
@@ -109,12 +108,13 @@ void DrawRoadVehDetails(const Vehicle *v
 
			str = STR_VEHICLE_DETAILS_CARGO_FROM;
 
			feeder_share += v->cargo.FeederShare();
 
		}
 
		DrawString(left, right, y + 2 * FONT_HEIGHT_NORMAL + 1 + y_offset, str);
 
		DrawString(r.left, r.right, y, str);
 
		y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 
	}
 

	
 
	/* Draw Transfer credits text */
 
	SetDParam(0, feeder_share);
 
	DrawString(left, right, y + 3 * FONT_HEIGHT_NORMAL + 3 + y_offset, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
	DrawString(r.left, r.right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
}
 

	
 
/**
src/ship_gui.cpp
Show inline comments
 
@@ -57,21 +57,23 @@ void DrawShipImage(const Vehicle *v, int
 
 * Draw the details for the given vehicle at the given position
 
 *
 
 * @param v     current vehicle
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
 
 * @param y     The y coordinate
 
 * @param r     the Rect to draw within
 
 */
 
void DrawShipDetails(const Vehicle *v, int left, int right, int y)
 
void DrawShipDetails(const Vehicle *v, const Rect &r)
 
{
 
	int y = r.top;
 

	
 
	SetDParam(0, v->engine_type);
 
	SetDParam(1, v->build_year);
 
	SetDParam(2, v->value);
 
	DrawString(left, right, y, STR_VEHICLE_INFO_BUILT_VALUE);
 
	DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE);
 
	y += FONT_HEIGHT_NORMAL;
 

	
 
	SetDParam(0, v->cargo_type);
 
	SetDParam(1, v->cargo_cap);
 
	SetDParam(4, GetCargoSubtypeText(v));
 
	DrawString(left, right, y + FONT_HEIGHT_NORMAL, STR_VEHICLE_INFO_CAPACITY);
 
	DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
 
	y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 

	
 
	StringID str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
 
	if (v->cargo.StoredCount() > 0) {
 
@@ -80,9 +82,10 @@ void DrawShipDetails(const Vehicle *v, i
 
		SetDParam(2, v->cargo.Source());
 
		str = STR_VEHICLE_DETAILS_CARGO_FROM;
 
	}
 
	DrawString(left, right, y + 2 * FONT_HEIGHT_NORMAL + 1, str);
 
	DrawString(r.left, r.right, y, str);
 
	y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
 

	
 
	/* Draw Transfer credits text */
 
	SetDParam(0, v->cargo.FeederShare());
 
	DrawString(left, right, y + 3 * FONT_HEIGHT_NORMAL + 3, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
	DrawString(r.left, r.right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
}
src/train_gui.cpp
Show inline comments
 
@@ -352,32 +352,22 @@ int GetTrainDetailsWndVScroll(VehicleID 
 
 * Draw the details for the given vehicle at the given position
 
 *
 
 * @param v     current vehicle
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
 
 * @param y     The y coordinate
 
 * @param r     the Rect to draw within
 
 * @param vscroll_pos Position of scrollbar
 
 * @param vscroll_cap Number of lines currently displayed
 
 * @param det_tab Selected details tab
 
 */
 
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
 
void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
 
{
 
	/* get rid of awkward offset */
 
	y -= WD_MATRIX_TOP;
 

	
 
	/* Indent the total cargo capacity details */
 
	int offs_left = _current_text_dir == TD_LTR ? TRAIN_DETAILS_LIST_INDENT : 0;
 
	int offs_right = _current_text_dir == TD_LTR ? 0 : TRAIN_DETAILS_LIST_INDENT;
 

	
 
	int sprite_height = ScaleGUITrad(GetVehicleHeight(VEH_TRAIN));
 
	int line_height = std::max(sprite_height, WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
 
	bool rtl = _current_text_dir == TD_RTL;
 
	int line_height = r.Height();
 
	int sprite_y_offset = line_height / 2;
 
	int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2;
 

	
 
	/* draw the first 3 details tabs */
 
	if (det_tab != TDW_TAB_TOTALS) {
 
		bool rtl = _current_text_dir == TD_RTL;
 
		Direction dir = rtl ? DIR_E : DIR_W;
 
		int x = rtl ? right : left;
 
		int x = rtl ? r.right : r.left;
 
		for (; v != nullptr && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
 
			GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
 

	
 
@@ -397,7 +387,7 @@ void DrawTrainDetails(const Train *v, in
 
					PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
					VehicleSpriteSeq seq;
 
					u->GetImage(dir, EIT_IN_DETAILS, &seq);
 
					seq.Draw(px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + pitch, pal, (v->vehstatus & VS_CRASHED) != 0);
 
					seq.Draw(px + (rtl ? -offset.x : offset.x), r.top - line_height * vscroll_pos + sprite_y_offset + pitch, pal, (v->vehstatus & VS_CRASHED) != 0);
 
				}
 
				px += rtl ? -width : width;
 
				dx += width;
 
@@ -410,35 +400,34 @@ void DrawTrainDetails(const Train *v, in
 
				dx = 0;
 
			}
 

	
 
			int sprite_width = std::max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
 
			Rect dr = r.Indent(sprite_width, rtl);
 
			uint num_lines = std::max(1u, (unsigned)_cargo_summary.size());
 
			for (uint i = 0; i < num_lines; i++) {
 
				int sprite_width = std::max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
 
				int data_left  = left + (rtl ? 0 : sprite_width);
 
				int data_right = right - (rtl ? sprite_width : 0);
 
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
 
					int py = y - line_height * vscroll_pos + text_y_offset;
 
					int py = r.top - line_height * vscroll_pos + text_y_offset;
 
					if (i > 0 || separate_sprite_row) {
 
						if (vscroll_pos != 0) GfxFillRect(left, py - WD_MATRIX_TOP - 1, right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]);
 
						if (vscroll_pos != 0) GfxFillRect(r.left, py - WD_MATRIX_TOP - 1, r.right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]);
 
					}
 
					switch (det_tab) {
 
						case TDW_TAB_CARGO:
 
							if (i < _cargo_summary.size()) {
 
								TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
 
								TrainDetailsCargoTab(&_cargo_summary[i], dr.left, dr.right, py);
 
							} else {
 
								DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
 
								DrawString(dr.left, dr.right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
 
							}
 
							break;
 

	
 
						case TDW_TAB_INFO:
 
							if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py);
 
							if (i == 0) TrainDetailsInfoTab(v, dr.left, dr.right, py);
 
							break;
 

	
 
						case TDW_TAB_CAPACITY:
 
							if (i < _cargo_summary.size()) {
 
								TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
 
								TrainDetailsCapacityTab(&_cargo_summary[i], dr.left, dr.right, py);
 
							} else {
 
								SetDParam(0, STR_EMPTY);
 
								DrawString(data_left, data_right, py, STR_VEHICLE_INFO_NO_CAPACITY);
 
								DrawString(dr.left, dr.right, py, STR_VEHICLE_INFO_NO_CAPACITY);
 
							}
 
							break;
 

	
 
@@ -449,6 +438,7 @@ void DrawTrainDetails(const Train *v, in
 
			}
 
		}
 
	} else {
 
		int y = r.top;
 
		CargoArray act_cargo;
 
		CargoArray max_cargo;
 
		Money feeder_share = 0;
 
@@ -460,9 +450,11 @@ void DrawTrainDetails(const Train *v, in
 
		}
 

	
 
		/* draw total cargo tab */
 
		DrawString(left, right, y + text_y_offset, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_TEXT);
 
		DrawString(r.left, r.right, y + text_y_offset, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_TEXT);
 
		y += line_height;
 

	
 
		/* Indent the total cargo capacity details */
 
		Rect ir = r.Indent(TRAIN_DETAILS_LIST_INDENT, rtl);
 
		for (CargoID i = 0; i < NUM_CARGO; i++) {
 
			if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
 
				SetDParam(0, i);            // {CARGO} #1
 
@@ -470,11 +462,11 @@ void DrawTrainDetails(const Train *v, in
 
				SetDParam(2, i);            // {SHORTCARGO} #1
 
				SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
 
				SetDParam(4, _settings_game.vehicle.freight_trains);
 
				DrawString(left + offs_left, right - offs_right, y + text_y_offset, FreightWagonMult(i) > 1 ? STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_MULT : STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY);
 
				DrawString(ir.left, ir.right, y + text_y_offset, FreightWagonMult(i) > 1 ? STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_MULT : STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY);
 
				y += line_height;
 
			}
 
		}
 
		SetDParam(0, feeder_share);
 
		DrawString(left, right, y + text_y_offset, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
		DrawString(r.left, r.right, y + text_y_offset, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
 
	}
 
}
src/vehicle_gui.cpp
Show inline comments
 
@@ -2236,10 +2236,10 @@ static const NWidgetPart _nested_train_v
 

	
 

	
 
extern int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab);
 
extern void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab);
 
extern void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y);
 
extern void DrawShipDetails(const Vehicle *v, int left, int right, int y);
 
extern void DrawAircraftDetails(const Aircraft *v, int left, int right, int y);
 
extern void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab);
 
extern void DrawRoadVehDetails(const Vehicle *v, const Rect &r);
 
extern void DrawShipDetails(const Vehicle *v, const Rect &r);
 
extern void DrawAircraftDetails(const Aircraft *v, const Rect &r);
 

	
 
static StringID _service_interval_dropdown[] = {
 
	STR_VEHICLE_DETAILS_DEFAULT,
 
@@ -2300,13 +2300,13 @@ struct VehicleDetailsWindow : Window {
 
		uint desired_height;
 
		if (v->HasArticulatedPart()) {
 
			/* An articulated RV has its text drawn under the sprite instead of after it, hence 15 pixels extra. */
 
			desired_height = WD_FRAMERECT_TOP + ScaleGUITrad(15) + 3 * FONT_HEIGHT_NORMAL + 2 + WD_FRAMERECT_BOTTOM;
 
			desired_height = WD_FRAMERECT_TOP + ScaleGUITrad(15) + 3 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL * 2 + WD_FRAMERECT_BOTTOM;
 
			/* Add space for the cargo amount for each part. */
 
			for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
 
				if (u->cargo_cap != 0) desired_height += FONT_HEIGHT_NORMAL + 1;
 
				if (u->cargo_cap != 0) desired_height += FONT_HEIGHT_NORMAL;
 
			}
 
		} else {
 
			desired_height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + 3 + WD_FRAMERECT_BOTTOM;
 
			desired_height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL * 2 + WD_FRAMERECT_BOTTOM;
 
		}
 
		return desired_height;
 
	}
 
@@ -2343,11 +2343,11 @@ struct VehicleDetailsWindow : Window {
 
						break;
 

	
 
					case VEH_SHIP:
 
						size->height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + 3 + WD_FRAMERECT_BOTTOM;
 
						size->height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL * 2 + WD_FRAMERECT_BOTTOM;
 
						break;
 

	
 
					case VEH_AIRCRAFT:
 
						size->height = WD_FRAMERECT_TOP + 5 * FONT_HEIGHT_NORMAL + 4 + WD_FRAMERECT_BOTTOM;
 
						size->height = WD_FRAMERECT_TOP + 5 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL * 2 + WD_FRAMERECT_BOTTOM;
 
						break;
 

	
 
					default:
 
@@ -2400,20 +2400,18 @@ struct VehicleDetailsWindow : Window {
 
	 * Draw the details for the given vehicle at the position of the Details windows
 
	 *
 
	 * @param v     current vehicle
 
	 * @param left  The left most coordinate to draw
 
	 * @param right The right most coordinate to draw
 
	 * @param y     The y coordinate
 
	 * @param r     the Rect to draw within
 
	 * @param vscroll_pos Position of scrollbar (train only)
 
	 * @param vscroll_cap Number of lines currently displayed (train only)
 
	 * @param det_tab Selected details tab (train only)
 
	 */
 
	static void DrawVehicleDetails(const Vehicle *v, int left, int right, int y, int vscroll_pos, uint vscroll_cap, TrainDetailsWindowTabs det_tab)
 
	static void DrawVehicleDetails(const Vehicle *v, const Rect &r, int vscroll_pos, uint vscroll_cap, TrainDetailsWindowTabs det_tab)
 
	{
 
		switch (v->type) {
 
			case VEH_TRAIN:    DrawTrainDetails(Train::From(v), left, right, y, vscroll_pos, vscroll_cap, det_tab);  break;
 
			case VEH_ROAD:     DrawRoadVehDetails(v, left, right, y);  break;
 
			case VEH_SHIP:     DrawShipDetails(v, left, right, y);     break;
 
			case VEH_AIRCRAFT: DrawAircraftDetails(Aircraft::From(v), left, right, y); break;
 
			case VEH_TRAIN:    DrawTrainDetails(Train::From(v), r, vscroll_pos, vscroll_cap, det_tab);  break;
 
			case VEH_ROAD:     DrawRoadVehDetails(v, r);  break;
 
			case VEH_SHIP:     DrawShipDetails(v, r);     break;
 
			case VEH_AIRCRAFT: DrawAircraftDetails(Aircraft::From(v), r); break;
 
			default: NOT_REACHED();
 
		}
 
	}
 
@@ -2491,37 +2489,36 @@ struct VehicleDetailsWindow : Window {
 

	
 
			case WID_VD_MATRIX:
 
				/* For trains only. */
 
				DrawVehicleDetails(v, r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, r.top + WD_MATRIX_TOP, this->vscroll->GetPosition(), this->vscroll->GetCapacity(), this->tab);
 
				DrawVehicleDetails(v, r.Shrink(WD_MATRIX_LEFT, 0, WD_MATRIX_RIGHT, 0).WithHeight(this->resize.step_height), this->vscroll->GetPosition(), this->vscroll->GetCapacity(), this->tab);
 
				break;
 

	
 
			case WID_VD_MIDDLE_DETAILS: {
 
				/* For other vehicles, at the place of the matrix. */
 
				bool rtl = _current_text_dir == TD_RTL;
 
				uint sprite_width = GetSingleVehicleWidth(v, EIT_IN_DETAILS) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 

	
 
				uint text_left  = r.left  + (rtl ? 0 : sprite_width);
 
				uint text_right = r.right - (rtl ? sprite_width : 0);
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 

	
 
				/* Articulated road vehicles use a complete line. */
 
				if (v->type == VEH_ROAD && v->HasArticulatedPart()) {
 
					DrawVehicleImage(v, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, EIT_IN_DETAILS, 0);
 
					DrawVehicleImage(v, tr.left, tr.right, tr.top, INVALID_VEHICLE, EIT_IN_DETAILS, 0);
 
				} else {
 
					uint sprite_left  = rtl ? text_right : r.left;
 
					uint sprite_right = rtl ? r.right : text_left;
 

	
 
					DrawVehicleImage(v, sprite_left + WD_FRAMERECT_LEFT, sprite_right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, EIT_IN_DETAILS, 0);
 
					Rect sr = tr.WithWidth(sprite_width, rtl);
 
					DrawVehicleImage(v, sr.left, sr.right, sr.top, INVALID_VEHICLE, EIT_IN_DETAILS, 0);
 
				}
 
				DrawVehicleDetails(v, text_left + WD_FRAMERECT_LEFT, text_right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, 0, 0, this->tab);
 

	
 
				DrawVehicleDetails(v, tr.Indent(sprite_width, rtl), 0, 0, this->tab);
 
				break;
 
			}
 

	
 
			case WID_VD_SERVICING_INTERVAL:
 
			case WID_VD_SERVICING_INTERVAL: {
 
				/* Draw service interval text */
 
				Rect tr = r.Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
 
				SetDParam(0, v->GetServiceInterval());
 
				SetDParam(1, v->date_of_last_service);
 
				DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL),
 
				DrawString(tr.left, tr.right, CenterBounds(r.top, r.bottom, FONT_HEIGHT_NORMAL),
 
						v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
 
				break;
 
			}
 
		}
 
	}
 

	
0 comments (0 inline, 0 general)