author | dominik |
Tue, 24 Aug 2004 09:09:49 +0000 | |
changeset 127 | 815ec4d365e2 |
parent 44 | 1923acc255d1 |
child 176 | 84990c4b9212 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
3 |
#include "window.h" |
|
4 |
#include "gui.h" |
|
5 |
#include "gfx.h" |
|
6 |
#include "vehicle.h" |
|
7 |
#include "station.h" |
|
8 |
#include "town.h" |
|
9 |
#include "command.h" |
|
10 |
#include "viewport.h" |
|
11 |
||
12 |
static int OrderGetSel(Window *w) |
|
13 |
{ |
|
14 |
Vehicle *v = &_vehicles[w->window_number]; |
|
15 |
uint16 *sched = v->schedule_ptr; |
|
16 |
int num = WP(w,order_d).sel; |
|
17 |
int count = 0; |
|
18 |
||
19 |
if (num == 0) |
|
20 |
return 0; |
|
21 |
||
22 |
while (*sched != 0) { |
|
23 |
sched++; |
|
24 |
count++; |
|
25 |
if (--num == 0) |
|
26 |
break; |
|
27 |
} |
|
28 |
||
29 |
return count; |
|
30 |
} |
|
31 |
||
32 |
static void DrawOrdersWindow(Window *w) |
|
33 |
{ |
|
34 |
Vehicle *v; |
|
35 |
int num, sel; |
|
36 |
uint16 *sched, ord; |
|
37 |
int y, i; |
|
38 |
StringID str; |
|
39 |
bool shared_schedule; |
|
40 |
||
41 |
v = &_vehicles[w->window_number]; |
|
42 |
||
43 |
w->disabled_state = (v->owner == _local_player) ? 0 : 0x3F0; |
|
44 |
||
45 |
shared_schedule = IsScheduleShared(v) != NULL; |
|
46 |
||
47 |
sched = v->schedule_ptr; |
|
48 |
num=0; |
|
49 |
while (*sched != 0) |
|
50 |
sched++,num++; |
|
51 |
||
52 |
if ((uint)num + shared_schedule <= (uint)WP(w,order_d).sel) |
|
53 |
SETBIT(w->disabled_state, 5); /* delete */ |
|
54 |
||
55 |
if (num == 0) |
|
56 |
SETBIT(w->disabled_state, 4); /* skip */ |
|
57 |
||
58 |
SetVScrollCount(w, num+1); |
|
59 |
||
60 |
sel = OrderGetSel(w); |
|
61 |
||
62 |
SET_DPARAM16(2,STR_8827_FULL_LOAD); |
|
63 |
switch(v->schedule_ptr[sel] & 0x1F) { |
|
64 |
case OT_GOTO_STATION: |
|
65 |
break; |
|
66 |
case OT_GOTO_DEPOT: |
|
67 |
SETBIT(w->disabled_state, 9); /* unload */ |
|
68 |
SET_DPARAM16(2,STR_SERVICE); |
|
69 |
break; |
|
70 |
default: |
|
71 |
SETBIT(w->disabled_state, 6); /* nonstop */ |
|
72 |
SETBIT(w->disabled_state, 8); /* full load */ |
|
73 |
SETBIT(w->disabled_state, 9); /* unload */ |
|
74 |
} |
|
75 |
||
76 |
SET_DPARAM16(0, v->string_id); |
|
77 |
SET_DPARAM16(1, v->unitnumber); |
|
78 |
DrawWindowWidgets(w); |
|
79 |
||
80 |
y = 15; |
|
81 |
||
82 |
i = 0; |
|
83 |
for(;;) { |
|
84 |
str = ((byte)v->cur_order_index == i) ? STR_8805 : STR_8804; |
|
85 |
||
86 |
ord = v->schedule_ptr[i]; |
|
87 |
||
88 |
if ( (uint)(i - w->vscroll.pos) < 6) { |
|
89 |
||
90 |
if (ord == 0) { |
|
91 |
str = shared_schedule ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS; |
|
92 |
} else { |
|
93 |
SET_DPARAM16(1, 6); |
|
94 |
||
95 |
if ( (ord & OT_MASK) == OT_GOTO_STATION) { |
|
96 |
SET_DPARAM16(1, STR_8806_GO_TO + ((ord >> 5) & 7)); |
|
97 |
SET_DPARAM16(2, ord >> 8); |
|
98 |
} else if ((ord & OT_MASK) == OT_GOTO_DEPOT) { |
|
99 |
StringID s = STR_NULL; |
|
100 |
if (v->type == VEH_Aircraft) { |
|
101 |
s = STR_GO_TO_AIRPORT_HANGAR; |
|
102 |
SET_DPARAM16(2, ord>>8); |
|
103 |
} else { |
|
104 |
SET_DPARAM16(2, _depots[ord >> 8].town_index); |
|
105 |
switch (v->type) { |
|
106 |
case VEH_Train: s = STR_880E_GO_TO_TRAIN_DEPOT; break; |
|
107 |
case VEH_Road: s = STR_9038_GO_TO_ROADVEH_DEPOT; break; |
|
108 |
case VEH_Ship: s = STR_GO_TO_SHIP_DEPOT; break; |
|
109 |
} |
|
110 |
} |
|
111 |
if (v->type == VEH_Train) |
|
112 |
s += (ord>>6)&2; |
|
113 |
SET_DPARAM16(1, s + ((ord>>6)&1) ); |
|
114 |
} else if ((ord & OT_MASK) == OT_GOTO_CHECKPOINT) { |
|
115 |
SET_DPARAM16(2, ord >> 8); |
|
116 |
SET_DPARAM16(1, STR_GO_TO_CHECKPOINT); |
|
117 |
} |
|
118 |
} |
|
119 |
{ |
|
120 |
byte color = (i == WP(w,order_d).sel) ? 0xC : 0x10; |
|
121 |
SET_DPARAM(0, i+1); |
|
127
815ec4d365e2
(svn r128) Invalid (void) orders in schedule are highlighted in red (Celestar)
dominik
parents:
44
diff
changeset
|
122 |
if ((ord & OT_MASK) != OT_DUMMY) { |
815ec4d365e2
(svn r128) Invalid (void) orders in schedule are highlighted in red (Celestar)
dominik
parents:
44
diff
changeset
|
123 |
DrawString(2, y, str, color); |
815ec4d365e2
(svn r128) Invalid (void) orders in schedule are highlighted in red (Celestar)
dominik
parents:
44
diff
changeset
|
124 |
} else { |
815ec4d365e2
(svn r128) Invalid (void) orders in schedule are highlighted in red (Celestar)
dominik
parents:
44
diff
changeset
|
125 |
SET_DPARAM16(1, STR_INVALID_ORDER); |
815ec4d365e2
(svn r128) Invalid (void) orders in schedule are highlighted in red (Celestar)
dominik
parents:
44
diff
changeset
|
126 |
SET_DPARAM16(2, ord >> 8); |
815ec4d365e2
(svn r128) Invalid (void) orders in schedule are highlighted in red (Celestar)
dominik
parents:
44
diff
changeset
|
127 |
DrawString(2, y, str, color); |
815ec4d365e2
(svn r128) Invalid (void) orders in schedule are highlighted in red (Celestar)
dominik
parents:
44
diff
changeset
|
128 |
} |
0 | 129 |
} |
130 |
y += 10; |
|
131 |
} |
|
132 |
||
133 |
i++; |
|
134 |
||
135 |
if (ord == 0) |
|
136 |
break; |
|
137 |
} |
|
138 |
} |
|
139 |
||
140 |
||
141 |
// lookup a vehicle on a tile |
|
142 |
typedef struct { |
|
143 |
TileIndex tile; |
|
144 |
byte owner; |
|
145 |
byte type; |
|
146 |
} FindVehS; |
|
147 |
||
148 |
static void *FindVehicleCallb(Vehicle *v, FindVehS *f) |
|
149 |
{ |
|
150 |
if (v->tile != f->tile || v->owner != f->owner || v->vehstatus & VS_HIDDEN ) return NULL; |
|
151 |
return v; |
|
152 |
} |
|
153 |
||
154 |
Vehicle *GetVehicleOnTile(TileIndex tile, byte owner) |
|
155 |
{ |
|
156 |
FindVehS fs = {tile, owner}; |
|
157 |
return VehicleFromPos(tile, &fs, (VehicleFromPosProc*)FindVehicleCallb); |
|
158 |
} |
|
159 |
||
160 |
static uint GetOrderCmdFromTile(Vehicle *v, uint tile) |
|
161 |
{ |
|
162 |
Station *st; |
|
163 |
int st_index; |
|
164 |
||
165 |
// check depot first |
|
166 |
if (_patches.gotodepot) { |
|
167 |
switch(GET_TILETYPE(tile)) { |
|
168 |
case MP_RAILWAY: |
|
169 |
if (v->type == VEH_Train && _map_owner[tile] == _local_player) { |
|
170 |
if ((_map5[tile]&0xFC)==0xC0) |
|
171 |
return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD; |
|
172 |
||
173 |
if ((_map5[tile]&0xFE)==0xC4) |
|
174 |
return (GetCheckpointByTile(tile)<<8) | OT_GOTO_CHECKPOINT; |
|
175 |
} |
|
176 |
break; |
|
177 |
||
178 |
case MP_STREET: |
|
179 |
if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player) |
|
180 |
return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD; |
|
181 |
break; |
|
182 |
||
183 |
case MP_STATION: |
|
184 |
if (v->type != VEH_Aircraft) break; |
|
185 |
if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player) |
|
186 |
return (_map2[tile]<<8) | OF_UNLOAD | OT_GOTO_DEPOT | OF_NON_STOP; |
|
187 |
break; |
|
188 |
||
189 |
case MP_WATER: |
|
190 |
if (v->type != VEH_Ship) break; |
|
191 |
if ( IsShipDepotTile(tile) && _map_owner[tile] == _local_player) { |
|
192 |
switch (_map5[tile]) { |
|
193 |
case 0x81: tile--; break; |
|
194 |
case 0x83: tile-= TILE_XY(0,1); break; |
|
195 |
} |
|
196 |
return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD; |
|
197 |
} |
|
198 |
} |
|
199 |
} |
|
200 |
||
201 |
if (IS_TILETYPE(tile, MP_STATION)) { |
|
202 |
st = DEREF_STATION(st_index = _map2[tile]); |
|
203 |
||
204 |
if (st->owner == _current_player || st->owner == OWNER_NONE) { |
|
205 |
byte facil; |
|
206 |
(facil=FACIL_DOCK, v->type == VEH_Ship) || |
|
207 |
(facil=FACIL_TRAIN, v->type == VEH_Train) || |
|
208 |
(facil=FACIL_AIRPORT, v->type == VEH_Aircraft) || |
|
209 |
(facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) || |
|
210 |
(facil=FACIL_TRUCK_STOP, 1); |
|
211 |
if (st->facilities & facil) |
|
212 |
return (st_index << 8) | OT_GOTO_STATION; |
|
213 |
} |
|
214 |
} |
|
215 |
||
216 |
// not found |
|
217 |
return (uint)-1; |
|
218 |
} |
|
219 |
||
220 |
static bool HandleOrderVehClick(Vehicle *v, Vehicle *u, Window *w) |
|
221 |
{ |
|
222 |
if (u->type != v->type) |
|
223 |
return false; |
|
224 |
||
225 |
if (u->type == VEH_Train && u->subtype != 0) { |
|
226 |
u = GetFirstVehicleInChain(u); |
|
227 |
if (u->subtype != 0) |
|
228 |
return false; |
|
229 |
} |
|
230 |
||
231 |
// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet |
|
232 |
// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing |
|
233 |
if (v->num_orders != 0 && _ctrl_pressed == 0) {return false;} |
|
234 |
||
235 |
if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL, |
|
236 |
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) { |
|
237 |
WP(w,order_d).sel = -1; |
|
238 |
ResetObjectToPlace(); |
|
239 |
} |
|
240 |
||
241 |
return true; |
|
242 |
} |
|
243 |
||
244 |
static void OrdersPlaceObj(Vehicle *v, uint tile, Window *w) |
|
245 |
{ |
|
246 |
uint cmd; |
|
247 |
Vehicle *u; |
|
248 |
||
249 |
// check if we're clicking on a vehicle first.. clone orders in that case. |
|
250 |
u = CheckMouseOverVehicle(); |
|
251 |
if (u && HandleOrderVehClick(v, u, w)) |
|
252 |
return; |
|
253 |
||
254 |
cmd = GetOrderCmdFromTile(v, tile); |
|
255 |
if ( cmd == (uint)-1) return; |
|
256 |
||
257 |
if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), cmd, NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) { |
|
258 |
if (WP(w,order_d).sel != -1) |
|
259 |
WP(w,order_d).sel++; |
|
260 |
ResetObjectToPlace(); |
|
261 |
} |
|
262 |
} |
|
263 |
||
264 |
||
265 |
static void OrdersWndProc(Window *w, WindowEvent *e) |
|
266 |
{ |
|
267 |
switch(e->event) { |
|
268 |
case WE_PAINT: |
|
269 |
DrawOrdersWindow(w); |
|
270 |
break; |
|
271 |
||
272 |
case WE_CLICK: { |
|
273 |
Vehicle *v = &_vehicles[w->window_number]; |
|
274 |
int mode; |
|
275 |
switch(e->click.widget) { |
|
276 |
case 2: {/* orders list */ |
|
277 |
int sel; |
|
278 |
sel = (e->click.pt.y - 15) / 10; |
|
279 |
||
280 |
if ( (uint) sel >= 6) |
|
281 |
return; |
|
282 |
||
283 |
sel += w->vscroll.pos; |
|
284 |
||
44
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
285 |
if (_ctrl_pressed && sel < v->num_orders) { // watch out for schedule_ptr overflow |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
286 |
int ord = v->schedule_ptr[sel]; |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
287 |
int xy = 0; |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
288 |
switch (ord & OT_MASK) { |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
289 |
case OT_GOTO_STATION: /* station order */ |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
290 |
xy = _stations[ord >> 8].xy ; |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
291 |
break; |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
292 |
case OT_GOTO_DEPOT: /* goto depot order */ |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
293 |
xy = _depots[ord >> 8].xy; |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
294 |
break; |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
295 |
case OT_GOTO_CHECKPOINT: /* goto checkpoint order */ |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
296 |
xy = _checkpoints[ord >> 8].xy; |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
297 |
} |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
298 |
|
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
299 |
if (xy) |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
300 |
ScrollMainWindowToTile(xy); |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
301 |
|
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
302 |
return; |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
303 |
} |
1923acc255d1
(svn r45) -Feature [992998] Scrollto Station in Orders. CTRL click on orders of a vehicle and main-window scrolls to that station. (chrishuebsch)
darkvater
parents:
25
diff
changeset
|
304 |
|
0 | 305 |
if (sel == WP(w,order_d).sel) sel = -1; |
306 |
WP(w,order_d).sel = sel; |
|
307 |
SetWindowDirty(w); |
|
308 |
} break; |
|
309 |
||
310 |
case 4: /* skip button */ |
|
311 |
DoCommandP(v->tile,v->index, 0, NULL, CMD_SKIP_ORDER); |
|
312 |
break; |
|
313 |
||
314 |
case 5: /* delete button */ |
|
315 |
DoCommandP(v->tile,v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER)); |
|
316 |
break; |
|
317 |
||
318 |
case 7: /* goto button */ |
|
319 |
InvalidateWidget(w, 7); |
|
320 |
w->click_state ^= 1<<7; |
|
321 |
if (HASBIT(w->click_state, 7)) { |
|
322 |
_place_clicked_vehicle = NULL; |
|
323 |
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, 1, w); |
|
324 |
} else { |
|
325 |
ResetObjectToPlace(); |
|
326 |
} |
|
327 |
break; |
|
328 |
||
329 |
case 8: /* full load button */ |
|
330 |
mode = 0; |
|
331 |
DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
|
332 |
break; |
|
333 |
||
334 |
case 9: /* unload button */ |
|
335 |
mode = 1; |
|
336 |
DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
|
337 |
break; |
|
338 |
||
339 |
case 6: /* non stop button */ |
|
340 |
mode = 2; |
|
341 |
DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
|
342 |
break; |
|
343 |
} |
|
344 |
} break; |
|
345 |
||
346 |
||
347 |
case WE_RCLICK: { |
|
348 |
Vehicle *v = &_vehicles[w->window_number]; |
|
349 |
if (e->click.widget != 8) break; |
|
350 |
if ((v->schedule_ptr[OrderGetSel(w)] & OT_MASK) == OT_GOTO_DEPOT) |
|
351 |
GuiShowTooltips(STR_SERVICE_HINT); |
|
352 |
else |
|
353 |
GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER); |
|
354 |
} break; |
|
355 |
||
356 |
case WE_4: { |
|
357 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
358 |
DeleteWindow(w); |
|
359 |
} break; |
|
360 |
||
361 |
case WE_PLACE_OBJ: { |
|
362 |
OrdersPlaceObj(&_vehicles[w->window_number], e->place.tile, w); |
|
363 |
} break; |
|
364 |
||
365 |
case WE_ABORT_PLACE_OBJ: { |
|
366 |
w->click_state &= ~(1<<7); |
|
367 |
InvalidateWidget(w, 7); |
|
368 |
} break; |
|
369 |
||
370 |
// check if a vehicle in a depot was clicked.. |
|
371 |
case WE_MOUSELOOP: { |
|
372 |
Vehicle *v = _place_clicked_vehicle; |
|
25 | 373 |
/* |
374 |
* Check if we clicked on a vehicle |
|
375 |
* and if the GOTO button of this window is pressed |
|
376 |
* This is because of all open order windows WE_MOUSELOOP is called |
|
377 |
* and if you have 3 windows open, and this check is not done |
|
378 |
* the order is copied to the last open window instead of the |
|
379 |
* one where GOTO is enalbed |
|
380 |
*/ |
|
381 |
if (v && HASBIT(w->click_state, 7)) { |
|
0 | 382 |
_place_clicked_vehicle = NULL; |
383 |
HandleOrderVehClick(&_vehicles[w->window_number], v, w); |
|
384 |
} |
|
385 |
} break; |
|
386 |
||
387 |
} |
|
388 |
} |
|
389 |
||
390 |
static const Widget _train_orders_widgets[] = { |
|
391 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
392 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
393 |
{ WWT_PANEL, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
|
394 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
395 |
{ WWT_PUSHTXTBTN, 14, 0, 52, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, |
|
396 |
{ WWT_PUSHTXTBTN, 14, 53, 105, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, |
|
397 |
{ WWT_PUSHTXTBTN, 14, 106, 158, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER}, |
|
398 |
{WWT_NODISTXTBTN, 14, 159, 211, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, |
|
399 |
{ WWT_PUSHTXTBTN, 14, 212, 264, 76, 87, STR_FULLLOAD_OR_SERVICE, 0}, |
|
400 |
{ WWT_PUSHTXTBTN, 14, 265, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
|
401 |
{ WWT_LAST}, |
|
402 |
}; |
|
403 |
||
404 |
static const WindowDesc _train_orders_desc = { |
|
405 |
-1,-1, 320, 88, |
|
406 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
407 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, |
|
408 |
_train_orders_widgets, |
|
409 |
OrdersWndProc |
|
410 |
}; |
|
411 |
||
412 |
static const Widget _other_train_orders_widgets[] = { |
|
413 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
414 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
415 |
{ WWT_PANEL, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
|
416 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
417 |
{ WWT_LAST}, |
|
418 |
}; |
|
419 |
||
420 |
static const WindowDesc _other_train_orders_desc = { |
|
421 |
-1,-1, 320, 76, |
|
422 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
423 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
424 |
_other_train_orders_widgets, |
|
425 |
OrdersWndProc |
|
426 |
}; |
|
427 |
||
428 |
||
429 |
static const Widget _roadveh_orders_widgets[] = { |
|
430 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
431 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_900B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
432 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0,STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
|
433 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
434 |
{ WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, |
|
435 |
{ WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, |
|
436 |
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0}, |
|
437 |
{WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, |
|
438 |
{ WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, 0}, |
|
439 |
{ WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
|
440 |
{ WWT_LAST}, |
|
441 |
}; |
|
442 |
||
443 |
static const WindowDesc _roadveh_orders_desc = { |
|
444 |
-1,-1, 320, 88, |
|
445 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
446 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, |
|
447 |
_roadveh_orders_widgets, |
|
448 |
OrdersWndProc |
|
449 |
}; |
|
450 |
||
451 |
static const Widget _other_roadveh_orders_widgets[] = { |
|
452 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
453 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_900B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
454 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0,STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
|
455 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
456 |
{ WWT_LAST}, |
|
457 |
}; |
|
458 |
||
459 |
static const WindowDesc _other_roadveh_orders_desc = { |
|
460 |
-1,-1, 320, 76, |
|
461 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
462 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
463 |
_other_roadveh_orders_widgets, |
|
464 |
OrdersWndProc |
|
465 |
}; |
|
466 |
||
467 |
static const Widget _ship_orders_widgets[] = { |
|
468 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
469 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_9810_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
470 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0,STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
|
471 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
472 |
{ WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, |
|
473 |
{ WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, |
|
474 |
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0}, |
|
475 |
{WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, |
|
476 |
{ WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, 0}, |
|
477 |
{ WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
|
478 |
{ WWT_LAST}, |
|
479 |
}; |
|
480 |
||
481 |
static const WindowDesc _ship_orders_desc = { |
|
482 |
-1,-1, 320, 88, |
|
483 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
484 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, |
|
485 |
_ship_orders_widgets, |
|
486 |
OrdersWndProc |
|
487 |
}; |
|
488 |
||
489 |
static const Widget _other_ship_orders_widgets[] = { |
|
490 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
491 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_9810_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
492 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0,STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
|
493 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
494 |
{ WWT_LAST}, |
|
495 |
}; |
|
496 |
||
497 |
static const WindowDesc _other_ship_orders_desc = { |
|
498 |
-1,-1, 320, 76, |
|
499 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
500 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
501 |
_other_ship_orders_widgets, |
|
502 |
OrdersWndProc |
|
503 |
}; |
|
504 |
||
505 |
||
506 |
static const Widget _aircraft_orders_widgets[] = { |
|
507 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
508 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
509 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
|
510 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
511 |
{ WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, |
|
512 |
{ WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, |
|
513 |
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0}, |
|
514 |
{WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, |
|
515 |
{ WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, 0}, |
|
516 |
{ WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
|
517 |
{ WWT_LAST}, |
|
518 |
}; |
|
519 |
||
520 |
static const WindowDesc _aircraft_orders_desc = { |
|
521 |
-1,-1, 320, 88, |
|
522 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
523 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, |
|
524 |
_aircraft_orders_widgets, |
|
525 |
OrdersWndProc |
|
526 |
}; |
|
527 |
||
528 |
static const Widget _other_aircraft_orders_widgets[] = { |
|
529 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
530 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
|
531 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
|
532 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
|
533 |
{ WWT_LAST}, |
|
534 |
}; |
|
535 |
||
536 |
static const WindowDesc _other_aircraft_orders_desc = { |
|
537 |
-1,-1, 320, 76, |
|
538 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
539 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
540 |
_other_aircraft_orders_widgets, |
|
541 |
OrdersWndProc |
|
542 |
}; |
|
543 |
||
544 |
static const WindowDesc * const _order_window_desc[8] = { |
|
545 |
&_train_orders_desc, &_other_train_orders_desc, |
|
546 |
&_roadveh_orders_desc, &_other_roadveh_orders_desc, |
|
547 |
&_ship_orders_desc, &_other_ship_orders_desc, |
|
548 |
&_aircraft_orders_desc, &_other_aircraft_orders_desc, |
|
549 |
}; |
|
550 |
||
551 |
||
552 |
void ShowOrdersWindow(Vehicle *v) |
|
553 |
{ |
|
554 |
Window *w; |
|
555 |
VehicleID veh = v->index; |
|
556 |
||
557 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
558 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
559 |
||
560 |
_alloc_wnd_parent_num = veh; |
|
561 |
w = AllocateWindowDesc( |
|
562 |
_order_window_desc[(v->type - VEH_Train)*2 + (v->owner != _local_player)]); |
|
563 |
||
564 |
w->window_number = veh; |
|
565 |
w->caption_color = v->owner; |
|
566 |
w->vscroll.cap = 6; |
|
567 |
WP(w,order_d).sel = -1; |
|
568 |
} |