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