28 */ |
28 */ |
29 void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number) |
29 void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number) |
30 { |
30 { |
31 const RoadVehicleInfo *rvi = RoadVehInfo(engine_number); |
31 const RoadVehicleInfo *rvi = RoadVehInfo(engine_number); |
32 const Engine* e = GetEngine(engine_number); |
32 const Engine* e = GetEngine(engine_number); |
|
33 bool refittable = (_engine_info[engine_number].refit_mask != 0); |
33 YearMonthDay ymd; |
34 YearMonthDay ymd; |
34 ConvertDayToYMD(&ymd, e->intro_date); |
35 ConvertDayToYMD(&ymd, e->intro_date); |
35 |
36 |
36 /* Purchase cost - Max speed */ |
37 /* Purchase cost - Max speed */ |
37 SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5); |
38 SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5); |
45 y += 10; |
46 y += 10; |
46 |
47 |
47 /* Cargo type + capacity */ |
48 /* Cargo type + capacity */ |
48 SetDParam(0, _cargoc.names_long[rvi->cargo_type]); |
49 SetDParam(0, _cargoc.names_long[rvi->cargo_type]); |
49 SetDParam(1, rvi->capacity); |
50 SetDParam(1, rvi->capacity); |
50 SetDParam(2, STR_EMPTY); |
51 SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY); |
51 DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
52 DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
52 y += 10; |
53 y += 10; |
53 |
54 |
54 /* Design date - Life length */ |
55 /* Design date - Life length */ |
55 SetDParam(0, ymd.year + 1920); |
56 SetDParam(0, ymd.year + 1920); |
69 DrawSprite(GetRoadVehImage(v, DIR_W) | pal, x + 14, y + 6); |
70 DrawSprite(GetRoadVehImage(v, DIR_W) | pal, x + 14, y + 6); |
70 |
71 |
71 if (v->index == selection) { |
72 if (v->index == selection) { |
72 DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY); |
73 DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY); |
73 } |
74 } |
|
75 } |
|
76 |
|
77 static void RoadVehRefitWndProc(Window *w, WindowEvent *e) |
|
78 { |
|
79 switch (e->event) { |
|
80 case WE_PAINT: { |
|
81 const Vehicle *v = GetVehicle(w->window_number); |
|
82 |
|
83 SetDParam(0, v->string_id); |
|
84 SetDParam(1, v->unitnumber); |
|
85 DrawWindowWidgets(w); |
|
86 |
|
87 DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
88 |
|
89 WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w,refit_d).sel); |
|
90 |
|
91 if (WP(w,refit_d).cargo != CT_INVALID) { |
|
92 int32 cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_ROAD_VEH); |
|
93 if (!CmdFailed(cost)) { |
|
94 SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]); |
|
95 SetDParam(1, _returned_refit_capacity); |
|
96 SetDParam(2, cost); |
|
97 DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); |
|
98 } |
|
99 } |
|
100 |
|
101 break; |
|
102 } |
|
103 |
|
104 case WE_CLICK: |
|
105 switch (e->click.widget) { |
|
106 case 2: { /* List box */ |
|
107 int y = e->click.pt.y - 25; |
|
108 if (y >= 0) { |
|
109 WP(w,refit_d).sel = y / 10; |
|
110 SetWindowDirty(w); |
|
111 } |
|
112 |
|
113 break; |
|
114 } |
|
115 |
|
116 case 4: /* Refit button */ |
|
117 if (WP(w,refit_d).cargo != CT_INVALID) { |
|
118 const Vehicle *v = GetVehicle(w->window_number); |
|
119 if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_ROAD_VEH | CMD_MSG(STR_REFIT_ROAD_VEHICLE_CAN_T))) |
|
120 DeleteWindow(w); |
|
121 } |
|
122 break; |
|
123 } |
|
124 break; |
|
125 } |
|
126 } |
|
127 |
|
128 static const Widget _road_veh_refit_widgets[] = { |
|
129 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
|
130 { WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
|
131 { WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_983D_SELECT_TYPE_OF_CARGO_FOR }, |
|
132 { WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 136, 157, 0x0, STR_NULL }, |
|
133 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_REFIT_ROAD_VEHICLE, STR_REFIT_ROAD_VEHICLE_TO_CARRY_HIGHLIGHTED }, |
|
134 { WIDGETS_END }, |
|
135 }; |
|
136 |
|
137 static const WindowDesc _road_veh_refit_desc = { |
|
138 -1, -1, 240, 170, |
|
139 WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, |
|
140 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
141 _road_veh_refit_widgets, |
|
142 RoadVehRefitWndProc, |
|
143 }; |
|
144 |
|
145 static void ShowRoadVehRefitWindow(const Vehicle *v) |
|
146 { |
|
147 Window *w; |
|
148 |
|
149 DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
150 |
|
151 _alloc_wnd_parent_num = v->index; |
|
152 w = AllocateWindowDesc(&_road_veh_refit_desc); |
|
153 w->window_number = v->index; |
|
154 w->caption_color = v->owner; |
|
155 WP(w,refit_d).sel = -1; |
74 } |
156 } |
75 |
157 |
76 static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) |
158 static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) |
77 { |
159 { |
78 switch (e->event) { |
160 switch (e->event) { |
292 DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
377 DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); |
293 break; |
378 break; |
294 case 6: /* center main view */ |
379 case 6: /* center main view */ |
295 ScrollMainWindowTo(v->x_pos, v->y_pos); |
380 ScrollMainWindowTo(v->x_pos, v->y_pos); |
296 break; |
381 break; |
297 case 7: /* goto hangar */ |
382 case 7: /* goto depot */ |
298 DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT)); |
383 DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_ROADVEH_TO_DEPOT | CMD_MSG(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT)); |
299 break; |
384 break; |
300 case 8: /* turn around */ |
385 case 8: /* turn around */ |
301 DoCommandP(v->tile, v->index, 0, NULL, CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); |
386 DoCommandP(v->tile, v->index, 0, NULL, CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); |
302 break; |
387 break; |
350 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AE, STR_901F_SEND_VEHICLE_TO_DEPOT }, |
438 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AE, STR_901F_SEND_VEHICLE_TO_DEPOT }, |
351 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2CB, STR_9020_FORCE_VEHICLE_TO_TURN_AROUND }, |
439 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2CB, STR_9020_FORCE_VEHICLE_TO_TURN_AROUND }, |
352 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_901D_SHOW_VEHICLE_S_ORDERS }, |
440 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_901D_SHOW_VEHICLE_S_ORDERS }, |
353 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_9021_SHOW_ROAD_VEHICLE_DETAILS }, |
441 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_9021_SHOW_ROAD_VEHICLE_DETAILS }, |
354 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_ROADVEH, STR_CLONE_ROAD_VEHICLE_INFO }, |
442 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_ROADVEH, STR_CLONE_ROAD_VEHICLE_INFO }, |
|
443 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B4, STR_REFIT_ROAD_VEHICLE_TO_CARRY }, |
355 { WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, |
444 { WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, |
356 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, |
445 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, |
357 { WIDGETS_END } |
446 { WIDGETS_END } |
358 }; |
447 }; |
359 |
448 |