author | tron |
Sat, 15 Oct 2005 11:06:54 +0000 | |
changeset 2517 | b90693227193 |
parent 2498 | befad2fe53d2 |
child 2548 | 97ada3bd2702 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
4 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
5 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
7 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
382
diff
changeset
|
8 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
588
diff
changeset
|
9 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1055
diff
changeset
|
10 |
#include "tile.h" |
0 | 11 |
#include "window.h" |
12 |
#include "gui.h" |
|
13 |
#include "vehicle.h" |
|
14 |
#include "gfx.h" |
|
15 |
#include "station.h" |
|
16 |
#include "command.h" |
|
17 |
#include "engine.h" |
|
18 |
#include "viewport.h" |
|
19 |
#include "player.h" |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
20 |
#include "depot.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2113
diff
changeset
|
21 |
#include "vehicle_gui.h" |
0 | 22 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
23 |
/** |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
24 |
* Draw the purchase info details of an aircraft at a given location. |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
25 |
* @param x,y location where to draw the info |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
26 |
* @param engine_number the engine of which to draw the info of |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
27 |
*/ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
28 |
void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number) |
842 | 29 |
{ |
30 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number); |
|
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
31 |
const Engine* e = GetEngine(engine_number); |
842 | 32 |
YearMonthDay ymd; |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
33 |
ConvertDayToYMD(&ymd, e->intro_date); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
34 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
35 |
/* Purchase cost - Max speed */ |
842 | 36 |
SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5); |
37 |
SetDParam(1, avi->max_speed * 8); |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
38 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
39 |
y += 10; |
842 | 40 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
41 |
/* Cargo capacity */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
42 |
SetDParam(0, avi->passenger_capacity); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
43 |
SetDParam(1, avi->mail_capacity); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
44 |
DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
45 |
y += 10; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
46 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
47 |
/* Running cost */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
48 |
SetDParam(0, avi->running_cost * _price.aircraft_running >> 8); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
49 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
50 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
51 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
52 |
/* Design date - Life length */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
53 |
SetDParam(0, ymd.year + 1920); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
54 |
SetDParam(1, e->lifelength); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
55 |
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
56 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
57 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
58 |
/* Reliability */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
59 |
SetDParam(0, e->reliability * 100 >> 16); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
60 |
DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
61 |
y += 10; |
842 | 62 |
} |
63 |
||
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
64 |
static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection) |
0 | 65 |
{ |
66 |
int image = GetAircraftImage(v, 6); |
|
67 |
uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
68 |
if (v->vehstatus & VS_CRASHED) |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
69 |
ormod = PALETTE_CRASH; |
0 | 70 |
DrawSprite(image | ormod, x+25, y+10); |
71 |
if (v->subtype == 0) |
|
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
72 |
DrawSprite(SPR_ROTOR_STOPPED, x + 25, y + 5); |
0 | 73 |
if (v->index == selection) { |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1926
diff
changeset
|
74 |
DrawFrameRect(x-1, y-1, x+58, y+21, 0xF, FR_BORDERONLY); |
0 | 75 |
} |
76 |
} |
|
77 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
78 |
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 79 |
{ |
80 |
Vehicle *v; |
|
81 |
||
82 |
if (success) { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
83 |
v = GetVehicle(_new_aircraft_id); |
0 | 84 |
if (v->tile == _backup_orders_tile) { |
85 |
_backup_orders_tile = 0; |
|
86 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
87 |
} |
|
88 |
ShowAircraftViewWindow(v); |
|
89 |
} |
|
90 |
} |
|
91 |
||
2244 | 92 |
void CcCloneAircraft(bool success, uint tile, uint32 p1, uint32 p2) |
93 |
{ |
|
94 |
Vehicle *v; |
|
95 |
||
96 |
if (success) { |
|
97 |
v = GetVehicle(_new_aircraft_id); |
|
98 |
ShowAircraftViewWindow(v); |
|
99 |
} |
|
100 |
} |
|
0 | 101 |
|
102 |
static void NewAircraftWndProc(Window *w, WindowEvent *e) |
|
103 |
{ |
|
104 |
switch(e->event) { |
|
105 |
||
106 |
case WE_PAINT: { |
|
107 |
if (w->window_number == 0) |
|
108 |
SETBIT(w->disabled_state, 5); |
|
109 |
||
110 |
{ |
|
111 |
int count = 0; |
|
112 |
int num = NUM_AIRCRAFT_ENGINES; |
|
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
113 |
const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX); |
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
114 |
|
0 | 115 |
do { |
116 |
if (HASBIT(e->player_avail, _local_player)) |
|
117 |
count++; |
|
118 |
} while (++e,--num); |
|
119 |
SetVScrollCount(w, count); |
|
120 |
} |
|
121 |
||
122 |
DrawWindowWidgets(w); |
|
123 |
||
124 |
{ |
|
125 |
int num = NUM_AIRCRAFT_ENGINES; |
|
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
126 |
const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX); |
0 | 127 |
int x = 2; |
128 |
int y = 15; |
|
129 |
int sel = WP(w,buildtrain_d).sel_index; |
|
130 |
int pos = w->vscroll.pos; |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2466
diff
changeset
|
131 |
EngineID engine_id = AIRCRAFT_ENGINES_INDEX; |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
132 |
EngineID selected_id = INVALID_ENGINE; |
0 | 133 |
|
134 |
do { |
|
135 |
if (HASBIT(e->player_avail, _local_player)) { |
|
136 |
if (sel==0) selected_id = engine_id; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
137 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
0 | 138 |
DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10); |
139 |
DrawAircraftEngine(x+29, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player))); |
|
140 |
y += 24; |
|
141 |
} |
|
142 |
sel--; |
|
143 |
} |
|
144 |
} while (++engine_id, ++e,--num); |
|
145 |
||
146 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
147 |
||
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
148 |
if (selected_id != INVALID_ENGINE) { |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
149 |
DrawAircraftPurchaseInfo(2, w->widget[4].top + 1, selected_id); |
0 | 150 |
} |
151 |
} |
|
152 |
} break; |
|
153 |
||
154 |
case WE_CLICK: |
|
155 |
switch(e->click.widget) { |
|
156 |
case 2: { /* listbox */ |
|
157 |
uint i = (e->click.pt.y - 14) / 24; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
158 |
if (i < w->vscroll.cap) { |
0 | 159 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
160 |
SetWindowDirty(w); |
|
161 |
} |
|
162 |
} break; |
|
163 |
||
164 |
case 5: { /* build */ |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
165 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
166 |
if (sel_eng != INVALID_ENGINE) |
0 | 167 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
168 |
} break; |
|
169 |
||
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
170 |
case 6: { /* rename */ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
171 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
172 |
if (sel_eng != INVALID_ENGINE) { |
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
173 |
WP(w,buildtrain_d).rename_engine = sel_eng; |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
174 |
ShowQueryString(GetCustomEngineName(sel_eng), |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
175 |
STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number); |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
176 |
} |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
177 |
} break; |
0 | 178 |
} |
179 |
break; |
|
180 |
||
181 |
case WE_4: |
|
182 |
if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) { |
|
183 |
DeleteWindow(w); |
|
184 |
} |
|
185 |
break; |
|
186 |
||
187 |
case WE_ON_EDIT_TEXT: { |
|
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
188 |
if (e->edittext.str[0] != '\0') { |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
189 |
_cmd_text = e->edittext.str; |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
190 |
DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
191 |
CMD_RENAME_ENGINE | CMD_MSG(STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
192 |
} |
0 | 193 |
} break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
194 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
195 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
196 |
w->vscroll.cap += e->sizing.diff.y / 24; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
197 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
198 |
break; |
0 | 199 |
} |
200 |
} |
|
201 |
||
202 |
static const Widget _new_aircraft_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
203 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
204 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_A005_NEW_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
205 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 227, 14, 109, 0x401, STR_A025_AIRCRAFT_SELECTION_LIST}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
206 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 228, 239, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
207 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 239, 110, 161, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
208 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 114, 162, 173, STR_A006_BUILD_AIRCRAFT, STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
209 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 115, 227, 162, 173, STR_A037_RENAME, STR_A038_RENAME_AIRCRAFT_TYPE}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
210 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 228, 239, 162, 173, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
211 |
{ WIDGETS_END}, |
0 | 212 |
}; |
213 |
||
214 |
static const WindowDesc _new_aircraft_desc = { |
|
215 |
-1, -1, 240, 174, |
|
216 |
WC_BUILD_VEHICLE,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
217 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 218 |
_new_aircraft_widgets, |
219 |
NewAircraftWndProc |
|
220 |
}; |
|
221 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
222 |
static void ShowBuildAircraftWindow(TileIndex tile) |
0 | 223 |
{ |
224 |
Window *w; |
|
225 |
||
226 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
227 |
||
228 |
w = AllocateWindowDesc(&_new_aircraft_desc); |
|
229 |
w->window_number = tile; |
|
230 |
w->vscroll.cap = 4; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
231 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
232 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
233 |
w->resize.step_height = 24; |
0 | 234 |
|
235 |
if (tile != 0) { |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
236 |
w->caption_color = GetTileOwner(tile); |
0 | 237 |
} else { |
238 |
w->caption_color = _local_player; |
|
239 |
} |
|
240 |
} |
|
241 |
||
242 |
static void AircraftRefitWndProc(Window *w, WindowEvent *e) |
|
243 |
{ |
|
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
244 |
switch (e->event) { |
0 | 245 |
case WE_PAINT: { |
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
246 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 247 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
248 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
249 |
SetDParam(1, v->unitnumber); |
0 | 250 |
DrawWindowWidgets(w); |
251 |
||
252 |
DrawString(1, 15, STR_A040_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
253 |
||
381
94c4794d6bd4
(svn r570) -newgrf: Support for custom aircrafts via GRF files. Planeset seems to work :). Also use aircraft_vehinfo() instead of the old tables (pasky).
darkvater
parents:
243
diff
changeset
|
254 |
/* TODO: Support for custom GRFSpecial-specified refitting! --pasky */ |
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
255 |
WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel); |
382
c0b43541ed8e
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
256 |
|
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
257 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
258 |
int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_AIRCRAFT); |
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
259 |
if (!CmdFailed(cost)) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
260 |
SetDParam(2, cost); |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
261 |
SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
262 |
SetDParam(1, _aircraft_refit_capacity); |
0 | 263 |
DrawString(1, 137, STR_A041_NEW_CAPACITY_COST_OF_REFIT, 0); |
264 |
} |
|
265 |
} |
|
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
266 |
} break; |
0 | 267 |
|
268 |
case WE_CLICK: |
|
269 |
switch(e->click.widget) { |
|
270 |
case 2: { /* listbox */ |
|
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
271 |
int y = e->click.pt.y - 25; |
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
272 |
if (y >= 0) { |
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
273 |
WP(w,refit_d).sel = y / 10; |
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
274 |
SetWindowDirty(w); |
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
275 |
} |
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
276 |
} break; |
0 | 277 |
case 4: /* refit button */ |
1802
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
278 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
448f187042d3
(svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents:
1790
diff
changeset
|
279 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 280 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT))) |
281 |
DeleteWindow(w); |
|
282 |
} |
|
283 |
break; |
|
284 |
} |
|
285 |
break; |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
static const Widget _aircraft_refit_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
290 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
291 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_A03C_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
292 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_A03E_SELECT_TYPE_OF_CARGO_FOR}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
293 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 136, 157, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
294 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_A03D_REFIT_AIRCRAFT, STR_A03F_REFIT_AIRCRAFT_TO_CARRY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
295 |
{ WIDGETS_END}, |
0 | 296 |
}; |
297 |
||
298 |
static const WindowDesc _aircraft_refit_desc = { |
|
299 |
-1,-1, 240, 170, |
|
300 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
|
301 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
302 |
_aircraft_refit_widgets, |
|
303 |
AircraftRefitWndProc |
|
304 |
}; |
|
305 |
||
306 |
static void ShowAircraftRefitWindow(Vehicle *v) |
|
307 |
{ |
|
308 |
Window *w; |
|
309 |
||
310 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
311 |
||
312 |
_alloc_wnd_parent_num = v->index; |
|
313 |
w = AllocateWindowDesc(&_aircraft_refit_desc); |
|
314 |
w->window_number = v->index; |
|
315 |
w->caption_color = v->owner; |
|
316 |
WP(w,refit_d).sel = -1; |
|
317 |
} |
|
318 |
||
319 |
static void AircraftDetailsWndProc(Window *w, WindowEvent *e) |
|
320 |
{ |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
321 |
switch (e->event) { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
322 |
case WE_PAINT: { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
323 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 324 |
|
325 |
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2); |
|
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
326 |
if (!_patches.servint_aircraft) // disable service-scroller when interval is set to disabled |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
327 |
w->disabled_state |= (1 << 5) | (1 << 6); |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
328 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
329 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
330 |
SetDParam(1, v->unitnumber); |
0 | 331 |
DrawWindowWidgets(w); |
332 |
||
333 |
/* Draw running cost */ |
|
334 |
{ |
|
335 |
int year = v->age / 366; |
|
336 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
337 |
SetDParam(1, year); |
0 | 338 |
|
2252
37e3ca7014e0
(svn r2772) Simplify the age notice in the vehicle details window
tron
parents:
2244
diff
changeset
|
339 |
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
340 |
SetDParam(2, v->max_age / 366); |
538
5dd99f3b7eca
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
534
diff
changeset
|
341 |
SetDParam(3, _price.aircraft_running * AircraftVehInfo(v->engine_type)->running_cost >> 8); |
0 | 342 |
DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0); |
343 |
} |
|
344 |
||
345 |
/* Draw max speed */ |
|
346 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
347 |
SetDParam(0, v->max_speed * 8); |
0 | 348 |
DrawString(2, 25, STR_A00E_MAX_SPEED, 0); |
349 |
} |
|
350 |
||
351 |
/* Draw profit */ |
|
352 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
353 |
SetDParam(0, v->profit_this_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
354 |
SetDParam(1, v->profit_last_year); |
0 | 355 |
DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
356 |
} |
|
357 |
||
358 |
/* Draw breakdown & reliability */ |
|
359 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
360 |
SetDParam(0, v->reliability * 100 >> 16); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
361 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 362 |
DrawString(2, 45, STR_A010_RELIABILITY_BREAKDOWNS, 0); |
363 |
} |
|
364 |
||
365 |
/* Draw service interval text */ |
|
366 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
367 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
368 |
SetDParam(1, v->date_of_last_service); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
369 |
DrawString(13, 103, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 370 |
} |
371 |
||
372 |
DrawAircraftImage(v, 3, 57, INVALID_VEHICLE); |
|
373 |
||
374 |
{ |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
375 |
const Vehicle *u; |
0 | 376 |
int y = 57; |
377 |
||
378 |
do { |
|
379 |
if (v->subtype <= 2) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
380 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
381 |
SetDParam(1, 1920 + v->build_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
382 |
SetDParam(2, v->value); |
0 | 383 |
DrawString(60, y, STR_A011_BUILT_VALUE, 0); |
384 |
y += 10; |
|
385 |
||
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
386 |
SetDParam(0, _cargoc.names_long[v->cargo_type]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
387 |
SetDParam(1, v->cargo_cap); |
0 | 388 |
u = v->next; |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
389 |
SetDParam(2, _cargoc.names_long[u->cargo_type]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
390 |
SetDParam(3, u->cargo_cap); |
2260
3e97367f7cbc
(svn r2780) Remove some more unused strings and make the use of a few strings more explicit
tron
parents:
2252
diff
changeset
|
391 |
DrawString(60, y, (u->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, 0); |
0 | 392 |
y += 14; |
393 |
} |
|
394 |
||
395 |
if (v->cargo_count != 0) { |
|
396 |
||
397 |
/* Cargo names (fix pluralness) */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
398 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
399 |
SetDParam(1, v->cargo_count); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
400 |
SetDParam(2, v->cargo_source); |
0 | 401 |
DrawString(60, y, STR_8813_FROM, 0); |
402 |
||
403 |
y += 10; |
|
404 |
} |
|
405 |
} while ( (v=v->next) != NULL); |
|
406 |
} |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
407 |
} break; |
0 | 408 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
409 |
case WE_CLICK: { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
410 |
int mod; |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
411 |
const Vehicle *v; |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
412 |
switch (e->click.widget) { |
0 | 413 |
case 2: /* rename */ |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
414 |
v = GetVehicle(w->window_number); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
415 |
SetDParam(0, v->unitnumber); |
0 | 416 |
ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w->window_class, w->window_number); |
417 |
break; |
|
418 |
case 5: /* increase int */ |
|
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
419 |
mod = _ctrl_pressed? 5 : 10; |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
420 |
goto do_change_service_int; |
0 | 421 |
case 6: /* decrease int */ |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
422 |
mod = _ctrl_pressed?- 5 : -10; |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
423 |
do_change_service_int: |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
424 |
v = GetVehicle(w->window_number); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
425 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
426 |
mod = GetServiceIntervalClamped(mod + v->service_interval); |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
427 |
if (mod == v->service_interval) return; |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
10
diff
changeset
|
428 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
429 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_AIRCRAFT_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
0 | 430 |
break; |
431 |
} |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
432 |
} break; |
0 | 433 |
|
434 |
case WE_4: |
|
435 |
if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) |
|
436 |
DeleteWindow(w); |
|
437 |
break; |
|
438 |
||
439 |
case WE_ON_EDIT_TEXT: { |
|
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
440 |
if (e->edittext.str[0] != '\0') { |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
441 |
_cmd_text = e->edittext.str; |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
442 |
DoCommandP(0, w->window_number, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
443 |
CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
444 |
} |
0 | 445 |
} break; |
446 |
||
447 |
} |
|
448 |
} |
|
449 |
||
450 |
||
451 |
static const Widget _aircraft_details_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
452 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
453 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 349, 0, 13, STR_A00C_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
454 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 350, 389, 0, 13, STR_01AA_NAME, STR_A032_NAME_AIRCRAFT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
455 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 389, 14, 55, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
456 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 389, 56, 101, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
457 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 102, 107, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
458 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 108, 113, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
459 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 11, 389, 102, 113, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
460 |
{ WIDGETS_END}, |
0 | 461 |
}; |
462 |
||
463 |
static const WindowDesc _aircraft_details_desc = { |
|
464 |
-1,-1, 390, 114, |
|
465 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
466 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
467 |
_aircraft_details_widgets, |
|
468 |
AircraftDetailsWndProc |
|
469 |
}; |
|
470 |
||
471 |
||
472 |
static void ShowAircraftDetailsWindow(Vehicle *v) |
|
473 |
{ |
|
474 |
Window *w; |
|
475 |
VehicleID veh = v->index; |
|
476 |
||
477 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
478 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
479 |
||
480 |
_alloc_wnd_parent_num = veh; |
|
481 |
w = AllocateWindowDesc(&_aircraft_details_desc); |
|
482 |
w->window_number = veh; |
|
483 |
w->caption_color = v->owner; |
|
484 |
// w->vscroll.cap = 6; |
|
485 |
// w->traindetails_d.tab = 0; |
|
486 |
} |
|
487 |
||
488 |
||
489 |
static const Widget _aircraft_view_widgets[] = { |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
490 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
491 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_A00A, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
492 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
493 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 231, 14, 103, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
494 |
{ WWT_6, RESIZE_RB, 14, 2, 229, 16, 101, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
495 |
{ WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 104, 115, 0x0, STR_A027_CURRENT_AIRCRAFT_ACTION }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
496 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
497 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AF, STR_A02A_SEND_AIRCRAFT_TO_HANGAR }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
498 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B4, STR_A03B_REFIT_AIRCRAFT_TO_CARRY }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
499 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_A028_SHOW_AIRCRAFT_S_ORDERS }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
500 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_A02B_SHOW_AIRCRAFT_DETAILS }, |
2244 | 501 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_AIRCRAFT, STR_CLONE_AIRCRAFT_INFO }, |
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
502 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
503 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
504 |
{ WIDGETS_END } |
0 | 505 |
}; |
506 |
||
2244 | 507 |
bool CheckStoppedInHangar(Vehicle *v); |
508 |
||
0 | 509 |
static void AircraftViewWndProc(Window *w, WindowEvent *e) |
510 |
{ |
|
511 |
switch(e->event) { |
|
512 |
case WE_PAINT: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
513 |
Vehicle *v = GetVehicle(w->window_number); |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
514 |
uint32 disabled = 1<<8; |
0 | 515 |
StringID str; |
516 |
||
517 |
{ |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
518 |
TileIndex tile = v->tile; |
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
519 |
|
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1024
diff
changeset
|
520 |
if (IsTileType(tile, MP_STATION) && |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1986
diff
changeset
|
521 |
(_m[tile].m5 == 32 || _m[tile].m5 == 65) && |
0 | 522 |
v->vehstatus&VS_STOPPED) |
523 |
disabled = 0; |
|
524 |
} |
|
525 |
||
526 |
if (v->owner != _local_player) |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
527 |
disabled |= 1<<8 | 1<<7; |
0 | 528 |
w->disabled_state = disabled; |
529 |
||
530 |
/* draw widgets & caption */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
531 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
532 |
SetDParam(1, v->unitnumber); |
0 | 533 |
DrawWindowWidgets(w); |
534 |
||
535 |
if (v->vehstatus & VS_CRASHED) { |
|
536 |
str = STR_8863_CRASHED; |
|
537 |
} else if (v->vehstatus & VS_STOPPED) { |
|
538 |
str = STR_8861_STOPPED; |
|
539 |
} else { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
540 |
switch (v->current_order.type) { |
0 | 541 |
case OT_GOTO_STATION: { |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
542 |
SetDParam(0, v->current_order.station); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
543 |
SetDParam(1, v->cur_speed * 8); |
0 | 544 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
545 |
} break; |
|
546 |
||
547 |
case OT_GOTO_DEPOT: { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
548 |
SetDParam(0, v->current_order.station); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
549 |
SetDParam(1, v->cur_speed * 8); |
0 | 550 |
str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; |
551 |
} break; |
|
552 |
||
553 |
case OT_LOADING: |
|
554 |
str = STR_882F_LOADING_UNLOADING; |
|
555 |
break; |
|
556 |
||
557 |
default: |
|
558 |
if (v->num_orders == 0) { |
|
559 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
560 |
SetDParam(0, v->cur_speed * 8); |
0 | 561 |
} else |
562 |
str = STR_EMPTY; |
|
563 |
break; |
|
564 |
} |
|
565 |
} |
|
566 |
||
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2084
diff
changeset
|
567 |
/* draw the flag plus orders */ |
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
568 |
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1); |
2113
f228b399da01
(svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents:
2103
diff
changeset
|
569 |
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0); |
0 | 570 |
DrawWindowViewport(w); |
571 |
} break; |
|
572 |
||
573 |
case WE_CLICK: { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
574 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 575 |
|
576 |
switch(e->click.widget) { |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
577 |
case 5: /* start stop */ |
0 | 578 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
579 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
580 |
case 6: /* center main view */ |
0 | 581 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
582 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
583 |
case 7: /* goto hangar */ |
0 | 584 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)); |
585 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
586 |
case 8: /* refit */ |
0 | 587 |
ShowAircraftRefitWindow(v); |
588 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
589 |
case 9: /* show orders */ |
0 | 590 |
ShowOrdersWindow(v); |
591 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
592 |
case 10: /* show details */ |
0 | 593 |
ShowAircraftDetailsWindow(v); |
594 |
break; |
|
2244 | 595 |
case 11: { |
596 |
/* clone vehicle */ |
|
597 |
Vehicle *v; |
|
598 |
v = GetVehicle(w->window_number); |
|
599 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneAircraft, CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
|
600 |
} break; |
|
0 | 601 |
} |
602 |
} break; |
|
603 |
||
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
604 |
case WE_RESIZE: |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
605 |
w->viewport->width += e->sizing.diff.x; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
606 |
w->viewport->height += e->sizing.diff.y; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
607 |
w->viewport->virtual_width += e->sizing.diff.x; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
608 |
w->viewport->virtual_height += e->sizing.diff.y; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
609 |
break; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
610 |
|
0 | 611 |
case WE_DESTROY: |
612 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
613 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
|
614 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
615 |
break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
616 |
|
2244 | 617 |
case WE_MOUSELOOP: |
618 |
{ |
|
619 |
Vehicle *v; |
|
620 |
uint32 h; |
|
621 |
v = GetVehicle(w->window_number); |
|
622 |
h = CheckStoppedInHangar(v) ? (1<< 7) : (1 << 11); |
|
623 |
if (h != w->hidden_state) { |
|
624 |
w->hidden_state = h; |
|
625 |
SetWindowDirty(w); |
|
626 |
} |
|
627 |
} break; |
|
628 |
||
0 | 629 |
} |
630 |
} |
|
631 |
||
632 |
||
633 |
static const WindowDesc _aircraft_view_desc = { |
|
634 |
-1,-1, 250, 116, |
|
635 |
WC_VEHICLE_VIEW ,0, |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
636 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 637 |
_aircraft_view_widgets, |
638 |
AircraftViewWndProc |
|
639 |
}; |
|
640 |
||
641 |
||
642 |
void ShowAircraftViewWindow(Vehicle *v) |
|
643 |
{ |
|
644 |
Window *w; |
|
645 |
||
646 |
w = AllocateWindowDescFront(&_aircraft_view_desc, v->index); |
|
647 |
if (w) { |
|
648 |
w->caption_color = v->owner; |
|
649 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
650 |
} |
|
651 |
} |
|
652 |
||
653 |
static void DrawAircraftDepotWindow(Window *w) |
|
654 |
{ |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
655 |
TileIndex tile; |
0 | 656 |
Vehicle *v; |
657 |
int num,x,y; |
|
658 |
||
659 |
tile = w->window_number; |
|
660 |
||
661 |
/* setup disabled buttons */ |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
662 |
w->disabled_state = |
2244 | 663 |
IsTileOwner(tile, _local_player) ? 0 : ((1<<4) | (1<<7) | (1<<8)); |
0 | 664 |
|
665 |
/* determine amount of items for scroller */ |
|
666 |
num = 0; |
|
667 |
FOR_ALL_VEHICLES(v) { |
|
668 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && v->vehstatus&VS_HIDDEN && |
|
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
669 |
v->tile == tile) |
0 | 670 |
num++; |
671 |
} |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
672 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
0 | 673 |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1986
diff
changeset
|
674 |
SetDParam(0, _m[tile].m2); |
0 | 675 |
DrawWindowWidgets(w); |
676 |
||
677 |
x = 2; |
|
678 |
y = 15; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
679 |
num = w->vscroll.pos * w->hscroll.cap; |
0 | 680 |
|
681 |
FOR_ALL_VEHICLES(v) { |
|
682 |
if (v->type == VEH_Aircraft && |
|
683 |
v->subtype <= 2 && |
|
684 |
v->vehstatus&VS_HIDDEN && |
|
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
685 |
v->tile == tile && |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
686 |
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) { |
0 | 687 |
|
688 |
DrawAircraftImage(v, x+12, y, WP(w,traindepot_d).sel); |
|
689 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
690 |
SetDParam(0, v->unitnumber); |
0 | 691 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
692 |
||
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
693 |
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x, y + 12); |
0 | 694 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
695 |
if ((x+=74) == 2 + 74 * w->hscroll.cap) { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
696 |
x = 2; |
0 | 697 |
y += 24; |
698 |
} |
|
699 |
} |
|
700 |
} |
|
701 |
} |
|
702 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
703 |
static int GetVehicleFromAircraftDepotWndPt(const Window *w, int x, int y, Vehicle **veh) { |
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
704 |
uint xt,row,xm,ym; |
0 | 705 |
Vehicle *v; |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
706 |
TileIndex tile; |
0 | 707 |
int pos; |
708 |
||
709 |
xt = x / 74; |
|
710 |
xm = x % 74; |
|
971
1b6f956d8ac5
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
711 |
if (xt >= w->hscroll.cap) |
0 | 712 |
return 1; |
713 |
||
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
714 |
row = (y - 14) / 24; |
0 | 715 |
ym = (y - 14) % 24; |
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
716 |
if (row >= w->vscroll.cap) |
0 | 717 |
return 1; |
718 |
||
971
1b6f956d8ac5
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
719 |
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt; |
0 | 720 |
|
721 |
tile = w->window_number; |
|
722 |
FOR_ALL_VEHICLES(v) { |
|
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
723 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
724 |
v->vehstatus & VS_HIDDEN && v->tile == tile && |
0 | 725 |
--pos < 0) { |
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
726 |
*veh = v; |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
727 |
if (xm >= 12) return 0; |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
728 |
if (ym <= 12) return -1; /* show window */ |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
729 |
return -2; /* start stop */ |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
730 |
} |
0 | 731 |
} |
732 |
return 1; /* outside */ |
|
733 |
} |
|
734 |
||
735 |
static void AircraftDepotClickAircraft(Window *w, int x, int y) |
|
736 |
{ |
|
737 |
Vehicle *v; |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
738 |
int mode = GetVehicleFromAircraftDepotWndPt(w, x, y, &v); |
0 | 739 |
|
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
740 |
// share / copy orders |
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
741 |
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = v; return; } |
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
742 |
|
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
743 |
switch(mode) { |
0 | 744 |
case 1: |
745 |
return; |
|
746 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
747 |
case 0: // start dragging of vehicle |
0 | 748 |
if (v != NULL) { |
749 |
WP(w,traindepot_d).sel = v->index; |
|
750 |
SetWindowDirty(w); |
|
751 |
SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) + GetAircraftImage(v, 6), 4, w); |
|
752 |
} |
|
753 |
break; |
|
754 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
755 |
case -1: // show info window |
0 | 756 |
ShowAircraftViewWindow(v); |
757 |
break; |
|
758 |
||
10
c35ab8426202
(svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik
parents:
0
diff
changeset
|
759 |
case -2: // click start/stop flag |
0 | 760 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
761 |
break; |
|
762 |
||
763 |
default: |
|
764 |
NOT_REACHED(); |
|
765 |
} |
|
766 |
} |
|
767 |
||
2244 | 768 |
/** |
769 |
* Clones an aircraft |
|
770 |
* @param *v is the original vehicle to clone |
|
771 |
* @param *w is the window of the hangar where the clone is build |
|
772 |
*/ |
|
773 |
static bool HandleCloneVehClick(Vehicle *v, Window *w) |
|
774 |
{ |
|
775 |
||
776 |
if (!v){ |
|
777 |
return false; |
|
778 |
} |
|
779 |
||
780 |
if (v->type != VEH_Aircraft) { |
|
781 |
// it's not an aircraft, do nothing |
|
782 |
return false; |
|
783 |
} |
|
784 |
||
785 |
||
2273
95dd61d9ca47
(svn r2795) -Fix: [Clone vehilcle] all error messages should now tell the right vehicle type (chrishuebsch)
bjarni
parents:
2261
diff
changeset
|
786 |
DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0,CcCloneAircraft,CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
2244 | 787 |
|
788 |
ResetObjectToPlace(); |
|
789 |
||
790 |
return true; |
|
791 |
} |
|
792 |
||
793 |
static void ClonePlaceObj(uint tile, Window *w) |
|
794 |
{ |
|
795 |
Vehicle *v; |
|
796 |
||
797 |
||
798 |
v = CheckMouseOverVehicle(); |
|
799 |
if (v && HandleCloneVehClick(v, w)) |
|
800 |
return; |
|
801 |
} |
|
802 |
||
803 |
||
0 | 804 |
static void AircraftDepotWndProc(Window *w, WindowEvent *e) |
805 |
{ |
|
806 |
switch(e->event) { |
|
807 |
case WE_PAINT: |
|
808 |
DrawAircraftDepotWindow(w); |
|
809 |
break; |
|
810 |
||
811 |
case WE_CLICK: |
|
812 |
switch(e->click.widget) { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
813 |
case 5: /* click aircraft */ |
0 | 814 |
AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y); |
815 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
816 |
case 7: /* show build aircraft window */ |
2244 | 817 |
ResetObjectToPlace(); |
0 | 818 |
ShowBuildAircraftWindow(w->window_number); |
819 |
break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
820 |
|
2244 | 821 |
case 8: /* clone button */ |
822 |
InvalidateWidget(w, 8); |
|
823 |
TOGGLEBIT(w->click_state, 8); |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
824 |
|
2244 | 825 |
if (HASBIT(w->click_state, 8)) { |
826 |
_place_clicked_vehicle = NULL; |
|
827 |
SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w); |
|
828 |
} else { |
|
829 |
ResetObjectToPlace(); |
|
830 |
} |
|
831 |
break; |
|
832 |
case 9: /* scroll to tile */ |
|
833 |
ResetObjectToPlace(); |
|
0 | 834 |
ScrollMainWindowToTile(w->window_number); |
835 |
break; |
|
836 |
} |
|
837 |
break; |
|
838 |
||
2244 | 839 |
|
840 |
case WE_PLACE_OBJ: { |
|
841 |
ClonePlaceObj(e->place.tile, w); |
|
842 |
} break; |
|
843 |
||
844 |
case WE_ABORT_PLACE_OBJ: { |
|
845 |
CLRBIT(w->click_state, 8); |
|
846 |
InvalidateWidget(w, 8); |
|
847 |
} break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
848 |
|
2244 | 849 |
// check if a vehicle in a depot was clicked.. |
850 |
case WE_MOUSELOOP: { |
|
851 |
Vehicle *v = _place_clicked_vehicle; |
|
852 |
// since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button |
|
853 |
if (v != NULL && HASBIT(w->click_state, 8)) { |
|
854 |
_place_clicked_vehicle = NULL; |
|
855 |
HandleCloneVehClick( v, w); |
|
856 |
} |
|
857 |
} break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
858 |
|
0 | 859 |
case WE_DESTROY: |
860 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
861 |
break; |
|
862 |
||
863 |
case WE_DRAGDROP: { |
|
864 |
switch(e->click.widget) { |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
865 |
case 5: { |
0 | 866 |
Vehicle *v; |
867 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
868 |
||
869 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
870 |
SetWindowDirty(w); |
|
871 |
||
872 |
if (GetVehicleFromAircraftDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
873 |
v != NULL && |
|
874 |
sel == v->index) { |
|
875 |
ShowAircraftViewWindow(v); |
|
876 |
} |
|
877 |
} break; |
|
878 |
||
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
879 |
case 4: |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
880 |
if (!HASBIT(w->disabled_state, 4) && |
0 | 881 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
882 |
Vehicle *v; |
|
883 |
||
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
884 |
HandleButtonClick(w, 4); |
0 | 885 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
886 |
v = GetVehicle(WP(w,traindepot_d).sel); |
0 | 887 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
888 |
||
889 |
_backup_orders_tile = v->tile; |
|
890 |
BackupVehicleOrders(v, _backup_orders_data); |
|
891 |
||
892 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT))) |
|
893 |
_backup_orders_tile = 0; |
|
894 |
} |
|
895 |
break; |
|
896 |
default: |
|
897 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
898 |
SetWindowDirty(w); |
|
899 |
} |
|
900 |
break; |
|
901 |
} |
|
902 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
903 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
904 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
905 |
w->vscroll.cap += e->sizing.diff.y / 24; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
906 |
w->hscroll.cap += e->sizing.diff.x / 74; |
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
907 |
w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
908 |
break; |
0 | 909 |
} |
910 |
} |
|
911 |
||
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
912 |
static const Widget _aircraft_depot_widgets[] = { |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
913 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
914 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 318, 0, 13, STR_A002_AIRCRAFT_HANGAR, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
915 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 319, 330, 0, 13, 0x0, STR_STICKY_BUTTON}, |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
916 |
{ WWT_PANEL, RESIZE_LRB, 14, 296, 318, 14, 13, 0x0, STR_NULL}, |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
917 |
{ WWT_IMGBTN, RESIZE_LRTB, 14, 296, 318, 14, 61, 0x2A9, STR_A023_DRAG_AIRCRAFT_TO_HERE_TO}, |
0 | 918 |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
919 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 295, 14, 61, 0x204, STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
920 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 319, 330, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
2244 | 921 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 105, 62, 73, STR_A003_NEW_AIRCRAFT, STR_A022_BUILD_NEW_AIRCRAFT}, |
922 |
{WWT_NODISTXTBTN, RESIZE_TB, 14, 106, 212, 62, 73, STR_CLONE_AIRCRAFT, STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW}, |
|
923 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 213, 318, 62, 73, STR_00E4_LOCATION, STR_A024_CENTER_MAIN_VIEW_ON_HANGAR}, |
|
982
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
924 |
{ WWT_PANEL, RESIZE_RTB, 14, 319, 318, 62, 73, 0x0, STR_NULL}, |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
925 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 319, 330, 62, 73, 0x0, STR_RESIZE_BUTTON}, |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
926 |
{ WIDGETS_END}, |
be834034b331
(svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents:
971
diff
changeset
|
927 |
}; |
0 | 928 |
|
929 |
static const WindowDesc _aircraft_depot_desc = { |
|
930 |
-1, -1, 331, 74, |
|
931 |
WC_VEHICLE_DEPOT,0, |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
932 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 933 |
_aircraft_depot_widgets, |
934 |
AircraftDepotWndProc |
|
935 |
}; |
|
936 |
||
937 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
938 |
void ShowAircraftDepotWindow(TileIndex tile) |
0 | 939 |
{ |
940 |
Window *w; |
|
941 |
||
942 |
w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); |
|
943 |
if (w) { |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
944 |
w->caption_color = GetTileOwner(tile); |
0 | 945 |
w->vscroll.cap = 2; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
946 |
w->hscroll.cap = 4; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
947 |
w->resize.step_width = 74; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
948 |
w->resize.step_height = 24; |
0 | 949 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
950 |
_backup_orders_tile = 0; |
|
951 |
} |
|
952 |
} |
|
953 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
954 |
static void DrawSmallOrderList(const Vehicle *v, int x, int y) { |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
955 |
const Order *order; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
956 |
int sel, i = 0; |
0 | 957 |
|
958 |
sel = v->cur_order_index; |
|
959 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
960 |
FOR_VEHICLE_ORDERS(v, order) { |
0 | 961 |
if (sel == 0) { |
962 |
_stringwidth_base = 0xE0; |
|
963 |
DoDrawString( "\xAF", x-6, y, 16); |
|
964 |
_stringwidth_base = 0; |
|
965 |
} |
|
966 |
sel--; |
|
967 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
968 |
if (order->type == OT_GOTO_STATION) { |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
969 |
SetDParam(0, order->station); |
0 | 970 |
DrawString(x, y, STR_A036, 0); |
971 |
||
972 |
y += 6; |
|
973 |
if (++i == 4) |
|
974 |
break; |
|
975 |
} |
|
976 |
} |
|
977 |
} |
|
978 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
979 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
980 |
static const Widget _player_aircraft_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
981 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
982 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
983 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
984 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
985 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
986 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
987 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
988 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
989 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
990 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_A003_NEW_AIRCRAFT, STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
991 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 170, 181, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
992 |
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 170, 181, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
993 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 994 |
{ WIDGETS_END}, |
995 |
}; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
996 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
997 |
static const Widget _other_player_aircraft_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
998 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
999 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1000 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1001 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP}, |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1002 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1003 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1004 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1005 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1006 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1007 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 170, 181, 0x0, STR_NULL}, |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
886
diff
changeset
|
1008 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 1009 |
{ WIDGETS_END}, |
1010 |
}; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1011 |
|
0 | 1012 |
static void PlayerAircraftWndProc(Window *w, WindowEvent *e) |
1013 |
{ |
|
2466
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1014 |
StationID station = GB(w->window_number, 16, 16); |
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1015 |
PlayerID owner = GB(w->window_number, 0, 8); |
588 | 1016 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
1017 |
||
0 | 1018 |
switch(e->event) { |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1019 |
case WE_PAINT: { |
588 | 1020 |
int x = 2; |
1021 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
1022 |
int max; |
|
1023 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1024 |
|
588 | 1025 |
BuildVehicleList(vl, VEH_Aircraft, owner, station); |
1026 |
SortVehicleList(vl); |
|
0 | 1027 |
|
588 | 1028 |
SetVScrollCount(w, vl->list_length); |
1029 |
||
1030 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
1031 |
if (vl->sort_type == SORT_BY_UNSORTED) |
|
757 | 1032 |
w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1033 |
|
0 | 1034 |
/* draw the widgets */ |
1035 |
{ |
|
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1938
diff
changeset
|
1036 |
const Player *p = GetPlayer(owner); |
2466
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1037 |
if (station == INVALID_STATION) { |
588 | 1038 |
/* Company Name -- (###) Aircraft */ |
1039 |
SetDParam(0, p->name_1); |
|
1040 |
SetDParam(1, p->name_2); |
|
1041 |
SetDParam(2, w->vscroll.count); |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1042 |
w->widget[1].unkA = STR_A009_AIRCRAFT; |
588 | 1043 |
} else { |
1044 |
/* Station Name -- (###) Aircraft */ |
|
1294
bc831562148e
(svn r1798) GetFoo(i)->index is per definition i, so replace the former with the latter
tron
parents:
1246
diff
changeset
|
1045 |
SetDParam(0, station); |
588 | 1046 |
SetDParam(1, w->vscroll.count); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1047 |
w->widget[1].unkA = STR_SCHEDULED_AIRCRAFT; |
588 | 1048 |
} |
0 | 1049 |
DrawWindowWidgets(w); |
1050 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1051 |
/* draw sorting criteria string */ |
588 | 1052 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
1053 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
2406
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2273
diff
changeset
|
1054 |
DoDrawString(vl->flags & VL_DESC ? DOWNARROW : UPARROW, 69, 15, 0x10); |
0 | 1055 |
|
588 | 1056 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
1057 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
1058 |
Vehicle *v = GetVehicle(vl->sort_list[i].index); |
588 | 1059 |
StringID str; |
0 | 1060 |
|
588 | 1061 |
assert(v->type == VEH_Aircraft && v->subtype <= 2); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1062 |
|
588 | 1063 |
DrawAircraftImage(v, x + 19, y + 6, INVALID_VEHICLE); |
1064 |
DrawVehicleProfitButton(v, x, y + 13); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1065 |
|
588 | 1066 |
SetDParam(0, v->unitnumber); |
1055
3aae1d6f12aa
(svn r1556) -Fix: Vehicle list updates should now really work
Celestar
parents:
1035
diff
changeset
|
1067 |
if (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_HIDDEN)) |
588 | 1068 |
str = STR_021F; |
1069 |
else |
|
1070 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
1071 |
DrawString(x, y + 2, str, 0); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1072 |
|
588 | 1073 |
SetDParam(0, v->profit_this_year); |
1074 |
SetDParam(1, v->profit_last_year); |
|
1075 |
DrawString(x + 19, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1076 |
||
1077 |
if (v->string_id != STR_SV_AIRCRAFT_NAME) { |
|
1078 |
SetDParam(0, v->string_id); |
|
1079 |
DrawString(x + 19, y, STR_01AB, 0); |
|
0 | 1080 |
} |
588 | 1081 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
1082 |
DrawSmallOrderList(v, x + 136, y); |
588 | 1083 |
|
1084 |
y += PLY_WND_PRC__SIZE_OF_ROW_BIG; |
|
0 | 1085 |
} |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1086 |
} break; |
0 | 1087 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1088 |
case WE_CLICK: { |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1089 |
switch(e->click.widget) { |
757 | 1090 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 1091 |
vl->flags ^= VL_DESC; |
1092 |
vl->flags |= VL_RESORT; |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1093 |
_sorting.aircraft.order = !!(vl->flags & VL_DESC); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1094 |
SetWindowDirty(w); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1095 |
break; |
588 | 1096 |
|
757 | 1097 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 1098 |
ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1099 |
return; |
588 | 1100 |
|
757 | 1101 |
case 7: { /* Matrix to show vehicles */ |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
1102 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1103 |
|
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
168
diff
changeset
|
1104 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1105 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1106 |
id_v += w->vscroll.pos; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1107 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1108 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1109 |
Vehicle *v; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1110 |
|
588 | 1111 |
if (id_v >= vl->list_length) return; // click out of list bound |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1112 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
1113 |
v = GetVehicle(vl->sort_list[id_v].index); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1114 |
|
588 | 1115 |
assert(v->type == VEH_Aircraft && v->subtype <= 2); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1116 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1117 |
ShowAircraftViewWindow(v); |
0 | 1118 |
} |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1119 |
} break; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1120 |
|
757 | 1121 |
case 9: { /* Build new Vehicle */ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
1122 |
TileIndex tile; |
0 | 1123 |
|
886
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1124 |
if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1125 |
break; |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1126 |
|
0 | 1127 |
tile = _last_built_aircraft_depot_tile; |
1128 |
do { |
|
1906
f5ae1d8ad052
(svn r2412) - Fix: [ 1214948 ] building vehicles without depot crashes game. (Chris Huebsch)
hackykid
parents:
1901
diff
changeset
|
1129 |
if (IsAircraftHangarTile(tile) && IsTileOwner(tile, _local_player)) { |
0 | 1130 |
ShowAircraftDepotWindow(tile); |
1131 |
ShowBuildAircraftWindow(tile); |
|
1132 |
return; |
|
1133 |
} |
|
1134 |
||
1135 |
tile = TILE_MASK(tile + 1); |
|
1136 |
} while(tile != _last_built_aircraft_depot_tile); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1137 |
|
0 | 1138 |
ShowBuildAircraftWindow(0); |
1139 |
} break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1140 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1141 |
case 10: |
886
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1142 |
if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1143 |
break; |
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
867
diff
changeset
|
1144 |
|
842 | 1145 |
ShowReplaceVehicleWindow(VEH_Aircraft); |
1146 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1147 |
|
0 | 1148 |
} |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1149 |
} break; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1150 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1151 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1152 |
if (vl->sort_type != e->dropdown.index) { |
1153 |
// value has changed -> resort |
|
1154 |
vl->flags |= VL_RESORT; |
|
1155 |
vl->sort_type = e->dropdown.index; |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1156 |
_sorting.aircraft.criteria = vl->sort_type; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1157 |
|
588 | 1158 |
// enable 'Sort By' if a sorter criteria is chosen |
1159 |
if (vl->sort_type != SORT_BY_UNSORTED) |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1160 |
CLRBIT(w->disabled_state, 3); |
588 | 1161 |
} |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1162 |
SetWindowDirty(w); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1163 |
break; |
588 | 1164 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1165 |
case WE_CREATE: /* set up resort timer */ |
588 | 1166 |
vl->sort_list = NULL; |
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1167 |
vl->flags = VL_REBUILD | (_sorting.aircraft.order << (VL_DESC - 1)); |
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1168 |
vl->sort_type = _sorting.aircraft.criteria; |
588 | 1169 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1170 |
break; |
588 | 1171 |
|
767 | 1172 |
case WE_DESTROY: |
1173 |
free(vl->sort_list); |
|
1174 |
break; |
|
1175 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1176 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1177 |
if (--vl->resort_timer == 0) { |
1178 |
DEBUG(misc, 1) ("Periodic resort aircraft list player %d station %d", |
|
1179 |
owner, station); |
|
1180 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1181 |
vl->flags |= VL_RESORT; |
|
1182 |
SetWindowDirty(w); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1183 |
} |
0 | 1184 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1185 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1186 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1187 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1188 |
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_BIG; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1189 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1190 |
break; |
0 | 1191 |
} |
1192 |
} |
|
1193 |
||
1194 |
static const WindowDesc _player_aircraft_desc = { |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1195 |
-1, -1, 260, 182, |
0 | 1196 |
WC_AIRCRAFT_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1197 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1198 |
_player_aircraft_widgets, |
1199 |
PlayerAircraftWndProc |
|
1200 |
}; |
|
1201 |
||
1202 |
static const WindowDesc _other_player_aircraft_desc = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1203 |
-1, -1, 260, 182, |
0 | 1204 |
WC_AIRCRAFT_LIST,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1205 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1206 |
_other_player_aircraft_widgets, |
1207 |
PlayerAircraftWndProc |
|
1208 |
}; |
|
1209 |
||
2466
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1210 |
void ShowPlayerAircraft(PlayerID player, StationID station) |
0 | 1211 |
{ |
1212 |
Window *w; |
|
1213 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
1214 |
if (player == _local_player) { |
588 | 1215 |
w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | player); |
0 | 1216 |
} else { |
588 | 1217 |
w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | player); |
0 | 1218 |
} |
1219 |
||
1220 |
if (w) { |
|
1221 |
w->caption_color = w->window_number; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1222 |
w->vscroll.cap = 4; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1223 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1224 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG; |
0 | 1225 |
} |
1226 |
} |