author | rubidium |
Thu, 30 Aug 2007 13:03:56 +0000 | |
changeset 7492 | 35acee076719 |
parent 7488 | 6f51ddf4c225 |
child 7530 | bfeada535347 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6117
6507b2a7e71d
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
5893
diff
changeset
|
3 |
/** @file aircraft_gui.cpp */ |
6507b2a7e71d
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
5893
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
6 |
#include "openttd.h" |
3963
6cab57074a9a
(svn r5124) Add IsAircraftInHangar{Stopped,}(), which supersedes CheckStoppedInHangar()
tron
parents:
3948
diff
changeset
|
7 |
#include "aircraft.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
8 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
9 |
#include "functions.h" |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1907
diff
changeset
|
10 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
382
diff
changeset
|
11 |
#include "table/strings.h" |
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7134
diff
changeset
|
12 |
#include "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
|
13 |
#include "map.h" |
0 | 14 |
#include "window.h" |
15 |
#include "gui.h" |
|
16 |
#include "vehicle.h" |
|
17 |
#include "gfx.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" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2113
diff
changeset
|
23 |
#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
|
24 |
#include "newgrf_engine.h" |
4787
5eaa3e93cf24
(svn r6708) -Feature: [build aircraft window] added sort options to the list
bjarni
parents:
4786
diff
changeset
|
25 |
|
5780
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
26 |
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection) |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
27 |
{ |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
28 |
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
7134
5b2d47128d05
(svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents:
7063
diff
changeset
|
29 |
DrawSprite(v->GetImage(DIR_W), pal, x + 25, y + 10); |
5854
9eee280920f0
(svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents:
5780
diff
changeset
|
30 |
if (v->subtype == AIR_HELICOPTER) { |
5780
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
31 |
SpriteID rotor_sprite = GetCustomRotorSprite(v, true); |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
32 |
if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED; |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
33 |
DrawSprite(rotor_sprite, PAL_NONE, x + 25, y + 5); |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
34 |
} |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
35 |
if (v->index == selection) { |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
36 |
DrawFrameRect(x - 1, y - 1, x + 58, y + 21, 0xF, FR_BORDERONLY); |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
37 |
} |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
38 |
} |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
39 |
|
6415
cb61e1346600
(svn r9551) -Documentation: Some more doxygen work
belugas
parents:
6198
diff
changeset
|
40 |
/** |
cb61e1346600
(svn r9551) -Documentation: Some more doxygen work
belugas
parents:
6198
diff
changeset
|
41 |
* This is the Callback method after the construction attempt of an aircraft |
cb61e1346600
(svn r9551) -Documentation: Some more doxygen work
belugas
parents:
6198
diff
changeset
|
42 |
* @param success indicates completion (or not) of the operation |
cb61e1346600
(svn r9551) -Documentation: Some more doxygen work
belugas
parents:
6198
diff
changeset
|
43 |
* @param tile of depot where aircraft is built |
cb61e1346600
(svn r9551) -Documentation: Some more doxygen work
belugas
parents:
6198
diff
changeset
|
44 |
* @param p1 unused |
cb61e1346600
(svn r9551) -Documentation: Some more doxygen work
belugas
parents:
6198
diff
changeset
|
45 |
* @param p2 unused |
cb61e1346600
(svn r9551) -Documentation: Some more doxygen work
belugas
parents:
6198
diff
changeset
|
46 |
*/ |
5780
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
47 |
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2) |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
48 |
{ |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
49 |
if (success) { |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
50 |
const Vehicle *v = GetVehicle(_new_vehicle_id); |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
51 |
|
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
52 |
if (v->tile == _backup_orders_tile) { |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
53 |
_backup_orders_tile = 0; |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
54 |
RestoreVehicleOrders(v, _backup_orders_data); |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
55 |
} |
7486
bf6a94009823
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents:
7484
diff
changeset
|
56 |
ShowVehicleViewWindow(v); |
5780
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
57 |
} |
b16aec7650c2
(svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni
parents:
5668
diff
changeset
|
58 |
} |
0 | 59 |
|
60 |
static void AircraftDetailsWndProc(Window *w, WindowEvent *e) |
|
61 |
{ |
|
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
|
62 |
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
|
63 |
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
|
64 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 65 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
66 |
SetWindowWidgetDisabledState(w, 2, v->owner != _local_player); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
67 |
|
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
68 |
/* Disable service-scroller when interval is set to disabled */ |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
69 |
SetWindowWidgetDisabledState(w, 5, !_patches.servint_aircraft); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
70 |
SetWindowWidgetDisabledState(w, 6, !_patches.servint_aircraft); |
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
|
71 |
|
7049
0ebe47348074
(svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents:
7010
diff
changeset
|
72 |
SetDParam(0, v->index); |
0 | 73 |
DrawWindowWidgets(w); |
74 |
||
75 |
/* Draw running cost */ |
|
76 |
{ |
|
77 |
int year = v->age / 366; |
|
78 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
79 |
SetDParam(1, year); |
0 | 80 |
|
2252
6df2bfd7a077
(svn r2772) Simplify the age notice in the vehicle details window
tron
parents:
2244
diff
changeset
|
81 |
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
|
82 |
SetDParam(2, v->max_age / 366); |
7488
6f51ddf4c225
(svn r10999) -Codechange: unify the way the running cost of a vehicle is determined. Patch by nycom.
rubidium
parents:
7486
diff
changeset
|
83 |
SetDParam(3, v->GetDisplayRunningCost()); |
0 | 84 |
DrawString(2, 15, STR_A00D_AGE_RUNNING_COST_YR, 0); |
85 |
} |
|
86 |
||
87 |
/* Draw max speed */ |
|
88 |
{ |
|
7484
7734e4119e70
(svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents:
7478
diff
changeset
|
89 |
SetDParam(0, v->GetDisplayMaxSpeed()); |
0 | 90 |
DrawString(2, 25, STR_A00E_MAX_SPEED, 0); |
91 |
} |
|
92 |
||
93 |
/* Draw profit */ |
|
94 |
{ |
|
7002
1bf6a62b0fcb
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
6991
diff
changeset
|
95 |
SetDParam(0, v->profit_this_year); |
1bf6a62b0fcb
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
6991
diff
changeset
|
96 |
SetDParam(1, v->profit_last_year); |
0 | 97 |
DrawString(2, 35, STR_A00F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
98 |
} |
|
99 |
||
100 |
/* Draw breakdown & reliability */ |
|
101 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
102 |
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
|
103 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 104 |
DrawString(2, 45, STR_A010_RELIABILITY_BREAKDOWNS, 0); |
105 |
} |
|
106 |
||
107 |
/* Draw service interval text */ |
|
108 |
{ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
109 |
SetDParam(0, v->service_interval); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
110 |
SetDParam(1, v->date_of_last_service); |
6198 | 111 |
DrawString(13, 115, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
112 |
} |
|
113 |
||
114 |
/* Draw Transfer credits text */ |
|
115 |
{ |
|
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7002
diff
changeset
|
116 |
SetDParam(0, v->cargo.FeederShare()); |
6198 | 117 |
DrawString(60, 101, STR_FEEDER_CARGO_VALUE, 0); |
0 | 118 |
} |
119 |
||
120 |
DrawAircraftImage(v, 3, 57, INVALID_VEHICLE); |
|
121 |
||
122 |
{ |
|
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
|
123 |
const Vehicle *u; |
0 | 124 |
int y = 57; |
125 |
||
126 |
do { |
|
5854
9eee280920f0
(svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents:
5780
diff
changeset
|
127 |
if (IsNormalAircraft(v)) { |
7059
c6d12e3de0dc
(svn r10324) -Codechange: reference engine names by index
peter1138
parents:
7049
diff
changeset
|
128 |
SetDParam(0, v->engine_type); |
4329
0e6e689f66e7
(svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents:
4299
diff
changeset
|
129 |
SetDParam(1, v->build_year); |
7002
1bf6a62b0fcb
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
6991
diff
changeset
|
130 |
SetDParam(2, v->value); |
0 | 131 |
DrawString(60, y, STR_A011_BUILT_VALUE, 0); |
132 |
y += 10; |
|
133 |
||
4896
f86350aaaaa5
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4800
diff
changeset
|
134 |
SetDParam(0, v->cargo_type); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
135 |
SetDParam(1, v->cargo_cap); |
7492
35acee076719
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7488
diff
changeset
|
136 |
u = v->Next(); |
4896
f86350aaaaa5
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4800
diff
changeset
|
137 |
SetDParam(2, u->cargo_type); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
138 |
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
|
139 |
DrawString(60, y, (u->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, 0); |
0 | 140 |
y += 14; |
141 |
} |
|
142 |
||
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7002
diff
changeset
|
143 |
uint cargo_count = v->cargo.Count(); |
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7002
diff
changeset
|
144 |
if (cargo_count != 0) { |
0 | 145 |
|
146 |
/* Cargo names (fix pluralness) */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
147 |
SetDParam(0, v->cargo_type); |
7010
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7002
diff
changeset
|
148 |
SetDParam(1, cargo_count); |
6f0d9f03180d
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7002
diff
changeset
|
149 |
SetDParam(2, v->cargo.Source()); |
0 | 150 |
DrawString(60, y, STR_8813_FROM, 0); |
151 |
||
152 |
y += 10; |
|
153 |
} |
|
7492
35acee076719
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents:
7488
diff
changeset
|
154 |
} while ((v = v->Next()) != NULL); |
0 | 155 |
} |
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
|
156 |
} break; |
0 | 157 |
|
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
|
158 |
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
|
159 |
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
|
160 |
const Vehicle *v; |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
161 |
switch (e->we.click.widget) { |
0 | 162 |
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
|
163 |
v = GetVehicle(w->window_number); |
7049
0ebe47348074
(svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents:
7010
diff
changeset
|
164 |
SetDParam(0, v->index); |
0ebe47348074
(svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents:
7010
diff
changeset
|
165 |
ShowQueryString(STR_VEHICLE_NAME, STR_A030_NAME_AIRCRAFT, 31, 150, w, CS_ALPHANUMERAL); |
0 | 166 |
break; |
167 |
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
|
168 |
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
|
169 |
goto do_change_service_int; |
0 | 170 |
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
|
171 |
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
|
172 |
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
|
173 |
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
|
174 |
|
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
|
175 |
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
|
176 |
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
|
177 |
|
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
|
178 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
0 | 179 |
break; |
180 |
} |
|
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
|
181 |
} break; |
0 | 182 |
|
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
|
183 |
case WE_ON_EDIT_TEXT: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
184 |
if (e->we.edittext.str[0] != '\0') { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
185 |
_cmd_text = e->we.edittext.str; |
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
|
186 |
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
|
187 |
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
|
188 |
} |
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
|
189 |
break; |
0 | 190 |
} |
191 |
} |
|
192 |
||
193 |
||
194 |
static const Widget _aircraft_details_widgets[] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
195 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
196 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 349, 0, 13, STR_A00C_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
197 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 350, 389, 0, 13, STR_01AA_NAME, STR_A032_NAME_AIRCRAFT }, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
198 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 389, 14, 55, 0x0, STR_NULL }, |
6198 | 199 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 389, 56, 113, 0x0, STR_NULL }, |
200 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 114, 119, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL }, |
|
201 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 120, 125, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL }, |
|
202 |
{ WWT_PANEL, RESIZE_NONE, 14, 11, 389, 114, 125, 0x0, STR_NULL }, |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
203 |
{ WIDGETS_END}, |
0 | 204 |
}; |
205 |
||
206 |
static const WindowDesc _aircraft_details_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
207 |
WDP_AUTO, WDP_AUTO, 390, 126, 390, 126, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
208 |
WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, |
0 | 209 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
210 |
_aircraft_details_widgets, |
|
211 |
AircraftDetailsWndProc |
|
212 |
}; |
|
213 |
||
214 |
||
7486
bf6a94009823
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents:
7484
diff
changeset
|
215 |
void ShowAircraftDetailsWindow(const Vehicle *v) |
0 | 216 |
{ |
217 |
Window *w; |
|
218 |
VehicleID veh = v->index; |
|
219 |
||
220 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
221 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
222 |
||
5071
e28106dfcb6f
(svn r7129) -Codechange: Get rid of a global variable that only sets a window's number.
Darkvater
parents:
5070
diff
changeset
|
223 |
w = AllocateWindowDescFront(&_aircraft_details_desc, veh); |
0 | 224 |
w->caption_color = v->owner; |
225 |
// w->vscroll.cap = 6; |
|
226 |
// w->traindetails_d.tab = 0; |
|
227 |
} |