author | Darkvater |
Sun, 13 Aug 2006 10:22:34 +0000 | |
changeset 4258 | 087d44b3514f |
parent 4243 | b0361faa4dfd |
child 4261 | 28670f743746 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
4 |
#include "openttd.h" |
3963
6cab57074a9a
(svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
3948
diff
changeset
|
5 |
#include "aircraft.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
6 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
7 |
#include "functions.h" |
3315
c9d989783c55
(svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
3157
diff
changeset
|
8 |
#include "station_map.h" |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
9 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
382
diff
changeset
|
10 |
#include "table/strings.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
588
diff
changeset
|
11 |
#include "map.h" |
1209
2e00193652b2
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1055
diff
changeset
|
12 |
#include "tile.h" |
0 | 13 |
#include "window.h" |
14 |
#include "gui.h" |
|
15 |
#include "vehicle.h" |
|
16 |
#include "gfx.h" |
|
17 |
#include "station.h" |
|
18 |
#include "command.h" |
|
19 |
#include "engine.h" |
|
20 |
#include "viewport.h" |
|
21 |
#include "player.h" |
|
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
22 |
#include "depot.h" |
4153
4dabb03d629c
(svn r5519) Fix: Only list helicopters in the new build window of helidepots and helistations.Suggested by peter1138 & Tron.
richk
parents:
4077
diff
changeset
|
23 |
#include "airport.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2113
diff
changeset
|
24 |
#include "vehicle_gui.h" |
2962
f0a49b646c48
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2958
diff
changeset
|
25 |
#include "newgrf_engine.h" |
0 | 26 |
|
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
27 |
/** |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
28 |
* Draw the purchase info details of an aircraft at a given location. |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
29 |
* @param x,y location where to draw the info |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
30 |
* @param engine_number the engine of which to draw the info of |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
31 |
*/ |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
32 |
void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number) |
842 | 33 |
{ |
34 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number); |
|
4171 | 35 |
const Engine *e = GetEngine(engine_number); |
3987
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
36 |
CargoID cargo; |
842 | 37 |
YearMonthDay ymd; |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
38 |
ConvertDayToYMD(&ymd, e->intro_date); |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
39 |
|
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
40 |
/* Purchase cost - Max speed */ |
842 | 41 |
SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3338
diff
changeset
|
42 |
SetDParam(1, avi->max_speed * 128 / 10); |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
43 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
44 |
y += 10; |
842 | 45 |
|
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
46 |
/* Cargo capacity */ |
3987
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
47 |
cargo = FindFirstRefittableCargo(engine_number); |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
48 |
if (cargo == CT_INVALID || cargo == CT_PASSENGERS) { |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
49 |
SetDParam(0, avi->passenger_capacity); |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
50 |
SetDParam(1, avi->mail_capacity); |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
51 |
DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, 0); |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
52 |
} else { |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
53 |
/* Note, if the default capacity is selected by the refit capacity |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
54 |
* callback, then the capacity shown is likely to be incorrect. */ |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
55 |
SetDParam(0, _cargoc.names_long[cargo]); |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
56 |
SetDParam(1, AircraftDefaultCargoCapacity(cargo, engine_number)); |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
57 |
SetDParam(2, STR_9842_REFITTABLE); |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
58 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
22972f38e240
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
59 |
} |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
60 |
y += 10; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
61 |
|
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
62 |
/* Running cost */ |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
63 |
SetDParam(0, avi->running_cost * _price.aircraft_running >> 8); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
64 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
65 |
y += 10; |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
66 |
|
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
67 |
/* Design date - Life length */ |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
68 |
SetDParam(0, ymd.year + 1920); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
69 |
SetDParam(1, e->lifelength); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
70 |
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
71 |
y += 10; |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
72 |
|
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
73 |
/* Reliability */ |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
74 |
SetDParam(0, e->reliability * 100 >> 16); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
75 |
DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, 0); |
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
76 |
y += 10; |
4243
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
77 |
|
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
78 |
/* Additional text from NewGRF */ |
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
79 |
// XXX 227 will become a calculated width... |
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
80 |
y += ShowAdditionalText(x, y, 227, engine_number); |
842 | 81 |
} |
82 |
||
1790
47963a0cfca3
(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
|
83 |
static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection) |
0 | 84 |
{ |
3049
d6109b5fd55d
(svn r3631) - 2cc: Remove use of some temporary variables and perform minor optimization in the form of the ternary operator.
peter1138
parents:
3040
diff
changeset
|
85 |
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3049
diff
changeset
|
86 |
DrawSprite(GetAircraftImage(v, DIR_W) | pal, x + 25, y + 10); |
4056
7899dc230a12
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4012
diff
changeset
|
87 |
if (v->subtype == 0) { |
7899dc230a12
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4012
diff
changeset
|
88 |
SpriteID rotor_sprite = GetCustomRotorSprite(v, true); |
7899dc230a12
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4012
diff
changeset
|
89 |
if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED; |
7899dc230a12
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4012
diff
changeset
|
90 |
DrawSprite(rotor_sprite, x + 25, y + 5); |
7899dc230a12
(svn r5336) - NewGRF: draw custom helicopter rotor sprites in vehicle info window, ensuring the correct direction is used (inspiration from mart3p)
peter1138
parents:
4012
diff
changeset
|
91 |
} |
0 | 92 |
if (v->index == selection) { |
2639 | 93 |
DrawFrameRect(x - 1, y - 1, x + 58, y + 21, 0xF, FR_BORDERONLY); |
0 | 94 |
} |
95 |
} |
|
96 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
97 |
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 98 |
{ |
2630 | 99 |
if (success) { |
4171 | 100 |
const Vehicle *v = GetVehicle(_new_vehicle_id); |
0 | 101 |
|
102 |
if (v->tile == _backup_orders_tile) { |
|
103 |
_backup_orders_tile = 0; |
|
104 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
105 |
} |
|
106 |
ShowAircraftViewWindow(v); |
|
107 |
} |
|
108 |
} |
|
109 |
||
3887
ece644bbf459
(svn r4943) uint tile -> TileIndex tile, byte player -> PlayerID player
tron
parents:
3884
diff
changeset
|
110 |
void CcCloneAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2) |
2244 | 111 |
{ |
3948
a09379beffd5
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3887
diff
changeset
|
112 |
if (success) ShowAircraftViewWindow(GetVehicle(_new_vehicle_id)); |
2244 | 113 |
} |
0 | 114 |
|
115 |
static void NewAircraftWndProc(Window *w, WindowEvent *e) |
|
116 |
{ |
|
2639 | 117 |
switch (e->event) { |
0 | 118 |
case WE_PAINT: { |
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
119 |
TileIndex tile = w->window_number; |
4162
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
120 |
byte acc_planes; |
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
121 |
|
4162
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
122 |
if (tile == 0) { |
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
123 |
SETBIT(w->disabled_state, 5); |
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
124 |
acc_planes = ALL; |
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
125 |
} else { |
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
126 |
acc_planes = GetAirport(GetStationByTile(tile)->airport_type)->acc_planes; |
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
127 |
} |
0 | 128 |
|
129 |
{ |
|
130 |
int count = 0; |
|
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
131 |
EngineID eid; |
1926
530480d14685
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
132 |
|
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
133 |
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { |
4171 | 134 |
const AircraftVehicleInfo *avi; |
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
135 |
|
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
136 |
if (!HASBIT(GetEngine(eid)->player_avail, _local_player)) continue; |
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
137 |
|
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
138 |
avi = AircraftVehInfo(eid); |
4162
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
139 |
if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == acc_planes) continue; |
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
140 |
|
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
141 |
count++; |
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
142 |
} |
0 | 143 |
SetVScrollCount(w, count); |
144 |
} |
|
145 |
||
146 |
DrawWindowWidgets(w); |
|
147 |
||
148 |
{ |
|
149 |
int x = 2; |
|
150 |
int y = 15; |
|
151 |
int sel = WP(w,buildtrain_d).sel_index; |
|
152 |
int pos = w->vscroll.pos; |
|
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
153 |
EngineID selected_id = INVALID_ENGINE; |
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
154 |
EngineID eid; |
0 | 155 |
|
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
156 |
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { |
4171 | 157 |
const AircraftVehicleInfo *avi; |
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
158 |
|
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
159 |
if (!HASBIT(GetEngine(eid)->player_avail, _local_player)) continue; |
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
160 |
|
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
161 |
avi = AircraftVehInfo(eid); |
4162
55a57b73a408
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
162 |
if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == acc_planes) continue; |
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
163 |
|
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
164 |
if (sel == 0) selected_id = eid; |
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
165 |
|
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
166 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
167 |
DrawString(x + 62, y + 7, GetCustomEngineName(eid), sel == 0 ? 0xC : 0x10); |
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
168 |
DrawAircraftEngine(x + 29, y + 10, eid, GetEnginePalette(eid, _local_player)); |
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
169 |
y += 24; |
0 | 170 |
} |
4161
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
171 |
|
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
172 |
sel--; |
60e38778d90b
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
tron
parents:
4153
diff
changeset
|
173 |
} |
0 | 174 |
|
175 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
176 |
||
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
177 |
if (selected_id != INVALID_ENGINE) { |
1907
61bafb476865
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
178 |
DrawAircraftPurchaseInfo(2, w->widget[4].top + 1, selected_id); |
0 | 179 |
} |
180 |
} |
|
181 |
} break; |
|
182 |
||
183 |
case WE_CLICK: |
|
2952 | 184 |
switch (e->click.widget) { |
0 | 185 |
case 2: { /* listbox */ |
186 |
uint i = (e->click.pt.y - 14) / 24; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
187 |
if (i < w->vscroll.cap) { |
0 | 188 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
189 |
SetWindowDirty(w); |
|
190 |
} |
|
191 |
} break; |
|
192 |
||
193 |
case 5: { /* build */ |
|
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
194 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
195 |
if (sel_eng != INVALID_ENGINE) |
0 | 196 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
197 |
} break; |
|
198 |
||
968
84a870c7a585
(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
|
199 |
case 6: { /* rename */ |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
200 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
201 |
if (sel_eng != INVALID_ENGINE) { |
968
84a870c7a585
(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
|
202 |
WP(w,buildtrain_d).rename_engine = sel_eng; |
84a870c7a585
(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
|
203 |
ShowQueryString(GetCustomEngineName(sel_eng), |
84a870c7a585
(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
|
204 |
STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number); |
84a870c7a585
(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
|
205 |
} |
84a870c7a585
(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
|
206 |
} break; |
0 | 207 |
} |
208 |
break; |
|
209 |
||
210 |
case WE_ON_EDIT_TEXT: { |
|
1820
d03c56850dc2
(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
|
211 |
if (e->edittext.str[0] != '\0') { |
d03c56850dc2
(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
|
212 |
_cmd_text = e->edittext.str; |
d03c56850dc2
(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
|
213 |
DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, |
d03c56850dc2
(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
|
214 |
CMD_RENAME_ENGINE | CMD_MSG(STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE)); |
d03c56850dc2
(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
|
215 |
} |
0 | 216 |
} break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
217 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
218 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
219 |
w->vscroll.cap += e->sizing.diff.y / 24; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
220 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
221 |
break; |
0 | 222 |
} |
223 |
} |
|
224 |
||
225 |
static const Widget _new_aircraft_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2647
diff
changeset
|
226 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
227 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_A005_NEW_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
893
f4698309dec7
(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
|
228 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 227, 14, 109, 0x401, STR_A025_AIRCRAFT_SELECTION_LIST}, |
f4698309dec7
(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
|
229 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 228, 239, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
4243
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
230 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 239, 110, 181, 0x0, STR_NULL}, |
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
231 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 114, 182, 193, STR_A006_BUILD_AIRCRAFT, STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT}, |
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
232 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 115, 227, 182, 193, STR_A037_RENAME, STR_A038_RENAME_AIRCRAFT_TYPE}, |
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
233 |
{ WWT_RESIZEBOX, RESIZE_TB, 14, 228, 239, 182, 193, 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
|
234 |
{ WIDGETS_END}, |
0 | 235 |
}; |
236 |
||
237 |
static const WindowDesc _new_aircraft_desc = { |
|
4243
b0361faa4dfd
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
238 |
-1, -1, 240, 194, |
0 | 239 |
WC_BUILD_VEHICLE,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
240 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 241 |
_new_aircraft_widgets, |
242 |
NewAircraftWndProc |
|
243 |
}; |
|
244 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
245 |
static void ShowBuildAircraftWindow(TileIndex tile) |
0 | 246 |
{ |
247 |
Window *w; |
|
248 |
||
249 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
250 |
||
251 |
w = AllocateWindowDesc(&_new_aircraft_desc); |
|
252 |
w->window_number = tile; |
|
253 |
w->vscroll.cap = 4; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
254 |
w->widget[2].unkA = (w->vscroll.cap << 8) + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
255 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
256 |
w->resize.step_height = 24; |
0 | 257 |
|
258 |
if (tile != 0) { |
|
1901
03bf9bf99319
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
259 |
w->caption_color = GetTileOwner(tile); |
0 | 260 |
} else { |
261 |
w->caption_color = _local_player; |
|
262 |
} |
|
263 |
} |
|
264 |
||
265 |
static void AircraftRefitWndProc(Window *w, WindowEvent *e) |
|
266 |
{ |
|
1802
da61740cc1e7
(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
|
267 |
switch (e->event) { |
0 | 268 |
case WE_PAINT: { |
1802
da61740cc1e7
(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
|
269 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 270 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
271 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
272 |
SetDParam(1, v->unitnumber); |
0 | 273 |
DrawWindowWidgets(w); |
274 |
||
275 |
DrawString(1, 15, STR_A040_SELECT_CARGO_TYPE_TO_CARRY, 0); |
|
276 |
||
381
527e47c8feec
(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
|
277 |
/* TODO: Support for custom GRFSpecial-specified refitting! --pasky */ |
1802
da61740cc1e7
(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 |
WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel); |
382
9f80e5141ef1
(svn r572) -newgrf: Support for custom (newGRF-yielded) refit masks for trains and aircrafts (pasky).
darkvater
parents:
381
diff
changeset
|
279 |
|
1802
da61740cc1e7
(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
|
280 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3477
diff
changeset
|
281 |
int32 cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_AIRCRAFT); |
1802
da61740cc1e7
(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
|
282 |
if (!CmdFailed(cost)) { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
283 |
SetDParam(2, cost); |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
284 |
SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]); |
3008
cef26520c91e
(svn r3588) - Refit: Use only one global to return the refit capacity rather than one per vehicle type.
peter1138
parents:
2962
diff
changeset
|
285 |
SetDParam(1, _returned_refit_capacity); |
2798
b0e26ead5de8
(svn r3346) - Increase size of aircraft refit window by one item; fixes "[ 1387477 ] Can't refit aircraft to carry Fizzy Drinks"
peter1138
parents:
2755
diff
changeset
|
286 |
DrawString(1, 147, STR_A041_NEW_CAPACITY_COST_OF_REFIT, 0); |
0 | 287 |
} |
288 |
} |
|
1802
da61740cc1e7
(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
|
289 |
} break; |
0 | 290 |
|
291 |
case WE_CLICK: |
|
2952 | 292 |
switch (e->click.widget) { |
0 | 293 |
case 2: { /* listbox */ |
1802
da61740cc1e7
(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
|
294 |
int y = e->click.pt.y - 25; |
da61740cc1e7
(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
|
295 |
if (y >= 0) { |
da61740cc1e7
(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
|
296 |
WP(w,refit_d).sel = y / 10; |
da61740cc1e7
(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
|
297 |
SetWindowDirty(w); |
da61740cc1e7
(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
|
298 |
} |
da61740cc1e7
(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
|
299 |
} break; |
0 | 300 |
case 4: /* refit button */ |
1802
da61740cc1e7
(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
|
301 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
da61740cc1e7
(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
|
302 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 303 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT))) |
304 |
DeleteWindow(w); |
|
305 |
} |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
306 |
break; |
0 | 307 |
} |
308 |
break; |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
static const Widget _aircraft_refit_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2647
diff
changeset
|
313 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
314 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_A03C_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
2798
b0e26ead5de8
(svn r3346) - Increase size of aircraft refit window by one item; fixes "[ 1387477 ] Can't refit aircraft to carry Fizzy Drinks"
peter1138
parents:
2755
diff
changeset
|
315 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 145, 0x0, STR_A03E_SELECT_TYPE_OF_CARGO_FOR}, |
b0e26ead5de8
(svn r3346) - Increase size of aircraft refit window by one item; fixes "[ 1387477 ] Can't refit aircraft to carry Fizzy Drinks"
peter1138
parents:
2755
diff
changeset
|
316 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 146, 167, 0x0, STR_NULL}, |
b0e26ead5de8
(svn r3346) - Increase size of aircraft refit window by one item; fixes "[ 1387477 ] Can't refit aircraft to carry Fizzy Drinks"
peter1138
parents:
2755
diff
changeset
|
317 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 168, 179, 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
|
318 |
{ WIDGETS_END}, |
0 | 319 |
}; |
320 |
||
321 |
static const WindowDesc _aircraft_refit_desc = { |
|
2798
b0e26ead5de8
(svn r3346) - Increase size of aircraft refit window by one item; fixes "[ 1387477 ] Can't refit aircraft to carry Fizzy Drinks"
peter1138
parents:
2755
diff
changeset
|
322 |
-1,-1, 240, 180, |
0 | 323 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
324 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
325 |
_aircraft_refit_widgets, |
|
326 |
AircraftRefitWndProc |
|
327 |
}; |
|
328 |
||
4171 | 329 |
static void ShowAircraftRefitWindow(const Vehicle *v) |
0 | 330 |
{ |
331 |
Window *w; |
|
332 |
||
333 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
334 |
||
335 |
_alloc_wnd_parent_num = v->index; |
|
336 |
w = AllocateWindowDesc(&_aircraft_refit_desc); |
|
337 |
w->window_number = v->index; |
|
338 |
w->caption_color = v->owner; |
|
339 |
WP(w,refit_d).sel = -1; |
|
340 |
} |
|
341 |
||
342 |
static void AircraftDetailsWndProc(Window *w, WindowEvent *e) |
|
343 |
{ |
|
1790
47963a0cfca3
(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
|
344 |
switch (e->event) { |
47963a0cfca3
(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
|
345 |
case WE_PAINT: { |
47963a0cfca3
(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
|
346 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 347 |
|
348 |
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
|
349 |
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
|
350 |
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
|
351 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
352 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
353 |
SetDParam(1, v->unitnumber); |
0 | 354 |
DrawWindowWidgets(w); |
355 |
||
356 |
/* Draw running cost */ |
|
357 |
{ |
|
358 |
int year = v->age / 366; |
|
359 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
360 |
SetDParam(1, year); |
0 | 361 |
|
2252
6df2bfd7a077
(svn r2772) Simplify the age notice in the vehicle details window
tron
parents:
2244
diff
changeset
|
362 |
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
363 |
SetDParam(2, v->max_age / 366); |
538
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
534
diff
changeset
|
364 |
SetDParam(3, _price.aircraft_running * AircraftVehInfo(v->engine_type)->running_cost >> 8); |
0 | 365 |
DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0); |
366 |
} |
|
367 |
||
368 |
/* Draw max speed */ |
|
369 |
{ |
|
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3338
diff
changeset
|
370 |
SetDParam(0, v->max_speed * 128 / 10); |
0 | 371 |
DrawString(2, 25, STR_A00E_MAX_SPEED, 0); |
372 |
} |
|
373 |
||
374 |
/* Draw profit */ |
|
375 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
376 |
SetDParam(0, v->profit_this_year); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
377 |
SetDParam(1, v->profit_last_year); |
0 | 378 |
DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
379 |
} |
|
380 |
||
381 |
/* Draw breakdown & reliability */ |
|
382 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
383 |
SetDParam(0, v->reliability * 100 >> 16); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
384 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 385 |
DrawString(2, 45, STR_A010_RELIABILITY_BREAKDOWNS, 0); |
386 |
} |
|
387 |
||
388 |
/* Draw service interval text */ |
|
389 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
390 |
SetDParam(0, v->service_interval); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
391 |
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
|
392 |
DrawString(13, 103, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 393 |
} |
394 |
||
395 |
DrawAircraftImage(v, 3, 57, INVALID_VEHICLE); |
|
396 |
||
397 |
{ |
|
1790
47963a0cfca3
(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
|
398 |
const Vehicle *u; |
0 | 399 |
int y = 57; |
400 |
||
401 |
do { |
|
402 |
if (v->subtype <= 2) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
403 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
404 |
SetDParam(1, 1920 + v->build_year); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
405 |
SetDParam(2, v->value); |
0 | 406 |
DrawString(60, y, STR_A011_BUILT_VALUE, 0); |
407 |
y += 10; |
|
408 |
||
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
409 |
SetDParam(0, _cargoc.names_long[v->cargo_type]); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
410 |
SetDParam(1, v->cargo_cap); |
0 | 411 |
u = v->next; |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
412 |
SetDParam(2, _cargoc.names_long[u->cargo_type]); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
413 |
SetDParam(3, u->cargo_cap); |
2260
10154bc4c650
(svn r2780) Remove some more unused strings and make the use of a few strings more explicit
tron
parents:
2252
diff
changeset
|
414 |
DrawString(60, y, (u->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, 0); |
0 | 415 |
y += 14; |
416 |
} |
|
417 |
||
418 |
if (v->cargo_count != 0) { |
|
419 |
||
420 |
/* Cargo names (fix pluralness) */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
421 |
SetDParam(0, v->cargo_type); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
422 |
SetDParam(1, v->cargo_count); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
423 |
SetDParam(2, v->cargo_source); |
0 | 424 |
DrawString(60, y, STR_8813_FROM, 0); |
425 |
||
426 |
y += 10; |
|
427 |
} |
|
428 |
} while ( (v=v->next) != NULL); |
|
429 |
} |
|
1790
47963a0cfca3
(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
|
430 |
} break; |
0 | 431 |
|
1790
47963a0cfca3
(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 |
case WE_CLICK: { |
47963a0cfca3
(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
|
433 |
int mod; |
47963a0cfca3
(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
|
434 |
const Vehicle *v; |
47963a0cfca3
(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
|
435 |
switch (e->click.widget) { |
0 | 436 |
case 2: /* rename */ |
1790
47963a0cfca3
(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
|
437 |
v = GetVehicle(w->window_number); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
438 |
SetDParam(0, v->unitnumber); |
0 | 439 |
ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w->window_class, w->window_number); |
440 |
break; |
|
441 |
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
|
442 |
mod = _ctrl_pressed? 5 : 10; |
1790
47963a0cfca3
(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
|
443 |
goto do_change_service_int; |
0 | 444 |
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
|
445 |
mod = _ctrl_pressed?- 5 : -10; |
1790
47963a0cfca3
(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
|
446 |
do_change_service_int: |
47963a0cfca3
(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
|
447 |
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
|
448 |
|
1790
47963a0cfca3
(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
|
449 |
mod = GetServiceIntervalClamped(mod + v->service_interval); |
47963a0cfca3
(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
|
450 |
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
|
451 |
|
2819
f25fb6ee397f
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
tron
parents:
2806
diff
changeset
|
452 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
0 | 453 |
break; |
454 |
} |
|
1790
47963a0cfca3
(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
|
455 |
} break; |
0 | 456 |
|
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
457 |
case WE_ON_EDIT_TEXT: |
1820
d03c56850dc2
(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
|
458 |
if (e->edittext.str[0] != '\0') { |
d03c56850dc2
(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
|
459 |
_cmd_text = e->edittext.str; |
d03c56850dc2
(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
|
460 |
DoCommandP(0, w->window_number, 0, NULL, |
d03c56850dc2
(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
|
461 |
CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT)); |
d03c56850dc2
(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
|
462 |
} |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
463 |
break; |
0 | 464 |
} |
465 |
} |
|
466 |
||
467 |
||
468 |
static const Widget _aircraft_details_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2647
diff
changeset
|
469 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
470 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 349, 0, 13, STR_A00C_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
471 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 350, 389, 0, 13, STR_01AA_NAME, STR_A032_NAME_AIRCRAFT}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
472 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 389, 14, 55, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
473 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 389, 56, 101, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
474 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 102, 107, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
475 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 108, 113, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
476 |
{ 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
|
477 |
{ WIDGETS_END}, |
0 | 478 |
}; |
479 |
||
480 |
static const WindowDesc _aircraft_details_desc = { |
|
481 |
-1,-1, 390, 114, |
|
482 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
483 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
484 |
_aircraft_details_widgets, |
|
485 |
AircraftDetailsWndProc |
|
486 |
}; |
|
487 |
||
488 |
||
4171 | 489 |
static void ShowAircraftDetailsWindow(const Vehicle *v) |
0 | 490 |
{ |
491 |
Window *w; |
|
492 |
VehicleID veh = v->index; |
|
493 |
||
494 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
495 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
496 |
||
497 |
_alloc_wnd_parent_num = veh; |
|
498 |
w = AllocateWindowDesc(&_aircraft_details_desc); |
|
499 |
w->window_number = veh; |
|
500 |
w->caption_color = v->owner; |
|
501 |
// w->vscroll.cap = 6; |
|
502 |
// w->traindetails_d.tab = 0; |
|
503 |
} |
|
504 |
||
505 |
||
506 |
static const Widget _aircraft_view_widgets[] = { |
|
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2647
diff
changeset
|
507 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
508 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_A00A, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
509 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
510 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 231, 14, 103, 0x0, STR_NULL }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
511 |
{ WWT_6, RESIZE_RB, 14, 2, 229, 16, 101, 0x0, STR_NULL }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
512 |
{ WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 104, 115, 0x0, STR_A027_CURRENT_AIRCRAFT_ACTION }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
513 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
514 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AF, STR_A02A_SEND_AIRCRAFT_TO_HANGAR }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
515 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B4, STR_A03B_REFIT_AIRCRAFT_TO_CARRY }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
516 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_A028_SHOW_AIRCRAFT_S_ORDERS }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
517 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_A02B_SHOW_AIRCRAFT_DETAILS }, |
2244 | 518 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_AIRCRAFT, STR_CLONE_AIRCRAFT_INFO }, |
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
519 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
520 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
521 |
{ WIDGETS_END } |
0 | 522 |
}; |
523 |
||
2244 | 524 |
|
0 | 525 |
static void AircraftViewWndProc(Window *w, WindowEvent *e) |
526 |
{ |
|
2952 | 527 |
switch (e->event) { |
0 | 528 |
case WE_PAINT: { |
4171 | 529 |
const Vehicle *v = GetVehicle(w->window_number); |
2639 | 530 |
uint32 disabled = 1 << 8; |
0 | 531 |
StringID str; |
532 |
||
3963
6cab57074a9a
(svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
3948
diff
changeset
|
533 |
if (IsAircraftInHangarStopped(v)) disabled = 0; |
0 | 534 |
|
2639 | 535 |
if (v->owner != _local_player) disabled |= 1 << 8 | 1 << 7; |
0 | 536 |
w->disabled_state = disabled; |
537 |
||
538 |
/* draw widgets & caption */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
539 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
540 |
SetDParam(1, v->unitnumber); |
0 | 541 |
DrawWindowWidgets(w); |
542 |
||
543 |
if (v->vehstatus & VS_CRASHED) { |
|
544 |
str = STR_8863_CRASHED; |
|
545 |
} else if (v->vehstatus & VS_STOPPED) { |
|
546 |
str = STR_8861_STOPPED; |
|
547 |
} else { |
|
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
548 |
switch (v->current_order.type) { |
0 | 549 |
case OT_GOTO_STATION: { |
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
550 |
SetDParam(0, v->current_order.station); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3338
diff
changeset
|
551 |
SetDParam(1, v->cur_speed * 128 / 10); |
0 | 552 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
553 |
} break; |
|
554 |
||
555 |
case OT_GOTO_DEPOT: { |
|
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
556 |
SetDParam(0, v->current_order.station); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3338
diff
changeset
|
557 |
SetDParam(1, v->cur_speed * 128 / 10); |
0 | 558 |
str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; |
559 |
} break; |
|
560 |
||
561 |
case OT_LOADING: |
|
562 |
str = STR_882F_LOADING_UNLOADING; |
|
563 |
break; |
|
564 |
||
565 |
default: |
|
566 |
if (v->num_orders == 0) { |
|
567 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3338
diff
changeset
|
568 |
SetDParam(0, v->cur_speed * 128 / 10); |
2639 | 569 |
} else { |
0 | 570 |
str = STR_EMPTY; |
2639 | 571 |
} |
0 | 572 |
break; |
573 |
} |
|
574 |
} |
|
575 |
||
2103
a2b3106d33d5
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2084
diff
changeset
|
576 |
/* draw the flag plus orders */ |
2517
6e3832ddd0f6
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
577 |
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1); |
2113
be2f07df0dfa
(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
|
578 |
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0); |
0 | 579 |
DrawWindowViewport(w); |
580 |
} break; |
|
581 |
||
582 |
case WE_CLICK: { |
|
4171 | 583 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 584 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
585 |
switch (e->click.widget) { |
755
80091de50044
(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 5: /* start stop */ |
0 | 587 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
588 |
break; |
|
755
80091de50044
(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 6: /* center main view */ |
0 | 590 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
591 |
break; |
|
755
80091de50044
(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 7: /* goto hangar */ |
0 | 593 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)); |
594 |
break; |
|
755
80091de50044
(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
|
595 |
case 8: /* refit */ |
0 | 596 |
ShowAircraftRefitWindow(v); |
597 |
break; |
|
755
80091de50044
(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
|
598 |
case 9: /* show orders */ |
0 | 599 |
ShowOrdersWindow(v); |
600 |
break; |
|
755
80091de50044
(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
|
601 |
case 10: /* show details */ |
0 | 602 |
ShowAircraftDetailsWindow(v); |
603 |
break; |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
604 |
case 11: |
2244 | 605 |
/* clone vehicle */ |
606 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneAircraft, CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
607 |
break; |
0 | 608 |
} |
609 |
} break; |
|
610 |
||
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
611 |
case WE_RESIZE: |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
612 |
w->viewport->width += e->sizing.diff.x; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
613 |
w->viewport->height += e->sizing.diff.y; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
614 |
w->viewport->virtual_width += e->sizing.diff.x; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
615 |
w->viewport->virtual_height += e->sizing.diff.y; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
616 |
break; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
617 |
|
0 | 618 |
case WE_DESTROY: |
619 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
620 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
|
621 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
622 |
break; |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
623 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
624 |
case WE_MOUSELOOP: { |
4171 | 625 |
const Vehicle *v = GetVehicle(w->window_number); |
3963
6cab57074a9a
(svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
3948
diff
changeset
|
626 |
uint32 h = IsAircraftInHangarStopped(v) ? 1 << 7 : 1 << 11; |
2244 | 627 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
628 |
if (h != w->hidden_state) { |
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
629 |
w->hidden_state = h; |
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
630 |
SetWindowDirty(w); |
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
631 |
} |
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
632 |
} break; |
0 | 633 |
} |
634 |
} |
|
635 |
||
636 |
||
637 |
static const WindowDesc _aircraft_view_desc = { |
|
638 |
-1,-1, 250, 116, |
|
639 |
WC_VEHICLE_VIEW ,0, |
|
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
640 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 641 |
_aircraft_view_widgets, |
642 |
AircraftViewWndProc |
|
643 |
}; |
|
644 |
||
645 |
||
4171 | 646 |
void ShowAircraftViewWindow(const Vehicle *v) |
0 | 647 |
{ |
4171 | 648 |
Window *w = AllocateWindowDescFront(&_aircraft_view_desc, v->index); |
0 | 649 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
650 |
if (w != NULL) { |
0 | 651 |
w->caption_color = v->owner; |
652 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
653 |
} |
|
654 |
} |
|
655 |
||
656 |
static void DrawAircraftDepotWindow(Window *w) |
|
657 |
{ |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
658 |
TileIndex tile; |
0 | 659 |
Vehicle *v; |
660 |
int num,x,y; |
|
661 |
||
662 |
tile = w->window_number; |
|
663 |
||
664 |
/* setup disabled buttons */ |
|
1901
03bf9bf99319
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
665 |
w->disabled_state = |
2244 | 666 |
IsTileOwner(tile, _local_player) ? 0 : ((1<<4) | (1<<7) | (1<<8)); |
0 | 667 |
|
668 |
/* determine amount of items for scroller */ |
|
669 |
num = 0; |
|
670 |
FOR_ALL_VEHICLES(v) { |
|
2639 | 671 |
if (v->type == VEH_Aircraft && |
672 |
v->subtype <= 2 && |
|
673 |
v->vehstatus & VS_HIDDEN && |
|
674 |
v->tile == tile) { |
|
675 |
num++; |
|
676 |
} |
|
0 | 677 |
} |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
678 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
0 | 679 |
|
3315
c9d989783c55
(svn r4079) Add GetSation{Index,ByTile}() to get the station index resp. the station from a tile
tron
parents:
3157
diff
changeset
|
680 |
SetDParam(0, GetStationIndex(tile)); |
0 | 681 |
DrawWindowWidgets(w); |
682 |
||
683 |
x = 2; |
|
684 |
y = 15; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
685 |
num = w->vscroll.pos * w->hscroll.cap; |
0 | 686 |
|
687 |
FOR_ALL_VEHICLES(v) { |
|
688 |
if (v->type == VEH_Aircraft && |
|
689 |
v->subtype <= 2 && |
|
690 |
v->vehstatus&VS_HIDDEN && |
|
1986
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
691 |
v->tile == tile && |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
692 |
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) { |
0 | 693 |
|
694 |
DrawAircraftImage(v, x+12, y, WP(w,traindepot_d).sel); |
|
695 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
696 |
SetDParam(0, v->unitnumber); |
0 | 697 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
698 |
||
2517
6e3832ddd0f6
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
699 |
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x, y + 12); |
0 | 700 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
701 |
if ((x+=74) == 2 + 74 * w->hscroll.cap) { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
702 |
x = 2; |
0 | 703 |
y += 24; |
704 |
} |
|
705 |
} |
|
706 |
} |
|
707 |
} |
|
708 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
709 |
static int GetVehicleFromAircraftDepotWndPt(const Window *w, int x, int y, Vehicle **veh) { |
969
862685f513ca
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
710 |
uint xt,row,xm,ym; |
0 | 711 |
Vehicle *v; |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
712 |
TileIndex tile; |
0 | 713 |
int pos; |
714 |
||
715 |
xt = x / 74; |
|
716 |
xm = x % 74; |
|
971
374251680a61
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
717 |
if (xt >= w->hscroll.cap) |
0 | 718 |
return 1; |
719 |
||
969
862685f513ca
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
720 |
row = (y - 14) / 24; |
0 | 721 |
ym = (y - 14) % 24; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
722 |
if (row >= w->vscroll.cap) return 1; |
0 | 723 |
|
971
374251680a61
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
724 |
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt; |
0 | 725 |
|
726 |
tile = w->window_number; |
|
727 |
FOR_ALL_VEHICLES(v) { |
|
1986
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
728 |
if (v->type == VEH_Aircraft && v->subtype <= 2 && |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
729 |
v->vehstatus & VS_HIDDEN && v->tile == tile && |
0 | 730 |
--pos < 0) { |
1986
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
731 |
*veh = v; |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
732 |
if (xm >= 12) return 0; |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
733 |
if (ym <= 12) return -1; /* show window */ |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
734 |
return -2; /* start stop */ |
fcc849a38ae6
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
735 |
} |
0 | 736 |
} |
737 |
return 1; /* outside */ |
|
738 |
} |
|
739 |
||
740 |
static void AircraftDepotClickAircraft(Window *w, int x, int y) |
|
741 |
{ |
|
742 |
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
|
743 |
int mode = GetVehicleFromAircraftDepotWndPt(w, x, y, &v); |
0 | 744 |
|
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
|
745 |
// share / copy orders |
2639 | 746 |
if (_thd.place_mode && mode <= 0) { |
747 |
_place_clicked_vehicle = v; |
|
748 |
return; |
|
749 |
} |
|
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
|
750 |
|
2639 | 751 |
switch (mode) { |
0 | 752 |
case 1: |
753 |
return; |
|
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 0: // start dragging of vehicle |
0 | 756 |
if (v != NULL) { |
757 |
WP(w,traindepot_d).sel = v->index; |
|
758 |
SetWindowDirty(w); |
|
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3049
diff
changeset
|
759 |
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetAircraftImage(v, DIR_W), 4, w); |
0 | 760 |
} |
761 |
break; |
|
762 |
||
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
|
763 |
case -1: // show info window |
0 | 764 |
ShowAircraftViewWindow(v); |
765 |
break; |
|
766 |
||
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
|
767 |
case -2: // click start/stop flag |
0 | 768 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
769 |
break; |
|
770 |
||
771 |
default: |
|
772 |
NOT_REACHED(); |
|
773 |
} |
|
774 |
} |
|
775 |
||
2244 | 776 |
/** |
777 |
* Clones an aircraft |
|
778 |
* @param *v is the original vehicle to clone |
|
779 |
* @param *w is the window of the hangar where the clone is build |
|
780 |
*/ |
|
4171 | 781 |
static void HandleCloneVehClick(const Vehicle *v, const Window *w) |
2244 | 782 |
{ |
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
783 |
if (v == NULL || v->type != VEH_Aircraft) return; |
2244 | 784 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
785 |
DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, |
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
786 |
CcCloneAircraft, CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT) |
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
787 |
); |
2244 | 788 |
|
789 |
ResetObjectToPlace(); |
|
790 |
} |
|
791 |
||
4171 | 792 |
static void ClonePlaceObj(const Window *w) |
2244 | 793 |
{ |
4171 | 794 |
const Vehicle *v = CheckMouseOverVehicle(); |
2244 | 795 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
796 |
if (v != NULL) HandleCloneVehClick(v, w); |
2244 | 797 |
} |
798 |
||
799 |
||
0 | 800 |
static void AircraftDepotWndProc(Window *w, WindowEvent *e) |
801 |
{ |
|
2952 | 802 |
switch (e->event) { |
0 | 803 |
case WE_PAINT: |
804 |
DrawAircraftDepotWindow(w); |
|
805 |
break; |
|
806 |
||
807 |
case WE_CLICK: |
|
2952 | 808 |
switch (e->click.widget) { |
2639 | 809 |
case 5: /* click aircraft */ |
810 |
AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y); |
|
811 |
break; |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
812 |
|
2639 | 813 |
case 7: /* show build aircraft window */ |
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
814 |
ResetObjectToPlace(); |
2639 | 815 |
ShowBuildAircraftWindow(w->window_number); |
816 |
break; |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
817 |
|
2639 | 818 |
case 8: /* clone button */ |
819 |
InvalidateWidget(w, 8); |
|
820 |
TOGGLEBIT(w->click_state, 8); |
|
821 |
||
822 |
if (HASBIT(w->click_state, 8)) { |
|
823 |
_place_clicked_vehicle = NULL; |
|
824 |
SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w); |
|
825 |
} else { |
|
826 |
ResetObjectToPlace(); |
|
827 |
} |
|
828 |
break; |
|
829 |
||
830 |
case 9: /* scroll to tile */ |
|
831 |
ResetObjectToPlace(); |
|
832 |
ScrollMainWindowToTile(w->window_number); |
|
833 |
break; |
|
0 | 834 |
} |
835 |
break; |
|
836 |
||
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
837 |
case WE_PLACE_OBJ: |
2958
ac0a9673b522
(svn r3520) Remove unused parameters from some functions
tron
parents:
2952
diff
changeset
|
838 |
ClonePlaceObj(w); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
839 |
break; |
2244 | 840 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
841 |
case WE_ABORT_PLACE_OBJ: |
2244 | 842 |
CLRBIT(w->click_state, 8); |
843 |
InvalidateWidget(w, 8); |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
844 |
break; |
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
845 |
|
2244 | 846 |
// check if a vehicle in a depot was clicked.. |
847 |
case WE_MOUSELOOP: { |
|
4171 | 848 |
const Vehicle *v = _place_clicked_vehicle; |
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
849 |
|
2244 | 850 |
// since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button |
851 |
if (v != NULL && HASBIT(w->click_state, 8)) { |
|
852 |
_place_clicked_vehicle = NULL; |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
853 |
HandleCloneVehClick(v, w); |
2244 | 854 |
} |
855 |
} break; |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
856 |
|
0 | 857 |
case WE_DESTROY: |
858 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
859 |
break; |
|
860 |
||
2755
ba133949851b
(svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents:
2725
diff
changeset
|
861 |
case WE_DRAGDROP: |
2952 | 862 |
switch (e->click.widget) { |
982
d3ce4d6a65f8
(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
|
863 |
case 5: { |
0 | 864 |
Vehicle *v; |
865 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
866 |
||
867 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
868 |
SetWindowDirty(w); |
|
869 |
||
870 |
if (GetVehicleFromAircraftDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
871 |
v != NULL && |
|
872 |
sel == v->index) { |
|
873 |
ShowAircraftViewWindow(v); |
|
874 |
} |
|
875 |
} break; |
|
876 |
||
982
d3ce4d6a65f8
(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
|
877 |
case 4: |
d3ce4d6a65f8
(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
|
878 |
if (!HASBIT(w->disabled_state, 4) && |
0 | 879 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
880 |
Vehicle *v; |
|
881 |
||
982
d3ce4d6a65f8
(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
|
882 |
HandleButtonClick(w, 4); |
0 | 883 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
884 |
v = GetVehicle(WP(w,traindepot_d).sel); |
0 | 885 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
886 |
||
887 |
_backup_orders_tile = v->tile; |
|
888 |
BackupVehicleOrders(v, _backup_orders_data); |
|
889 |
||
890 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT))) |
|
891 |
_backup_orders_tile = 0; |
|
892 |
} |
|
893 |
break; |
|
894 |
default: |
|
895 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
896 |
SetWindowDirty(w); |
|
897 |
} |
|
898 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
899 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
900 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
901 |
w->vscroll.cap += e->sizing.diff.y / 24; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
902 |
w->hscroll.cap += e->sizing.diff.x / 74; |
982
d3ce4d6a65f8
(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
|
903 |
w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
904 |
break; |
0 | 905 |
} |
906 |
} |
|
907 |
||
982
d3ce4d6a65f8
(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
|
908 |
static const Widget _aircraft_depot_widgets[] = { |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2647
diff
changeset
|
909 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
982
d3ce4d6a65f8
(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
|
910 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 318, 0, 13, STR_A002_AIRCRAFT_HANGAR, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
d3ce4d6a65f8
(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
|
911 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 319, 330, 0, 13, 0x0, STR_STICKY_BUTTON}, |
d3ce4d6a65f8
(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 |
{ WWT_PANEL, RESIZE_LRB, 14, 296, 318, 14, 13, 0x0, STR_NULL}, |
d3ce4d6a65f8
(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_IMGBTN, RESIZE_LRTB, 14, 296, 318, 14, 61, 0x2A9, STR_A023_DRAG_AIRCRAFT_TO_HERE_TO}, |
0 | 914 |
|
982
d3ce4d6a65f8
(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_MATRIX, RESIZE_RB, 14, 0, 295, 14, 61, 0x204, STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
d3ce4d6a65f8
(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_SCROLLBAR, RESIZE_LRB, 14, 319, 330, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
2244 | 917 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 105, 62, 73, STR_A003_NEW_AIRCRAFT, STR_A022_BUILD_NEW_AIRCRAFT}, |
918 |
{WWT_NODISTXTBTN, RESIZE_TB, 14, 106, 212, 62, 73, STR_CLONE_AIRCRAFT, STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW}, |
|
919 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 213, 318, 62, 73, STR_00E4_LOCATION, STR_A024_CENTER_MAIN_VIEW_ON_HANGAR}, |
|
982
d3ce4d6a65f8
(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_PANEL, RESIZE_RTB, 14, 319, 318, 62, 73, 0x0, STR_NULL}, |
d3ce4d6a65f8
(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
|
921 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 319, 330, 62, 73, 0x0, STR_RESIZE_BUTTON}, |
d3ce4d6a65f8
(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
|
922 |
{ WIDGETS_END}, |
d3ce4d6a65f8
(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
|
923 |
}; |
0 | 924 |
|
925 |
static const WindowDesc _aircraft_depot_desc = { |
|
926 |
-1, -1, 331, 74, |
|
927 |
WC_VEHICLE_DEPOT,0, |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
928 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 929 |
_aircraft_depot_widgets, |
930 |
AircraftDepotWndProc |
|
931 |
}; |
|
932 |
||
933 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
934 |
void ShowAircraftDepotWindow(TileIndex tile) |
0 | 935 |
{ |
936 |
Window *w; |
|
937 |
||
938 |
w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); |
|
2639 | 939 |
if (w != NULL) { |
1901
03bf9bf99319
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
940 |
w->caption_color = GetTileOwner(tile); |
0 | 941 |
w->vscroll.cap = 2; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
942 |
w->hscroll.cap = 4; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
943 |
w->resize.step_width = 74; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
944 |
w->resize.step_height = 24; |
0 | 945 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
946 |
_backup_orders_tile = 0; |
|
947 |
} |
|
948 |
} |
|
949 |
||
4171 | 950 |
static void DrawSmallOrderList(const Vehicle *v, int x, int y) |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
951 |
{ |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
952 |
const Order *order; |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
953 |
int sel, i = 0; |
0 | 954 |
|
955 |
sel = v->cur_order_index; |
|
956 |
||
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
957 |
FOR_VEHICLE_ORDERS(v, order) { |
3732
c9c5f8635c9c
(svn r4709) - Codechange: avoid messing around with globals, magic numbers and literal strings by using a string ID, when drawing the small right arrow for the small order lists (aircraft and ships)
peter1138
parents:
3491
diff
changeset
|
958 |
if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, 16); |
0 | 959 |
sel--; |
960 |
||
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
961 |
if (order->type == OT_GOTO_STATION) { |
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
962 |
SetDParam(0, order->station); |
0 | 963 |
DrawString(x, y, STR_A036, 0); |
964 |
||
965 |
y += 6; |
|
2639 | 966 |
if (++i == 4) break; |
0 | 967 |
} |
968 |
} |
|
969 |
} |
|
970 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
971 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
972 |
static const Widget _player_aircraft_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
973 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
974 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
975 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
2806
74949f22099e
(svn r3354) Fix a typo, which survived for about 3000 revisions: s/SRT_SORT_BY/STR_SORT_BY/ (noticed by chu)
tron
parents:
2798
diff
changeset
|
976 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
893
f4698309dec7
(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
|
977 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2647
diff
changeset
|
978 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
893
f4698309dec7
(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
|
979 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
f4698309dec7
(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
|
980 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
f4698309dec7
(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
|
981 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
982 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_A003_NEW_AIRCRAFT, STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES}, |
893
f4698309dec7
(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
|
983 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 170, 181, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
f4698309dec7
(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
|
984 |
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 170, 181, 0x0, STR_NULL}, |
f4698309dec7
(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_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 986 |
{ WIDGETS_END}, |
987 |
}; |
|
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
|
988 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
989 |
static const Widget _other_player_aircraft_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
990 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
991 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_A009_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
992 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
2806
74949f22099e
(svn r3354) Fix a typo, which survived for about 3000 revisions: s/SRT_SORT_BY/STR_SORT_BY/ (noticed by chu)
tron
parents:
2798
diff
changeset
|
993 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
893
f4698309dec7
(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
|
994 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2647
diff
changeset
|
995 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
893
f4698309dec7
(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
|
996 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
f4698309dec7
(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
|
997 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT}, |
f4698309dec7
(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
|
998 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
f4698309dec7
(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
|
999 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 170, 181, 0x0, STR_NULL}, |
f4698309dec7
(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
|
1000 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 1001 |
{ WIDGETS_END}, |
1002 |
}; |
|
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
|
1003 |
|
0 | 1004 |
static void PlayerAircraftWndProc(Window *w, WindowEvent *e) |
1005 |
{ |
|
2466
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1006 |
StationID station = GB(w->window_number, 16, 16); |
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1007 |
PlayerID owner = GB(w->window_number, 0, 8); |
588 | 1008 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
1009 |
||
2952 | 1010 |
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
|
1011 |
case WE_PAINT: { |
588 | 1012 |
int x = 2; |
1013 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
1014 |
int max; |
|
1015 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
1016 |
|
588 | 1017 |
BuildVehicleList(vl, VEH_Aircraft, owner, station); |
1018 |
SortVehicleList(vl); |
|
0 | 1019 |
|
588 | 1020 |
SetVScrollCount(w, vl->list_length); |
1021 |
||
1022 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
2639 | 1023 |
if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1024 |
|
0 | 1025 |
/* draw the widgets */ |
1026 |
{ |
|
1962
8254df1b359b
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1938
diff
changeset
|
1027 |
const Player *p = GetPlayer(owner); |
2466
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1028 |
if (station == INVALID_STATION) { |
588 | 1029 |
/* Company Name -- (###) Aircraft */ |
1030 |
SetDParam(0, p->name_1); |
|
1031 |
SetDParam(1, p->name_2); |
|
1032 |
SetDParam(2, w->vscroll.count); |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1033 |
w->widget[1].unkA = STR_A009_AIRCRAFT; |
588 | 1034 |
} else { |
1035 |
/* Station Name -- (###) Aircraft */ |
|
1294
4cdf0e76c093
(svn r1798) GetFoo(i)->index is per definition i, so replace the former with the latter
tron
parents:
1246
diff
changeset
|
1036 |
SetDParam(0, station); |
588 | 1037 |
SetDParam(1, w->vscroll.count); |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1038 |
w->widget[1].unkA = STR_SCHEDULED_AIRCRAFT; |
588 | 1039 |
} |
0 | 1040 |
DrawWindowWidgets(w); |
1041 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1042 |
/* draw sorting criteria string */ |
588 | 1043 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
1044 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
2406
8c873205483a
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2273
diff
changeset
|
1045 |
DoDrawString(vl->flags & VL_DESC ? DOWNARROW : UPARROW, 69, 15, 0x10); |
0 | 1046 |
|
588 | 1047 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
1048 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
1049 |
Vehicle *v = GetVehicle(vl->sort_list[i].index); |
588 | 1050 |
StringID str; |
0 | 1051 |
|
588 | 1052 |
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
|
1053 |
|
588 | 1054 |
DrawAircraftImage(v, x + 19, y + 6, INVALID_VEHICLE); |
1055 |
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
|
1056 |
|
588 | 1057 |
SetDParam(0, v->unitnumber); |
3963
6cab57074a9a
(svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
3948
diff
changeset
|
1058 |
if (IsAircraftInHangar(v)) { |
588 | 1059 |
str = STR_021F; |
2549 | 1060 |
} else { |
588 | 1061 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
2549 | 1062 |
} |
588 | 1063 |
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
|
1064 |
|
588 | 1065 |
SetDParam(0, v->profit_this_year); |
1066 |
SetDParam(1, v->profit_last_year); |
|
1067 |
DrawString(x + 19, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1068 |
||
1069 |
if (v->string_id != STR_SV_AIRCRAFT_NAME) { |
|
1070 |
SetDParam(0, v->string_id); |
|
1071 |
DrawString(x + 19, y, STR_01AB, 0); |
|
0 | 1072 |
} |
588 | 1073 |
|
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
1074 |
DrawSmallOrderList(v, x + 136, y); |
588 | 1075 |
|
1076 |
y += PLY_WND_PRC__SIZE_OF_ROW_BIG; |
|
0 | 1077 |
} |
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
|
1078 |
} break; |
0 | 1079 |
|
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
|
1080 |
case WE_CLICK: { |
2952 | 1081 |
switch (e->click.widget) { |
757 | 1082 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 1083 |
vl->flags ^= VL_DESC; |
1084 |
vl->flags |= VL_RESORT; |
|
1246
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1085 |
_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
|
1086 |
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
|
1087 |
break; |
588 | 1088 |
|
757 | 1089 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 1090 |
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
|
1091 |
return; |
588 | 1092 |
|
757 | 1093 |
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
|
1094 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG; |
4171 | 1095 |
const Vehicle *v; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1096 |
|
2549 | 1097 |
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
|
1098 |
|
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 |
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
|
1100 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
1101 |
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
|
1102 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
1103 |
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
|
1104 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
1105 |
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
|
1106 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
1107 |
ShowAircraftViewWindow(v); |
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
|
1108 |
} 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
|
1109 |
|
3884
793081f80381
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3732
diff
changeset
|
1110 |
case 9: /* Build new Vehicle */ |
793081f80381
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3732
diff
changeset
|
1111 |
if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) break; |
0 | 1112 |
ShowBuildAircraftWindow(0); |
3884
793081f80381
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3732
diff
changeset
|
1113 |
break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1114 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1115 |
case 10: |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
1116 |
if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) break; |
842 | 1117 |
ShowReplaceVehicleWindow(VEH_Aircraft); |
1118 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1119 |
|
0 | 1120 |
} |
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
|
1121 |
} 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
|
1122 |
|
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
|
1123 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1124 |
if (vl->sort_type != e->dropdown.index) { |
1125 |
// value has changed -> resort |
|
1126 |
vl->flags |= VL_RESORT; |
|
1127 |
vl->sort_type = e->dropdown.index; |
|
1246
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1128 |
_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
|
1129 |
|
588 | 1130 |
// enable 'Sort By' if a sorter criteria is chosen |
2639 | 1131 |
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3); |
588 | 1132 |
} |
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
|
1133 |
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
|
1134 |
break; |
588 | 1135 |
|
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
|
1136 |
case WE_CREATE: /* set up resort timer */ |
588 | 1137 |
vl->sort_list = NULL; |
1246
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1138 |
vl->flags = VL_REBUILD | (_sorting.aircraft.order << (VL_DESC - 1)); |
eb66ff34348f
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1209
diff
changeset
|
1139 |
vl->sort_type = _sorting.aircraft.criteria; |
588 | 1140 |
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
|
1141 |
break; |
588 | 1142 |
|
767 | 1143 |
case WE_DESTROY: |
1144 |
free(vl->sort_list); |
|
1145 |
break; |
|
1146 |
||
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
|
1147 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1148 |
if (--vl->resort_timer == 0) { |
1149 |
DEBUG(misc, 1) ("Periodic resort aircraft list player %d station %d", |
|
1150 |
owner, station); |
|
1151 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1152 |
vl->flags |= VL_RESORT; |
|
1153 |
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
|
1154 |
} |
0 | 1155 |
break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1156 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1157 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1158 |
/* Update the scroll + matrix */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1159 |
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_BIG; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1160 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1161 |
break; |
0 | 1162 |
} |
1163 |
} |
|
1164 |
||
1165 |
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
|
1166 |
-1, -1, 260, 182, |
0 | 1167 |
WC_AIRCRAFT_LIST,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1168 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1169 |
_player_aircraft_widgets, |
1170 |
PlayerAircraftWndProc |
|
1171 |
}; |
|
1172 |
||
1173 |
static const WindowDesc _other_player_aircraft_desc = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1174 |
-1, -1, 260, 182, |
0 | 1175 |
WC_AIRCRAFT_LIST,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1176 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1177 |
_other_player_aircraft_widgets, |
1178 |
PlayerAircraftWndProc |
|
1179 |
}; |
|
1180 |
||
2466
1aa260b43faa
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
1181 |
void ShowPlayerAircraft(PlayerID player, StationID station) |
0 | 1182 |
{ |
1183 |
Window *w; |
|
1184 |
||
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
|
1185 |
if (player == _local_player) { |
588 | 1186 |
w = AllocateWindowDescFront(&_player_aircraft_desc, (station << 16) | player); |
0 | 1187 |
} else { |
588 | 1188 |
w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | player); |
0 | 1189 |
} |
1190 |
||
2639 | 1191 |
if (w != NULL) { |
0 | 1192 |
w->caption_color = w->window_number; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1193 |
w->vscroll.cap = 4; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1194 |
w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1195 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG; |
0 | 1196 |
} |
1197 |
} |