452 SetDParam(0, v->unitnumber); |
452 SetDParam(0, v->unitnumber); |
453 DrawString(x, y, (v->max_age - 366 < v->age) ? STR_00E3 : STR_00E2, 0); |
453 DrawString(x, y, (v->max_age - 366 < v->age) ? STR_00E3 : STR_00E2, 0); |
454 |
454 |
455 // Number of wagons relative to a standard length wagon (rounded up) |
455 // Number of wagons relative to a standard length wagon (rounded up) |
456 SetDParam(0, (v->u.rail.cached_total_length + 7) / 8); |
456 SetDParam(0, (v->u.rail.cached_total_length + 7) / 8); |
457 DrawStringRightAligned(w->widget[6].right - 1, y + 4, STR_TINY_BLACK, 0); //Draw the counter |
457 DrawStringRightAligned(w->widget[6].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter |
458 |
458 |
459 /* Draw the pretty flag */ |
459 /* Draw the pretty flag */ |
460 DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + 15, y); |
460 DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + 15, y); |
461 |
461 |
462 y += 14; |
462 y += 14; |
472 DrawString(x, y+2, STR_8816, 0); |
472 DrawString(x, y+2, STR_8816, 0); |
473 |
473 |
474 /*Draw the train counter */ |
474 /*Draw the train counter */ |
475 i = 0; |
475 i = 0; |
476 u = v; |
476 u = v; |
477 do i++; while ( (u=u->next) != NULL); //Determine length of train |
477 do i++; while ( (u=u->next) != NULL); // Determine length of train |
478 SetDParam(0, i); //Set the counter |
478 SetDParam(0, i); // Set the counter |
479 DrawStringRightAligned(w->widget[6].right - 1, y + 4, STR_TINY_BLACK, 0); //Draw the counter |
479 DrawStringRightAligned(w->widget[6].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter |
480 y += 14; |
480 y += 14; |
481 } |
481 } |
482 } |
482 } |
483 } |
483 } |
484 |
484 |
1018 |
1018 |
1019 switch (wid) { |
1019 switch (wid) { |
1020 case 5: /* start/stop train */ |
1020 case 5: /* start/stop train */ |
1021 DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
1021 DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
1022 break; |
1022 break; |
1023 case 6: /* center main view */ |
1023 case 6: /* center main view */ |
1024 ScrollMainWindowTo(v->x_pos, v->y_pos); |
1024 ScrollMainWindowTo(v->x_pos, v->y_pos); |
1025 break; |
1025 break; |
1026 case 7: /* goto depot */ |
1026 case 7: /* goto depot */ |
1027 /* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */ |
1027 /* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */ |
1028 DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT)); |
1028 DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT)); |
1029 break; |
1029 break; |
1030 case 8: /* force proceed */ |
1030 case 8: /* force proceed */ |
1031 DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); |
1031 DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); |
1147 }; |
1147 }; |
1148 |
1148 |
1149 static void DrawTrainDetailsWindow(Window *w) |
1149 static void DrawTrainDetailsWindow(Window *w) |
1150 { |
1150 { |
1151 const Vehicle *v, *u; |
1151 const Vehicle *v, *u; |
1152 uint16 tot_cargo[NUM_CARGO][2]; // count total cargo ([0]-actual cargo, [1]-total cargo) |
1152 uint16 tot_cargo[NUM_CARGO][2]; // count total cargo ([0]-actual cargo, [1]-total cargo) |
1153 int i,num,x,y,sel; |
1153 int i,num,x,y,sel; |
1154 byte det_tab = WP(w, traindetails_d).tab; |
1154 byte det_tab = WP(w, traindetails_d).tab; |
1155 |
1155 |
1156 /* Count number of vehicles */ |
1156 /* Count number of vehicles */ |
1157 num = 0; |
1157 num = 0; |
1158 |
1158 |
1159 // det_tab == 3 <-- Total Cargo tab |
1159 // det_tab == 3 <-- Total Cargo tab |
1160 if (det_tab == 3) // reset tot_cargo array to 0 values |
1160 if (det_tab == 3) // reset tot_cargo array to 0 values |
1161 memset(tot_cargo, 0, sizeof(tot_cargo)); |
1161 memset(tot_cargo, 0, sizeof(tot_cargo)); |
1162 |
1162 |
1163 u = v = GetVehicle(w->window_number); |
1163 u = v = GetVehicle(w->window_number); |
1164 do { |
1164 do { |
1165 if (det_tab != 3) |
1165 if (det_tab != 3) |
1168 tot_cargo[u->cargo_type][0] += u->cargo_count; |
1168 tot_cargo[u->cargo_type][0] += u->cargo_count; |
1169 tot_cargo[u->cargo_type][1] += u->cargo_cap; |
1169 tot_cargo[u->cargo_type][1] += u->cargo_cap; |
1170 } |
1170 } |
1171 } while ((u = GetNextVehicle(u)) != NULL); |
1171 } while ((u = GetNextVehicle(u)) != NULL); |
1172 |
1172 |
1173 /* set scroll-amount seperately from counting, as to not |
1173 /* set scroll-amount seperately from counting, as to not |
1174 compute num double for more carriages of the same type |
1174 * compute num double for more carriages of the same type |
1175 */ |
1175 */ |
1176 if (det_tab == 3) { |
1176 if (det_tab == 3) { |
1177 for (i = 0; i != NUM_CARGO; i++) { |
1177 for (i = 0; i != NUM_CARGO; i++) { |
1178 if (tot_cargo[i][1] > 0) // only count carriages that the train has |
1178 if (tot_cargo[i][1] > 0) // only count carriages that the train has |
1179 num++; |
1179 num++; |
1180 } |
1180 } |
1181 num++; // needs one more because first line is description string |
1181 num++; // needs one more because first line is description string |
1182 } |
1182 } |
1183 |
1183 |
1184 SetVScrollCount(w, num); |
1184 SetVScrollCount(w, num); |
1185 |
1185 |
1186 w->disabled_state = 1 << (det_tab + 9); |
1186 w->disabled_state = 1 << (det_tab + 9); |
1247 // draw total cargo tab |
1247 // draw total cargo tab |
1248 DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
1248 DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
1249 for (i = 0; i != NUM_CARGO; i++) { |
1249 for (i = 0; i != NUM_CARGO; i++) { |
1250 if (tot_cargo[i][1] > 0 && --sel < 0 && sel > -w->vscroll.cap) { |
1250 if (tot_cargo[i][1] > 0 && --sel < 0 && sel > -w->vscroll.cap) { |
1251 y += 14; |
1251 y += 14; |
1252 // STR_013F_TOTAL_CAPACITY :{LTBLUE}- {CARGO} ({SHORTCARGO}) |
1252 // STR_013F_TOTAL_CAPACITY :{LTBLUE}- {CARGO} ({SHORTCARGO}) |
1253 SetDParam(0, i); // {CARGO} #1 |
1253 SetDParam(0, i); // {CARGO} #1 |
1254 SetDParam(1, tot_cargo[i][0]); // {CARGO} #2 |
1254 SetDParam(1, tot_cargo[i][0]); // {CARGO} #2 |
1255 SetDParam(2, i); // {SHORTCARGO} #1 |
1255 SetDParam(2, i); // {SHORTCARGO} #1 |
1256 SetDParam(3, tot_cargo[i][1]); // {SHORTCARGO} #2 |
1256 SetDParam(3, tot_cargo[i][1]); // {SHORTCARGO} #2 |
1257 DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY, 0); |
1257 DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY, 0); |
1258 } |
1258 } |
1259 } |
1259 } |
1260 } |
1260 } |
1261 } |
1261 } |
1273 case 2: /* name train */ |
1273 case 2: /* name train */ |
1274 v = GetVehicle(w->window_number); |
1274 v = GetVehicle(w->window_number); |
1275 SetDParam(0, v->unitnumber); |
1275 SetDParam(0, v->unitnumber); |
1276 ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); |
1276 ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); |
1277 break; |
1277 break; |
1278 case 6: /* inc serv interval */ |
1278 case 6: /* inc serv interval */ |
1279 mod = _ctrl_pressed? 5 : 10; |
1279 mod = _ctrl_pressed? 5 : 10; |
1280 goto do_change_service_int; |
1280 goto do_change_service_int; |
1281 |
1281 |
1282 case 7: /* dec serv interval */ |
1282 case 7: /* dec serv interval */ |
1283 mod = _ctrl_pressed? -5 : -10; |
1283 mod = _ctrl_pressed? -5 : -10; |
1288 if (mod == v->service_interval) return; |
1288 if (mod == v->service_interval) return; |
1289 |
1289 |
1290 DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
1290 DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
1291 break; |
1291 break; |
1292 /* details buttons*/ |
1292 /* details buttons*/ |
1293 case 9: // Cargo |
1293 case 9: // Cargo |
1294 case 10: // Information |
1294 case 10: // Information |
1295 case 11: // Capacities |
1295 case 11: // Capacities |
1296 case 12: // Total cargo |
1296 case 12: // Total cargo |
1297 CLRBIT(w->disabled_state, 9); |
1297 CLRBIT(w->disabled_state, 9); |
1298 CLRBIT(w->disabled_state, 10); |
1298 CLRBIT(w->disabled_state, 10); |
1299 CLRBIT(w->disabled_state, 11); |
1299 CLRBIT(w->disabled_state, 11); |
1300 CLRBIT(w->disabled_state, 12); |
1300 CLRBIT(w->disabled_state, 12); |
1301 SETBIT(w->disabled_state, e->click.widget); |
1301 SETBIT(w->disabled_state, e->click.widget); |
1624 ShowPlayerTrainsLocal(player, station, INVALID_ORDER, false); |
1624 ShowPlayerTrainsLocal(player, station, INVALID_ORDER, false); |
1625 } |
1625 } |
1626 |
1626 |
1627 void ShowVehWithSharedOrdersTrains(Vehicle *v) |
1627 void ShowVehWithSharedOrdersTrains(Vehicle *v) |
1628 { |
1628 { |
1629 if (v->orders == NULL) return; // no shared list to show |
1629 if (v->orders == NULL) return; // no shared list to show |
1630 ShowPlayerTrainsLocal(v->owner, INVALID_STATION, v->orders->index, true); |
1630 ShowPlayerTrainsLocal(v->owner, INVALID_STATION, v->orders->index, true); |
1631 } |
1631 } |