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/>.
10 /** @file vehicle_gui.h Functions related to the vehicle's GUIs. */
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"
23 void ShowVehicleRefitWindow (Window
*parent
, const Vehicle
*v
,
24 VehicleOrderID order
= INVALID_VEH_ORDER_ID
,
25 bool auto_refit
= false, CargoMask mask
= 0);
27 /** The tabs in the train details window */
28 enum TrainDetailsWindowTabs
{
29 TDW_TAB_CARGO
= 0, ///< Tab with cargo carried by the vehicles
30 TDW_TAB_INFO
, ///< Tab with name and value of the vehicles
31 TDW_TAB_CAPACITY
, ///< Tab with cargo capacity of the vehicles
32 TDW_TAB_TOTALS
, ///< Tab with sum of total cargo transported
35 /** Special values for vehicle-related windows for the data parameter of #InvalidateWindowData. */
36 enum VehicleInvalidateWindowData
{
37 VIWD_REMOVE_ALL_ORDERS
= -1, ///< Removed / replaced all orders (after deleting / sharing).
38 VIWD_MODIFY_ORDERS
= -2, ///< Other order modifications.
39 VIWD_CONSIST_CHANGED
= -3, ///< Vehicle composition was changed.
40 VIWD_AUTOREPLACE
= -4, ///< Autoreplace replaced the vehicle.
43 int DrawVehiclePurchaseInfo (BlitArea
*dpi
, int left
, int right
, int y
, EngineID engine_number
);
45 void DrawTrainImage (const Train
*v
, BlitArea
*dpi
, int left
, int right
, int y
, VehicleID selection
, bool chain
, EngineImageType image_type
, int skip
, VehicleID drag_dest
= INVALID_VEHICLE
);
46 void DrawRoadVehImage (const Vehicle
*v
, BlitArea
*dpi
, int left
, int right
, int y
, VehicleID selection
, EngineImageType image_type
, int skip
= 0);
47 void DrawShipImage (const Vehicle
*v
, BlitArea
*dpi
, int left
, int right
, int y
, VehicleID selection
, EngineImageType image_type
);
48 void DrawAircraftImage (const Vehicle
*v
, BlitArea
*dpi
, int left
, int right
, int y
, VehicleID selection
, EngineImageType image_type
);
50 void ShowBuildVehicleWindow(TileIndex tile
, VehicleType type
);
52 uint
ShowRefitOptionsList (BlitArea
*dpi
, 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
);
61 * Get the height of a single vehicle in the GUIs.
62 * @param type the vehicle type to look at
65 static inline uint
GetVehicleHeight(VehicleType type
)
67 return (type
== VEH_TRAIN
|| type
== VEH_ROAD
) ? 14 : 24;
70 /** Dimensions of a cell in the purchase/depot windows. */
71 struct VehicleCellSize
{
72 uint height
; ///< Vehicle cell height.
73 uint extend_left
; ///< Extend of the cell to the left.
74 uint extend_right
; ///< Extend of the cell to the right.
77 VehicleCellSize
GetVehicleImageCellSize(VehicleType type
, EngineImageType image_type
);
80 * Get WindowClass for vehicle list of given vehicle type
81 * @param vt vehicle type to check
82 * @return corresponding window class
83 * @note works only for company buildable vehicle types
85 static inline WindowClass
GetWindowClassForVehicleType(VehicleType vt
)
88 default: NOT_REACHED();
89 case VEH_TRAIN
: return WC_TRAINS_LIST
;
90 case VEH_ROAD
: return WC_ROADVEH_LIST
;
91 case VEH_SHIP
: return WC_SHIPS_LIST
;
92 case VEH_AIRCRAFT
: return WC_AIRCRAFT_LIST
;
96 /* Unified window procedure */
97 void ShowVehicleViewWindow(const Vehicle
*v
);
98 bool VehicleClicked(const Vehicle
*v
);
99 void StartStopVehicle(const Vehicle
*v
, bool texteffect
);
101 Vehicle
*CheckClickOnVehicle (int x
, int y
);
103 void DrawVehicleImage (const Vehicle
*v
, BlitArea
*dpi
, int left
, int right
, int y
, EngineImageType image_type
, int skip
= 0, VehicleID selection
= INVALID_VEHICLE
);
104 void SetMouseCursorVehicle(const Vehicle
*v
, EngineImageType image_type
);
106 #endif /* VEHICLE_GUI_H */