author | bjarni |
Sat, 30 Sep 2006 17:13:39 +0000 | |
changeset 4683 | 13d7b7d779cf |
parent 4668 | 8b6035c51188 |
child 4702 | 5179f9adc5b3 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
4 |
#include "openttd.h" |
3963
d7d284c2f1f7
(svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
3948
diff
changeset
|
5 |
#include "aircraft.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
6 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
7 |
#include "functions.h" |
3315
1f65f8260092
(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
797081e56d13
(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
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
382
diff
changeset
|
10 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
588
diff
changeset
|
11 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1055
diff
changeset
|
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
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
22 |
#include "depot.h" |
4153
c73342cbd387
(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
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2113
diff
changeset
|
24 |
#include "vehicle_gui.h" |
2962
dbd168a4703a
(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" |
4261
2ec8f5a9747b
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4243
diff
changeset
|
26 |
#include "date.h" |
0 | 27 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
28 |
/** |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
29 |
* Draw the purchase info details of an aircraft at a given location. |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
30 |
* @param x,y location where to draw the info |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
31 |
* @param engine_number the engine of which to draw the info of |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
32 |
*/ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
33 |
void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number) |
842 | 34 |
{ |
35 |
const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number); |
|
4171 | 36 |
const Engine *e = GetEngine(engine_number); |
3987
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
37 |
CargoID cargo; |
842 | 38 |
YearMonthDay ymd; |
4288
60398d0e64ee
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
39 |
ConvertDateToYMD(e->intro_date, &ymd); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
40 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
41 |
/* Purchase cost - Max speed */ |
842 | 42 |
SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5); |
3477
80c3465b38ee
(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
|
43 |
SetDParam(1, avi->max_speed * 128 / 10); |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
44 |
DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
45 |
y += 10; |
842 | 46 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
47 |
/* Cargo capacity */ |
3987
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
48 |
cargo = FindFirstRefittableCargo(engine_number); |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
49 |
if (cargo == CT_INVALID || cargo == CT_PASSENGERS) { |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
50 |
SetDParam(0, avi->passenger_capacity); |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
51 |
SetDParam(1, avi->mail_capacity); |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
52 |
DrawString(x, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY, 0); |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
53 |
} else { |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
54 |
/* Note, if the default capacity is selected by the refit capacity |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
55 |
* callback, then the capacity shown is likely to be incorrect. */ |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
56 |
SetDParam(0, _cargoc.names_long[cargo]); |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
57 |
SetDParam(1, AircraftDefaultCargoCapacity(cargo, engine_number)); |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
58 |
SetDParam(2, STR_9842_REFITTABLE); |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
59 |
DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0); |
96b119a9fb94
(svn r5186) - NewGRF: show default aircraft cargo type and the purchase list (mart3p)
peter1138
parents:
3963
diff
changeset
|
60 |
} |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
61 |
y += 10; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
62 |
|
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
63 |
/* Running cost */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
64 |
SetDParam(0, avi->running_cost * _price.aircraft_running >> 8); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
65 |
DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
66 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
67 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
68 |
/* Design date - Life length */ |
4293
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4288
diff
changeset
|
69 |
SetDParam(0, ymd.year); |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
70 |
SetDParam(1, e->lifelength); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
71 |
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
72 |
y += 10; |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
73 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
74 |
/* Reliability */ |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
75 |
SetDParam(0, e->reliability * 100 >> 16); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
76 |
DrawString(x, y, STR_PURCHASE_INFO_RELIABILITY, 0); |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
77 |
y += 10; |
4243
900826bcac92
(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 |
|
900826bcac92
(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 |
/* Additional text from NewGRF */ |
900826bcac92
(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 |
// XXX 227 will become a calculated width... |
900826bcac92
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
81 |
y += ShowAdditionalText(x, y, 227, engine_number); |
842 | 82 |
} |
83 |
||
4442
8d8d0c2df7cb
(svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents:
4434
diff
changeset
|
84 |
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection) |
0 | 85 |
{ |
3049
b797ca543c13
(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
|
86 |
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3049
diff
changeset
|
87 |
DrawSprite(GetAircraftImage(v, DIR_W) | pal, x + 25, y + 10); |
4056
30ceffc75059
(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 |
if (v->subtype == 0) { |
30ceffc75059
(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 |
SpriteID rotor_sprite = GetCustomRotorSprite(v, true); |
30ceffc75059
(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 |
if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED; |
30ceffc75059
(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 |
DrawSprite(rotor_sprite, x + 25, y + 5); |
30ceffc75059
(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
|
92 |
} |
0 | 93 |
if (v->index == selection) { |
2639 | 94 |
DrawFrameRect(x - 1, y - 1, x + 58, y + 21, 0xF, FR_BORDERONLY); |
0 | 95 |
} |
96 |
} |
|
97 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
98 |
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 99 |
{ |
2630 | 100 |
if (success) { |
4171 | 101 |
const Vehicle *v = GetVehicle(_new_vehicle_id); |
0 | 102 |
|
103 |
if (v->tile == _backup_orders_tile) { |
|
104 |
_backup_orders_tile = 0; |
|
105 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
106 |
} |
|
107 |
ShowAircraftViewWindow(v); |
|
108 |
} |
|
109 |
} |
|
110 |
||
3887
3e44ae3b1e7c
(svn r4943) uint tile -> TileIndex tile, byte player -> PlayerID player
tron
parents:
3884
diff
changeset
|
111 |
void CcCloneAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2) |
2244 | 112 |
{ |
3948
95f9fa0ac551
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3887
diff
changeset
|
113 |
if (success) ShowAircraftViewWindow(GetVehicle(_new_vehicle_id)); |
2244 | 114 |
} |
0 | 115 |
|
116 |
static void NewAircraftWndProc(Window *w, WindowEvent *e) |
|
117 |
{ |
|
2639 | 118 |
switch (e->event) { |
0 | 119 |
case WE_PAINT: { |
4161
7b08131239f7
(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
|
120 |
TileIndex tile = w->window_number; |
4162
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
121 |
byte acc_planes; |
4161
7b08131239f7
(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
|
122 |
|
4162
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
123 |
if (tile == 0) { |
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
124 |
SETBIT(w->disabled_state, 5); |
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
125 |
acc_planes = ALL; |
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
126 |
} else { |
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
127 |
acc_planes = GetAirport(GetStationByTile(tile)->airport_type)->acc_planes; |
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
128 |
} |
0 | 129 |
|
130 |
{ |
|
131 |
int count = 0; |
|
4161
7b08131239f7
(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
|
132 |
EngineID eid; |
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1922
diff
changeset
|
133 |
|
4161
7b08131239f7
(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
|
134 |
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { |
4171 | 135 |
const AircraftVehicleInfo *avi; |
4161
7b08131239f7
(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 |
|
7b08131239f7
(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 |
if (!HASBIT(GetEngine(eid)->player_avail, _local_player)) continue; |
7b08131239f7
(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 |
|
7b08131239f7
(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
|
139 |
avi = AircraftVehInfo(eid); |
4162
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
140 |
if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == acc_planes) continue; |
4161
7b08131239f7
(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 |
|
7b08131239f7
(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 |
count++; |
7b08131239f7
(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
|
143 |
} |
0 | 144 |
SetVScrollCount(w, count); |
145 |
} |
|
146 |
||
147 |
DrawWindowWidgets(w); |
|
148 |
||
149 |
{ |
|
150 |
int x = 2; |
|
151 |
int y = 15; |
|
152 |
int sel = WP(w,buildtrain_d).sel_index; |
|
153 |
int pos = w->vscroll.pos; |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
154 |
EngineID selected_id = INVALID_ENGINE; |
4161
7b08131239f7
(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
|
155 |
EngineID eid; |
0 | 156 |
|
4161
7b08131239f7
(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
|
157 |
for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) { |
4171 | 158 |
const AircraftVehicleInfo *avi; |
4161
7b08131239f7
(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 |
|
7b08131239f7
(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 |
if (!HASBIT(GetEngine(eid)->player_avail, _local_player)) continue; |
7b08131239f7
(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 |
|
7b08131239f7
(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
|
162 |
avi = AircraftVehInfo(eid); |
4162
e5c7f9156b43
(svn r5595) Show all aircraft in the dry-run build window of the global aircraft list again
tron
parents:
4161
diff
changeset
|
163 |
if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == acc_planes) continue; |
4161
7b08131239f7
(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 |
|
7b08131239f7
(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 |
if (sel == 0) selected_id = eid; |
7b08131239f7
(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 |
|
7b08131239f7
(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 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
7b08131239f7
(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 |
DrawString(x + 62, y + 7, GetCustomEngineName(eid), sel == 0 ? 0xC : 0x10); |
7b08131239f7
(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 |
DrawAircraftEngine(x + 29, y + 10, eid, GetEnginePalette(eid, _local_player)); |
7b08131239f7
(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
|
170 |
y += 24; |
0 | 171 |
} |
4161
7b08131239f7
(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 |
|
7b08131239f7
(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 |
sel--; |
7b08131239f7
(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
|
174 |
} |
0 | 175 |
|
176 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
177 |
||
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
178 |
if (selected_id != INVALID_ENGINE) { |
1907
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
179 |
DrawAircraftPurchaseInfo(2, w->widget[4].top + 1, selected_id); |
0 | 180 |
} |
181 |
} |
|
182 |
} break; |
|
183 |
||
184 |
case WE_CLICK: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
185 |
switch (e->we.click.widget) { |
0 | 186 |
case 2: { /* listbox */ |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
187 |
uint i = (e->we.click.pt.y - 14) / 24; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
188 |
if (i < w->vscroll.cap) { |
0 | 189 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
190 |
SetWindowDirty(w); |
|
191 |
} |
|
192 |
} break; |
|
193 |
||
194 |
case 5: { /* build */ |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
195 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
196 |
if (sel_eng != INVALID_ENGINE) |
0 | 197 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
198 |
} break; |
|
199 |
||
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4426
diff
changeset
|
200 |
case 6: { /* rename */ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
201 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
202 |
if (sel_eng != INVALID_ENGINE) { |
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
203 |
WP(w,buildtrain_d).rename_engine = sel_eng; |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
204 |
ShowQueryString(GetCustomEngineName(sel_eng), |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
205 |
STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL); |
968
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
206 |
} |
9c47631d62dc
(svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater
parents:
924
diff
changeset
|
207 |
} break; |
0 | 208 |
} |
209 |
break; |
|
210 |
||
211 |
case WE_ON_EDIT_TEXT: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
212 |
if (e->we.edittext.str[0] != '\0') { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
213 |
_cmd_text = e->we.edittext.str; |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
214 |
DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
215 |
CMD_RENAME_ENGINE | CMD_MSG(STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
216 |
} |
0 | 217 |
} break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
218 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
219 |
case WE_RESIZE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
220 |
w->vscroll.cap += e->we.sizing.diff.y / 24; |
4547
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4541
diff
changeset
|
221 |
w->widget[2].data = (w->vscroll.cap << 8) + 1; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
222 |
break; |
0 | 223 |
} |
224 |
} |
|
225 |
||
226 |
static const Widget _new_aircraft_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
227 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
228 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_A005_NEW_AIRCRAFT, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
229 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 227, 14, 109, 0x401, STR_A025_AIRCRAFT_SELECTION_LIST }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
230 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 228, 239, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
231 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 239, 110, 181, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
232 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 114, 182, 193, STR_A006_BUILD_AIRCRAFT, STR_A026_BUILD_THE_HIGHLIGHTED_AIRCRAFT }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
233 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 115, 227, 182, 193, STR_A037_RENAME, STR_A038_RENAME_AIRCRAFT_TYPE }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
234 |
{ 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
|
235 |
{ WIDGETS_END}, |
0 | 236 |
}; |
237 |
||
238 |
static const WindowDesc _new_aircraft_desc = { |
|
4243
900826bcac92
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
239 |
-1, -1, 240, 194, |
0 | 240 |
WC_BUILD_VEHICLE,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
241 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 242 |
_new_aircraft_widgets, |
243 |
NewAircraftWndProc |
|
244 |
}; |
|
245 |
||
4442
8d8d0c2df7cb
(svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents:
4434
diff
changeset
|
246 |
void ShowBuildAircraftWindow(TileIndex tile) |
0 | 247 |
{ |
248 |
Window *w; |
|
249 |
||
250 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
251 |
||
252 |
w = AllocateWindowDesc(&_new_aircraft_desc); |
|
253 |
w->window_number = tile; |
|
254 |
w->vscroll.cap = 4; |
|
4547
9786a24c4102
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4541
diff
changeset
|
255 |
w->widget[2].data = (w->vscroll.cap << 8) + 1; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
256 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
257 |
w->resize.step_height = 24; |
0 | 258 |
|
259 |
if (tile != 0) { |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
260 |
w->caption_color = GetTileOwner(tile); |
0 | 261 |
} else { |
262 |
w->caption_color = _local_player; |
|
263 |
} |
|
264 |
} |
|
265 |
||
266 |
static void AircraftDetailsWndProc(Window *w, WindowEvent *e) |
|
267 |
{ |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
268 |
switch (e->event) { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
269 |
case WE_PAINT: { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
270 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 271 |
|
272 |
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
|
273 |
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
|
274 |
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
|
275 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
276 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
277 |
SetDParam(1, v->unitnumber); |
0 | 278 |
DrawWindowWidgets(w); |
279 |
||
280 |
/* Draw running cost */ |
|
281 |
{ |
|
282 |
int year = v->age / 366; |
|
283 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
284 |
SetDParam(1, year); |
0 | 285 |
|
2252
37e3ca7014e0
(svn r2772) Simplify the age notice in the vehicle details window
tron
parents:
2244
diff
changeset
|
286 |
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
287 |
SetDParam(2, v->max_age / 366); |
538
5dd99f3b7eca
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
534
diff
changeset
|
288 |
SetDParam(3, _price.aircraft_running * AircraftVehInfo(v->engine_type)->running_cost >> 8); |
0 | 289 |
DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0); |
290 |
} |
|
291 |
||
292 |
/* Draw max speed */ |
|
293 |
{ |
|
3477
80c3465b38ee
(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
|
294 |
SetDParam(0, v->max_speed * 128 / 10); |
0 | 295 |
DrawString(2, 25, STR_A00E_MAX_SPEED, 0); |
296 |
} |
|
297 |
||
298 |
/* Draw profit */ |
|
299 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
300 |
SetDParam(0, v->profit_this_year); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
301 |
SetDParam(1, v->profit_last_year); |
0 | 302 |
DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
303 |
} |
|
304 |
||
305 |
/* Draw breakdown & reliability */ |
|
306 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
307 |
SetDParam(0, v->reliability * 100 >> 16); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
308 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 309 |
DrawString(2, 45, STR_A010_RELIABILITY_BREAKDOWNS, 0); |
310 |
} |
|
311 |
||
312 |
/* Draw service interval text */ |
|
313 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
314 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
315 |
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
|
316 |
DrawString(13, 103, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 317 |
} |
318 |
||
319 |
DrawAircraftImage(v, 3, 57, INVALID_VEHICLE); |
|
320 |
||
321 |
{ |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
322 |
const Vehicle *u; |
0 | 323 |
int y = 57; |
324 |
||
325 |
do { |
|
326 |
if (v->subtype <= 2) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
327 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
4329
9759d5c52010
(svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents:
4299
diff
changeset
|
328 |
SetDParam(1, v->build_year); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
329 |
SetDParam(2, v->value); |
0 | 330 |
DrawString(60, y, STR_A011_BUILT_VALUE, 0); |
331 |
y += 10; |
|
332 |
||
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
333 |
SetDParam(0, _cargoc.names_long[v->cargo_type]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
334 |
SetDParam(1, v->cargo_cap); |
0 | 335 |
u = v->next; |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2049
diff
changeset
|
336 |
SetDParam(2, _cargoc.names_long[u->cargo_type]); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
337 |
SetDParam(3, u->cargo_cap); |
2260
3e97367f7cbc
(svn r2780) Remove some more unused strings and make the use of a few strings more explicit
tron
parents:
2252
diff
changeset
|
338 |
DrawString(60, y, (u->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, 0); |
0 | 339 |
y += 14; |
340 |
} |
|
341 |
||
342 |
if (v->cargo_count != 0) { |
|
343 |
||
344 |
/* Cargo names (fix pluralness) */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
345 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
346 |
SetDParam(1, v->cargo_count); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
347 |
SetDParam(2, v->cargo_source); |
0 | 348 |
DrawString(60, y, STR_8813_FROM, 0); |
349 |
||
350 |
y += 10; |
|
351 |
} |
|
352 |
} while ( (v=v->next) != NULL); |
|
353 |
} |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
354 |
} break; |
0 | 355 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
356 |
case WE_CLICK: { |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
357 |
int mod; |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
358 |
const Vehicle *v; |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
359 |
switch (e->we.click.widget) { |
0 | 360 |
case 2: /* rename */ |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
361 |
v = GetVehicle(w->window_number); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
362 |
SetDParam(0, v->unitnumber); |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
363 |
ShowQueryString(v->string_id, STR_A030_NAME_AIRCRAFT, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); |
0 | 364 |
break; |
365 |
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
|
366 |
mod = _ctrl_pressed? 5 : 10; |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
367 |
goto do_change_service_int; |
0 | 368 |
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
|
369 |
mod = _ctrl_pressed?- 5 : -10; |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
370 |
do_change_service_int: |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
371 |
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
|
372 |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
373 |
mod = GetServiceIntervalClamped(mod + v->service_interval); |
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
374 |
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
|
375 |
|
2819
710436dd4288
(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
|
376 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
0 | 377 |
break; |
378 |
} |
|
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1485
diff
changeset
|
379 |
} break; |
0 | 380 |
|
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
381 |
case WE_ON_EDIT_TEXT: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
382 |
if (e->we.edittext.str[0] != '\0') { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
383 |
_cmd_text = e->we.edittext.str; |
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
384 |
DoCommandP(0, w->window_number, 0, NULL, |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
385 |
CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT)); |
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
386 |
} |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
387 |
break; |
0 | 388 |
} |
389 |
} |
|
390 |
||
391 |
||
392 |
static const Widget _aircraft_details_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
393 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
394 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 349, 0, 13, STR_A00C_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
395 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 350, 389, 0, 13, STR_01AA_NAME, STR_A032_NAME_AIRCRAFT }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
396 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 389, 14, 55, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
397 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 389, 56, 101, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
398 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 102, 107, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
399 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 108, 113, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
400 |
{ 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
|
401 |
{ WIDGETS_END}, |
0 | 402 |
}; |
403 |
||
404 |
static const WindowDesc _aircraft_details_desc = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
405 |
-1, -1, 390, 114, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
406 |
WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, |
0 | 407 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
408 |
_aircraft_details_widgets, |
|
409 |
AircraftDetailsWndProc |
|
410 |
}; |
|
411 |
||
412 |
||
4171 | 413 |
static void ShowAircraftDetailsWindow(const Vehicle *v) |
0 | 414 |
{ |
415 |
Window *w; |
|
416 |
VehicleID veh = v->index; |
|
417 |
||
418 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
419 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
420 |
||
421 |
_alloc_wnd_parent_num = veh; |
|
422 |
w = AllocateWindowDesc(&_aircraft_details_desc); |
|
423 |
w->window_number = veh; |
|
424 |
w->caption_color = v->owner; |
|
425 |
// w->vscroll.cap = 6; |
|
426 |
// w->traindetails_d.tab = 0; |
|
427 |
} |
|
428 |
||
429 |
||
430 |
static const Widget _aircraft_view_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
431 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
432 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_A00A, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
433 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
434 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 231, 14, 103, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
435 |
{ WWT_6, RESIZE_RB, 14, 2, 229, 16, 101, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
436 |
{ WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 104, 115, 0x0, STR_A027_CURRENT_AIRCRAFT_ACTION }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
437 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_A029_CENTER_MAIN_VIEW_ON_AIRCRAFT }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
438 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2AF, STR_A02A_SEND_AIRCRAFT_TO_HANGAR }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
439 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B4, STR_A03B_REFIT_AIRCRAFT_TO_CARRY }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
440 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_A028_SHOW_AIRCRAFT_S_ORDERS }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
441 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_A02B_SHOW_AIRCRAFT_DETAILS }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
442 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_AIRCRAFT, STR_CLONE_AIRCRAFT_INFO }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
443 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
444 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
445 |
{ WIDGETS_END}, |
0 | 446 |
}; |
447 |
||
2244 | 448 |
|
0 | 449 |
static void AircraftViewWndProc(Window *w, WindowEvent *e) |
450 |
{ |
|
2952 | 451 |
switch (e->event) { |
0 | 452 |
case WE_PAINT: { |
4171 | 453 |
const Vehicle *v = GetVehicle(w->window_number); |
2639 | 454 |
uint32 disabled = 1 << 8; |
0 | 455 |
StringID str; |
456 |
||
3963
d7d284c2f1f7
(svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
3948
diff
changeset
|
457 |
if (IsAircraftInHangarStopped(v)) disabled = 0; |
0 | 458 |
|
2639 | 459 |
if (v->owner != _local_player) disabled |= 1 << 8 | 1 << 7; |
0 | 460 |
w->disabled_state = disabled; |
461 |
||
462 |
/* draw widgets & caption */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
463 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
464 |
SetDParam(1, v->unitnumber); |
0 | 465 |
DrawWindowWidgets(w); |
466 |
||
467 |
if (v->vehstatus & VS_CRASHED) { |
|
468 |
str = STR_8863_CRASHED; |
|
469 |
} else if (v->vehstatus & VS_STOPPED) { |
|
470 |
str = STR_8861_STOPPED; |
|
471 |
} else { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
472 |
switch (v->current_order.type) { |
0 | 473 |
case OT_GOTO_STATION: { |
4527
b18634a31a4a
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4524
diff
changeset
|
474 |
SetDParam(0, v->current_order.dest); |
3477
80c3465b38ee
(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
|
475 |
SetDParam(1, v->cur_speed * 128 / 10); |
0 | 476 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
477 |
} break; |
|
478 |
||
479 |
case OT_GOTO_DEPOT: { |
|
4389
e4555522d257
(svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore)
truelight
parents:
4345
diff
changeset
|
480 |
/* Aircrafts always go to a station, even if you say depot */ |
4527
b18634a31a4a
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4524
diff
changeset
|
481 |
SetDParam(0, v->current_order.dest); |
3477
80c3465b38ee
(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
|
482 |
SetDParam(1, v->cur_speed * 128 / 10); |
4633
fae5d85ef53d
(svn r6497) -Fix r6165: Vehicles heading for depots when their orders contained "service in depot" displayed the stopping in depot string
bjarni
parents:
4547
diff
changeset
|
483 |
if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT) && !HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) { |
4412
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
484 |
str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
485 |
} else { |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
486 |
str = STR_HEADING_FOR_HANGAR_SERVICE + _patches.vehicle_speed; |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
487 |
} |
0 | 488 |
} break; |
489 |
||
490 |
case OT_LOADING: |
|
491 |
str = STR_882F_LOADING_UNLOADING; |
|
492 |
break; |
|
493 |
||
494 |
default: |
|
495 |
if (v->num_orders == 0) { |
|
496 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
3477
80c3465b38ee
(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
|
497 |
SetDParam(0, v->cur_speed * 128 / 10); |
2639 | 498 |
} else { |
0 | 499 |
str = STR_EMPTY; |
2639 | 500 |
} |
0 | 501 |
break; |
502 |
} |
|
503 |
} |
|
504 |
||
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2084
diff
changeset
|
505 |
/* draw the flag plus orders */ |
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
506 |
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1); |
2113
f228b399da01
(svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents:
2103
diff
changeset
|
507 |
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0); |
0 | 508 |
DrawWindowViewport(w); |
509 |
} break; |
|
510 |
||
511 |
case WE_CLICK: { |
|
4171 | 512 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 513 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
514 |
switch (e->we.click.widget) { |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
515 |
case 5: /* start stop */ |
0 | 516 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); |
517 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
518 |
case 6: /* center main view */ |
0 | 519 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
520 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
521 |
case 7: /* goto hangar */ |
4506
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4456
diff
changeset
|
522 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? DEPOT_SERVICE : 0, NULL, CMD_SEND_AIRCRAFT_TO_HANGAR | CMD_MSG(STR_A012_CAN_T_SEND_AIRCRAFT_TO)); |
0 | 523 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
524 |
case 8: /* refit */ |
4642
486900e9288d
(svn r6518) -Codechange: unified the vehicle refit windows
bjarni
parents:
4638
diff
changeset
|
525 |
ShowVehicleRefitWindow(v); |
0 | 526 |
break; |
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
527 |
case 9: /* show orders */ |
0 | 528 |
ShowOrdersWindow(v); |
529 |
break; |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
727
diff
changeset
|
530 |
case 10: /* show details */ |
0 | 531 |
ShowAircraftDetailsWindow(v); |
532 |
break; |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
533 |
case 11: |
2244 | 534 |
/* clone vehicle */ |
535 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneAircraft, CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
536 |
break; |
0 | 537 |
} |
538 |
} break; |
|
539 |
||
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
540 |
case WE_RESIZE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
541 |
w->viewport->width += e->we.sizing.diff.x; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
542 |
w->viewport->height += e->we.sizing.diff.y; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
543 |
w->viewport->virtual_width += e->we.sizing.diff.x; |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
544 |
w->viewport->virtual_height += e->we.sizing.diff.y; |
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
545 |
break; |
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
546 |
|
0 | 547 |
case WE_DESTROY: |
548 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
549 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
|
550 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
551 |
break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
552 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
553 |
case WE_MOUSELOOP: { |
4171 | 554 |
const Vehicle *v = GetVehicle(w->window_number); |
3963
d7d284c2f1f7
(svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
3948
diff
changeset
|
555 |
uint32 h = IsAircraftInHangarStopped(v) ? 1 << 7 : 1 << 11; |
2244 | 556 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
557 |
if (h != w->hidden_state) { |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
558 |
w->hidden_state = h; |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
559 |
SetWindowDirty(w); |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
560 |
} |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
561 |
} break; |
0 | 562 |
} |
563 |
} |
|
564 |
||
565 |
||
566 |
static const WindowDesc _aircraft_view_desc = { |
|
567 |
-1,-1, 250, 116, |
|
568 |
WC_VEHICLE_VIEW ,0, |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1323
diff
changeset
|
569 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 570 |
_aircraft_view_widgets, |
571 |
AircraftViewWndProc |
|
572 |
}; |
|
573 |
||
574 |
||
4171 | 575 |
void ShowAircraftViewWindow(const Vehicle *v) |
0 | 576 |
{ |
4171 | 577 |
Window *w = AllocateWindowDescFront(&_aircraft_view_desc, v->index); |
0 | 578 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
579 |
if (w != NULL) { |
0 | 580 |
w->caption_color = v->owner; |
581 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
582 |
} |
|
583 |
} |
|
584 |
||
4442
8d8d0c2df7cb
(svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents:
4434
diff
changeset
|
585 |
void DrawSmallOrderListAircraft(const Vehicle *v, int x, int y) |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4056
diff
changeset
|
586 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
587 |
const Order *order; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
588 |
int sel, i = 0; |
0 | 589 |
|
590 |
sel = v->cur_order_index; |
|
591 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
592 |
FOR_VEHICLE_ORDERS(v, order) { |
3732
84cadfb100ed
(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
|
593 |
if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, 16); |
0 | 594 |
sel--; |
595 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1019
diff
changeset
|
596 |
if (order->type == OT_GOTO_STATION) { |
4527
b18634a31a4a
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents:
4524
diff
changeset
|
597 |
SetDParam(0, order->dest); |
0 | 598 |
DrawString(x, y, STR_A036, 0); |
599 |
||
600 |
y += 6; |
|
2639 | 601 |
if (++i == 4) break; |
0 | 602 |
} |
603 |
} |
|
604 |
} |