OpenTTD Source  1.11.0-beta2
vehicle_gui.h
Go to the documentation of this file.
1 /*
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/>.
6  */
7 
10 #ifndef VEHICLE_GUI_H
11 #define VEHICLE_GUI_H
12 
13 #include "window_type.h"
14 #include "vehicle_type.h"
15 #include "order_type.h"
16 #include "station_type.h"
17 #include "engine_type.h"
18 #include "company_type.h"
19 
20 void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit = false);
21 
28 };
29 
36 };
37 
42  uint capacity;
43  uint16 mail_capacity;
44 };
45 
46 int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te);
47 
48 void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest = INVALID_VEHICLE);
49 void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip = 0);
50 void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type);
51 void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type);
52 
53 void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
54 
55 uint ShowRefitOptionsList(int left, int right, int y, EngineID engine);
57 
58 void ShowVehicleListWindow(const Vehicle *v);
59 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
60 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
61 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
62 
68 static inline uint GetVehicleHeight(VehicleType type)
69 {
70  return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
71 }
72 
73 int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type);
74 int GetVehicleWidth(const Vehicle *v, EngineImageType image_type);
75 
78  uint height;
79  uint extend_left;
80  uint extend_right;
81 };
82 
84 
92 {
93  switch (vt) {
94  default: NOT_REACHED();
95  case VEH_TRAIN: return WC_TRAINS_LIST;
96  case VEH_ROAD: return WC_ROADVEH_LIST;
97  case VEH_SHIP: return WC_SHIPS_LIST;
98  case VEH_AIRCRAFT: return WC_AIRCRAFT_LIST;
99  }
100 }
101 
102 /* Unified window procedure */
103 void ShowVehicleViewWindow(const Vehicle *v);
104 bool VehicleClicked(const Vehicle *v);
105 void StartStopVehicle(const Vehicle *v, bool texteffect);
106 
107 Vehicle *CheckClickOnVehicle(const struct Viewport *vp, int x, int y);
108 
109 void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip);
110 void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type);
111 
112 #endif /* VEHICLE_GUI_H */
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
StartStopVehicle
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
Definition: vehicle_gui.cpp:2599
VehicleOrderID
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:15
WC_ROADVEH_LIST
@ WC_ROADVEH_LIST
Road vehicle list; Window numbers:
Definition: window_type.h:307
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
VehicleCellSize::height
uint height
Vehicle cell height.
Definition: vehicle_gui.h:78
TDW_TAB_INFO
@ TDW_TAB_INFO
Tab with name and value of the vehicles.
Definition: vehicle_gui.h:25
TestedEngineDetails::mail_capacity
uint16 mail_capacity
Mail capacity if available.
Definition: vehicle_gui.h:43
GetVehicleWidth
int GetVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (including all parts of the consist) in pixels.
Definition: vehicle_gui.cpp:3119
TrainDetailsWindowTabs
TrainDetailsWindowTabs
The tabs in the train details window.
Definition: vehicle_gui.h:23
window_type.h
DrawRoadVehImage
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip=0)
Draws an image of a road vehicle chain.
Definition: roadveh_gui.cpp:129
TestedEngineDetails::cargo
CargoID cargo
Cargo type.
Definition: vehicle_gui.h:41
VehicleCellSize::extend_right
uint extend_right
Extend of the cell to the right.
Definition: vehicle_gui.h:80
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition: vehicle_type.h:85
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:222
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
TestedEngineDetails::capacity
uint capacity
Cargo capacity.
Definition: vehicle_gui.h:42
CheckClickOnVehicle
Vehicle * CheckClickOnVehicle(const Viewport *vp, int x, int y)
Find the vehicle close to the clicked coordinates.
Definition: vehicle.cpp:1201
GetVehicleImageCellSize
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
Definition: depot_gui.cpp:158
TDW_TAB_TOTALS
@ TDW_TAB_TOTALS
Tab with sum of total cargo transported.
Definition: vehicle_gui.h:27
EngineID
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:21
Viewport
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
GetVehicleHeight
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
Definition: vehicle_gui.h:68
ShowRefitOptionsList
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
Display list of cargo types of the engine, for the purchase information window.
Definition: vehicle_gui.cpp:1123
INVALID_VEHICLE
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition: vehicle_type.h:55
Train
'Train' is either a loco or a wagon.
Definition: train.h:85
WC_SHIPS_LIST
@ WC_SHIPS_LIST
Ships list; Window numbers:
Definition: window_type.h:313
TestedEngineDetails
Extra information about refitted cargo and capacity.
Definition: vehicle_gui.h:39
WindowClass
WindowClass
Window classes.
Definition: window_type.h:37
WC_TRAINS_LIST
@ WC_TRAINS_LIST
Trains list; Window numbers:
Definition: window_type.h:301
GetCargoSubtypeText
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
Definition: vehicle_gui.cpp:1152
DrawShipImage
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
Definition: ship_gui.cpp:32
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
VIWD_CONSIST_CHANGED
@ VIWD_CONSIST_CHANGED
Vehicle composition was changed.
Definition: vehicle_gui.h:34
GetSingleVehicleWidth
int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (part) in pixels.
Definition: vehicle_gui.cpp:3095
DrawVehicleImage
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a vehicle chain.
Definition: vehicle_gui.cpp:1468
GetWindowClassForVehicleType
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Definition: vehicle_gui.h:91
SetMouseCursorVehicle
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
Definition: vehicle_gui.cpp:3137
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
vehicle_type.h
engine_type.h
TDW_TAB_CAPACITY
@ TDW_TAB_CAPACITY
Tab with cargo capacity of the vehicles.
Definition: vehicle_gui.h:26
VIWD_AUTOREPLACE
@ VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
Definition: vehicle_gui.h:35
ShowVehicleRefitWindow
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit=false)
Show the refit window for a vehicle.
Definition: vehicle_gui.cpp:1115
TestedEngineDetails::cost
Money cost
Refit cost.
Definition: vehicle_gui.h:40
VehicleCellSize
Dimensions of a cell in the purchase/depot windows.
Definition: vehicle_gui.h:77
DrawVehiclePurchaseInfo
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te)
Draw the purchase info details of a vehicle at a given location.
Definition: build_vehicle_gui.cpp:867
DrawAircraftImage
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
Definition: aircraft_gui.cpp:80
VehicleID
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
VehicleInvalidateWindowData
VehicleInvalidateWindowData
Special values for vehicle-related windows for the data parameter of InvalidateWindowData.
Definition: vehicle_gui.h:31
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
Window
Data structure for an opened window.
Definition: window_gui.h:276
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
VIWD_MODIFY_ORDERS
@ VIWD_MODIFY_ORDERS
Other order modifications.
Definition: vehicle_gui.h:33
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
VIWD_REMOVE_ALL_ORDERS
@ VIWD_REMOVE_ALL_ORDERS
Removed / replaced all orders (after deleting / sharing).
Definition: vehicle_gui.h:32
WC_AIRCRAFT_LIST
@ WC_AIRCRAFT_LIST
Aircraft list; Window numbers:
Definition: window_type.h:319
order_type.h
company_type.h
VehicleCellSize::extend_left
uint extend_left
Extend of the cell to the left.
Definition: vehicle_gui.h:79
ShowVehicleViewWindow
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
Definition: vehicle_gui.cpp:3043
VehicleClicked
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
Definition: vehicle_gui.cpp:3053
DrawTrainImage
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest=INVALID_VEHICLE)
Draws an image of a whole train.
Definition: train_gui.cpp:92
station_type.h
TDW_TAB_CARGO
@ TDW_TAB_CARGO
Tab with cargo carried by the vehicles.
Definition: vehicle_gui.h:24