summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-04-24 09:55:20 +0000
committersmatz <smatz@openttd.org>2008-04-24 09:55:20 +0000
commit9fc355fca5d80a7d38d4a35dd6ec00e6adb1391a (patch)
tree425b0f3d08a6a6ba4e8c57af527383861642e162 /src/vehicle_gui.h
parent48eda2b6ef4ac2b29bb007218b162207658d70a5 (diff)
downloadopenttd-9fc355fca5d80a7d38d4a35dd6ec00e6adb1391a.tar.xz
(svn r12862) -Codechange: reduce code duplication for VehicleType -> WindowClass lookup
Diffstat (limited to 'src/vehicle_gui.h')
-rw-r--r--src/vehicle_gui.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index d9e4ff173..e10ed2c18 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -99,6 +99,22 @@ static inline uint GetVehicleListHeight(VehicleType type)
return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
}
+/** Get WindowClass for vehicle list of given vehicle type
+ * @param vt vehicle type to check
+ * @return corresponding window class
+ * @note works only for player buildable vehicle types
+ */
+static inline WindowClass GetWindowClassForVehicleType(VehicleType vt)
+{
+ switch (vt) {
+ default: NOT_REACHED();
+ case VEH_TRAIN: return WC_TRAINS_LIST;
+ case VEH_ROAD: return WC_ROADVEH_LIST;
+ case VEH_SHIP: return WC_SHIPS_LIST;
+ case VEH_AIRCRAFT: return WC_AIRCRAFT_LIST;
+ }
+}
+
/* Unified window procedure */
void ShowVehicleViewWindow(const Vehicle *v);