changeset 4171 | 5c6e60c392c3 |
parent 4088 | 15e5d08bf433 |
child 4251 | e8f69de723e1 |
4170:81bafc4dd1b9 | 4171:5c6e60c392c3 |
---|---|
28 * @param engine_number the engine of which to draw the info of |
28 * @param engine_number the engine of which to draw the info of |
29 */ |
29 */ |
30 void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number) |
30 void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number) |
31 { |
31 { |
32 const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
32 const RailVehicleInfo *rvi = RailVehInfo(engine_number); |
33 const Engine* e = GetEngine(engine_number); |
33 const Engine *e = GetEngine(engine_number); |
34 int multihead = (rvi->flags&RVI_MULTIHEAD?1:0); |
34 int multihead = (rvi->flags&RVI_MULTIHEAD?1:0); |
35 YearMonthDay ymd; |
35 YearMonthDay ymd; |
36 ConvertDayToYMD(&ymd, e->intro_date); |
36 ConvertDayToYMD(&ymd, e->intro_date); |
37 |
37 |
38 /* Purchase Cost - Engine weight */ |
38 /* Purchase Cost - Engine weight */ |
130 y += ShowAdditionalText(x, y, 227, engine_number); |
130 y += ShowAdditionalText(x, y, 227, engine_number); |
131 } |
131 } |
132 |
132 |
133 void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2) |
133 void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2) |
134 { |
134 { |
135 Vehicle *v,*found; |
135 Vehicle *v, *found; |
136 |
136 |
137 if (!success) return; |
137 if (!success) return; |
138 |
138 |
139 // find a locomotive in the depot. |
139 // find a locomotive in the depot. |
140 found = NULL; |
140 found = NULL; |
156 } |
156 } |
157 } |
157 } |
158 |
158 |
159 void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2) |
159 void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2) |
160 { |
160 { |
161 const Vehicle* v; |
161 const Vehicle *v; |
162 |
162 |
163 if (!success) return; |
163 if (!success) return; |
164 |
164 |
165 v = GetVehicle(_new_vehicle_id); |
165 v = GetVehicle(_new_vehicle_id); |
166 if (tile == _backup_orders_tile) { |
166 if (tile == _backup_orders_tile) { |
174 { |
174 { |
175 if (success) ShowTrainViewWindow(GetVehicle(_new_vehicle_id)); |
175 if (success) ShowTrainViewWindow(GetVehicle(_new_vehicle_id)); |
176 } |
176 } |
177 |
177 |
178 static void engine_drawing_loop(int *x, int *y, int *pos, int *sel, |
178 static void engine_drawing_loop(int *x, int *y, int *pos, int *sel, |
179 EngineID* selected_id, RailType railtype, byte show_max, bool is_engine) |
179 EngineID *selected_id, RailType railtype, byte show_max, bool is_engine) |
180 { |
180 { |
181 EngineID j; |
181 EngineID j; |
182 |
182 |
183 for (j = 0; j < NUM_TRAIN_ENGINES; j++) { |
183 for (j = 0; j < NUM_TRAIN_ENGINES; j++) { |
184 EngineID i = GetRailVehAtPosition(j); |
184 EngineID i = GetRailVehAtPosition(j); |
617 /** |
617 /** |
618 * Clones a train |
618 * Clones a train |
619 * @param *v is the original vehicle to clone |
619 * @param *v is the original vehicle to clone |
620 * @param *w is the window of the depot where the clone is build |
620 * @param *w is the window of the depot where the clone is build |
621 */ |
621 */ |
622 static void HandleCloneVehClick(const Vehicle* v, const Window* w) |
622 static void HandleCloneVehClick(const Vehicle *v, const Window *w) |
623 { |
623 { |
624 if (v == NULL || v->type != VEH_Train) return; |
624 if (v == NULL || v->type != VEH_Train) return; |
625 |
625 |
626 // for train vehicles: subtype 0 for locs and not zero for others |
626 // for train vehicles: subtype 0 for locs and not zero for others |
627 if (!IsFrontEngine(v)) { |
627 if (!IsFrontEngine(v)) { |
635 ); |
635 ); |
636 |
636 |
637 ResetObjectToPlace(); |
637 ResetObjectToPlace(); |
638 } |
638 } |
639 |
639 |
640 static void ClonePlaceObj(const Window* w) |
640 static void ClonePlaceObj(const Window *w) |
641 { |
641 { |
642 Vehicle* v = CheckMouseOverVehicle(); |
642 Vehicle *v = CheckMouseOverVehicle(); |
643 |
643 |
644 if (v != NULL) HandleCloneVehClick(v, w); |
644 if (v != NULL) HandleCloneVehClick(v, w); |
645 } |
645 } |
646 |
646 |
647 static void TrainDepotWndProc(Window *w, WindowEvent *e) |
647 static void TrainDepotWndProc(Window *w, WindowEvent *e) |
688 InvalidateWidget(w, 9); |
688 InvalidateWidget(w, 9); |
689 break; |
689 break; |
690 |
690 |
691 // check if a vehicle in a depot was clicked.. |
691 // check if a vehicle in a depot was clicked.. |
692 case WE_MOUSELOOP: { |
692 case WE_MOUSELOOP: { |
693 const Vehicle* v = _place_clicked_vehicle; |
693 const Vehicle *v = _place_clicked_vehicle; |
694 |
694 |
695 // since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button |
695 // since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button |
696 if (v != NULL && HASBIT(w->click_state, 9)) { |
696 if (v != NULL && HASBIT(w->click_state, 9)) { |
697 _place_clicked_vehicle = NULL; |
697 _place_clicked_vehicle = NULL; |
698 HandleCloneVehClick(v, w); |
698 HandleCloneVehClick(v, w); |
912 { WWT_PANEL, RESIZE_LRB, 14, 232, 249, 122, 121, 0x0, STR_NULL }, |
912 { WWT_PANEL, RESIZE_LRB, 14, 232, 249, 122, 121, 0x0, STR_NULL }, |
913 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 122, 133, 0x0, STR_NULL }, |
913 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 122, 133, 0x0, STR_NULL }, |
914 { WIDGETS_END } |
914 { WIDGETS_END } |
915 }; |
915 }; |
916 |
916 |
917 static void ShowTrainDetailsWindow(const Vehicle* v); |
917 static void ShowTrainDetailsWindow(const Vehicle *v); |
918 |
918 |
919 static void TrainViewWndProc(Window *w, WindowEvent *e) |
919 static void TrainViewWndProc(Window *w, WindowEvent *e) |
920 { |
920 { |
921 switch (e->event) { |
921 switch (e->event) { |
922 case WE_PAINT: { |
922 case WE_PAINT: { |
1051 DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
1051 DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
1052 DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
1052 DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
1053 break; |
1053 break; |
1054 |
1054 |
1055 case WE_MOUSELOOP: { |
1055 case WE_MOUSELOOP: { |
1056 const Vehicle* v = GetVehicle(w->window_number); |
1056 const Vehicle *v = GetVehicle(w->window_number); |
1057 uint32 h; |
1057 uint32 h; |
1058 |
1058 |
1059 assert(v->type == VEH_Train); |
1059 assert(v->type == VEH_Train); |
1060 h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9)| (1 << 7) : (1 << 12) | (1 << 13); |
1060 h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9)| (1 << 7) : (1 << 12) | (1 << 13); |
1061 if (h != w->hidden_state) { |
1061 if (h != w->hidden_state) { |
1074 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
1074 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
1075 _train_view_widgets, |
1075 _train_view_widgets, |
1076 TrainViewWndProc |
1076 TrainViewWndProc |
1077 }; |
1077 }; |
1078 |
1078 |
1079 void ShowTrainViewWindow(const Vehicle* v) |
1079 void ShowTrainViewWindow(const Vehicle *v) |
1080 { |
1080 { |
1081 Window* w = AllocateWindowDescFront(&_train_view_desc,v->index); |
1081 Window *w = AllocateWindowDescFront(&_train_view_desc,v->index); |
1082 |
1082 |
1083 if (w != NULL) { |
1083 if (w != NULL) { |
1084 w->caption_color = v->owner; |
1084 w->caption_color = v->owner; |
1085 AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0); |
1085 AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0); |
1086 } |
1086 } |
1339 _train_details_widgets, |
1339 _train_details_widgets, |
1340 TrainDetailsWndProc |
1340 TrainDetailsWndProc |
1341 }; |
1341 }; |
1342 |
1342 |
1343 |
1343 |
1344 static void ShowTrainDetailsWindow(const Vehicle* v) |
1344 static void ShowTrainDetailsWindow(const Vehicle *v) |
1345 { |
1345 { |
1346 Window *w; |
1346 Window *w; |
1347 VehicleID veh = v->index; |
1347 VehicleID veh = v->index; |
1348 |
1348 |
1349 DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
1349 DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
1483 ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0); |
1483 ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0); |
1484 return; |
1484 return; |
1485 |
1485 |
1486 case 7: { /* Matrix to show vehicles */ |
1486 case 7: { /* Matrix to show vehicles */ |
1487 uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
1487 uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
1488 const Vehicle* v; |
1488 const Vehicle *v; |
1489 |
1489 |
1490 if (id_v >= w->vscroll.cap) return; // click out of bounds |
1490 if (id_v >= w->vscroll.cap) return; // click out of bounds |
1491 |
1491 |
1492 id_v += w->vscroll.pos; |
1492 id_v += w->vscroll.pos; |
1493 |
1493 |