author | tron |
Sat, 25 Jun 2005 16:44:57 +0000 | |
changeset 1981 | de031d2aed47 |
parent 1977 | 4392ae3d8e31 |
child 2049 | ad0d49c916d4 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1857
diff
changeset
|
2 |
#include "openttd.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1334
diff
changeset
|
3 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
395
diff
changeset
|
4 |
#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
|
5 |
#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
|
6 |
#include "tile.h" |
0 | 7 |
#include "window.h" |
8 |
#include "gui.h" |
|
9 |
#include "gfx.h" |
|
10 |
#include "vehicle.h" |
|
11 |
#include "station.h" |
|
12 |
#include "town.h" |
|
13 |
#include "command.h" |
|
14 |
#include "viewport.h" |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1256
diff
changeset
|
15 |
#include "depot.h" |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1530
diff
changeset
|
16 |
#include "waypoint.h" |
0 | 17 |
|
18 |
static int OrderGetSel(Window *w) |
|
19 |
{ |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
20 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 21 |
int num = WP(w,order_d).sel; |
22 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
23 |
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
|
24 |
return v->num_orders; |
0 | 25 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
26 |
return num; |
0 | 27 |
} |
28 |
||
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
29 |
static StringID StationOrderStrings[] = { |
1937
0c1f7f4083c7
(svn r2443) -Fix: somehow I delete one line too many :(
celestar
parents:
1935
diff
changeset
|
30 |
STR_8806_GO_TO, |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
31 |
STR_8807_GO_TO_TRANSFER, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
32 |
STR_8808_GO_TO_UNLOAD, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
33 |
STR_8809_GO_TO_TRANSFER_UNLOAD, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
34 |
STR_880A_GO_TO_LOAD, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
35 |
STR_880B_GO_TO_TRANSFER_LOAD, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
36 |
STR_NULL, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
37 |
STR_NULL, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
38 |
STR_880C_GO_NON_STOP_TO, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
39 |
STR_880D_GO_TO_NON_STOP_TRANSFER, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
40 |
STR_880E_GO_NON_STOP_TO_UNLOAD, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
41 |
STR_880F_GO_TO_NON_STOP_TRANSFER_UNLOAD, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
42 |
STR_8810_GO_NON_STOP_TO_LOAD, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
43 |
STR_8811_GO_TO_NON_STOP_TRANSFER_LOAD, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
44 |
STR_NULL |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
45 |
}; |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
46 |
|
0 | 47 |
static void DrawOrdersWindow(Window *w) |
48 |
{ |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
49 |
const Vehicle *v; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
50 |
const Order *order; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
51 |
StringID str; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
52 |
int sel; |
0 | 53 |
int y, i; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
54 |
bool shared_orders; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
55 |
byte color; |
0 | 56 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
57 |
v = GetVehicle(w->window_number); |
0 | 58 |
|
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
59 |
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
|
60 |
1 << 4 | //skip |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
61 |
1 << 5 | //delete |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
62 |
1 << 6 | //non-stop |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
63 |
1 << 7 | //go-to |
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
64 |
1 << 8 | //full load |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
65 |
1 << 9 | //unload |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
66 |
1 << 10 //transfer |
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
67 |
); |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
68 |
|
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
69 |
if (v->type != VEH_Train) |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
70 |
SETBIT(w->disabled_state, 6); //disable non-stop for non-trains |
0 | 71 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
72 |
shared_orders = IsOrderListShared(v); |
0 | 73 |
|
1857
7321b4c1d4e1
(svn r2363) - Codechange: [NPF] Removed caching the endnode check. The code for this was buggy, fundamentally flawed and barely useful. (Hackykid)
matthijs
parents:
1752
diff
changeset
|
74 |
if ((uint)v->num_orders + (shared_orders?1:0) <= (uint)WP(w,order_d).sel) |
0 | 75 |
SETBIT(w->disabled_state, 5); /* delete */ |
76 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
77 |
if (v->num_orders == 0) |
0 | 78 |
SETBIT(w->disabled_state, 4); /* skip */ |
79 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
80 |
SetVScrollCount(w, v->num_orders + 1); |
0 | 81 |
|
82 |
sel = OrderGetSel(w); |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
83 |
SetDParam(2, STR_8827_FULL_LOAD); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
84 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
85 |
order = GetVehicleOrder(v, sel); |
725 | 86 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
87 |
if (order != NULL) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
88 |
switch (order->type) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
89 |
case OT_GOTO_STATION: |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
90 |
break; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
91 |
case OT_GOTO_DEPOT: |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
92 |
SETBIT(w->disabled_state, 9); /* unload */ |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
93 |
SETBIT(w->disabled_state, 10); /* transfer */ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
94 |
SetDParam(2,STR_SERVICE); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
95 |
break; |
725 | 96 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
97 |
case OT_GOTO_WAYPOINT: |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
98 |
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
|
99 |
SETBIT(w->disabled_state, 9); /* unload */ |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
100 |
SETBIT(w->disabled_state, 10); /* transfer */ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
101 |
break; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
102 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
103 |
default: |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
104 |
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
|
105 |
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
|
106 |
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
|
107 |
} |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
108 |
} else { |
0 | 109 |
SETBIT(w->disabled_state, 6); /* nonstop */ |
110 |
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
|
111 |
SETBIT(w->disabled_state, 9); /* unload */ |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
112 |
SETBIT(w->disabled_state, 10); /* transfer */ |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
113 |
|
0 | 114 |
} |
115 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
116 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
117 |
SetDParam(1, v->unitnumber); |
0 | 118 |
DrawWindowWidgets(w); |
119 |
||
120 |
y = 15; |
|
121 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
122 |
i = w->vscroll.pos; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
123 |
order = GetVehicleOrder(v, i); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
124 |
while (order != NULL) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
125 |
str = (v->cur_order_index == i) ? STR_8805 : STR_8804; |
0 | 126 |
|
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
127 |
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
|
128 |
SetDParam(1, 6); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
129 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
130 |
if (order->type == OT_GOTO_STATION) { |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
131 |
SetDParam(1, StationOrderStrings[order->flags]); |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
132 |
SetDParam(2, order->station); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
133 |
} 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
|
134 |
StringID s = STR_NULL; |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
135 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
136 |
if (v->type == VEH_Aircraft) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
137 |
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
|
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 |
} else { |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1256
diff
changeset
|
140 |
SetDParam(2, GetDepot(order->station)->town_index); |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
141 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
142 |
switch (v->type) { |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
143 |
case VEH_Train: s = STR_GO_TO_TRAIN_DEPOT; break; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
144 |
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
|
145 |
case VEH_Ship: s = STR_GO_TO_SHIP_DEPOT; break; |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1542
diff
changeset
|
146 |
default: |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1542
diff
changeset
|
147 |
break; |
0 | 148 |
} |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
149 |
|
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
150 |
if (v->type == VEH_Train && order->flags & OF_NON_STOP) s += 2; |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
151 |
SetDParam(1, s); |
0 | 152 |
} |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
153 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
154 |
if (order->flags & OF_FULL_LOAD) |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
155 |
s++; /* service at */ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
156 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
157 |
SetDParam(1, s); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
158 |
} 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
|
159 |
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
|
160 |
SetDParam(2, order->station); |
0 | 161 |
} |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
162 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
163 |
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
|
164 |
SetDParam(0, i + 1); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
165 |
if (order->type != OT_DUMMY) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
166 |
DrawString(2, y, str, color); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
167 |
} else { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
168 |
SetDParam(1, STR_INVALID_ORDER); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
169 |
SetDParam(2, order->station); |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
170 |
DrawString(2, y, str, color); |
0 | 171 |
} |
172 |
y += 10; |
|
173 |
} |
|
174 |
||
175 |
i++; |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
176 |
order = order->next; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
177 |
} |
0 | 178 |
|
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
DrawString(2, y, str, color); |
0 | 183 |
} |
184 |
} |
|
185 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1937
diff
changeset
|
186 |
static Order GetOrderCmdFromTile(Vehicle *v, TileIndex tile) |
0 | 187 |
{ |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
188 |
Order order; |
0 | 189 |
Station *st; |
190 |
int st_index; |
|
191 |
||
192 |
// check depot first |
|
193 |
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
|
194 |
switch (GetTileType(tile)) { |
0 | 195 |
case MP_RAILWAY: |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
196 |
if (v->type == VEH_Train && IsTileOwner(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
|
197 |
if ((_map5[tile]&0xFC)==0xC0) { |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
198 |
order.type = OT_GOTO_DEPOT; |
1530
caa16c506a22
(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents:
1363
diff
changeset
|
199 |
order.flags = OF_PART_OF_ORDERS; |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1256
diff
changeset
|
200 |
order.station = GetDepotByTile(tile)->index; |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
201 |
return order; |
560
bd8a572dc8b9
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
202 |
} |
0 | 203 |
} |
204 |
break; |
|
205 |
||
206 |
case MP_STREET: |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
207 |
if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && IsTileOwner(tile, _local_player)) { |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
208 |
order.type = OT_GOTO_DEPOT; |
1530
caa16c506a22
(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents:
1363
diff
changeset
|
209 |
order.flags = OF_PART_OF_ORDERS; |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1256
diff
changeset
|
210 |
order.station = GetDepotByTile(tile)->index; |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
211 |
return order; |
560
bd8a572dc8b9
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
212 |
} |
0 | 213 |
break; |
214 |
||
215 |
case MP_STATION: |
|
216 |
if (v->type != VEH_Aircraft) break; |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
217 |
if (IsAircraftHangarTile(tile) && IsTileOwner(tile, _local_player)) { |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
218 |
order.type = OT_GOTO_DEPOT; |
1530
caa16c506a22
(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents:
1363
diff
changeset
|
219 |
order.flags = OF_PART_OF_ORDERS | OF_NON_STOP; //XXX - whats the nonstop stuff doing here? |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
220 |
order.station = _map2[tile]; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
221 |
return order; |
560
bd8a572dc8b9
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
222 |
} |
0 | 223 |
break; |
224 |
||
225 |
case MP_WATER: |
|
226 |
if (v->type != VEH_Ship) break; |
|
1334 | 227 |
if (IsTileDepotType(tile, TRANSPORT_WATER) && |
228 |
IsTileOwner(tile, _local_player)) { |
|
0 | 229 |
switch (_map5[tile]) { |
1981 | 230 |
case 0x81: tile -= TileDiffXY(1, 0); break; |
231 |
case 0x83: tile -= TileDiffXY(0, 1); break; |
|
0 | 232 |
} |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
233 |
order.type = OT_GOTO_DEPOT; |
1530
caa16c506a22
(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents:
1363
diff
changeset
|
234 |
order.flags = OF_PART_OF_ORDERS; |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1256
diff
changeset
|
235 |
order.station = GetDepotByTile(tile)->index; |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
236 |
return order; |
0 | 237 |
} |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
238 |
|
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
239 |
default: |
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
240 |
break; |
0 | 241 |
} |
242 |
} |
|
243 |
||
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
|
244 |
// check waypoint |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
245 |
if (IsTileType(tile, MP_RAILWAY) && |
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
246 |
v->type == VEH_Train && |
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
247 |
IsTileOwner(tile, _local_player) && |
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
248 |
(_map5[tile] & 0xFE) == 0xC4) { |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
249 |
order.type = OT_GOTO_WAYPOINT; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
250 |
order.flags = 0; |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1530
diff
changeset
|
251 |
order.station = GetWaypointByTile(tile)->index; |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
252 |
return order; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
253 |
} |
319
1891d07574d6
(svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents:
193
diff
changeset
|
254 |
|
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
|
255 |
if (IsTileType(tile, MP_STATION)) { |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
256 |
st = GetStation(st_index = _map2[tile]); |
0 | 257 |
|
258 |
if (st->owner == _current_player || st->owner == OWNER_NONE) { |
|
259 |
byte facil; |
|
260 |
(facil=FACIL_DOCK, v->type == VEH_Ship) || |
|
261 |
(facil=FACIL_TRAIN, v->type == VEH_Train) || |
|
262 |
(facil=FACIL_AIRPORT, v->type == VEH_Aircraft) || |
|
263 |
(facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) || |
|
264 |
(facil=FACIL_TRUCK_STOP, 1); |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
265 |
if (st->facilities & facil) { |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
266 |
order.type = OT_GOTO_STATION; |
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 |
order.station = st_index; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
269 |
return order; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
270 |
} |
0 | 271 |
} |
272 |
} |
|
273 |
||
274 |
// not found |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
275 |
order.type = OT_NOTHING; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
276 |
order.flags = 0; |
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
277 |
return order; |
0 | 278 |
} |
279 |
||
280 |
static bool HandleOrderVehClick(Vehicle *v, Vehicle *u, Window *w) |
|
281 |
{ |
|
282 |
if (u->type != v->type) |
|
283 |
return false; |
|
284 |
||
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1043
diff
changeset
|
285 |
if (u->type == VEH_Train && u->subtype != TS_Front_Engine) { |
0 | 286 |
u = GetFirstVehicleInChain(u); |
1067
a083a6dd1419
(svn r1568) made an enum of train subtypes to make the code more readable
bjarni
parents:
1043
diff
changeset
|
287 |
if (u->subtype != TS_Front_Engine) |
0 | 288 |
return false; |
289 |
} |
|
290 |
||
291 |
// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet |
|
292 |
// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing |
|
293 |
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
|
294 |
|
0 | 295 |
if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL, |
296 |
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) { |
|
297 |
WP(w,order_d).sel = -1; |
|
298 |
ResetObjectToPlace(); |
|
299 |
} |
|
300 |
||
301 |
return true; |
|
302 |
} |
|
303 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1937
diff
changeset
|
304 |
static void OrdersPlaceObj(Vehicle *v, TileIndex tile, Window *w) |
0 | 305 |
{ |
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
306 |
Order cmd; |
0 | 307 |
Vehicle *u; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
308 |
|
0 | 309 |
// check if we're clicking on a vehicle first.. clone orders in that case. |
310 |
u = CheckMouseOverVehicle(); |
|
311 |
if (u && HandleOrderVehClick(v, u, w)) |
|
312 |
return; |
|
313 |
||
314 |
cmd = GetOrderCmdFromTile(v, tile); |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
315 |
if (cmd.type == OT_NOTHING) return; |
0 | 316 |
|
558
9b115b39c515
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
317 |
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 | 318 |
if (WP(w,order_d).sel != -1) |
319 |
WP(w,order_d).sel++; |
|
320 |
ResetObjectToPlace(); |
|
321 |
} |
|
322 |
} |
|
323 |
||
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
324 |
static void OrderClick_Goto(Window *w, Vehicle *v) |
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 |
InvalidateWidget(w, 7); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
327 |
TOGGLEBIT(w->click_state, 7); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
328 |
if (HASBIT(w->click_state, 7)) { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
329 |
_place_clicked_vehicle = NULL; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
330 |
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, 1, w); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
331 |
} else { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
332 |
ResetObjectToPlace(); |
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 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
335 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
336 |
static void OrderClick_FullLoad(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
337 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
338 |
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
|
339 |
} |
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 |
static void OrderClick_Unload(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
342 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
343 |
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
|
344 |
} |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
345 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
346 |
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
|
347 |
{ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
348 |
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
|
349 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
350 |
|
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
351 |
static void OrderClick_Transfer(Window *w, Vehicle *v) |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
352 |
{ |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
353 |
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_TRANSFER, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
354 |
} |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
355 |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
356 |
static void OrderClick_Skip(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
357 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
358 |
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
|
359 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
360 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
361 |
static void OrderClick_Delete(Window *w, Vehicle *v) |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
362 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
363 |
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
|
364 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
365 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
366 |
typedef void OnButtonClick(Window *w, Vehicle *v); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
367 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
368 |
static OnButtonClick * const _order_button_proc[] = { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
369 |
OrderClick_Skip, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
370 |
OrderClick_Delete, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
371 |
OrderClick_Nonstop, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
372 |
OrderClick_Goto, |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
373 |
OrderClick_FullLoad, |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
374 |
OrderClick_Unload, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
375 |
OrderClick_Transfer |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
376 |
}; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
377 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
378 |
static const uint16 _order_keycodes[] = { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
379 |
'D', //skip order |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
380 |
'F', //delete order |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
381 |
'G', //non-stop |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
382 |
'H', //goto order |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
383 |
'J', //full load |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
384 |
'K' //unload |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
385 |
}; |
0 | 386 |
|
387 |
static void OrdersWndProc(Window *w, WindowEvent *e) |
|
388 |
{ |
|
389 |
switch(e->event) { |
|
390 |
case WE_PAINT: |
|
391 |
DrawOrdersWindow(w); |
|
392 |
break; |
|
393 |
||
394 |
case WE_CLICK: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
395 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 396 |
switch(e->click.widget) { |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
397 |
case 2: { /* orders list */ |
0 | 398 |
int sel; |
399 |
sel = (e->click.pt.y - 15) / 10; |
|
400 |
||
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
401 |
if ((uint)sel >= w->vscroll.cap) |
0 | 402 |
return; |
403 |
||
404 |
sel += w->vscroll.pos; |
|
405 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
406 |
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
|
407 |
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
|
408 |
int xy = 0; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
409 |
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
|
410 |
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
|
411 |
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
|
412 |
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
|
413 |
case OT_GOTO_DEPOT: /* goto depot order */ |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1256
diff
changeset
|
414 |
xy = GetDepot(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
|
415 |
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
|
416 |
case OT_GOTO_WAYPOINT: /* goto waypoint order */ |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1530
diff
changeset
|
417 |
xy = GetWaypoint(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
|
418 |
} |
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
|
419 |
|
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
|
420 |
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
|
421 |
ScrollMainWindowToTile(xy); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
422 |
|
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
|
423 |
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
|
424 |
} |
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
|
425 |
|
0 | 426 |
if (sel == WP(w,order_d).sel) sel = -1; |
427 |
WP(w,order_d).sel = sel; |
|
428 |
SetWindowDirty(w); |
|
429 |
} break; |
|
430 |
||
431 |
case 4: /* skip button */ |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
432 |
OrderClick_Skip(w, v); |
0 | 433 |
break; |
434 |
||
435 |
case 5: /* delete button */ |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
436 |
OrderClick_Delete(w, v); |
0 | 437 |
break; |
438 |
||
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
439 |
case 6: /* non stop button */ |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
440 |
OrderClick_Nonstop(w, v); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
441 |
break; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
442 |
|
0 | 443 |
case 7: /* goto button */ |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
444 |
OrderClick_Goto(w, v); |
0 | 445 |
break; |
446 |
||
447 |
case 8: /* full load button */ |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
448 |
OrderClick_FullLoad(w, v); |
0 | 449 |
break; |
450 |
||
451 |
case 9: /* unload button */ |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
452 |
OrderClick_Unload(w, v); |
0 | 453 |
break; |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
454 |
case 10: /* transfer button */ |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
455 |
OrderClick_Transfer(w, v); |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
456 |
break; |
0 | 457 |
} |
458 |
} break; |
|
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
459 |
|
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
460 |
case WE_KEYPRESS: { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
461 |
Vehicle *v = GetVehicle(w->window_number); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
462 |
uint i; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
463 |
|
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
464 |
for(i = 0; i < lengthof(_order_keycodes); i++) { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
465 |
if (e->keypress.keycode == _order_keycodes[i]) { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
466 |
e->keypress.cont = false; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
467 |
//see if the button is disabled |
1000
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
468 |
if (!(HASBIT(w->disabled_state, (i + 4)))) { |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
469 |
_order_button_proc[i](w, v); |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
470 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
471 |
break; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
472 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
473 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
474 |
break; |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
475 |
} |
a418026097f6
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
476 |
|
0 | 477 |
case WE_RCLICK: { |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
478 |
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
|
479 |
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
|
480 |
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
|
481 |
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
|
482 |
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
|
483 |
else |
0 | 484 |
GuiShowTooltips(STR_SERVICE_HINT); |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
485 |
} break; |
0 | 486 |
|
487 |
case WE_4: { |
|
488 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
489 |
DeleteWindow(w); |
|
490 |
} break; |
|
491 |
||
492 |
case WE_PLACE_OBJ: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
493 |
OrdersPlaceObj(GetVehicle(w->window_number), e->place.tile, w); |
0 | 494 |
} break; |
495 |
||
496 |
case WE_ABORT_PLACE_OBJ: { |
|
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
497 |
CLRBIT(w->click_state, 7); |
0 | 498 |
InvalidateWidget(w, 7); |
499 |
} break; |
|
500 |
||
501 |
// check if a vehicle in a depot was clicked.. |
|
502 |
case WE_MOUSELOOP: { |
|
503 |
Vehicle *v = _place_clicked_vehicle; |
|
25 | 504 |
/* |
505 |
* Check if we clicked on a vehicle |
|
506 |
* and if the GOTO button of this window is pressed |
|
507 |
* This is because of all open order windows WE_MOUSELOOP is called |
|
508 |
* and if you have 3 windows open, and this check is not done |
|
509 |
* the order is copied to the last open window instead of the |
|
510 |
* one where GOTO is enalbed |
|
511 |
*/ |
|
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
512 |
if (v != NULL && HASBIT(w->click_state, 7)) { |
0 | 513 |
_place_clicked_vehicle = NULL; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
514 |
HandleOrderVehClick(GetVehicle(w->window_number), v, w); |
0 | 515 |
} |
516 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
517 |
|
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
518 |
case WE_RESIZE: |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
519 |
/* Update the scroll + matrix */ |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
520 |
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
|
521 |
break; |
0 | 522 |
} |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
523 |
|
0 | 524 |
} |
525 |
||
1081
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
526 |
static const Widget _orders_train_widgets[] = { |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
527 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
528 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 384, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
529 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 372, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
530 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 373, 384, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
531 |
{ 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
|
532 |
{ 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
|
533 |
{ 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
|
534 |
{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
|
535 |
{ 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
|
536 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 265, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
537 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 320, 372, 76, 87, STR_886F_TRANSFER, STR_886D_MAKE_THE_HIGHLIGHTED_ORDER}, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
538 |
{ WWT_PANEL, RESIZE_RTB, 14, 373, 372, 76, 87, 0x0, STR_NULL}, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
539 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 373, 384, 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
|
540 |
{ WIDGETS_END}, |
0 | 541 |
}; |
542 |
||
1081
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
543 |
static const WindowDesc _orders_train_desc = { |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
544 |
-1,-1, 385, 88, |
1081
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
545 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
546 |
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
|
547 |
_orders_train_widgets, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
548 |
OrdersWndProc |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
549 |
}; |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
550 |
|
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
551 |
static const Widget _orders_widgets[] = { |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
552 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
553 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 395, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
554 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 383, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
555 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 384, 395, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
556 |
{ 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
|
557 |
{ 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
|
558 |
{ 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
|
559 |
{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
|
560 |
{ 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
|
561 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 257, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
562 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 320, 383, 76, 87, STR_886F_TRANSFER, STR_886D_MAKE_THE_HIGHLIGHTED_ORDER}, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
563 |
{ WWT_PANEL, RESIZE_RTB, 14, 384, 383, 76, 87, 0x0, STR_NULL}, |
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
564 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 384, 395, 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
|
565 |
{ WIDGETS_END}, |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
566 |
}; |
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
567 |
|
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
568 |
static const WindowDesc _orders_desc = { |
1935
f43f062c9498
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
569 |
-1,-1, 396, 88, |
0 | 570 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
571 |
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
|
572 |
_orders_widgets, |
0 | 573 |
OrdersWndProc |
574 |
}; |
|
575 |
||
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
576 |
static const Widget _other_orders_widgets[] = { |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
577 |
{ 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
|
578 |
{ 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
|
579 |
{ 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
|
580 |
{ 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
|
581 |
{ 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
|
582 |
{ 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
|
583 |
{ 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
|
584 |
{ 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
|
585 |
{ 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
|
586 |
{ 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
|
587 |
{ 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
|
588 |
{ 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
|
589 |
{ WIDGETS_END}, |
0 | 590 |
}; |
591 |
||
995
96e9f70280d7
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
592 |
static const WindowDesc _other_orders_desc = { |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
593 |
-1,-1, 332, 88, |
0 | 594 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
595 |
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
|
596 |
_other_orders_widgets, |
0 | 597 |
OrdersWndProc |
598 |
}; |
|
599 |
||
600 |
void ShowOrdersWindow(Vehicle *v) |
|
601 |
{ |
|
602 |
Window *w; |
|
603 |
VehicleID veh = v->index; |
|
604 |
||
605 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
606 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
607 |
|
0 | 608 |
_alloc_wnd_parent_num = veh; |
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
609 |
|
1081
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
610 |
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
|
611 |
w = AllocateWindowDesc( &_other_orders_desc); |
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
612 |
} else |
1081
b22fd4020122
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
613 |
w = AllocateWindowDesc( (v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc); |
0 | 614 |
|
1242
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
615 |
if (w != NULL) { |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
616 |
w->window_number = veh; |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
617 |
w->caption_color = v->owner; |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
618 |
w->vscroll.cap = 6; |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
619 |
w->resize.step_height = 10; |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
620 |
WP(w,order_d).sel = -1; |
bd3e74f757b4
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
621 |
} |
0 | 622 |
} |