2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 /** @file vehicle_gui.h Functions related to the vehicle's GUIs. */
13 #include "window_type.h"
14 #include "vehicle_type.h"
15 #include "vehicle_gui_base.h"
16 #include "vehiclelist.h"
17 #include "order_type.h"
18 #include "station_type.h"
19 #include "engine_type.h"
20 #include "company_type.h"
22 void ShowVehicleRefitWindow(const Vehicle
*v
, VehicleOrderID order
, Window
*parent
, bool auto_refit
= false);
24 /** The tabs in the train details window */
25 enum TrainDetailsWindowTabs
: uint8_t {
26 TDW_TAB_CARGO
= 0, ///< Tab with cargo carried by the vehicles
27 TDW_TAB_INFO
, ///< Tab with name and value of the vehicles
28 TDW_TAB_CAPACITY
, ///< Tab with cargo capacity of the vehicles
29 TDW_TAB_TOTALS
, ///< Tab with sum of total cargo transported
31 DECLARE_ENUM_AS_ADDABLE(TrainDetailsWindowTabs
)
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 /** Extra information about refitted cargo and capacity */
42 struct TestedEngineDetails
{
43 Money cost
; ///< Refit cost
44 CargoID cargo
; ///< Cargo type
45 uint capacity
; ///< Cargo capacity
46 uint16_t mail_capacity
; ///< Mail capacity if available
47 CargoArray all_capacities
{}; ///< Capacities for all cargoes
49 void FillDefaultCapacities(const Engine
*e
);
52 int DrawVehiclePurchaseInfo(int left
, int right
, int y
, EngineID engine_number
, TestedEngineDetails
&te
);
54 void DrawTrainImage(const Train
*v
, const Rect
&r
, VehicleID selection
, EngineImageType image_type
, int skip
, VehicleID drag_dest
= INVALID_VEHICLE
);
55 void DrawRoadVehImage(const Vehicle
*v
, const Rect
&r
, VehicleID selection
, EngineImageType image_type
, int skip
= 0);
56 void DrawShipImage(const Vehicle
*v
, const Rect
&r
, VehicleID selection
, EngineImageType image_type
);
57 void DrawAircraftImage(const Vehicle
*v
, const Rect
&r
, VehicleID selection
, EngineImageType image_type
);
59 void ShowBuildVehicleWindow(TileIndex tile
, VehicleType type
);
61 uint
ShowRefitOptionsList(int left
, int right
, int y
, EngineID engine
);
62 StringID
GetCargoSubtypeText(const Vehicle
*v
);
64 void ShowVehicleListWindow(const Vehicle
*v
);
65 void ShowVehicleListWindow(CompanyID company
, VehicleType vehicle_type
);
66 void ShowVehicleListWindow(CompanyID company
, VehicleType vehicle_type
, StationID station
);
67 void ShowVehicleListWindow(CompanyID company
, VehicleType vehicle_type
, TileIndex depot_tile
);
70 * Get the height of a single vehicle in the GUIs.
71 * @param type the vehicle type to look at
74 inline uint
GetVehicleHeight(VehicleType type
)
76 return (type
== VEH_TRAIN
|| type
== VEH_ROAD
) ? 14 : 24;
79 int GetSingleVehicleWidth(const Vehicle
*v
, EngineImageType image_type
);
80 int GetVehicleWidth(const Vehicle
*v
, EngineImageType image_type
);
82 /** Dimensions of a cell in the purchase/depot windows. */
83 struct VehicleCellSize
{
84 uint height
; ///< Vehicle cell height.
85 uint extend_left
; ///< Extend of the cell to the left.
86 uint extend_right
; ///< Extend of the cell to the right.
89 VehicleCellSize
GetVehicleImageCellSize(VehicleType type
, EngineImageType image_type
);
92 * Get WindowClass for vehicle list of given vehicle type
93 * @param vt vehicle type to check
94 * @return corresponding window class
95 * @note works only for company buildable vehicle types
97 inline WindowClass
GetWindowClassForVehicleType(VehicleType vt
)
100 default: NOT_REACHED();
101 case VEH_TRAIN
: return WC_TRAINS_LIST
;
102 case VEH_ROAD
: return WC_ROADVEH_LIST
;
103 case VEH_SHIP
: return WC_SHIPS_LIST
;
104 case VEH_AIRCRAFT
: return WC_AIRCRAFT_LIST
;
108 /* Unified window procedure */
109 void ShowVehicleViewWindow(const Vehicle
*v
);
110 bool VehicleClicked(const Vehicle
*v
);
111 bool VehicleClicked(VehicleList::const_iterator begin
, VehicleList::const_iterator end
);
112 bool VehicleClicked(const GUIVehicleGroup
&vehgroup
);
113 void StartStopVehicle(const Vehicle
*v
, bool texteffect
);
115 Vehicle
*CheckClickOnVehicle(const struct Viewport
*vp
, int x
, int y
);
116 void StopGlobalFollowVehicle(const Vehicle
*v
);
118 void DrawVehicleImage(const Vehicle
*v
, const Rect
&r
, VehicleID selection
, EngineImageType image_type
, int skip
);
119 void SetMouseCursorVehicle(const Vehicle
*v
, EngineImageType image_type
);
121 #endif /* VEHICLE_GUI_H */