Delete pointless project file remnants.
[openttd-joker.git] / src / vehicle_gui.h
blob53429ed0ad0fab7484eb7171a06573ac22261337
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file vehicle_gui.h Functions related to the vehicle's GUIs. */
12 #ifndef VEHICLE_GUI_H
13 #define VEHICLE_GUI_H
15 #include "window_type.h"
16 #include "vehicle_type.h"
17 #include "order_type.h"
18 #include "station_type.h"
19 #include "engine_type.h"
20 #include "company_type.h"
21 #include "widgets/dropdown_func.h"
23 void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit = false, bool is_virtual_train = false);
25 /** The tabs in the train details window */
26 enum TrainDetailsWindowTabs {
27 TDW_TAB_CARGO = 0, ///< Tab with cargo carried by the vehicles
28 TDW_TAB_INFO, ///< Tab with name and value of the vehicles
29 TDW_TAB_CAPACITY, ///< Tab with cargo capacity of the vehicles
30 TDW_TAB_TOTALS, ///< Tab with sum of total cargo transported
33 /** Special values for vehicle-related windows for the data parameter of #InvalidateWindowData. */
34 enum VehicleInvalidateWindowData {
35 VIWD_REMOVE_ALL_ORDERS = -1, ///< Removed / replaced all orders (after deleting / sharing).
36 VIWD_MODIFY_ORDERS = -2, ///< Other order modifications.
37 VIWD_CONSIST_CHANGED = -3, ///< Vehicle composition was changed.
38 VIWD_AUTOREPLACE = -4, ///< Autoreplace replaced the vehicle.
41 int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number);
43 void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest = INVALID_VEHICLE);
44 void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip = 0);
45 void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type);
46 void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type);
48 void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
50 uint GetEngineListHeight(VehicleType type);
52 uint ShowRefitOptionsList(int left, int right, int y, EngineID engine);
53 StringID GetCargoSubtypeText(const Vehicle *v);
55 void ShowVehicleListWindow(const Vehicle *v);
56 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
57 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
58 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
60 /**
61 * Get the height of a single vehicle in the GUIs.
62 * @param type the vehicle type to look at
63 * @return the height
65 static inline uint GetVehicleHeight(VehicleType type)
67 return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
70 int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type);
71 int GetVehicleWidth(const Vehicle *v, EngineImageType image_type);
73 /** Dimensions of a cell in the purchase/depot windows. */
74 struct VehicleCellSize {
75 uint height; ///< Vehicle cell height.
76 uint extend_left; ///< Extend of the cell to the left.
77 uint extend_right; ///< Extend of the cell to the right.
80 VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type);
82 /**
83 * Get WindowClass for vehicle list of given vehicle type
84 * @param vt vehicle type to check
85 * @return corresponding window class
86 * @note works only for company buildable vehicle types
88 static inline WindowClass GetWindowClassForVehicleType(VehicleType vt)
90 switch (vt) {
91 default: NOT_REACHED();
92 case VEH_TRAIN: return WC_TRAINS_LIST;
93 case VEH_ROAD: return WC_ROADVEH_LIST;
94 case VEH_SHIP: return WC_SHIPS_LIST;
95 case VEH_AIRCRAFT: return WC_AIRCRAFT_LIST;
99 /* Unified window procedure */
100 void ShowVehicleViewWindow(const Vehicle *v);
101 bool VehicleClicked(const Vehicle *v);
102 void StartStopVehicle(const Vehicle *v, bool texteffect);
104 Vehicle *CheckClickOnVehicle(const struct ViewPort *vp, int x, int y);
106 void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip);
107 void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type);
109 void ShowTripHistoryWindow(const Vehicle *v);
112 * Tell if the focused window concerns the specified vehicle.
113 * @param vid Vehicle id to check.
114 * @param ref_window The window to check against.
115 * @return True if the focused window is about specified vehicle.
117 static inline bool HasFocusedVehicleChanged(const VehicleID vid, Window *ref_window)
119 if (ref_window) {
120 WindowClass wc = ref_window->window_class;
121 WindowNumber wn = ref_window->window_number;
123 if (wc == WC_DROPDOWN_MENU) GetParentWindowInfo(ref_window, wc, wn);
125 switch (wc) {
126 default:
127 break;
128 case WC_VEHICLE_DETAILS:
129 case WC_VEHICLE_REFIT:
130 case WC_VEHICLE_ORDERS:
131 case WC_VEHICLE_TIMETABLE:
132 case WC_VEHICLE_VIEW:
133 case WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS:
134 case WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS:
135 return ((uint32) wn != vid);
139 return true;
142 #endif /* VEHICLE_GUI_H */