203 if (u->cargo_cap == 0) continue; |
203 if (u->cargo_cap == 0) continue; |
204 |
204 |
205 /* Loop through all cargos in the refit mask */ |
205 /* Loop through all cargos in the refit mask */ |
206 for (CargoID cid = 0; cid < NUM_CARGO && num_lines < max_lines; cid++) { |
206 for (CargoID cid = 0; cid < NUM_CARGO && num_lines < max_lines; cid++) { |
207 /* Skip cargo type if it's not listed */ |
207 /* Skip cargo type if it's not listed */ |
208 if (!HASBIT(cmask, cid)) continue; |
208 if (!HasBit(cmask, cid)) continue; |
209 |
209 |
210 /* Check the vehicle's callback mask for cargo suffixes */ |
210 /* Check the vehicle's callback mask for cargo suffixes */ |
211 if (HASBIT(callbackmask, CBM_VEHICLE_CARGO_SUFFIX)) { |
211 if (HasBit(callbackmask, CBM_VEHICLE_CARGO_SUFFIX)) { |
212 /* Make a note of the original cargo type. It has to be |
212 /* Make a note of the original cargo type. It has to be |
213 * changed to test the cargo & subtype... */ |
213 * changed to test the cargo & subtype... */ |
214 CargoID temp_cargo = u->cargo_type; |
214 CargoID temp_cargo = u->cargo_type; |
215 byte temp_subtype = u->cargo_subtype; |
215 byte temp_subtype = u->cargo_subtype; |
216 byte refit_cyc; |
216 byte refit_cyc; |
483 /* List of cargo types available in this climate */ |
483 /* List of cargo types available in this climate */ |
484 uint32 lmask = _cargo_mask; |
484 uint32 lmask = _cargo_mask; |
485 char *b = _userstring; |
485 char *b = _userstring; |
486 |
486 |
487 /* Draw nothing if the engine is not refittable */ |
487 /* Draw nothing if the engine is not refittable */ |
488 if (COUNTBITS(cmask) <= 1) return 0; |
488 if (CountBits(cmask) <= 1) return 0; |
489 |
489 |
490 b = InlineString(b, STR_PURCHASE_INFO_REFITTABLE_TO); |
490 b = InlineString(b, STR_PURCHASE_INFO_REFITTABLE_TO); |
491 |
491 |
492 if (cmask == lmask) { |
492 if (cmask == lmask) { |
493 /* Engine can be refitted to all types in this climate */ |
493 /* Engine can be refitted to all types in this climate */ |
494 b = InlineString(b, STR_PURCHASE_INFO_ALL_TYPES); |
494 b = InlineString(b, STR_PURCHASE_INFO_ALL_TYPES); |
495 } else { |
495 } else { |
496 /* Check if we are able to refit to more cargo types and unable to. If |
496 /* Check if we are able to refit to more cargo types and unable to. If |
497 * so, invert the cargo types to list those that we can't refit to. */ |
497 * so, invert the cargo types to list those that we can't refit to. */ |
498 if (COUNTBITS(cmask ^ lmask) < COUNTBITS(cmask)) { |
498 if (CountBits(cmask ^ lmask) < CountBits(cmask)) { |
499 cmask ^= lmask; |
499 cmask ^= lmask; |
500 b = InlineString(b, STR_PURCHASE_INFO_ALL_BUT); |
500 b = InlineString(b, STR_PURCHASE_INFO_ALL_BUT); |
501 } |
501 } |
502 |
502 |
503 bool first = true; |
503 bool first = true; |
504 |
504 |
505 /* Add each cargo type to the list */ |
505 /* Add each cargo type to the list */ |
506 for (CargoID cid = 0; cid < NUM_CARGO; cid++) { |
506 for (CargoID cid = 0; cid < NUM_CARGO; cid++) { |
507 if (!HASBIT(cmask, cid)) continue; |
507 if (!HasBit(cmask, cid)) continue; |
508 |
508 |
509 if (!first) b = strecpy(b, ", ", lastof(_userstring)); |
509 if (!first) b = strecpy(b, ", ", lastof(_userstring)); |
510 first = false; |
510 first = false; |
511 |
511 |
512 b = InlineString(b, GetCargo(cid)->name); |
512 b = InlineString(b, GetCargo(cid)->name); |
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()) { |
1413 |
1413 |
1414 WP(w, vehicledetails_d).tab = 0; |
1414 WP(w, vehicledetails_d).tab = 0; |
1415 } |
1415 } |
1416 |
1416 |
1417 /** Checks whether service interval is enabled for the vehicle. */ |
1417 /** Checks whether service interval is enabled for the vehicle. */ |
1418 static bool inline IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type) |
1418 static inline bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type) |
1419 { |
1419 { |
1420 switch (vehicle_type) { |
1420 switch (vehicle_type) { |
|
1421 default: NOT_REACHED(); |
1421 case VEH_TRAIN: return _patches.servint_trains != 0; break; |
1422 case VEH_TRAIN: return _patches.servint_trains != 0; break; |
1422 case VEH_ROAD: return _patches.servint_roadveh != 0; break; |
1423 case VEH_ROAD: return _patches.servint_roadveh != 0; break; |
1423 case VEH_SHIP: return _patches.servint_ships != 0; break; |
1424 case VEH_SHIP: return _patches.servint_ships != 0; break; |
1424 case VEH_AIRCRAFT: return _patches.servint_aircraft != 0; break; |
1425 case VEH_AIRCRAFT: return _patches.servint_aircraft != 0; break; |
1425 default: NOT_REACHED(); |
1426 } |
1426 } |
1427 return false; // kill a compiler warning |
1427 } |
1428 } |
1428 |
1429 |
1429 extern int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab); |
1430 extern int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab); |
1430 extern void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab); |
1431 extern void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab); |
1431 extern void DrawRoadVehDetails(const Vehicle *v, int x, int y); |
1432 extern void DrawRoadVehDetails(const Vehicle *v, int x, int y); |
1488 /* Draw running cost */ |
1489 /* Draw running cost */ |
1489 SetDParam(1, v->age / 366); |
1490 SetDParam(1, v->age / 366); |
1490 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); |
1491 SetDParam(2, v->max_age / 366); |
1492 SetDParam(2, v->max_age / 366); |
1492 SetDParam(3, v->GetDisplayRunningCost()); |
1493 SetDParam(3, v->GetDisplayRunningCost()); |
1493 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); |
1494 |
1495 |
1495 /* Draw max speed */ |
1496 /* Draw max speed */ |
1496 switch (v->type) { |
1497 switch (v->type) { |
1497 case VEH_TRAIN: |
1498 case VEH_TRAIN: |
1498 SetDParam(2, v->GetDisplayMaxSpeed()); |
1499 SetDParam(2, v->GetDisplayMaxSpeed()); |
1499 SetDParam(1, v->u.rail.cached_power); |
1500 SetDParam(1, v->u.rail.cached_power); |
1500 SetDParam(0, v->u.rail.cached_weight); |
1501 SetDParam(0, v->u.rail.cached_weight); |
1501 SetDParam(3, v->u.rail.cached_max_te / 1000); |
1502 SetDParam(3, v->u.rail.cached_max_te / 1000); |
1502 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) ? |
1503 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE : |
1504 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE : |
1504 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0); |
1505 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, TC_FROMSTRING); |
1505 break; |
1506 break; |
1506 |
1507 |
1507 case VEH_ROAD: |
1508 case VEH_ROAD: |
1508 case VEH_SHIP: |
1509 case VEH_SHIP: |
1509 case VEH_AIRCRAFT: |
1510 case VEH_AIRCRAFT: |
1510 SetDParam(0, v->GetDisplayMaxSpeed()); |
1511 SetDParam(0, v->GetDisplayMaxSpeed()); |
1511 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); |
1512 break; |
1513 break; |
1513 |
1514 |
1514 default: NOT_REACHED(); |
1515 default: NOT_REACHED(); |
1515 } |
1516 } |
1516 |
1517 |
1517 /* Draw profit */ |
1518 /* Draw profit */ |
1518 SetDParam(0, v->profit_this_year); |
1519 SetDParam(0, v->profit_this_year); |
1519 SetDParam(1, v->profit_last_year); |
1520 SetDParam(1, v->profit_last_year); |
1520 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); |
1521 |
1522 |
1522 /* Draw breakdown & reliability */ |
1523 /* Draw breakdown & reliability */ |
1523 SetDParam(0, v->reliability * 100 >> 16); |
1524 SetDParam(0, v->reliability * 100 >> 16); |
1524 SetDParam(1, v->breakdowns_since_last_service); |
1525 SetDParam(1, v->breakdowns_since_last_service); |
1525 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); |
1526 |
1527 |
1527 /* Draw service interval text */ |
1528 /* Draw service interval text */ |
1528 SetDParam(0, v->service_interval); |
1529 SetDParam(0, v->service_interval); |
1529 SetDParam(1, v->date_of_last_service); |
1530 SetDParam(1, v->date_of_last_service); |
1530 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); |
1531 |
1532 |
1532 switch (v->type) { |
1533 switch (v->type) { |
1533 case VEH_TRAIN: |
1534 case VEH_TRAIN: |
1534 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); |
1535 break; |
1536 break; |
2023 } |
2024 } |
2024 } |
2025 } |
2025 |
2026 |
2026 /* draw the flag plus orders */ |
2027 /* draw the flag plus orders */ |
2027 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); |
2028 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); |
2029 DrawWindowViewport(w); |
2030 DrawWindowViewport(w); |
2030 } |
2031 } |
2031 |
2032 |
2032 /** Command indices for the _vehicle_command_translation_table. */ |
2033 /** Command indices for the _vehicle_command_translation_table. */ |
2033 enum VehicleCommandTranslation { |
2034 enum VehicleCommandTranslation { |