MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawAircraftDetails

Function DrawAircraftDetails

src/aircraft_gui.cpp:29–61  ·  view source on GitHub ↗

* Draw the details for the given vehicle at the given position * * @param v current vehicle * @param r the Rect to draw within */

Source from the content-addressed store, hash-verified

27 * @param r the Rect to draw within
28 */
29void DrawAircraftDetails(const Aircraft *v, const Rect &r)
30{
31 Money feeder_share = 0;
32
33 int y = r.top;
34 for (const Aircraft *u = v; u != nullptr; u = u->Next()) {
35 if (u->IsNormalAircraft()) {
36 DrawString(r.left, r.right, y, GetString(STR_VEHICLE_INFO_BUILT_VALUE, PackEngineNameDParam(u->engine_type, EngineNameContext::VehicleDetails), u->build_year, u->value));
37 y += GetCharacterHeight(FS_NORMAL);
38
39 if (u->Next()->cargo_cap != 0) {
40 DrawString(r.left, r.right, y, GetString(STR_VEHICLE_INFO_CAPACITY_CAPACITY, u->cargo_type, u->cargo_cap, u->Next()->cargo_type, u->Next()->cargo_cap, GetCargoSubtypeText(u)));
41 } else {
42 DrawString(r.left, r.right, y, GetString(STR_VEHICLE_INFO_CAPACITY, u->cargo_type, u->cargo_cap, GetCargoSubtypeText(u)));
43 }
44 y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
45 }
46
47 if (u->cargo_cap != 0) {
48 uint cargo_count = u->cargo.StoredCount();
49
50 if (cargo_count != 0) {
51 /* Cargo names (fix pluralness) */
52 DrawString(r.left, r.right, y, GetString(STR_VEHICLE_DETAILS_CARGO_FROM, u->cargo_type, cargo_count, u->cargo.GetFirstStation()));
53 y += GetCharacterHeight(FS_NORMAL);
54 feeder_share += u->cargo.GetFeederShare();
55 }
56 }
57 }
58
59 y += WidgetDimensions::scaled.vsep_normal;
60 DrawString(r.left, r.right, y, GetString(STR_VEHICLE_INFO_FEEDER_CARGO_VALUE, feeder_share));
61}
62
63
64/**

Callers 1

DrawVehicleDetailsMethod · 0.85

Calls 10

PackEngineNameDParamFunction · 0.85
GetCharacterHeightFunction · 0.85
GetCargoSubtypeTextFunction · 0.85
IsNormalAircraftMethod · 0.80
StoredCountMethod · 0.80
DrawStringFunction · 0.70
GetStringFunction · 0.70
NextMethod · 0.45
GetFirstStationMethod · 0.45
GetFeederShareMethod · 0.45

Tested by

no test coverage detected