annotate src/aircraft_gui.cpp @ 10123:57aa34285d05 draft

(svn r14307) -Fix: when deleting a station, remove news items regarding it
author smatz <smatz@openttd.org>
date Sat, 13 Sep 2008 10:19:51 +0000
parents 9c82d1a69e62
children a4e5b5d2837c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 8962
diff changeset
3 /** @file aircraft_gui.cpp The GUI of aircraft. */
6117
6def6ecb1bf7 (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 <belugas@openttd.org>
parents: 5893
diff changeset
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
6 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
7 #include "aircraft.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
8 #include "debug.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
9 #include "gui.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
10 #include "vehicle_gui.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
11 #include "newgrf_engine.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
12 #include "strings_func.h"
8144
d18c8a0bb638 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents: 8139
diff changeset
13 #include "vehicle_func.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8144
diff changeset
14 #include "gfx_func.h"
8784
6280c0d48a6d (svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
15 #include "order_func.h"
9274
85a62fb8608f (svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
rubidium <rubidium@openttd.org>
parents: 9111
diff changeset
16 #include "window_gui.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
17
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
18 #include "table/sprites.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
19 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
20
7530
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
21 /**
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
22 * Draw the details for the given vehicle at the position (x,y)
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
23 *
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
24 * @param v current vehicle
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
25 * @param x The x coordinate
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
26 * @param y The y coordinate
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
27 */
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
28 void DrawAircraftDetails(const Vehicle *v, int x, int y)
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
29 {
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
30 int y_offset = (v->Next()->cargo_cap != 0) ? -11 : 0;
9943
9c82d1a69e62 (svn r14098) -Fix: Make the 'Transfer Credit' display aware of the entire consist, not only the first vehicle
celestar <celestar@openttd.org>
parents: 9770
diff changeset
31 Money feeder_share = 0;
7530
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
32
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
33 for (const Vehicle *u = v ; u != NULL ; u = u->Next()) {
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
34 if (IsNormalAircraft(u)) {
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
35 SetDParam(0, u->engine_type);
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
36 SetDParam(1, u->build_year);
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
37 SetDParam(2, u->value);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7653
diff changeset
38 DrawString(x, y, STR_A011_BUILT_VALUE, TC_FROMSTRING);
7530
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
39
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
40 SetDParam(0, u->cargo_type);
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
41 SetDParam(1, u->cargo_cap);
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
42 SetDParam(2, u->Next()->cargo_type);
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
43 SetDParam(3, u->Next()->cargo_cap);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7653
diff changeset
44 DrawString(x, y + 10, (u->Next()->cargo_cap != 0) ? STR_A019_CAPACITY : STR_A01A_CAPACITY, TC_FROMSTRING);
7530
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
45 }
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
46
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
47 if (u->cargo_cap != 0) {
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
48 uint cargo_count = u->cargo.Count();
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
49
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
50 y_offset += 11;
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
51 if (cargo_count != 0) {
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
52 /* Cargo names (fix pluralness) */
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
53 SetDParam(0, u->cargo_type);
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
54 SetDParam(1, cargo_count);
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
55 SetDParam(2, u->cargo.Source());
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7653
diff changeset
56 DrawString(x, y + 21 + y_offset, STR_8813_FROM, TC_FROMSTRING);
9943
9c82d1a69e62 (svn r14098) -Fix: Make the 'Transfer Credit' display aware of the entire consist, not only the first vehicle
celestar <celestar@openttd.org>
parents: 9770
diff changeset
57 feeder_share += u->cargo.FeederShare();
7530
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
58 }
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
59 }
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
60 }
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
61
9943
9c82d1a69e62 (svn r14098) -Fix: Make the 'Transfer Credit' display aware of the entire consist, not only the first vehicle
celestar <celestar@openttd.org>
parents: 9770
diff changeset
62 SetDParam(0, feeder_share);
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7653
diff changeset
63 DrawString(x, y + 33 + y_offset, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
7530
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
64 }
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
65
614aeff92fd3 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
66
5780
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
67 void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
68 {
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
69 SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
7134
e1c4f52f82cd (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium <rubidium@openttd.org>
parents: 7063
diff changeset
70 DrawSprite(v->GetImage(DIR_W), pal, x + 25, y + 10);
5854
b52317eb405c (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 <Darkvater@openttd.org>
parents: 5780
diff changeset
71 if (v->subtype == AIR_HELICOPTER) {
5780
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
72 SpriteID rotor_sprite = GetCustomRotorSprite(v, true);
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
73 if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
74 DrawSprite(rotor_sprite, PAL_NONE, x + 25, y + 5);
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
75 }
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
76 if (v->index == selection) {
9770
9f72f4a2aee0 (svn r13907) -Codechange: Replace a number with Colours enum on DrawFrameRect usage
belugas <belugas@openttd.org>
parents: 9274
diff changeset
77 DrawFrameRect(x - 1, y - 1, x + 58, y + 21, COLOUR_WHITE, FR_BORDERONLY);
5780
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
78 }
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
79 }
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
80
6415
c2c9492ad5f1 (svn r9551) -Documentation: Some more doxygen work
belugas <belugas@openttd.org>
parents: 6198
diff changeset
81 /**
c2c9492ad5f1 (svn r9551) -Documentation: Some more doxygen work
belugas <belugas@openttd.org>
parents: 6198
diff changeset
82 * This is the Callback method after the construction attempt of an aircraft
c2c9492ad5f1 (svn r9551) -Documentation: Some more doxygen work
belugas <belugas@openttd.org>
parents: 6198
diff changeset
83 * @param success indicates completion (or not) of the operation
c2c9492ad5f1 (svn r9551) -Documentation: Some more doxygen work
belugas <belugas@openttd.org>
parents: 6198
diff changeset
84 * @param tile of depot where aircraft is built
c2c9492ad5f1 (svn r9551) -Documentation: Some more doxygen work
belugas <belugas@openttd.org>
parents: 6198
diff changeset
85 * @param p1 unused
c2c9492ad5f1 (svn r9551) -Documentation: Some more doxygen work
belugas <belugas@openttd.org>
parents: 6198
diff changeset
86 * @param p2 unused
c2c9492ad5f1 (svn r9551) -Documentation: Some more doxygen work
belugas <belugas@openttd.org>
parents: 6198
diff changeset
87 */
5780
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
88 void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
89 {
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
90 if (success) {
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
91 const Vehicle *v = GetVehicle(_new_vehicle_id);
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
92
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
93 if (v->tile == _backup_orders_tile) {
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
94 _backup_orders_tile = 0;
7653
e6f32e659811 (svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium <rubidium@openttd.org>
parents: 7530
diff changeset
95 RestoreVehicleOrders(v);
5780
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
96 }
7486
1af81beda3fb (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents: 7484
diff changeset
97 ShowVehicleViewWindow(v);
5780
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
98 }
10c1b221d4bc (svn r8332) -Codechange: moved DrawAircraftImage() and CcBuildAircraft() from build_vehicle_gui.cpp to aircraft_gui.cpp
bjarni <bjarni@openttd.org>
parents: 5668
diff changeset
99 }