88 Vehicle *v; |
88 Vehicle *v; |
89 |
89 |
90 if (!success) |
90 if (!success) |
91 return; |
91 return; |
92 |
92 |
93 v = &_vehicles[_new_train_id]; |
93 v = GetVehicle(_new_train_id); |
94 if (tile == _backup_orders_tile) { |
94 if (tile == _backup_orders_tile) { |
95 _backup_orders_tile = 0; |
95 _backup_orders_tile = 0; |
96 RestoreVehicleOrders(v, _backup_orders_data); |
96 RestoreVehicleOrders(v, _backup_orders_data); |
97 } |
97 } |
98 ShowTrainViewWindow(v); |
98 ShowTrainViewWindow(v); |
551 return; |
551 return; |
552 |
552 |
553 if (WP(w,traindepot_d).sel == INVALID_VEHICLE) |
553 if (WP(w,traindepot_d).sel == INVALID_VEHICLE) |
554 return; |
554 return; |
555 |
555 |
556 v = &_vehicles[WP(w,traindepot_d).sel]; |
556 v = GetVehicle(WP(w,traindepot_d).sel); |
557 |
557 |
558 WP(w,traindepot_d).sel = INVALID_VEHICLE; |
558 WP(w,traindepot_d).sel = INVALID_VEHICLE; |
559 SetWindowDirty(w); |
559 SetWindowDirty(w); |
560 |
560 |
561 HandleButtonClick(w, e->click.widget); |
561 HandleButtonClick(w, e->click.widget); |
732 SetWindowDirty(w); |
732 SetWindowDirty(w); |
733 } |
733 } |
734 } break; |
734 } break; |
735 case 4: /* refit button */ |
735 case 4: /* refit button */ |
736 if (WP(w,refit_d).cargo != 0xFF) { |
736 if (WP(w,refit_d).cargo != 0xFF) { |
737 Vehicle *v = &_vehicles[w->window_number]; |
737 Vehicle *v = GetVehicle(w->window_number); |
738 if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE))) |
738 if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE))) |
739 DeleteWindow(w); |
739 DeleteWindow(w); |
740 } |
740 } |
741 break; |
741 break; |
742 } |
742 } |
862 DrawWindowViewport(w); |
862 DrawWindowViewport(w); |
863 } break; |
863 } break; |
864 |
864 |
865 case WE_CLICK: { |
865 case WE_CLICK: { |
866 int wid = e->click.widget; |
866 int wid = e->click.widget; |
867 Vehicle *v = &_vehicles[w->window_number]; |
867 Vehicle *v = GetVehicle(w->window_number); |
868 |
868 |
869 switch(wid) { |
869 switch(wid) { |
870 case 5: /* start/stop train */ |
870 case 5: /* start/stop train */ |
871 DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
871 DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
872 break; |
872 break; |
1001 |
1001 |
1002 // det_tab == 3 <-- Total Cargo tab |
1002 // det_tab == 3 <-- Total Cargo tab |
1003 if (det_tab == 3) // reset tot_cargo array to 0 values |
1003 if (det_tab == 3) // reset tot_cargo array to 0 values |
1004 memset(tot_cargo, 0, sizeof(tot_cargo)); |
1004 memset(tot_cargo, 0, sizeof(tot_cargo)); |
1005 |
1005 |
1006 u = v = &_vehicles[w->window_number]; |
1006 u = v = GetVehicle(w->window_number); |
1007 do { |
1007 do { |
1008 if (det_tab != 3) |
1008 if (det_tab != 3) |
1009 num++; |
1009 num++; |
1010 else { |
1010 else { |
1011 tot_cargo[u->cargo_type][0] += u->cargo_count; |
1011 tot_cargo[u->cargo_type][0] += u->cargo_count; |
1112 case WE_CLICK: { |
1112 case WE_CLICK: { |
1113 int mod; |
1113 int mod; |
1114 Vehicle *v; |
1114 Vehicle *v; |
1115 switch(e->click.widget) { |
1115 switch(e->click.widget) { |
1116 case 2: /* name train */ |
1116 case 2: /* name train */ |
1117 v = &_vehicles[w->window_number]; |
1117 v = GetVehicle(w->window_number); |
1118 SetDParam(0, v->unitnumber); |
1118 SetDParam(0, v->unitnumber); |
1119 ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number); |
1119 ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number); |
1120 break; |
1120 break; |
1121 case 6: /* inc serv interval */ |
1121 case 6: /* inc serv interval */ |
1122 mod = _ctrl_pressed? 5 : 10; |
1122 mod = _ctrl_pressed? 5 : 10; |
1123 goto do_change_service_int; |
1123 goto do_change_service_int; |
1124 |
1124 |
1125 case 7: /* dec serv interval */ |
1125 case 7: /* dec serv interval */ |
1126 mod = _ctrl_pressed? -5 : -10; |
1126 mod = _ctrl_pressed? -5 : -10; |
1127 do_change_service_int: |
1127 do_change_service_int: |
1128 v = &_vehicles[w->window_number]; |
1128 v = GetVehicle(w->window_number); |
1129 mod += v->service_interval; |
1129 mod += v->service_interval; |
1130 |
1130 |
1131 /* %-based service interval max 5%-90% |
1131 /* %-based service interval max 5%-90% |
1132 day-based service interval max 30-800 days */ |
1132 day-based service interval max 30-800 days */ |
1133 mod = _patches.servint_ispercent ? clamp(mod, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(mod, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS+1); |
1133 mod = _patches.servint_ispercent ? clamp(mod, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : clamp(mod, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS+1); |
1274 SetDParam(1, p->name_2); |
1274 SetDParam(1, p->name_2); |
1275 SetDParam(2, w->vscroll.count); |
1275 SetDParam(2, w->vscroll.count); |
1276 w->widget[1].unkA = STR_881B_TRAINS; |
1276 w->widget[1].unkA = STR_881B_TRAINS; |
1277 } else { |
1277 } else { |
1278 /* Station Name -- (###) Trains */ |
1278 /* Station Name -- (###) Trains */ |
1279 SetDParam(0, DEREF_STATION(station)->index); |
1279 SetDParam(0, GetStation(station)->index); |
1280 SetDParam(1, w->vscroll.count); |
1280 SetDParam(1, w->vscroll.count); |
1281 w->widget[1].unkA = STR_SCHEDULED_TRAINS; |
1281 w->widget[1].unkA = STR_SCHEDULED_TRAINS; |
1282 } |
1282 } |
1283 DrawWindowWidgets(w); |
1283 DrawWindowWidgets(w); |
1284 } |
1284 } |
1288 DoDrawString( |
1288 DoDrawString( |
1289 vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10); |
1289 vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10); |
1290 |
1290 |
1291 max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
1291 max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
1292 for (i = w->vscroll.pos; i < max; ++i) { |
1292 for (i = w->vscroll.pos; i < max; ++i) { |
1293 Vehicle *v = DEREF_VEHICLE(vl->sort_list[i].index); |
1293 Vehicle *v = GetVehicle(vl->sort_list[i].index); |
1294 StringID str; |
1294 StringID str; |
1295 |
1295 |
1296 assert(v->type == VEH_Train && v->owner == owner); |
1296 assert(v->type == VEH_Train && v->owner == owner); |
1297 |
1297 |
1298 DrawTrainImage( |
1298 DrawTrainImage( |