summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2017-03-18 20:43:43 +0000
committeralberth <alberth@openttd.org>2017-03-18 20:43:43 +0000
commitad88588481d043a84030ce4deefaf064ee11fc79 (patch)
tree2b1ddbe06b0c10666b5275b08a30765c7a194eeb /src
parent19188818eae21fd3ff3b3c5ae35cde693b31ec28 (diff)
downloadopenttd-ad88588481d043a84030ce4deefaf064ee11fc79.tar.xz
(svn r27797) -Add: Display aircraft type in its vehicle window (patch by Samu)
Diffstat (limited to 'src')
-rw-r--r--src/engine.cpp21
-rw-r--r--src/engine_base.h1
-rw-r--r--src/lang/english.txt3
-rw-r--r--src/vehicle_gui.cpp11
4 files changed, 31 insertions, 5 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index 3e69c4ac8..b0af3bc4d 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -464,7 +464,26 @@ uint16 Engine::GetRange() const
}
/**
- * Initializes the EngineOverrideManager with the default engines.
+ * Get the name of the aircraft type for display purposes.
+ * @return Aircraft type string.
+ */
+StringID Engine::GetAircraftTypeText() const
+{
+ switch (this->type) {
+ case VEH_AIRCRAFT:
+ switch (this->u.air.subtype) {
+ case AIR_HELI: return STR_LIVERY_HELICOPTER;
+ case AIR_CTOL: return STR_LIVERY_SMALL_PLANE;
+ case AIR_CTOL | AIR_FAST: return STR_LIVERY_LARGE_PLANE;
+ default: NOT_REACHED();
+ }
+
+ default: NOT_REACHED();
+ }
+}
+
+/**
+ * Initializes the #EngineOverrideManager with the default engines.
*/
void EngineOverrideManager::ResetToDefaultMapping()
{
diff --git a/src/engine_base.h b/src/engine_base.h
index 6a2e6816c..25c6bfbeb 100644
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -111,6 +111,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
uint GetDisplayMaxTractiveEffort() const;
Date GetLifeLengthInDays() const;
uint16 GetRange() const;
+ StringID GetAircraftTypeText() const;
/**
* Check whether the engine is hidden in the GUI for the given company.
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 505356f08..978e90ffa 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3657,7 +3657,8 @@ STR_VEHICLE_INFO_AGE :{COMMA} year{P
STR_VEHICLE_INFO_AGE_RED :{RED}{COMMA} year{P "" s} ({COMMA})
STR_VEHICLE_INFO_MAX_SPEED :{BLACK}Max. speed: {LTBLUE}{VELOCITY}
-STR_VEHICLE_INFO_MAX_SPEED_RANGE :{BLACK}Max. speed: {LTBLUE}{VELOCITY} {BLACK}Range: {LTBLUE}{COMMA} tiles
+STR_VEHICLE_INFO_MAX_SPEED_TYPE :{BLACK}Max. speed: {LTBLUE}{VELOCITY} {BLACK}Aircraft type: {LTBLUE}{STRING}
+STR_VEHICLE_INFO_MAX_SPEED_TYPE_RANGE :{BLACK}Max. speed: {LTBLUE}{VELOCITY} {BLACK}Aircraft type: {LTBLUE}{STRING} {BLACK}Range: {LTBLUE}{COMMA} tiles
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED :{BLACK}Weight: {LTBLUE}{WEIGHT_SHORT} {BLACK}Power: {LTBLUE}{POWER}{BLACK} Max. speed: {LTBLUE}{VELOCITY}
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :{BLACK}Weight: {LTBLUE}{WEIGHT_SHORT} {BLACK}Power: {LTBLUE}{POWER}{BLACK} Max. speed: {LTBLUE}{VELOCITY} {BLACK}Max. T.E.: {LTBLUE}{FORCE}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 8ea8cda4c..a77ea18df 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -2069,9 +2069,14 @@ struct VehicleDetailsWindow : Window {
}
} else {
SetDParam(0, v->GetDisplayMaxSpeed());
- if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0) {
- SetDParam(1, Aircraft::From(v)->GetRange());
- string = STR_VEHICLE_INFO_MAX_SPEED_RANGE;
+ if (v->type == VEH_AIRCRAFT) {
+ SetDParam(1, v->GetEngine()->GetAircraftTypeText());
+ if (Aircraft::From(v)->GetRange() > 0) {
+ SetDParam(2, Aircraft::From(v)->GetRange());
+ string = STR_VEHICLE_INFO_MAX_SPEED_TYPE_RANGE;
+ } else {
+ string = STR_VEHICLE_INFO_MAX_SPEED_TYPE;
+ }
} else {
string = STR_VEHICLE_INFO_MAX_SPEED;
}