author | tron |
Sat, 29 Jan 2005 15:12:40 +0000 | |
changeset 1214 | 33e07bbb7779 |
parent 1209 | a1ac96655b79 |
child 1242 | bd3e74f757b4 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
395
diff
changeset
|
3 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
560
diff
changeset
|
4 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1095
diff
changeset
|
5 |
#include "tile.h" |
0 | 6 |
#include "window.h" |
7 |
#include "gui.h" |
|
8 |
#include "gfx.h" |
|
9 |
#include "vehicle.h" |
|
10 |
#include "station.h" |
|
11 |
#include "town.h" |
|
12 |
#include "command.h" |
|
13 |
#include "viewport.h" |
|
14 |
||
15 |
static int OrderGetSel(Window *w) |
|
16 |
{ |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
17 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 18 |
int num = WP(w,order_d).sel; |
19 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
20 |
if (num < 0 || num > v->num_orders) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
21 |
return v->num_orders; |
0 | 22 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
23 |
return num; |
0 | 24 |
} |
25 |
||
26 |
static void DrawOrdersWindow(Window *w) |
|
27 |
{ |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
28 |
const Vehicle *v; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
29 |
const Order *order; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
30 |
StringID str; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
31 |
int sel; |
0 | 32 |
int y, i; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
33 |
bool shared_orders; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
34 |
byte color; |
0 | 35 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
36 |
v = GetVehicle(w->window_number); |
0 | 37 |
|
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
38 |
w->disabled_state = (v->owner == _local_player) ? 0 : ( |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
39 |
1 << 4 | //skip |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
40 |
1 << 5 | //delete |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
41 |
1 << 6 | //non-stop |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
42 |
1 << 7 | //go-to |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
43 |
1 << 8 | //full load |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
44 |
1 << 9 //unload |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
45 |
); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
46 |
|
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
47 |
//disable non-stop for non-trains |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
48 |
if (v->type != VEH_Train) { |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
49 |
w->disabled_state |= 1 << 6; |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
50 |
} |
0 | 51 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
52 |
shared_orders = IsOrderListShared(v); |
0 | 53 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
54 |
if ((uint)v->num_orders + shared_orders <= (uint)WP(w,order_d).sel) |
0 | 55 |
SETBIT(w->disabled_state, 5); /* delete */ |
56 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
57 |
if (v->num_orders == 0) |
0 | 58 |
SETBIT(w->disabled_state, 4); /* skip */ |
59 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
60 |
SetVScrollCount(w, v->num_orders + 1); |
0 | 61 |
|
62 |
sel = OrderGetSel(w); |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
63 |
SetDParam(2, STR_8827_FULL_LOAD); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
64 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
65 |
order = GetVehicleOrder(v, sel); |
725 | 66 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
67 |
if (order != NULL) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
68 |
switch (order->type) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
69 |
case OT_GOTO_STATION: |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
70 |
break; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
71 |
case OT_GOTO_DEPOT: |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
72 |
SETBIT(w->disabled_state, 9); /* unload */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
73 |
SetDParam(2,STR_SERVICE); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
74 |
break; |
725 | 75 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
76 |
case OT_GOTO_WAYPOINT: |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
77 |
SETBIT(w->disabled_state, 8); /* full load */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
78 |
SETBIT(w->disabled_state, 9); /* unload */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
79 |
break; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
80 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
81 |
default: |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
82 |
SETBIT(w->disabled_state, 6); /* nonstop */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
83 |
SETBIT(w->disabled_state, 8); /* full load */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
84 |
SETBIT(w->disabled_state, 9); /* unload */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
85 |
} |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
86 |
} else { |
0 | 87 |
SETBIT(w->disabled_state, 6); /* nonstop */ |
88 |
SETBIT(w->disabled_state, 8); /* full load */ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
89 |
SETBIT(w->disabled_state, 9); /* unload */ |
0 | 90 |
} |
91 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
92 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
93 |
SetDParam(1, v->unitnumber); |
0 | 94 |
DrawWindowWidgets(w); |
95 |
||
96 |
y = 15; |
|
97 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
98 |
i = w->vscroll.pos; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
99 |
order = GetVehicleOrder(v, i); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
100 |
while (order != NULL) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
101 |
str = (v->cur_order_index == i) ? STR_8805 : STR_8804; |
0 | 102 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
103 |
if (i - w->vscroll.pos < 6) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
104 |
SetDParam(1, 6); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
105 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
106 |
if (order->type == OT_GOTO_STATION) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
107 |
SetDParam(1, STR_8806_GO_TO + (order->flags >> 1)); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
108 |
SetDParam(2, order->station); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
109 |
} else if (order->type == OT_GOTO_DEPOT) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
110 |
StringID s = STR_NULL; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
111 |
if (v->type == VEH_Aircraft) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
112 |
s = STR_GO_TO_AIRPORT_HANGAR; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
113 |
SetDParam(2, order->station); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
114 |
} else { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
115 |
SetDParam(2, _depots[order->station].town_index); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
116 |
switch (v->type) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
117 |
case VEH_Train: s = STR_880E_GO_TO_TRAIN_DEPOT; break; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
118 |
case VEH_Road: s = STR_9038_GO_TO_ROADVEH_DEPOT; break; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
119 |
case VEH_Ship: s = STR_GO_TO_SHIP_DEPOT; break; |
0 | 120 |
} |
121 |
} |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
122 |
if (v->type == VEH_Train && order->flags & OF_NON_STOP) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
123 |
s += 2; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
124 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
125 |
if (order->flags & OF_FULL_LOAD) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
126 |
s++; /* XXX service */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
127 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
128 |
SetDParam(1, s); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
129 |
} else if (order->type == OT_GOTO_WAYPOINT) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
130 |
SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
131 |
SetDParam(2, order->station); |
0 | 132 |
} |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
133 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
134 |
color = (i == WP(w,order_d).sel) ? 0xC : 0x10; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
135 |
SetDParam(0, i + 1); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
136 |
if (order->type != OT_DUMMY) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
137 |
DrawString(2, y, str, color); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
138 |
} else { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
139 |
SetDParam(1, STR_INVALID_ORDER); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
140 |
SetDParam(2, order->station); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
141 |
DrawString(2, y, str, color); |
0 | 142 |
} |
143 |
y += 10; |
|
144 |
} |
|
145 |
||
146 |
i++; |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
147 |
order = order->next; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
148 |
} |
0 | 149 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
150 |
if (i - w->vscroll.pos < 6) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
151 |
str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
152 |
color = (i == WP(w,order_d).sel) ? 0xC : 0x10; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
153 |
DrawString(2, y, str, color); |
0 | 154 |
} |
155 |
} |
|
156 |
||
157 |
||
158 |
// lookup a vehicle on a tile |
|
159 |
typedef struct { |
|
160 |
TileIndex tile; |
|
161 |
byte owner; |
|
162 |
byte type; |
|
163 |
} FindVehS; |
|
164 |
||
165 |
static void *FindVehicleCallb(Vehicle *v, FindVehS *f) |
|
166 |
{ |
|
167 |
if (v->tile != f->tile || v->owner != f->owner || v->vehstatus & VS_HIDDEN ) return NULL; |
|
168 |
return v; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
169 |
} |
0 | 170 |
|
1095 | 171 |
static Vehicle *GetVehicleOnTile(TileIndex tile, byte owner) |
0 | 172 |
{ |
781
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
725
diff
changeset
|
173 |
FindVehS fs; |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
725
diff
changeset
|
174 |
fs.tile = tile; |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
725
diff
changeset
|
175 |
fs.owner = owner; |
9717ff353c17
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
725
diff
changeset
|
176 |
fs.type = 0; |
0 | 177 |
return VehicleFromPos(tile, &fs, (VehicleFromPosProc*)FindVehicleCallb); |
178 |
} |
|
179 |
||
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
180 |
static Order GetOrderCmdFromTile(Vehicle *v, uint tile) |
0 | 181 |
{ |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
182 |
Order order; |
0 | 183 |
Station *st; |
184 |
int st_index; |
|
185 |
||
186 |
// check depot first |
|
187 |
if (_patches.gotodepot) { |
|
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
188 |
switch (GetTileType(tile)) { |
0 | 189 |
case MP_RAILWAY: |
190 |
if (v->type == VEH_Train && _map_owner[tile] == _local_player) { |
|
560
bd8a572dc8b9
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
191 |
if ((_map5[tile]&0xFC)==0xC0) { |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
192 |
order.type = OT_GOTO_DEPOT; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
193 |
order.flags = OF_UNLOAD; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
194 |
order.station = GetDepotByTile(tile); |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
195 |
return order; |
560
bd8a572dc8b9
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
196 |
} |
0 | 197 |
} |
198 |
break; |
|
199 |
||
200 |
case MP_STREET: |
|
560
bd8a572dc8b9
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
201 |
if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player) { |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
202 |
order.type = OT_GOTO_DEPOT; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
203 |
order.flags = OF_UNLOAD; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
204 |
order.station = GetDepotByTile(tile); |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
205 |
return order; |
560
bd8a572dc8b9
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
206 |
} |
0 | 207 |
break; |
208 |
||
209 |
case MP_STATION: |
|
210 |
if (v->type != VEH_Aircraft) break; |
|
559
2003549c0ddb
(svn r961) Fixed a problem with the new order system due to missing '{}'
Celestar
parents:
558
diff
changeset
|
211 |
if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player) { |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
212 |
order.type = OT_GOTO_DEPOT; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
213 |
order.flags = OF_UNLOAD | OF_NON_STOP; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
214 |
order.station = _map2[tile]; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
215 |
return order; |
560
bd8a572dc8b9
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
216 |
} |
0 | 217 |
break; |
218 |
||
219 |
case MP_WATER: |
|
220 |
if (v->type != VEH_Ship) break; |
|
221 |
if ( IsShipDepotTile(tile) && _map_owner[tile] == _local_player) { |
|
222 |
switch (_map5[tile]) { |
|
223 |
case 0x81: tile--; break; |
|
224 |
case 0x83: tile-= TILE_XY(0,1); break; |
|
225 |
} |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
226 |
order.type = OT_GOTO_DEPOT; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
227 |
order.flags = OF_UNLOAD; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
228 |
order.station = GetDepotByTile(tile); |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
229 |
return order; |
0 | 230 |
} |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
231 |
|
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
232 |
default: |
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
233 |
break; |
0 | 234 |
} |
235 |
} |
|
236 |
||
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
319
diff
changeset
|
237 |
// check waypoint |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1024
diff
changeset
|
238 |
if (IsTileType(tile, MP_RAILWAY) |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
239 |
&& v->type == VEH_Train |
319
1891d07574d6
(svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents:
193
diff
changeset
|
240 |
&& _map_owner[tile] == _local_player |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
241 |
&& (_map5[tile]&0xFE)==0xC4) { |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
242 |
order.type = OT_GOTO_WAYPOINT; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
243 |
order.flags = 0; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
244 |
order.station = GetWaypointByTile(tile); |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
245 |
return order; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
246 |
} |
319
1891d07574d6
(svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents:
193
diff
changeset
|
247 |
|
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1024
diff
changeset
|
248 |
if (IsTileType(tile, MP_STATION)) { |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
249 |
st = GetStation(st_index = _map2[tile]); |
0 | 250 |
|
251 |
if (st->owner == _current_player || st->owner == OWNER_NONE) { |
|
252 |
byte facil; |
|
253 |
(facil=FACIL_DOCK, v->type == VEH_Ship) || |
|
254 |
(facil=FACIL_TRAIN, v->type == VEH_Train) || |
|
255 |
(facil=FACIL_AIRPORT, v->type == VEH_Aircraft) || |
|
256 |
(facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) || |
|
257 |
(facil=FACIL_TRUCK_STOP, 1); |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
258 |
if (st->facilities & facil) { |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
259 |
order.type = OT_GOTO_STATION; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
260 |
order.flags = 0; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
261 |
order.station = st_index; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
262 |
return order; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
263 |
} |
0 | 264 |
} |
265 |
} |
|
266 |
||
267 |
// not found |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
268 |
order.type = OT_NOTHING; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
269 |
order.flags = 0; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
270 |
return order; |
0 | 271 |
} |
272 |
||
273 |
static bool HandleOrderVehClick(Vehicle *v, Vehicle *u, Window *w) |
|
274 |
{ |
|
275 |
if (u->type != v->type) |
|
276 |
return false; |
|
277 |
||
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1043
diff
changeset
|
278 |
if (u->type == VEH_Train && u->subtype != TS_Front_Engine) { |
0 | 279 |
u = GetFirstVehicleInChain(u); |
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1043
diff
changeset
|
280 |
if (u->subtype != TS_Front_Engine) |
0 | 281 |
return false; |
282 |
} |
|
283 |
||
284 |
// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet |
|
285 |
// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing |
|
286 |
if (v->num_orders != 0 && _ctrl_pressed == 0) {return false;} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
287 |
|
0 | 288 |
if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL, |
289 |
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) { |
|
290 |
WP(w,order_d).sel = -1; |
|
291 |
ResetObjectToPlace(); |
|
292 |
} |
|
293 |
||
294 |
return true; |
|
295 |
} |
|
296 |
||
297 |
static void OrdersPlaceObj(Vehicle *v, uint tile, Window *w) |
|
298 |
{ |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
299 |
Order cmd; |
0 | 300 |
Vehicle *u; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
301 |
|
0 | 302 |
// check if we're clicking on a vehicle first.. clone orders in that case. |
303 |
u = CheckMouseOverVehicle(); |
|
304 |
if (u && HandleOrderVehClick(v, u, w)) |
|
305 |
return; |
|
306 |
||
307 |
cmd = GetOrderCmdFromTile(v, tile); |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
308 |
if (cmd.type == OT_NOTHING) return; |
0 | 309 |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
310 |
if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) { |
0 | 311 |
if (WP(w,order_d).sel != -1) |
312 |
WP(w,order_d).sel++; |
|
313 |
ResetObjectToPlace(); |
|
314 |
} |
|
315 |
} |
|
316 |
||
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
317 |
static void OrderClick_Goto(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
318 |
{ |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
319 |
InvalidateWidget(w, 7); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
320 |
TOGGLEBIT(w->click_state, 7); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
321 |
if (HASBIT(w->click_state, 7)) { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
322 |
_place_clicked_vehicle = NULL; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
323 |
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, 1, w); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
324 |
} else { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
325 |
ResetObjectToPlace(); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
326 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
327 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
328 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
329 |
static void OrderClick_FullLoad(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
330 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
331 |
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_FULL_LOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
332 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
333 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
334 |
static void OrderClick_Unload(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
335 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
336 |
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_UNLOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
337 |
} |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
338 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
339 |
static void OrderClick_Nonstop(Window *w, Vehicle *v) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
340 |
{ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
341 |
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_NON_STOP, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
342 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
343 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
344 |
static void OrderClick_Skip(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
345 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
346 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SKIP_ORDER); |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
347 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
348 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
349 |
static void OrderClick_Delete(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
350 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
351 |
DoCommandP(v->tile, v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER)); |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
352 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
353 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
354 |
typedef void OnButtonClick(Window *w, Vehicle *v); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
355 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
356 |
static OnButtonClick * const _order_button_proc[] = { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
357 |
OrderClick_Skip, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
358 |
OrderClick_Delete, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
359 |
OrderClick_Nonstop, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
360 |
OrderClick_Goto, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
361 |
OrderClick_FullLoad, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
362 |
OrderClick_Unload |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
363 |
}; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
364 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
365 |
static const uint16 _order_keycodes[] = { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
366 |
'D', //skip order |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
367 |
'F', //delete order |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
368 |
'G', //non-stop |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
369 |
'H', //goto order |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
370 |
'J', //full load |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
371 |
'K' //unload |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
372 |
}; |
0 | 373 |
|
374 |
static void OrdersWndProc(Window *w, WindowEvent *e) |
|
375 |
{ |
|
376 |
switch(e->event) { |
|
377 |
case WE_PAINT: |
|
378 |
DrawOrdersWindow(w); |
|
379 |
break; |
|
380 |
||
381 |
case WE_CLICK: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
382 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 383 |
switch(e->click.widget) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
384 |
case 2: {/* orders list */ |
0 | 385 |
int sel; |
386 |
sel = (e->click.pt.y - 15) / 10; |
|
387 |
||
388 |
if ( (uint) sel >= 6) |
|
389 |
return; |
|
390 |
||
391 |
sel += w->vscroll.pos; |
|
392 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
393 |
if (_ctrl_pressed && sel < v->num_orders) { |
1043
123072ba6ced
(svn r1544) -Fix: SwapOrder did not use AssignOrder, which caused the saveroutine to
truelight
parents:
1035
diff
changeset
|
394 |
const Order *ord = GetVehicleOrder(v, sel); |
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
|
395 |
int xy = 0; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
396 |
switch (ord->type) { |
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
|
397 |
case OT_GOTO_STATION: /* station order */ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
398 |
xy = GetStation(ord->station)->xy ; |
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
|
399 |
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
|
400 |
case OT_GOTO_DEPOT: /* goto depot order */ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
401 |
xy = _depots[ord->station].xy; |
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
|
402 |
break; |
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
319
diff
changeset
|
403 |
case OT_GOTO_WAYPOINT: /* goto waypoint order */ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
404 |
xy = _waypoints[ord->station].xy; |
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
|
405 |
} |
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
|
406 |
|
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
|
407 |
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
|
408 |
ScrollMainWindowToTile(xy); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
409 |
|
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
|
410 |
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
|
411 |
} |
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
|
412 |
|
0 | 413 |
if (sel == WP(w,order_d).sel) sel = -1; |
414 |
WP(w,order_d).sel = sel; |
|
415 |
SetWindowDirty(w); |
|
416 |
} break; |
|
417 |
||
418 |
case 4: /* skip button */ |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
419 |
OrderClick_Skip(w, v); |
0 | 420 |
break; |
421 |
||
422 |
case 5: /* delete button */ |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
423 |
OrderClick_Delete(w, v); |
0 | 424 |
break; |
425 |
||
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
426 |
case 6: /* non stop button */ |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
427 |
OrderClick_Nonstop(w, v); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
428 |
break; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
429 |
|
0 | 430 |
case 7: /* goto button */ |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
431 |
OrderClick_Goto(w, v); |
0 | 432 |
break; |
433 |
||
434 |
case 8: /* full load button */ |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
435 |
OrderClick_FullLoad(w, v); |
0 | 436 |
break; |
437 |
||
438 |
case 9: /* unload button */ |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
439 |
OrderClick_Unload(w, v); |
0 | 440 |
break; |
441 |
} |
|
442 |
} break; |
|
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
443 |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
444 |
case WE_KEYPRESS: { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
445 |
Vehicle *v = GetVehicle(w->window_number); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
446 |
uint i; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
447 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
448 |
for(i = 0; i < lengthof(_order_keycodes); i++) { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
449 |
if (e->keypress.keycode == _order_keycodes[i]) { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
450 |
e->keypress.cont = false; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
451 |
//see if the button is disabled |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
452 |
if (!(HASBIT(w->disabled_state, (i + 4)))) { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
453 |
_order_button_proc[i](w, v); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
454 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
455 |
break; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
456 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
457 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
458 |
break; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
459 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
460 |
|
0 | 461 |
|
462 |
||
463 |
case WE_RCLICK: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
464 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 465 |
if (e->click.widget != 8) break; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
466 |
if (GetVehicleOrder(v, OrderGetSel(w))->type == OT_GOTO_DEPOT) |
0 | 467 |
GuiShowTooltips(STR_SERVICE_HINT); |
468 |
else |
|
469 |
GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER); |
|
470 |
} break; |
|
471 |
||
472 |
case WE_4: { |
|
473 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
474 |
DeleteWindow(w); |
|
475 |
} break; |
|
476 |
||
477 |
case WE_PLACE_OBJ: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
478 |
OrdersPlaceObj(GetVehicle(w->window_number), e->place.tile, w); |
0 | 479 |
} break; |
480 |
||
481 |
case WE_ABORT_PLACE_OBJ: { |
|
482 |
w->click_state &= ~(1<<7); |
|
483 |
InvalidateWidget(w, 7); |
|
484 |
} break; |
|
485 |
||
486 |
// check if a vehicle in a depot was clicked.. |
|
487 |
case WE_MOUSELOOP: { |
|
488 |
Vehicle *v = _place_clicked_vehicle; |
|
25 | 489 |
/* |
490 |
* Check if we clicked on a vehicle |
|
491 |
* and if the GOTO button of this window is pressed |
|
492 |
* This is because of all open order windows WE_MOUSELOOP is called |
|
493 |
* and if you have 3 windows open, and this check is not done |
|
494 |
* the order is copied to the last open window instead of the |
|
495 |
* one where GOTO is enalbed |
|
496 |
*/ |
|
497 |
if (v && HASBIT(w->click_state, 7)) { |
|
0 | 498 |
_place_clicked_vehicle = NULL; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
499 |
HandleOrderVehClick(GetVehicle(w->window_number), v, w); |
0 | 500 |
} |
501 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
502 |
|
0 | 503 |
} |
504 |
} |
|
505 |
||
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
506 |
|
1081
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
507 |
static const Widget _orders_train_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
508 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
509 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 319, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
510 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 307, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
511 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 308, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
512 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 52, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
513 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 53, 105, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
514 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 106, 158, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
515 |
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 159, 211, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
516 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 212, 264, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
517 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 265, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
127
diff
changeset
|
518 |
{ WIDGETS_END}, |
0 | 519 |
}; |
520 |
||
1081
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
521 |
static const WindowDesc _orders_train_desc = { |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
522 |
-1,-1, 320, 88, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
523 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
524 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
525 |
_orders_train_widgets, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
526 |
OrdersWndProc |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
527 |
}; |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
528 |
|
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
529 |
static const Widget _orders_widgets[] = { |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
530 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
531 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 319, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
532 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 307, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
533 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 308, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
534 |
|
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
535 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
536 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
537 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, 0x0}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
538 |
{WWT_NODISTXTBTN, RESIZE_NONE, 14, 129, 192, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
539 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 256, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
540 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 257, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
541 |
{ WIDGETS_END}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
542 |
}; |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
543 |
|
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
544 |
static const WindowDesc _orders_desc = { |
0 | 545 |
-1,-1, 320, 88, |
546 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
547 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, |
|
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
548 |
_orders_widgets, |
0 | 549 |
OrdersWndProc |
550 |
}; |
|
551 |
||
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
552 |
static const Widget _other_orders_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
553 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
781
diff
changeset
|
554 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 319, 0, 13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
555 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 307, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
556 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 308, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
127
diff
changeset
|
557 |
{ WIDGETS_END}, |
0 | 558 |
}; |
559 |
||
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
560 |
static const WindowDesc _other_orders_desc = { |
0 | 561 |
-1,-1, 320, 76, |
562 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
|
563 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
564 |
_other_orders_widgets, |
0 | 565 |
OrdersWndProc |
566 |
}; |
|
567 |
||
568 |
void ShowOrdersWindow(Vehicle *v) |
|
569 |
{ |
|
570 |
Window *w; |
|
571 |
VehicleID veh = v->index; |
|
572 |
||
573 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
574 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
575 |
|
0 | 576 |
_alloc_wnd_parent_num = veh; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
577 |
|
1081
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
578 |
if (v->owner != _local_player) { |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
579 |
w = AllocateWindowDesc( &_other_orders_desc); |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
580 |
} else { |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
581 |
w = AllocateWindowDesc( (v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc); |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
582 |
} |
0 | 583 |
|
584 |
w->window_number = veh; |
|
585 |
w->caption_color = v->owner; |
|
586 |
w->vscroll.cap = 6; |
|
587 |
WP(w,order_d).sel = -1; |
|
588 |
} |