OpenTTD

vehicle_gui.h
Go to the documentation of this file.
1 /* $Id: vehicle_gui.h 27631 2016-08-15 18:34:09Z frosch $ */
2
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 */
9
12 #ifndef VEHICLE_GUI_H
13 #define VEHICLE_GUI_H
14
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
22 void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit = false);
23
25 enum TrainDetailsWindowTabs {
26 TDW_TAB_CARGO = 0,
27 TDW_TAB_INFO,
28 TDW_TAB_CAPACITY,
29 TDW_TAB_TOTALS,
30 };
31
33 enum VehicleInvalidateWindowData {
34 VIWD_REMOVE_ALL_ORDERS = -1,
35 VIWD_MODIFY_ORDERS = -2,
36 VIWD_CONSIST_CHANGED = -3,
37 VIWD_AUTOREPLACE = -4,
38 };
39
40 int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number);
41
42 void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest = INVALID_VEHICLE);
43 void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip = 0);
44 void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type);
45 void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type);
46
47 void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
48
49 uint ShowRefitOptionsList(int left, int right, int y, EngineID engine);
50 StringID GetCargoSubtypeText(const Vehicle *v);
51
52 void ShowVehicleListWindow(const Vehicle *v);
53 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
54 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
55 void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
56
62 static inline uint GetVehicleHeight(VehicleType type)
63 {
64 return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
65 }
66
67 int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type);
68 int GetVehicleWidth(const Vehicle *v, EngineImageType image_type);
69
71 struct VehicleCellSize {
72 uint height;
73 uint extend_left;
74 uint extend_right;
75 };
76
77 VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type);
78
85 static inline WindowClass GetWindowClassForVehicleType(VehicleType vt)
86 {
87 switch (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;
93 }
94 }
95
96 /* Unified window procedure */
97 void ShowVehicleViewWindow(const Vehicle *v);
98 bool VehicleClicked(const Vehicle *v);
99 void StartStopVehicle(const Vehicle *v, bool texteffect);
100
101 Vehicle *CheckClickOnVehicle(const struct ViewPort *vp, int x, int y);
102
103 void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip);
104 void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type);
105
106 #endif /* VEHICLE_GUI_H */
ShowVehicleViewWindow
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
Definition: vehicle_gui.cpp:2788
order_type.h
Types related to orders.
VIWD_CONSIST_CHANGED
Vehicle composition was changed.
Definition: vehicle_gui.h:36
window_type.h
Types related to windows.
VIWD_MODIFY_ORDERS
Other order modifications.
Definition: vehicle_gui.h:35
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:1043
engine_type.h
Types related to engines.
TDW_TAB_CAPACITY
Tab with cargo capacity of the vehicles.
Definition: vehicle_gui.h:28
VehicleCellSize::extend_right
uint extend_right
Extend of the cell to the right.
Definition: vehicle_gui.h:74
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:212
VehicleCellSize::height
uint height
Vehicle cell height.
Definition: vehicle_gui.h:72
WindowClass
WindowClass
Window classes.
Definition: window_type.h:39
GetCargoSubtypeText
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
Definition: vehicle_gui.cpp:1072
INVALID_VEHICLE
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition: vehicle_type.h:57
SetMouseCursorVehicle
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
Definition: vehicle_gui.cpp:2881
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition: vehicle_type.h:87
StartStopVehicle
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
Definition: vehicle_gui.cpp:2401
Window
Data structure for an opened window.
Definition: window_gui.h:271
VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
Definition: vehicle_gui.h:37
VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
station_type.h
Types related to stations.
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:1333
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
VehicleClicked
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
Definition: vehicle_gui.cpp:2798
VehicleID
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:18
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:2863
VIWD_REMOVE_ALL_ORDERS
Removed / replaced all orders (after deleting / sharing).
Definition: vehicle_gui.h:34
VehicleInvalidateWindowData
VehicleInvalidateWindowData
Special values for vehicle-related windows for the data parameter of InvalidateWindowData.
Definition: vehicle_gui.h:33
DrawVehiclePurchaseInfo
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
Draw the purchase info details of a vehicle at a given location.
Definition: build_vehicle_gui.cpp:812
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:82
WC_ROADVEH_LIST
Road vehicle list; Window numbers:
Definition: window_type.h:309
VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
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:131
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
TDW_TAB_CARGO
Tab with cargo carried by the vehicles.
Definition: vehicle_gui.h:26
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:34
VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
Train
&#39;Train&#39; is either a loco or a wagon.
Definition: train.h:88
TrainDetailsWindowTabs
TrainDetailsWindowTabs
The tabs in the train details window.
Definition: vehicle_gui.h:25
ViewPort
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:24
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:1035
EngineID
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:22
WC_SHIPS_LIST
Ships list; Window numbers:
Definition: window_type.h:315
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
TDW_TAB_TOTALS
Tab with sum of total cargo transported.
Definition: vehicle_gui.h:29
vehicle_type.h
Types related to vehicles.
WC_TRAINS_LIST
Trains list; Window numbers:
Definition: window_type.h:303
VehicleCellSize
Dimensions of a cell in the purchase/depot windows.
Definition: vehicle_gui.h:71
GetVehicleImageCellSize
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
Definition: depot_gui.cpp:159
CheckClickOnVehicle
Vehicle * CheckClickOnVehicle(const ViewPort *vp, int x, int y)
Find the vehicle close to the clicked coordinates.
Definition: vehicle.cpp:1161
GetVehicleHeight
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
Definition: vehicle_gui.h:62
WC_AIRCRAFT_LIST
Aircraft list; Window numbers:
Definition: window_type.h:321
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:94
GetWindowClassForVehicleType
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Definition: vehicle_gui.h:85
company_type.h
Types related to companies.
VehicleOrderID
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:17
VehicleCellSize::extend_left
uint extend_left
Extend of the cell to the left.
Definition: vehicle_gui.h:73
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
GetSingleVehicleWidth
int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (part) in pixels.
Definition: vehicle_gui.cpp:2839
VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
TDW_TAB_INFO
Tab with name and value of the vehicles.
Definition: vehicle_gui.h:27