author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5831 | 203e589f1c52 |
child 5964 | 7c23f5123fd7 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1857
diff
changeset
|
4 |
#include "openttd.h" |
3144
33e42feae531
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3071
diff
changeset
|
5 |
#include "road_map.h" |
3315
c9d989783c55
(svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
3269
diff
changeset
|
6 |
#include "station_map.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1334
diff
changeset
|
7 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
395
diff
changeset
|
8 |
#include "table/strings.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2064
diff
changeset
|
9 |
#include "functions.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
560
diff
changeset
|
10 |
#include "map.h" |
1209
2e00193652b2
(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
|
11 |
#include "tile.h" |
0 | 12 |
#include "window.h" |
13 |
#include "gui.h" |
|
14 |
#include "gfx.h" |
|
15 |
#include "vehicle.h" |
|
16 |
#include "station.h" |
|
17 |
#include "town.h" |
|
18 |
#include "command.h" |
|
19 |
#include "viewport.h" |
|
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1256
diff
changeset
|
20 |
#include "depot.h" |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1530
diff
changeset
|
21 |
#include "waypoint.h" |
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2668
diff
changeset
|
22 |
#include "train.h" |
3392
469942e8a0ca
(svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents:
3387
diff
changeset
|
23 |
#include "water_map.h" |
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4634
diff
changeset
|
24 |
#include "vehicle_gui.h" |
0 | 25 |
|
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
26 |
enum OrderWindowWidgets { |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
27 |
ORDER_WIDGET_CLOSEBOX = 0, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
28 |
ORDER_WIDGET_CAPTION, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
29 |
ORDER_WIDGET_ORDER_LIST, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
30 |
ORDER_WIDGET_SCROLLBAR, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
31 |
ORDER_WIDGET_SKIP, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
32 |
ORDER_WIDGET_DELETE, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
33 |
ORDER_WIDGET_NON_STOP, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
34 |
ORDER_WIDGET_GOTO, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
35 |
ORDER_WIDGET_FULL_LOAD, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
36 |
ORDER_WIDGET_UNLOAD, |
5829
580c0b309122
(svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents:
5828
diff
changeset
|
37 |
ORDER_WIDGET_REFIT, |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
38 |
ORDER_WIDGET_TRANSFER, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
39 |
ORDER_WIDGET_SHARED_ORDER_LIST, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
40 |
ORDER_WIDGET_RESIZE_BAR, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
41 |
ORDER_WIDGET_RESIZE, |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
42 |
}; |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
43 |
|
4171 | 44 |
static int OrderGetSel(const Window *w) |
0 | 45 |
{ |
4171 | 46 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 47 |
int num = WP(w,order_d).sel; |
48 |
||
2549 | 49 |
return (num >= 0 && num < v->num_orders) ? num : v->num_orders; |
0 | 50 |
} |
51 |
||
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
52 |
static StringID StationOrderStrings[] = { |
1937
8497de87e4a2
(svn r2443) -Fix: somehow I delete one line too many :(
celestar
parents:
1935
diff
changeset
|
53 |
STR_8806_GO_TO, |
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
54 |
STR_8807_GO_TO_TRANSFER, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
55 |
STR_8808_GO_TO_UNLOAD, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
56 |
STR_8809_GO_TO_TRANSFER_UNLOAD, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
57 |
STR_880A_GO_TO_LOAD, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
58 |
STR_880B_GO_TO_TRANSFER_LOAD, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
59 |
STR_NULL, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
60 |
STR_NULL, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
61 |
STR_880C_GO_NON_STOP_TO, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
62 |
STR_880D_GO_TO_NON_STOP_TRANSFER, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
63 |
STR_880E_GO_NON_STOP_TO_UNLOAD, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
64 |
STR_880F_GO_TO_NON_STOP_TRANSFER_UNLOAD, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
65 |
STR_8810_GO_NON_STOP_TO_LOAD, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
66 |
STR_8811_GO_TO_NON_STOP_TRANSFER_LOAD, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
67 |
STR_NULL |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
68 |
}; |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
69 |
|
0 | 70 |
static void DrawOrdersWindow(Window *w) |
71 |
{ |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
72 |
const Vehicle *v; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
73 |
const Order *order; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
74 |
StringID str; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
75 |
int sel; |
0 | 76 |
int y, i; |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
77 |
bool shared_orders; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
78 |
byte color; |
0 | 79 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
80 |
v = GetVehicle(w->window_number); |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
81 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
82 |
shared_orders = IsOrderListShared(v); |
0 | 83 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
84 |
SetVScrollCount(w, v->num_orders + 1); |
0 | 85 |
|
86 |
sel = OrderGetSel(w); |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
87 |
SetDParam(2, STR_8827_FULL_LOAD); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
88 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
89 |
order = GetVehicleOrder(v, sel); |
725 | 90 |
|
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
91 |
if (v->owner == _local_player) { |
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
92 |
/* skip */ |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
93 |
SetWindowWidgetDisabledState(w, ORDER_WIDGET_SKIP, v->num_orders == 0); |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
94 |
|
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
95 |
/* delete */ |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
96 |
SetWindowWidgetDisabledState(w, ORDER_WIDGET_DELETE, |
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
97 |
(uint)v->num_orders + (shared_orders ? 1 : 0) <= (uint)WP(w, order_d).sel); |
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
98 |
|
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
99 |
/* non-stop only for trains */ |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
100 |
SetWindowWidgetDisabledState(w, ORDER_WIDGET_NON_STOP, v->type != VEH_Train || order == NULL); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
101 |
SetWindowWidgetDisabledState(w, ORDER_WIDGET_FULL_LOAD, order == NULL); // full load |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
102 |
SetWindowWidgetDisabledState(w, ORDER_WIDGET_UNLOAD, order == NULL); // unload |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
103 |
SetWindowWidgetDisabledState(w, ORDER_WIDGET_TRANSFER, order == NULL); // transfer |
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
104 |
/* Disable list of vehicles with the same shared orders if there is no list */ |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
105 |
SetWindowWidgetDisabledState(w, ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
106 |
SetWindowWidgetDisabledState(w, ORDER_WIDGET_REFIT, order == NULL); // Refit |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
107 |
HideWindowWidget(w, ORDER_WIDGET_REFIT); // Refit |
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
108 |
} else { |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
109 |
DisableWindowWidget(w, ORDER_WIDGET_TRANSFER); |
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
110 |
} |
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
111 |
|
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
112 |
ShowWindowWidget(w, ORDER_WIDGET_UNLOAD); // Unload |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
113 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
114 |
if (order != NULL) { |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
115 |
switch (order->type) { |
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
116 |
case OT_GOTO_STATION: break; |
2549 | 117 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
118 |
case OT_GOTO_DEPOT: |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
119 |
DisableWindowWidget(w, ORDER_WIDGET_TRANSFER); |
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
120 |
|
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
121 |
/* Remove unload and replace it with refit */ |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
122 |
HideWindowWidget(w, ORDER_WIDGET_UNLOAD); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
123 |
ShowWindowWidget(w, ORDER_WIDGET_REFIT); |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
124 |
SetDParam(2,STR_SERVICE); |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
125 |
break; |
725 | 126 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
127 |
case OT_GOTO_WAYPOINT: |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
128 |
DisableWindowWidget(w, ORDER_WIDGET_FULL_LOAD); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
129 |
DisableWindowWidget(w, ORDER_WIDGET_UNLOAD); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
130 |
DisableWindowWidget(w, ORDER_WIDGET_TRANSFER); |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
131 |
break; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
132 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
133 |
default: // every other orders |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
134 |
DisableWindowWidget(w, ORDER_WIDGET_NON_STOP); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
135 |
DisableWindowWidget(w, ORDER_WIDGET_FULL_LOAD); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
136 |
DisableWindowWidget(w, ORDER_WIDGET_UNLOAD); |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
137 |
} |
0 | 138 |
} |
139 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
140 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
141 |
SetDParam(1, v->unitnumber); |
0 | 142 |
DrawWindowWidgets(w); |
143 |
||
144 |
y = 15; |
|
145 |
||
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
146 |
i = w->vscroll.pos; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
147 |
order = GetVehicleOrder(v, i); |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
148 |
while (order != NULL) { |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
149 |
str = (v->cur_order_index == i) ? STR_8805 : STR_8804; |
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
150 |
SetDParam(3, STR_EMPTY); |
0 | 151 |
|
1242
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
152 |
if (i - w->vscroll.pos < w->vscroll.cap) { |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
153 |
SetDParam(1, 6); |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
154 |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
155 |
switch (order->type) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
156 |
case OT_GOTO_STATION: |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
157 |
SetDParam(1, StationOrderStrings[order->flags]); |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
158 |
SetDParam(2, order->dest); |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
159 |
break; |
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
160 |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
161 |
case OT_GOTO_DEPOT: { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
162 |
StringID s = STR_NULL; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
163 |
|
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
164 |
if (v->type == VEH_Aircraft) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
165 |
s = STR_GO_TO_AIRPORT_HANGAR; |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
166 |
SetDParam(2, order->dest); |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
167 |
} else { |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
168 |
SetDParam(2, GetDepot(order->dest)->town_index); |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
169 |
|
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
170 |
switch (v->type) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
171 |
case VEH_Train: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
172 |
case VEH_Road: s = STR_9038_GO_TO_ROADVEH_DEPOT; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
173 |
case VEH_Ship: s = STR_GO_TO_SHIP_DEPOT; break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
174 |
default: break; |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
175 |
} |
0 | 176 |
} |
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
177 |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
178 |
if (order->flags & OF_FULL_LOAD) s++; /* service at */ |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
179 |
|
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
180 |
SetDParam(1, s); |
4782
6aa485b21dae
(svn r6696) -Codechange: changed all comparision for refit cargo in orders against CT_NO_REFIT to checks for valid cargo IDs
bjarni
parents:
4719
diff
changeset
|
181 |
if (order->refit_cargo < NUM_CARGO) { |
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
182 |
SetDParam(3, STR_REFIT_ORDER); |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
183 |
SetDParam(4, _cargoc.names_s[order->refit_cargo]); |
4782
6aa485b21dae
(svn r6696) -Codechange: changed all comparision for refit cargo in orders against CT_NO_REFIT to checks for valid cargo IDs
bjarni
parents:
4719
diff
changeset
|
184 |
} else { |
6aa485b21dae
(svn r6696) -Codechange: changed all comparision for refit cargo in orders against CT_NO_REFIT to checks for valid cargo IDs
bjarni
parents:
4719
diff
changeset
|
185 |
SetDParam(3, STR_EMPTY); |
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
186 |
} |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
187 |
break; |
0 | 188 |
} |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
189 |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
190 |
case OT_GOTO_WAYPOINT: |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
191 |
SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
192 |
SetDParam(2, order->dest); |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2549
diff
changeset
|
193 |
break; |
4351
c9799dd53eec
(svn r6052) -Codechange: change OrderType (order->type) in a typedef
truelight
parents:
4344
diff
changeset
|
194 |
|
c9799dd53eec
(svn r6052) -Codechange: change OrderType (order->type) in a typedef
truelight
parents:
4344
diff
changeset
|
195 |
default: break; |
0 | 196 |
} |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
197 |
|
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
198 |
color = (i == WP(w,order_d).sel) ? 0xC : 0x10; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
199 |
SetDParam(0, i + 1); |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
200 |
if (order->type != OT_DUMMY) { |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
201 |
DrawString(2, y, str, color); |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
202 |
} else { |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
203 |
SetDParam(1, STR_INVALID_ORDER); |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
204 |
SetDParam(2, order->dest); |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
205 |
DrawString(2, y, str, color); |
0 | 206 |
} |
207 |
y += 10; |
|
208 |
} |
|
209 |
||
210 |
i++; |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
211 |
order = order->next; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
212 |
} |
0 | 213 |
|
1242
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
214 |
if (i - w->vscroll.pos < w->vscroll.cap) { |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
215 |
str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
216 |
color = (i == WP(w,order_d).sel) ? 0xC : 0x10; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
217 |
DrawString(2, y, str, color); |
0 | 218 |
} |
219 |
} |
|
220 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2186
diff
changeset
|
221 |
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) |
0 | 222 |
{ |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
223 |
Order order; |
3387
a779ba33aab4
(svn r4195) - Codechange: Initialize order variables to avoid a compiler warning. These are unused anyway... (smells of r3476-7, but not the same)
peter1138
parents:
3338
diff
changeset
|
224 |
order.next = NULL; |
a779ba33aab4
(svn r4195) - Codechange: Initialize order variables to avoid a compiler warning. These are unused anyway... (smells of r3476-7, but not the same)
peter1138
parents:
3338
diff
changeset
|
225 |
order.index = 0; |
4715 | 226 |
order.refit_cargo = CT_INVALID; |
227 |
order.refit_subtype = 0; |
|
0 | 228 |
|
229 |
// check depot first |
|
230 |
if (_patches.gotodepot) { |
|
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
231 |
switch (GetTileType(tile)) { |
0 | 232 |
case MP_RAILWAY: |
1901
03bf9bf99319
(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
|
233 |
if (v->type == VEH_Train && IsTileOwner(tile, _local_player)) { |
4182
48dba107ff43
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4171
diff
changeset
|
234 |
if (IsRailDepot(tile)) { |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
235 |
order.type = OT_GOTO_DEPOT; |
1530
2b46869fc0d4
(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents:
1363
diff
changeset
|
236 |
order.flags = OF_PART_OF_ORDERS; |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
237 |
order.dest = GetDepotByTile(tile)->index; |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
238 |
return order; |
560
60e198893a41
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
239 |
} |
0 | 240 |
} |
241 |
break; |
|
242 |
||
243 |
case MP_STREET: |
|
3793
7fe24e10ea63
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3792
diff
changeset
|
244 |
if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) { |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
245 |
order.type = OT_GOTO_DEPOT; |
1530
2b46869fc0d4
(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents:
1363
diff
changeset
|
246 |
order.flags = OF_PART_OF_ORDERS; |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
247 |
order.dest = GetDepotByTile(tile)->index; |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
248 |
return order; |
560
60e198893a41
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
249 |
} |
0 | 250 |
break; |
251 |
||
252 |
case MP_STATION: |
|
253 |
if (v->type != VEH_Aircraft) break; |
|
3338
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3315
diff
changeset
|
254 |
if (IsHangar(tile) && IsTileOwner(tile, _local_player)) { |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
255 |
order.type = OT_GOTO_DEPOT; |
2778
e0412c57f738
(svn r3325) - Fix: You couldn't send an airplane to a hangar for mandatory servicing, the NON_STOP flag failed the command.
Darkvater
parents:
2725
diff
changeset
|
256 |
order.flags = OF_PART_OF_ORDERS; |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
257 |
order.dest = GetStationIndex(tile); |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
258 |
return order; |
560
60e198893a41
(svn r962) Fixed a problem with the new order system due to missing '{}' (another place)
Celestar
parents:
559
diff
changeset
|
259 |
} |
0 | 260 |
break; |
261 |
||
262 |
case MP_WATER: |
|
263 |
if (v->type != VEH_Ship) break; |
|
1334 | 264 |
if (IsTileDepotType(tile, TRANSPORT_WATER) && |
265 |
IsTileOwner(tile, _local_player)) { |
|
3392
469942e8a0ca
(svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents:
3387
diff
changeset
|
266 |
TileIndex tile2 = GetOtherShipDepotTile(tile); |
469942e8a0ca
(svn r4200) -Codechange: Make use of water map accessors when getting the Index of a Ship Depot. TODO: Store the depot index in the map
celestar
parents:
3387
diff
changeset
|
267 |
|
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
268 |
order.type = OT_GOTO_DEPOT; |
1530
2b46869fc0d4
(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful
celestar
parents:
1363
diff
changeset
|
269 |
order.flags = OF_PART_OF_ORDERS; |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
270 |
order.dest = GetDepotByTile(tile < tile2 ? tile : tile2)->index; |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
271 |
return order; |
0 | 272 |
} |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
273 |
|
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
274 |
default: |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
275 |
break; |
0 | 276 |
} |
277 |
} |
|
278 |
||
395
788a9bba0889
(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
|
279 |
// check waypoint |
1901
03bf9bf99319
(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
|
280 |
if (IsTileType(tile, MP_RAILWAY) && |
03bf9bf99319
(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
|
281 |
v->type == VEH_Train && |
03bf9bf99319
(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
|
282 |
IsTileOwner(tile, _local_player) && |
2668
c0f1828b89e4
(svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers)
truelight
parents:
2643
diff
changeset
|
283 |
IsRailWaypoint(tile)) { |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
284 |
order.type = OT_GOTO_WAYPOINT; |
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
285 |
order.flags = 0; |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
286 |
order.dest = GetWaypointByTile(tile)->index; |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
287 |
return order; |
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
288 |
} |
319
1769185de5f5
(svn r329) Fix: [ 1035066 ] 'Allow goto depot' turned off, no checkpoints in orders
dominik
parents:
193
diff
changeset
|
289 |
|
1035
812f837ee03f
(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
|
290 |
if (IsTileType(tile, MP_STATION)) { |
3315
c9d989783c55
(svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
3269
diff
changeset
|
291 |
StationID st_index = GetStationIndex(tile); |
4171 | 292 |
const Station *st = GetStation(st_index); |
0 | 293 |
|
294 |
if (st->owner == _current_player || st->owner == OWNER_NONE) { |
|
295 |
byte facil; |
|
296 |
(facil=FACIL_DOCK, v->type == VEH_Ship) || |
|
297 |
(facil=FACIL_TRAIN, v->type == VEH_Train) || |
|
298 |
(facil=FACIL_AIRPORT, v->type == VEH_Aircraft) || |
|
299 |
(facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) || |
|
300 |
(facil=FACIL_TRUCK_STOP, 1); |
|
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
301 |
if (st->facilities & facil) { |
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
302 |
order.type = OT_GOTO_STATION; |
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
303 |
order.flags = 0; |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
304 |
order.dest = st_index; |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
305 |
return order; |
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
306 |
} |
0 | 307 |
} |
308 |
} |
|
309 |
||
310 |
// not found |
|
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
311 |
order.type = OT_NOTHING; |
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
312 |
order.flags = 0; |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
313 |
order.dest = INVALID_STATION; |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
314 |
return order; |
0 | 315 |
} |
316 |
||
4171 | 317 |
static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w) |
0 | 318 |
{ |
2549 | 319 |
if (u->type != v->type) return false; |
0 | 320 |
|
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2668
diff
changeset
|
321 |
if (u->type == VEH_Train && !IsFrontEngine(u)) { |
0 | 322 |
u = GetFirstVehicleInChain(u); |
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2668
diff
changeset
|
323 |
if (!IsFrontEngine(u)) return false; |
0 | 324 |
} |
325 |
||
326 |
// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet |
|
327 |
// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing |
|
2549 | 328 |
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
|
329 |
|
0 | 330 |
if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL, |
331 |
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) { |
|
332 |
WP(w,order_d).sel = -1; |
|
333 |
ResetObjectToPlace(); |
|
334 |
} |
|
335 |
||
336 |
return true; |
|
337 |
} |
|
338 |
||
4171 | 339 |
static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, Window *w) |
0 | 340 |
{ |
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
341 |
Order cmd; |
4171 | 342 |
const Vehicle *u; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
343 |
|
0 | 344 |
// check if we're clicking on a vehicle first.. clone orders in that case. |
345 |
u = CheckMouseOverVehicle(); |
|
2549 | 346 |
if (u != NULL && HandleOrderVehClick(v, u, w)) return; |
0 | 347 |
|
348 |
cmd = GetOrderCmdFromTile(v, tile); |
|
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
349 |
if (cmd.type == OT_NOTHING) return; |
0 | 350 |
|
558
1ae2a752501e
(svn r960) -Fix: forgotten conversion of orders for the AI (Tron)
darkvater
parents:
555
diff
changeset
|
351 |
if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) { |
2549 | 352 |
if (WP(w,order_d).sel != -1) WP(w,order_d).sel++; |
0 | 353 |
ResetObjectToPlace(); |
354 |
} |
|
355 |
} |
|
356 |
||
4171 | 357 |
static void OrderClick_Goto(Window *w, const Vehicle *v) |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
358 |
{ |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
359 |
InvalidateWidget(w, ORDER_WIDGET_GOTO); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
360 |
ToggleWidgetLoweredState(w, ORDER_WIDGET_GOTO); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
361 |
if (IsWindowWidgetLowered(w, ORDER_WIDGET_GOTO)) { |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
362 |
_place_clicked_vehicle = NULL; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5584
diff
changeset
|
363 |
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, 1, w); |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
364 |
} else { |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
365 |
ResetObjectToPlace(); |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
366 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
367 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
368 |
|
4171 | 369 |
static void OrderClick_FullLoad(Window *w, const Vehicle *v) |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
370 |
{ |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
371 |
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
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
372 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
373 |
|
4171 | 374 |
static void OrderClick_Unload(Window *w, const Vehicle *v) |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
375 |
{ |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
376 |
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_UNLOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
377 |
} |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
378 |
|
4171 | 379 |
static void OrderClick_Nonstop(Window *w, const Vehicle *v) |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
380 |
{ |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
381 |
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
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
382 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
383 |
|
2549 | 384 |
static void OrderClick_Transfer(Window* w, const Vehicle* v) |
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
385 |
{ |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
386 |
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_TRANSFER, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
387 |
} |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
388 |
|
4171 | 389 |
static void OrderClick_Skip(Window *w, const Vehicle *v) |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
390 |
{ |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
391 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SKIP_ORDER); |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
392 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
393 |
|
4171 | 394 |
static void OrderClick_Delete(Window *w, const Vehicle *v) |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
395 |
{ |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
396 |
DoCommandP(v->tile, v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER)); |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
397 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
398 |
|
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
399 |
static void OrderClick_Refit(Window *w, const Vehicle *v) |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
400 |
{ |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
401 |
if (_ctrl_pressed) { |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
402 |
/* Cancel refitting */ |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
403 |
DoCommandP(v->tile, v->index, (WP(w,order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT); |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
404 |
} else { |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
405 |
ShowVehicleRefitWindow(v, WP(w,order_d).sel); |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
406 |
} |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
407 |
} |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
408 |
|
4171 | 409 |
typedef void OnButtonVehClick(Window *w, const Vehicle *v); |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
410 |
|
4171 | 411 |
static OnButtonVehClick* const _order_button_proc[] = { |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
412 |
OrderClick_Skip, |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
413 |
OrderClick_Delete, |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
414 |
OrderClick_Nonstop, |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
415 |
OrderClick_Goto, |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
416 |
OrderClick_FullLoad, |
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
417 |
OrderClick_Unload, |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
418 |
OrderClick_Transfer |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
419 |
}; |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
420 |
|
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
421 |
static const uint16 _order_keycodes[] = { |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
422 |
'D', //skip order |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
423 |
'F', //delete order |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
424 |
'G', //non-stop |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
425 |
'H', //goto order |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
426 |
'J', //full load |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
427 |
'K' //unload |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
428 |
}; |
0 | 429 |
|
430 |
static void OrdersWndProc(Window *w, WindowEvent *e) |
|
431 |
{ |
|
2549 | 432 |
switch (e->event) { |
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
433 |
case WE_CREATE: |
5831
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
434 |
/* Ensure that the refit and unload buttons always remain at the same location. |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
435 |
* Only one of them can be active at any one time and takes turns on being disabled. |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
436 |
* To ensure that they stay at the same location, we also verify that they behave the same |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
437 |
* when resizing. */ |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
438 |
if (GetVehicle(w->window_number)->owner == _local_player) { // only the vehicle owner got these buttons |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
439 |
assert(w->widget[ORDER_WIDGET_REFIT].left == w->widget[ORDER_WIDGET_UNLOAD].left); |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
440 |
assert(w->widget[ORDER_WIDGET_REFIT].right == w->widget[ORDER_WIDGET_UNLOAD].right); |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
441 |
assert(w->widget[ORDER_WIDGET_REFIT].top == w->widget[ORDER_WIDGET_UNLOAD].top); |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
442 |
assert(w->widget[ORDER_WIDGET_REFIT].bottom == w->widget[ORDER_WIDGET_UNLOAD].bottom); |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
443 |
assert(w->widget[ORDER_WIDGET_REFIT].display_flags == w->widget[ORDER_WIDGET_UNLOAD].display_flags); |
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
444 |
} |
4712
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
445 |
break; |
4335ad42e163
(svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents:
4709
diff
changeset
|
446 |
|
0 | 447 |
case WE_PAINT: |
448 |
DrawOrdersWindow(w); |
|
449 |
break; |
|
450 |
||
451 |
case WE_CLICK: { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
452 |
Vehicle *v = GetVehicle(w->window_number); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4547
diff
changeset
|
453 |
switch (e->we.click.widget) { |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
454 |
case ORDER_WIDGET_ORDER_LIST: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4547
diff
changeset
|
455 |
int sel = (e->we.click.pt.y - 15) / 10; |
0 | 456 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
457 |
if ((uint)sel >= w->vscroll.cap) return; |
0 | 458 |
|
459 |
sel += w->vscroll.pos; |
|
460 |
||
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
461 |
if (_ctrl_pressed && sel < v->num_orders) { |
1043
44508ede2f92
(svn r1544) -Fix: SwapOrder did not use AssignOrder, which caused the saveroutine to
truelight
parents:
1035
diff
changeset
|
462 |
const Order *ord = GetVehicleOrder(v, sel); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
463 |
TileIndex xy; |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
464 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
465 |
switch (ord->type) { |
4527
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
466 |
case OT_GOTO_STATION: xy = GetStation(ord->dest)->xy ; break; |
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
467 |
case OT_GOTO_DEPOT: xy = GetDepot(ord->dest)->xy; break; |
fa30d19685c2
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4408
diff
changeset
|
468 |
case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->dest)->xy; break; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
469 |
default: xy = 0; break; |
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
|
470 |
} |
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
|
471 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
472 |
if (xy != 0) ScrollMainWindowToTile(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
|
473 |
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
|
474 |
} |
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
|
475 |
|
0 | 476 |
if (sel == WP(w,order_d).sel) sel = -1; |
477 |
WP(w,order_d).sel = sel; |
|
478 |
SetWindowDirty(w); |
|
479 |
} break; |
|
480 |
||
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
481 |
case ORDER_WIDGET_SKIP: |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
482 |
OrderClick_Skip(w, v); |
0 | 483 |
break; |
484 |
||
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
485 |
case ORDER_WIDGET_DELETE: |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
486 |
OrderClick_Delete(w, v); |
0 | 487 |
break; |
488 |
||
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
489 |
case ORDER_WIDGET_NON_STOP: |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
490 |
OrderClick_Nonstop(w, v); |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
491 |
break; |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
492 |
|
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
493 |
case ORDER_WIDGET_GOTO: |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
494 |
OrderClick_Goto(w, v); |
0 | 495 |
break; |
496 |
||
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
497 |
case ORDER_WIDGET_FULL_LOAD: |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
498 |
OrderClick_FullLoad(w, v); |
0 | 499 |
break; |
500 |
||
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
501 |
case ORDER_WIDGET_UNLOAD: |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
502 |
OrderClick_Unload(w, v); |
0 | 503 |
break; |
5829
580c0b309122
(svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents:
5828
diff
changeset
|
504 |
case ORDER_WIDGET_REFIT: |
580c0b309122
(svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents:
5828
diff
changeset
|
505 |
OrderClick_Refit(w, v); |
580c0b309122
(svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents:
5828
diff
changeset
|
506 |
break; |
580c0b309122
(svn r8395) -Cleanup: [orders window] moved the refit button two places up, so the order of the widget array fits the placement on the screen
bjarni
parents:
5828
diff
changeset
|
507 |
|
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
508 |
case ORDER_WIDGET_TRANSFER: |
1935
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
509 |
OrderClick_Transfer(w, v); |
164d58b9137c
(svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents:
1901
diff
changeset
|
510 |
break; |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
511 |
case ORDER_WIDGET_SHARED_ORDER_LIST: |
5745
c8069ea3af5d
(svn r8293) -Codechange: overloaded ShowVehicleListWindow() so it can open all types of vehicle lists (depending on arguments)
bjarni
parents:
5668
diff
changeset
|
512 |
ShowVehicleListWindow(v); |
4408
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
513 |
break; |
0 | 514 |
} |
515 |
} break; |
|
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
516 |
|
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
517 |
case WE_KEYPRESS: { |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
518 |
Vehicle *v = GetVehicle(w->window_number); |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
519 |
uint i; |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
520 |
|
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
521 |
if (v->owner != _local_player) break; |
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
522 |
|
2952 | 523 |
for (i = 0; i < lengthof(_order_keycodes); i++) { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4547
diff
changeset
|
524 |
if (e->we.keypress.keycode == _order_keycodes[i]) { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4547
diff
changeset
|
525 |
e->we.keypress.cont = false; |
1019
6bae6c11e865
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1000
diff
changeset
|
526 |
//see if the button is disabled |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
527 |
if (!IsWindowWidgetDisabled(w, i + ORDER_WIDGET_SKIP)) _order_button_proc[i](w, v); |
1000
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
528 |
break; |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
529 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
530 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
531 |
break; |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
532 |
} |
db05d7d665b4
(svn r1498) -Feature: Addded keyboard shortcuts for the order window
Celestar
parents:
995
diff
changeset
|
533 |
|
0 | 534 |
case WE_RCLICK: { |
4171 | 535 |
const Vehicle *v = GetVehicle(w->window_number); |
2639 | 536 |
int s = OrderGetSel(w); |
537 |
||
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
538 |
if (e->we.click.widget != ORDER_WIDGET_FULL_LOAD) break; |
2639 | 539 |
if (s == v->num_orders || GetVehicleOrder(v, s)->type != OT_GOTO_DEPOT) { |
1256
5b4916eb49ff
(svn r1760) -Fix: [ 1113399 ] Game no longer crashes when right-clicking a disabled Full Load button
celestar
parents:
1242
diff
changeset
|
540 |
GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER); |
2639 | 541 |
} else { |
0 | 542 |
GuiShowTooltips(STR_SERVICE_HINT); |
2639 | 543 |
} |
1242
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
544 |
} break; |
0 | 545 |
|
546 |
case WE_PLACE_OBJ: { |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4547
diff
changeset
|
547 |
OrdersPlaceObj(GetVehicle(w->window_number), e->we.place.tile, w); |
0 | 548 |
} break; |
549 |
||
550 |
case WE_ABORT_PLACE_OBJ: { |
|
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
551 |
RaiseWindowWidget(w, ORDER_WIDGET_GOTO); |
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
552 |
InvalidateWidget( w, ORDER_WIDGET_GOTO); |
0 | 553 |
} break; |
554 |
||
555 |
// check if a vehicle in a depot was clicked.. |
|
556 |
case WE_MOUSELOOP: { |
|
4171 | 557 |
const Vehicle *v = _place_clicked_vehicle; |
25 | 558 |
/* |
559 |
* Check if we clicked on a vehicle |
|
560 |
* and if the GOTO button of this window is pressed |
|
561 |
* This is because of all open order windows WE_MOUSELOOP is called |
|
562 |
* and if you have 3 windows open, and this check is not done |
|
563 |
* the order is copied to the last open window instead of the |
|
4949
6bf60913767f
(svn r6938) -Codechange: Comments, typo, variable naming, whitespace, strecpy and simplification
Darkvater
parents:
4935
diff
changeset
|
564 |
* one where GOTO is enabled |
25 | 565 |
*/ |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
566 |
if (v != NULL && IsWindowWidgetLowered(w, ORDER_WIDGET_GOTO)) { |
0 | 567 |
_place_clicked_vehicle = NULL; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
568 |
HandleOrderVehClick(GetVehicle(w->window_number), v, w); |
0 | 569 |
} |
570 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
571 |
|
1242
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
572 |
case WE_RESIZE: |
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
573 |
/* Update the scroll + matrix */ |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
574 |
w->vscroll.cap = (w->widget[ORDER_WIDGET_ORDER_LIST].bottom - w->widget[ORDER_WIDGET_ORDER_LIST].top) / 10; |
1242
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
575 |
break; |
5013
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
576 |
|
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
577 |
case WE_TIMEOUT: { // handle button unclick ourselves... |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
578 |
// unclick all buttons except for the 'goto' button (ORDER_WIDGET_GOTO), which is 'persistent' |
5235
2313d53f426a
(svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents:
5071
diff
changeset
|
579 |
uint i; |
2313d53f426a
(svn r7355) -Codechange: replace 'for (i = 0; w->widget[i].type != WWT_TYPE; i++)'-type for loops with 'for (i = 0; i < w->widget_count; i++)'-type for loops
rubidium
parents:
5071
diff
changeset
|
580 |
for (i = 0; i < w->widget_count; i++) { |
5828
e7b332dac5e8
(svn r8394) -Cleanup: added an enum with widget names to the orders window
bjarni
parents:
5745
diff
changeset
|
581 |
if (IsWindowWidgetLowered(w, i) && i != ORDER_WIDGET_GOTO) { |
5013
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
582 |
RaiseWindowWidget(w, i); |
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
583 |
InvalidateWidget(w, i); |
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
584 |
} |
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
585 |
} |
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
586 |
} break; |
0 | 587 |
} |
588 |
} |
|
589 |
||
1081
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
590 |
static const Widget _orders_train_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
591 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4408
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
592 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 398, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
593 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 386, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
594 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 387, 398, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
595 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 52, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
596 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 53, 105, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
597 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 106, 158, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER}, |
4968
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
598 |
{ WWT_TEXTBTN, RESIZE_TB, 14, 159, 211, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
599 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 212, 264, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
600 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 265, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
5831
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
601 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 265, 319, 76, 87, STR_REFIT, STR_REFIT_TIP}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
602 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 320, 372, 76, 87, STR_886F_TRANSFER, STR_886D_MAKE_THE_HIGHLIGHTED_ORDER}, |
4935
1eeda247f1ea
(svn r6922) -Feature: Add proper cloning sprites and cursors, different for each vehicle. Big thanks
Darkvater
parents:
4782
diff
changeset
|
603 |
{ WWT_PUSHIMGBTN, RESIZE_TB, 14, 373, 386, 76, 87, SPR_SHARED_ORDERS_ICON, STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, |
4408
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
604 |
{ WWT_PANEL, RESIZE_RTB, 14, 387, 386, 76, 87, 0x0, STR_NULL}, |
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
605 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 387, 398, 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
|
606 |
{ WIDGETS_END}, |
0 | 607 |
}; |
608 |
||
1081
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
609 |
static const WindowDesc _orders_train_desc = { |
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5013
diff
changeset
|
610 |
WDP_AUTO, WDP_AUTO, 399, 88, |
1081
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
611 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
5013
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
612 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE, |
1081
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
613 |
_orders_train_widgets, |
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
614 |
OrdersWndProc |
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
615 |
}; |
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
616 |
|
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
617 |
static const Widget _orders_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
618 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
4408
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
619 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 409, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
620 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 397, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
621 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 398, 409, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
622 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
623 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 64, 128, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
624 |
{ WWT_EMPTY, RESIZE_TB, 14, 0, 0, 76, 87, 0x0, 0x0}, |
4968
59dcd41ce2d0
(svn r6971) -Fix r6961: WWT_NODISTXTBTN buttons were normal buttons not push buttons
glx
parents:
4963
diff
changeset
|
625 |
{ WWT_TEXTBTN, RESIZE_TB, 14, 129, 192, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
626 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 193, 256, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
627 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 257, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, |
5831
203e589f1c52
(svn r8397) -Codechange: [orders window] don't move the refit button to the same location as the unload button
bjarni
parents:
5829
diff
changeset
|
628 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 257, 319, 76, 87, STR_REFIT, STR_REFIT_TIP}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
629 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 320, 383, 76, 87, STR_886F_TRANSFER, STR_886D_MAKE_THE_HIGHLIGHTED_ORDER}, |
4935
1eeda247f1ea
(svn r6922) -Feature: Add proper cloning sprites and cursors, different for each vehicle. Big thanks
Darkvater
parents:
4782
diff
changeset
|
630 |
{ WWT_PUSHIMGBTN, RESIZE_TB, 14, 384, 397, 76, 87, SPR_SHARED_ORDERS_ICON, STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, |
4408
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
631 |
{ WWT_PANEL, RESIZE_RTB, 14, 397, 396, 76, 87, 0x0, STR_NULL}, |
db2afc41002a
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
632 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 398, 409, 76, 87, 0x0, STR_RESIZE_BUTTON}, |
1081
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
633 |
{ WIDGETS_END}, |
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
634 |
}; |
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
635 |
|
995
0a8d27dcc231
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
636 |
static const WindowDesc _orders_desc = { |
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5013
diff
changeset
|
637 |
WDP_AUTO, WDP_AUTO, 410, 88, |
0 | 638 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
5013
1d20ebec3510
(svn r7046) -Fix [FS#311]: 'Goto' button in orders window got depressed along with all other
Darkvater
parents:
4968
diff
changeset
|
639 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE, |
995
0a8d27dcc231
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
640 |
_orders_widgets, |
0 | 641 |
OrdersWndProc |
642 |
}; |
|
643 |
||
995
0a8d27dcc231
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
644 |
static const Widget _other_orders_widgets[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
645 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
646 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 331, 0, 13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
647 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 319, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
648 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 320, 331, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
649 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 319, 76, 87, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
650 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 319, 76, 87, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
651 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 319, 76, 87, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
652 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 319, 76, 87, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
653 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 319, 76, 87, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
654 |
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 319, 76, 87, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
655 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 319, 76, 87, 0x0, STR_NULL}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4182
diff
changeset
|
656 |
{ 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
|
657 |
{ WIDGETS_END}, |
0 | 658 |
}; |
659 |
||
995
0a8d27dcc231
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
660 |
static const WindowDesc _other_orders_desc = { |
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5013
diff
changeset
|
661 |
WDP_AUTO, WDP_AUTO, 332, 88, |
0 | 662 |
WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, |
1242
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
663 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
995
0a8d27dcc231
(svn r1493) -Codechange: Removed redundancy in the order GUI. Currently we had most
celestar
parents:
919
diff
changeset
|
664 |
_other_orders_widgets, |
0 | 665 |
OrdersWndProc |
666 |
}; |
|
667 |
||
4171 | 668 |
void ShowOrdersWindow(const Vehicle *v) |
0 | 669 |
{ |
670 |
Window *w; |
|
671 |
VehicleID veh = v->index; |
|
672 |
||
673 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
674 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
675 |
|
1081
0d79fc43fae2
(svn r1582) Fix: Only the train orders GUI has a non-stop button now.
dominik
parents:
1067
diff
changeset
|
676 |
if (v->owner != _local_player) { |
5071
e28106dfcb6f
(svn r7129) -Codechange: Get rid of a global variable that only sets a window's number.
Darkvater
parents:
5070
diff
changeset
|
677 |
w = AllocateWindowDescFront(&_other_orders_desc, veh); |
2549 | 678 |
} else { |
5071
e28106dfcb6f
(svn r7129) -Codechange: Get rid of a global variable that only sets a window's number.
Darkvater
parents:
5070
diff
changeset
|
679 |
w = AllocateWindowDescFront((v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc, veh); |
2549 | 680 |
} |
0 | 681 |
|
1242
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
682 |
if (w != NULL) { |
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
683 |
w->caption_color = v->owner; |
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
684 |
w->vscroll.cap = 6; |
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
685 |
w->resize.step_height = 10; |
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
686 |
WP(w,order_d).sel = -1; |
1ca216c50426
(svn r1746) - Feature: [GUI] [ 1107690 ] Resizable orders GUI (nzhook)
darkvater
parents:
1214
diff
changeset
|
687 |
} |
0 | 688 |
} |