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);
|
|
122 |
DrawString(2, y, str, color);
|
|
123 |
}
|
|
124 |
y += 10;
|
|
125 |
}
|
|
126 |
|
|
127 |
i++;
|
|
128 |
|
|
129 |
if (ord == 0)
|
|
130 |
break;
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
|
|
135 |
// lookup a vehicle on a tile
|
|
136 |
typedef struct {
|
|
137 |
TileIndex tile;
|
|
138 |
byte owner;
|
|
139 |
byte type;
|
|
140 |
} FindVehS;
|
|
141 |
|
|
142 |
static void *FindVehicleCallb(Vehicle *v, FindVehS *f)
|
|
143 |
{
|
|
144 |
if (v->tile != f->tile || v->owner != f->owner || v->vehstatus & VS_HIDDEN ) return NULL;
|
|
145 |
return v;
|
|
146 |
}
|
|
147 |
|
|
148 |
Vehicle *GetVehicleOnTile(TileIndex tile, byte owner)
|
|
149 |
{
|
|
150 |
FindVehS fs = {tile, owner};
|
|
151 |
return VehicleFromPos(tile, &fs, (VehicleFromPosProc*)FindVehicleCallb);
|
|
152 |
}
|
|
153 |
|
|
154 |
static uint GetOrderCmdFromTile(Vehicle *v, uint tile)
|
|
155 |
{
|
|
156 |
Station *st;
|
|
157 |
int st_index;
|
|
158 |
|
|
159 |
// check depot first
|
|
160 |
if (_patches.gotodepot) {
|
|
161 |
switch(GET_TILETYPE(tile)) {
|
|
162 |
case MP_RAILWAY:
|
|
163 |
if (v->type == VEH_Train && _map_owner[tile] == _local_player) {
|
|
164 |
if ((_map5[tile]&0xFC)==0xC0)
|
|
165 |
return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD;
|
|
166 |
|
|
167 |
if ((_map5[tile]&0xFE)==0xC4)
|
|
168 |
return (GetCheckpointByTile(tile)<<8) | OT_GOTO_CHECKPOINT;
|
|
169 |
}
|
|
170 |
break;
|
|
171 |
|
|
172 |
case MP_STREET:
|
|
173 |
if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player)
|
|
174 |
return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD;
|
|
175 |
break;
|
|
176 |
|
|
177 |
case MP_STATION:
|
|
178 |
if (v->type != VEH_Aircraft) break;
|
|
179 |
if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player)
|
|
180 |
return (_map2[tile]<<8) | OF_UNLOAD | OT_GOTO_DEPOT | OF_NON_STOP;
|
|
181 |
break;
|
|
182 |
|
|
183 |
case MP_WATER:
|
|
184 |
if (v->type != VEH_Ship) break;
|
|
185 |
if ( IsShipDepotTile(tile) && _map_owner[tile] == _local_player) {
|
|
186 |
switch (_map5[tile]) {
|
|
187 |
case 0x81: tile--; break;
|
|
188 |
case 0x83: tile-= TILE_XY(0,1); break;
|
|
189 |
}
|
|
190 |
return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD;
|
|
191 |
}
|
|
192 |
}
|
|
193 |
}
|
|
194 |
|
|
195 |
if (IS_TILETYPE(tile, MP_STATION)) {
|
|
196 |
st = DEREF_STATION(st_index = _map2[tile]);
|
|
197 |
|
|
198 |
if (st->owner == _current_player || st->owner == OWNER_NONE) {
|
|
199 |
byte facil;
|
|
200 |
(facil=FACIL_DOCK, v->type == VEH_Ship) ||
|
|
201 |
(facil=FACIL_TRAIN, v->type == VEH_Train) ||
|
|
202 |
(facil=FACIL_AIRPORT, v->type == VEH_Aircraft) ||
|
|
203 |
(facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) ||
|
|
204 |
(facil=FACIL_TRUCK_STOP, 1);
|
|
205 |
if (st->facilities & facil)
|
|
206 |
return (st_index << 8) | OT_GOTO_STATION;
|
|
207 |
}
|
|
208 |
}
|
|
209 |
|
|
210 |
// not found
|
|
211 |
return (uint)-1;
|
|
212 |
}
|
|
213 |
|
|
214 |
static bool HandleOrderVehClick(Vehicle *v, Vehicle *u, Window *w)
|
|
215 |
{
|
|
216 |
if (u->type != v->type)
|
|
217 |
return false;
|
|
218 |
|
|
219 |
if (u->type == VEH_Train && u->subtype != 0) {
|
|
220 |
u = GetFirstVehicleInChain(u);
|
|
221 |
if (u->subtype != 0)
|
|
222 |
return false;
|
|
223 |
}
|
|
224 |
|
|
225 |
// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
|
|
226 |
// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
|
|
227 |
if (v->num_orders != 0 && _ctrl_pressed == 0) {return false;}
|
|
228 |
|
|
229 |
if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL,
|
|
230 |
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
|
|
231 |
WP(w,order_d).sel = -1;
|
|
232 |
ResetObjectToPlace();
|
|
233 |
}
|
|
234 |
|
|
235 |
return true;
|
|
236 |
}
|
|
237 |
|
|
238 |
static void OrdersPlaceObj(Vehicle *v, uint tile, Window *w)
|
|
239 |
{
|
|
240 |
uint cmd;
|
|
241 |
Vehicle *u;
|
|
242 |
|
|
243 |
// check if we're clicking on a vehicle first.. clone orders in that case.
|
|
244 |
u = CheckMouseOverVehicle();
|
|
245 |
if (u && HandleOrderVehClick(v, u, w))
|
|
246 |
return;
|
|
247 |
|
|
248 |
cmd = GetOrderCmdFromTile(v, tile);
|
|
249 |
if ( cmd == (uint)-1) return;
|
|
250 |
|
|
251 |
if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), cmd, NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
|
|
252 |
if (WP(w,order_d).sel != -1)
|
|
253 |
WP(w,order_d).sel++;
|
|
254 |
ResetObjectToPlace();
|
|
255 |
}
|
|
256 |
}
|
|
257 |
|
|
258 |
|
|
259 |
static void OrdersWndProc(Window *w, WindowEvent *e)
|
|
260 |
{
|
|
261 |
switch(e->event) {
|
|
262 |
case WE_PAINT:
|
|
263 |
DrawOrdersWindow(w);
|
|
264 |
break;
|
|
265 |
|
|
266 |
case WE_CLICK: {
|
|
267 |
Vehicle *v = &_vehicles[w->window_number];
|
|
268 |
int mode;
|
|
269 |
switch(e->click.widget) {
|
|
270 |
case 2: {/* orders list */
|
|
271 |
int sel;
|
|
272 |
sel = (e->click.pt.y - 15) / 10;
|
|
273 |
|
|
274 |
if ( (uint) sel >= 6)
|
|
275 |
return;
|
|
276 |
|
|
277 |
sel += w->vscroll.pos;
|
|
278 |
|
|
279 |
if (sel == WP(w,order_d).sel) sel = -1;
|
|
280 |
WP(w,order_d).sel = sel;
|
|
281 |
SetWindowDirty(w);
|
|
282 |
} break;
|
|
283 |
|
|
284 |
case 4: /* skip button */
|
|
285 |
DoCommandP(v->tile,v->index, 0, NULL, CMD_SKIP_ORDER);
|
|
286 |
break;
|
|
287 |
|
|
288 |
case 5: /* delete button */
|
|
289 |
DoCommandP(v->tile,v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER));
|
|
290 |
break;
|
|
291 |
|
|
292 |
case 7: /* goto button */
|
|
293 |
InvalidateWidget(w, 7);
|
|
294 |
w->click_state ^= 1<<7;
|
|
295 |
if (HASBIT(w->click_state, 7)) {
|
|
296 |
_place_clicked_vehicle = NULL;
|
|
297 |
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, 1, w);
|
|
298 |
} else {
|
|
299 |
ResetObjectToPlace();
|
|
300 |
}
|
|
301 |
break;
|
|
302 |
|
|
303 |
case 8: /* full load button */
|
|
304 |
mode = 0;
|
|
305 |
DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
|
306 |
break;
|
|
307 |
|
|
308 |
case 9: /* unload button */
|
|
309 |
mode = 1;
|
|
310 |
DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
|
311 |
break;
|
|
312 |
|
|
313 |
case 6: /* non stop button */
|
|
314 |
mode = 2;
|
|
315 |
DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
|
316 |
break;
|
|
317 |
}
|
|
318 |
} break;
|
|
319 |
|
|
320 |
|
|
321 |
case WE_RCLICK: {
|
|
322 |
Vehicle *v = &_vehicles[w->window_number];
|
|
323 |
if (e->click.widget != 8) break;
|
|
324 |
if ((v->schedule_ptr[OrderGetSel(w)] & OT_MASK) == OT_GOTO_DEPOT)
|
|
325 |
GuiShowTooltips(STR_SERVICE_HINT);
|
|
326 |
else
|
|
327 |
GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER);
|
|
328 |
} break;
|
|
329 |
|
|
330 |
case WE_4: {
|
|
331 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL)
|
|
332 |
DeleteWindow(w);
|
|
333 |
} break;
|
|
334 |
|
|
335 |
case WE_PLACE_OBJ: {
|
|
336 |
OrdersPlaceObj(&_vehicles[w->window_number], e->place.tile, w);
|
|
337 |
} break;
|
|
338 |
|
|
339 |
case WE_ABORT_PLACE_OBJ: {
|
|
340 |
w->click_state &= ~(1<<7);
|
|
341 |
InvalidateWidget(w, 7);
|
|
342 |
} break;
|
|
343 |
|
|
344 |
// check if a vehicle in a depot was clicked..
|
|
345 |
case WE_MOUSELOOP: {
|
|
346 |
Vehicle *v = _place_clicked_vehicle;
|
|
347 |
if (v) {
|
|
348 |
_place_clicked_vehicle = NULL;
|
|
349 |
HandleOrderVehClick(&_vehicles[w->window_number], v, w);
|
|
350 |
}
|
|
351 |
} break;
|
|
352 |
|
|
353 |
}
|
|
354 |
}
|
|
355 |
|
|
356 |
static const Widget _train_orders_widgets[] = {
|
|
357 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
358 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
359 |
{ WWT_PANEL, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
|
|
360 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
361 |
{ WWT_PUSHTXTBTN, 14, 0, 52, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER},
|
|
362 |
{ WWT_PUSHTXTBTN, 14, 53, 105, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED},
|
|
363 |
{ WWT_PUSHTXTBTN, 14, 106, 158, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER},
|
|
364 |
{WWT_NODISTXTBTN, 14, 159, 211, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE},
|
|
365 |
{ WWT_PUSHTXTBTN, 14, 212, 264, 76, 87, STR_FULLLOAD_OR_SERVICE, 0},
|
|
366 |
{ WWT_PUSHTXTBTN, 14, 265, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
|
|
367 |
{ WWT_LAST},
|
|
368 |
};
|
|
369 |
|
|
370 |
static const WindowDesc _train_orders_desc = {
|
|
371 |
-1,-1, 320, 88,
|
|
372 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
|
|
373 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM,
|
|
374 |
_train_orders_widgets,
|
|
375 |
OrdersWndProc
|
|
376 |
};
|
|
377 |
|
|
378 |
static const Widget _other_train_orders_widgets[] = {
|
|
379 |
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
380 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
381 |
{ WWT_PANEL, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
|
|
382 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
383 |
{ WWT_LAST},
|
|
384 |
};
|
|
385 |
|
|
386 |
static const WindowDesc _other_train_orders_desc = {
|
|
387 |
-1,-1, 320, 76,
|
|
388 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
|
|
389 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
390 |
_other_train_orders_widgets,
|
|
391 |
OrdersWndProc
|
|
392 |
};
|
|
393 |
|
|
394 |
|
|
395 |
static const Widget _roadveh_orders_widgets[] = {
|
|
396 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
397 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_900B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
398 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0,STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
|
|
399 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
400 |
{ WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER},
|
|
401 |
{ WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED},
|
|
402 |
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0},
|
|
403 |
{WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE},
|
|
404 |
{ WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, 0},
|
|
405 |
{ WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
|
|
406 |
{ WWT_LAST},
|
|
407 |
};
|
|
408 |
|
|
409 |
static const WindowDesc _roadveh_orders_desc = {
|
|
410 |
-1,-1, 320, 88,
|
|
411 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
|
|
412 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM,
|
|
413 |
_roadveh_orders_widgets,
|
|
414 |
OrdersWndProc
|
|
415 |
};
|
|
416 |
|
|
417 |
static const Widget _other_roadveh_orders_widgets[] = {
|
|
418 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
419 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_900B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
420 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0,STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
|
|
421 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
422 |
{ WWT_LAST},
|
|
423 |
};
|
|
424 |
|
|
425 |
static const WindowDesc _other_roadveh_orders_desc = {
|
|
426 |
-1,-1, 320, 76,
|
|
427 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
|
|
428 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
429 |
_other_roadveh_orders_widgets,
|
|
430 |
OrdersWndProc
|
|
431 |
};
|
|
432 |
|
|
433 |
static const Widget _ship_orders_widgets[] = {
|
|
434 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
435 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_9810_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
436 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0,STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
|
|
437 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
438 |
{ WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER},
|
|
439 |
{ WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED},
|
|
440 |
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0},
|
|
441 |
{WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE},
|
|
442 |
{ WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, 0},
|
|
443 |
{ WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
|
|
444 |
{ WWT_LAST},
|
|
445 |
};
|
|
446 |
|
|
447 |
static const WindowDesc _ship_orders_desc = {
|
|
448 |
-1,-1, 320, 88,
|
|
449 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
|
|
450 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM,
|
|
451 |
_ship_orders_widgets,
|
|
452 |
OrdersWndProc
|
|
453 |
};
|
|
454 |
|
|
455 |
static const Widget _other_ship_orders_widgets[] = {
|
|
456 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
457 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_9810_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
458 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0,STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
|
|
459 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
460 |
{ WWT_LAST},
|
|
461 |
};
|
|
462 |
|
|
463 |
static const WindowDesc _other_ship_orders_desc = {
|
|
464 |
-1,-1, 320, 76,
|
|
465 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
|
|
466 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
467 |
_other_ship_orders_widgets,
|
|
468 |
OrdersWndProc
|
|
469 |
};
|
|
470 |
|
|
471 |
|
|
472 |
static const Widget _aircraft_orders_widgets[] = {
|
|
473 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
474 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
475 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
|
|
476 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
477 |
{ WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER},
|
|
478 |
{ WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED},
|
|
479 |
{ WWT_EMPTY, 0, 0, 0, 0, 0, 0x0},
|
|
480 |
{WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE},
|
|
481 |
{ WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, 0},
|
|
482 |
{ WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER},
|
|
483 |
{ WWT_LAST},
|
|
484 |
};
|
|
485 |
|
|
486 |
static const WindowDesc _aircraft_orders_desc = {
|
|
487 |
-1,-1, 320, 88,
|
|
488 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
|
|
489 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM,
|
|
490 |
_aircraft_orders_widgets,
|
|
491 |
OrdersWndProc
|
|
492 |
};
|
|
493 |
|
|
494 |
static const Widget _other_aircraft_orders_widgets[] = {
|
|
495 |
{ WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
496 |
{ WWT_CAPTION, 14, 11, 319, 0, 13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
497 |
{ WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER},
|
|
498 |
{ WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
|
499 |
{ WWT_LAST},
|
|
500 |
};
|
|
501 |
|
|
502 |
static const WindowDesc _other_aircraft_orders_desc = {
|
|
503 |
-1,-1, 320, 76,
|
|
504 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
|
|
505 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
|
|
506 |
_other_aircraft_orders_widgets,
|
|
507 |
OrdersWndProc
|
|
508 |
};
|
|
509 |
|
|
510 |
static const WindowDesc * const _order_window_desc[8] = {
|
|
511 |
&_train_orders_desc, &_other_train_orders_desc,
|
|
512 |
&_roadveh_orders_desc, &_other_roadveh_orders_desc,
|
|
513 |
&_ship_orders_desc, &_other_ship_orders_desc,
|
|
514 |
&_aircraft_orders_desc, &_other_aircraft_orders_desc,
|
|
515 |
};
|
|
516 |
|
|
517 |
|
|
518 |
void ShowOrdersWindow(Vehicle *v)
|
|
519 |
{
|
|
520 |
Window *w;
|
|
521 |
VehicleID veh = v->index;
|
|
522 |
|
|
523 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh);
|
|
524 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
|
|
525 |
|
|
526 |
_alloc_wnd_parent_num = veh;
|
|
527 |
w = AllocateWindowDesc(
|
|
528 |
_order_window_desc[(v->type - VEH_Train)*2 + (v->owner != _local_player)]);
|
|
529 |
|
|
530 |
w->window_number = veh;
|
|
531 |
w->caption_color = v->owner;
|
|
532 |
w->vscroll.cap = 6;
|
|
533 |
WP(w,order_d).sel = -1;
|
|
534 |
}
|