src/vehicle_gui.cpp
changeset 8320 6ffad7a5d242
parent 8294 a7b17349a0b5
child 8328 6909973c8359
equal deleted inserted replaced
8319:434ce8c1e463 8320:6ffad7a5d242
   286 	uint y = 31;
   286 	uint y = 31;
   287 	uint i;
   287 	uint i;
   288 
   288 
   289 	/* Draw the list, and find the selected cargo (by its position in list) */
   289 	/* Draw the list, and find the selected cargo (by its position in list) */
   290 	for (i = 0; i < num_lines; i++) {
   290 	for (i = 0; i < num_lines; i++) {
   291 		byte colour = 16;
   291 		TextColour colour = TC_BLACK;
   292 		if (sel == 0) {
   292 		if (sel == 0) {
   293 			selected = &refit[i];
   293 			selected = &refit[i];
   294 			colour = 12;
   294 			colour = TC_WHITE;
   295 		}
   295 		}
   296 
   296 
   297 		if (i >= pos && i < pos + rows) {
   297 		if (i >= pos && i < pos + rows) {
   298 			/* Draw the cargo name */
   298 			/* Draw the cargo name */
   299 			int last_x = DrawString(2, y, GetCargo(refit[i].cargo)->name, colour);
   299 			int last_x = DrawString(2, y, GetCargo(refit[i].cargo)->name, colour);
   344 
   344 
   345 				if (CmdSucceeded(cost)) {
   345 				if (CmdSucceeded(cost)) {
   346 					SetDParam(0, WP(w, refit_d).cargo->cargo);
   346 					SetDParam(0, WP(w, refit_d).cargo->cargo);
   347 					SetDParam(1, _returned_refit_capacity);
   347 					SetDParam(1, _returned_refit_capacity);
   348 					SetDParam(2, cost.GetCost());
   348 					SetDParam(2, cost.GetCost());
   349 					DrawString(2, w->widget[5].top + 1, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0);
   349 					DrawString(2, w->widget[5].top + 1, STR_9840_NEW_CAPACITY_COST_OF_REFIT, TC_FROMSTRING);
   350 				}
   350 				}
   351 			}
   351 			}
   352 		} break;
   352 		} break;
   353 
   353 
   354 		case WE_CLICK:
   354 		case WE_CLICK:
   904 	int sel, i = 0;
   904 	int sel, i = 0;
   905 
   905 
   906 	sel = v->cur_order_index;
   906 	sel = v->cur_order_index;
   907 
   907 
   908 	FOR_VEHICLE_ORDERS(v, order) {
   908 	FOR_VEHICLE_ORDERS(v, order) {
   909 		if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, 16);
   909 		if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, TC_BLACK);
   910 		sel--;
   910 		sel--;
   911 
   911 
   912 		if (order->type == OT_GOTO_STATION) {
   912 		if (order->type == OT_GOTO_STATION) {
   913 			if (v->type == VEH_SHIP && GetStation(order->dest)->IsBuoy()) continue;
   913 			if (v->type == VEH_SHIP && GetStation(order->dest)->IsBuoy()) continue;
   914 
   914 
   915 			SetDParam(0, order->dest);
   915 			SetDParam(0, order->dest);
   916 			DrawString(x, y, STR_A036, 0);
   916 			DrawString(x, y, STR_A036, TC_FROMSTRING);
   917 
   917 
   918 			y += 6;
   918 			y += 6;
   919 			if (++i == 4) break;
   919 			if (++i == 4) break;
   920 		}
   920 		}
   921 	}
   921 	}
   984 		WIDGET_LIST_END);
   984 		WIDGET_LIST_END);
   985 
   985 
   986 	DrawWindowWidgets(w);
   986 	DrawWindowWidgets(w);
   987 
   987 
   988 	/* draw sorting criteria string */
   988 	/* draw sorting criteria string */
   989 	DrawString(85, 15, _vehicle_sort_listing[vl->l.sort_type], 0x10);
   989 	DrawString(85, 15, _vehicle_sort_listing[vl->l.sort_type], TC_BLACK);
   990 	/* draw arrow pointing up/down for ascending/descending sorting */
   990 	/* draw arrow pointing up/down for ascending/descending sorting */
   991 	DoDrawString(vl->l.flags & VL_DESC ? DOWNARROW : UPARROW, 69, 15, 0x10);
   991 	DoDrawString(vl->l.flags & VL_DESC ? DOWNARROW : UPARROW, 69, 15, TC_BLACK);
   992 
   992 
   993 	max = min(w->vscroll.pos + w->vscroll.cap, vl->l.list_length);
   993 	max = min(w->vscroll.pos + w->vscroll.cap, vl->l.list_length);
   994 	for (i = w->vscroll.pos; i < max; ++i) {
   994 	for (i = w->vscroll.pos; i < max; ++i) {
   995 		const Vehicle *v = vl->sort_list[i];
   995 		const Vehicle *v = vl->sort_list[i];
   996 		StringID str;
   996 		StringID str;
   997 
   997 
   998 		SetDParam(0, v->profit_this_year);
   998 		SetDParam(0, v->profit_this_year);
   999 		SetDParam(1, v->profit_last_year);
   999 		SetDParam(1, v->profit_last_year);
  1000 
  1000 
  1001 		DrawVehicleImage(v, x + 19, y + 6, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0, INVALID_VEHICLE);
  1001 		DrawVehicleImage(v, x + 19, y + 6, w->widget[VLW_WIDGET_LIST].right - w->widget[VLW_WIDGET_LIST].left - 20, 0, INVALID_VEHICLE);
  1002 		DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
  1002 		DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, TC_FROMSTRING);
  1003 
  1003 
  1004 		if ((v->type == VEH_TRAIN    && v->string_id != STR_SV_TRAIN_NAME)   ||
  1004 		if ((v->type == VEH_TRAIN    && v->string_id != STR_SV_TRAIN_NAME)   ||
  1005 			(v->type == VEH_ROAD     && v->string_id != STR_SV_ROADVEH_NAME) ||
  1005 			(v->type == VEH_ROAD     && v->string_id != STR_SV_ROADVEH_NAME) ||
  1006 			(v->type == VEH_SHIP     && v->string_id != STR_SV_SHIP_NAME)    ||
  1006 			(v->type == VEH_SHIP     && v->string_id != STR_SV_SHIP_NAME)    ||
  1007 			(v->type == VEH_AIRCRAFT && v->string_id != STR_SV_AIRCRAFT_NAME)) {
  1007 			(v->type == VEH_AIRCRAFT && v->string_id != STR_SV_AIRCRAFT_NAME)) {
  1008 
  1008 
  1009 			/* The vehicle got a name so we will print it */
  1009 			/* The vehicle got a name so we will print it */
  1010 			SetDParam(0, v->index);
  1010 			SetDParam(0, v->index);
  1011 			DrawString(x + 19, y, STR_01AB, 0);
  1011 			DrawString(x + 19, y, STR_01AB, TC_FROMSTRING);
  1012 		}
  1012 		}
  1013 
  1013 
  1014 		if (w->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, x + 138, y);
  1014 		if (w->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, x + 138, y);
  1015 
  1015 
  1016 		if (v->IsInDepot()) {
  1016 		if (v->IsInDepot()) {
  1018 		} else {
  1018 		} else {
  1019 			str = (v->age > v->max_age - 366) ? STR_00E3 : STR_00E2;
  1019 			str = (v->age > v->max_age - 366) ? STR_00E3 : STR_00E2;
  1020 		}
  1020 		}
  1021 
  1021 
  1022 		SetDParam(0, v->unitnumber);
  1022 		SetDParam(0, v->unitnumber);
  1023 		DrawString(x, y + 2, str, 0);
  1023 		DrawString(x, y + 2, str, TC_FROMSTRING);
  1024 
  1024 
  1025 		DrawVehicleProfitButton(v, x, y + 13);
  1025 		DrawVehicleProfitButton(v, x, y + 13);
  1026 
  1026 
  1027 		y += w->resize.step_height;
  1027 		y += w->resize.step_height;
  1028 	}
  1028 	}
  1489 	/* Draw running cost */
  1489 	/* Draw running cost */
  1490 	SetDParam(1, v->age / 366);
  1490 	SetDParam(1, v->age / 366);
  1491 	SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
  1491 	SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
  1492 	SetDParam(2, v->max_age / 366);
  1492 	SetDParam(2, v->max_age / 366);
  1493 	SetDParam(3, v->GetDisplayRunningCost());
  1493 	SetDParam(3, v->GetDisplayRunningCost());
  1494 	DrawString(2, 15, _vehicle_translation_table[VST_VEHICLE_AGE_RUNNING_COST_YR][v->type], 0);
  1494 	DrawString(2, 15, _vehicle_translation_table[VST_VEHICLE_AGE_RUNNING_COST_YR][v->type], TC_FROMSTRING);
  1495 
  1495 
  1496 	/* Draw max speed */
  1496 	/* Draw max speed */
  1497 	switch (v->type) {
  1497 	switch (v->type) {
  1498 		case VEH_TRAIN:
  1498 		case VEH_TRAIN:
  1499 			SetDParam(2, v->GetDisplayMaxSpeed());
  1499 			SetDParam(2, v->GetDisplayMaxSpeed());
  1500 			SetDParam(1, v->u.rail.cached_power);
  1500 			SetDParam(1, v->u.rail.cached_power);
  1501 			SetDParam(0, v->u.rail.cached_weight);
  1501 			SetDParam(0, v->u.rail.cached_weight);
  1502 			SetDParam(3, v->u.rail.cached_max_te / 1000);
  1502 			SetDParam(3, v->u.rail.cached_max_te / 1000);
  1503 			DrawString(2, 25, (_patches.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ?
  1503 			DrawString(2, 25, (_patches.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ?
  1504 				STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :
  1504 				STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :
  1505 				STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0);
  1505 				STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, TC_FROMSTRING);
  1506 			break;
  1506 			break;
  1507 
  1507 
  1508 		case VEH_ROAD:
  1508 		case VEH_ROAD:
  1509 		case VEH_SHIP:
  1509 		case VEH_SHIP:
  1510 		case VEH_AIRCRAFT:
  1510 		case VEH_AIRCRAFT:
  1511 			SetDParam(0, v->GetDisplayMaxSpeed());
  1511 			SetDParam(0, v->GetDisplayMaxSpeed());
  1512 			DrawString(2, 25, _vehicle_translation_table[VST_VEHICLE_MAX_SPEED][v->type], 0);
  1512 			DrawString(2, 25, _vehicle_translation_table[VST_VEHICLE_MAX_SPEED][v->type], TC_FROMSTRING);
  1513 			break;
  1513 			break;
  1514 
  1514 
  1515 		default: NOT_REACHED();
  1515 		default: NOT_REACHED();
  1516 	}
  1516 	}
  1517 
  1517 
  1518 	/* Draw profit */
  1518 	/* Draw profit */
  1519 	SetDParam(0, v->profit_this_year);
  1519 	SetDParam(0, v->profit_this_year);
  1520 	SetDParam(1, v->profit_last_year);
  1520 	SetDParam(1, v->profit_last_year);
  1521 	DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], 0);
  1521 	DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING);
  1522 
  1522 
  1523 	/* Draw breakdown & reliability */
  1523 	/* Draw breakdown & reliability */
  1524 	SetDParam(0, v->reliability * 100 >> 16);
  1524 	SetDParam(0, v->reliability * 100 >> 16);
  1525 	SetDParam(1, v->breakdowns_since_last_service);
  1525 	SetDParam(1, v->breakdowns_since_last_service);
  1526 	DrawString(2, 45, _vehicle_translation_table[VST_VEHICLE_RELIABILITY_BREAKDOWNS][v->type], 0);
  1526 	DrawString(2, 45, _vehicle_translation_table[VST_VEHICLE_RELIABILITY_BREAKDOWNS][v->type], TC_FROMSTRING);
  1527 
  1527 
  1528 	/* Draw service interval text */
  1528 	/* Draw service interval text */
  1529 	SetDParam(0, v->service_interval);
  1529 	SetDParam(0, v->service_interval);
  1530 	SetDParam(1, v->date_of_last_service);
  1530 	SetDParam(1, v->date_of_last_service);
  1531 	DrawString(13, w->height - (v->type != VEH_TRAIN ? 11 : 23), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0);
  1531 	DrawString(13, w->height - (v->type != VEH_TRAIN ? 11 : 23), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, TC_FROMSTRING);
  1532 
  1532 
  1533 	switch (v->type) {
  1533 	switch (v->type) {
  1534 		case VEH_TRAIN:
  1534 		case VEH_TRAIN:
  1535 			DrawVehicleDetails(v, 2, 57, w->vscroll.pos, w->vscroll.cap, det_tab);
  1535 			DrawVehicleDetails(v, 2, 57, w->vscroll.pos, w->vscroll.cap, det_tab);
  1536 			break;
  1536 			break;
  2024 		}
  2024 		}
  2025 	}
  2025 	}
  2026 
  2026 
  2027 	/* draw the flag plus orders */
  2027 	/* draw the flag plus orders */
  2028 	DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[VVW_WIDGET_START_STOP_VEH].top + 1);
  2028 	DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[VVW_WIDGET_START_STOP_VEH].top + 1);
  2029 	DrawStringCenteredTruncated(w->widget[VVW_WIDGET_START_STOP_VEH].left + 8, w->widget[VVW_WIDGET_START_STOP_VEH].right, w->widget[VVW_WIDGET_START_STOP_VEH].top + 1, str, 0);
  2029 	DrawStringCenteredTruncated(w->widget[VVW_WIDGET_START_STOP_VEH].left + 8, w->widget[VVW_WIDGET_START_STOP_VEH].right, w->widget[VVW_WIDGET_START_STOP_VEH].top + 1, str, TC_FROMSTRING);
  2030 	DrawWindowViewport(w);
  2030 	DrawWindowViewport(w);
  2031 }
  2031 }
  2032 
  2032 
  2033 /** Command indices for the _vehicle_command_translation_table. */
  2033 /** Command indices for the _vehicle_command_translation_table. */
  2034 enum VehicleCommandTranslation {
  2034 enum VehicleCommandTranslation {