OpenTTD Source 20241224-master-gf74b0cf984
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 "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"
21
22void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit = false);
23
32
33
40
45 uint capacity;
46 uint16_t mail_capacity;
48
49 void FillDefaultCapacities(const Engine *e);
50};
51
52int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te);
53
54void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest = INVALID_VEHICLE);
55void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip = 0);
56void DrawShipImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type);
57void DrawAircraftImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type);
58
59void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
60
61uint ShowRefitOptionsList(int left, int right, int y, EngineID engine);
63
64void ShowVehicleListWindow(const Vehicle *v);
65void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
66void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
67void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
68
75{
76 return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
77}
78
79int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type);
80int GetVehicleWidth(const Vehicle *v, EngineImageType image_type);
81
88
90
98{
99 switch (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;
105 }
106}
107
108/* Unified window procedure */
109void ShowVehicleViewWindow(const Vehicle *v);
110bool VehicleClicked(const Vehicle *v);
111bool VehicleClicked(VehicleList::const_iterator begin, VehicleList::const_iterator end);
112bool VehicleClicked(const GUIVehicleGroup &vehgroup);
113void StartStopVehicle(const Vehicle *v, bool texteffect);
114
115Vehicle *CheckClickOnVehicle(const struct Viewport *vp, int x, int y);
116void StopGlobalFollowVehicle(const Vehicle *v);
117
118void DrawVehicleImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip);
119void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type);
120
121#endif /* VEHICLE_GUI_H */
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
Types related to companies.
Owner
Enum for all companies/owners.
Types related to engines.
uint16_t EngineID
Unique identification number of an engine.
Definition engine_type.h:21
#define DECLARE_ENUM_AS_ADDABLE(EnumType)
Operator that allows this enumeration to be added to any other enumeration.
Definition enum_type.hpp:45
Types related to orders.
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition order_type.h:15
Types related to stations.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Class for storing amounts of cargo.
Definition cargo_type.h:114
Specification of a rectangle with absolute coordinates of all edges.
Extra information about refitted cargo and capacity.
Definition vehicle_gui.h:42
CargoID cargo
Cargo type.
Definition vehicle_gui.h:44
Money cost
Refit cost.
Definition vehicle_gui.h:43
CargoArray all_capacities
Capacities for all cargoes.
Definition vehicle_gui.h:47
uint16_t mail_capacity
Mail capacity if available.
Definition vehicle_gui.h:46
uint capacity
Cargo capacity.
Definition vehicle_gui.h:45
'Train' is either a loco or a wagon.
Definition train.h:89
Dimensions of a cell in the purchase/depot windows.
Definition vehicle_gui.h:83
uint extend_left
Extend of the cell to the left.
Definition vehicle_gui.h:85
uint height
Vehicle cell height.
Definition vehicle_gui.h:84
uint extend_right
Extend of the cell to the right.
Definition vehicle_gui.h:86
Vehicle data structure.
Data structure for viewport, display of a part of the world.
Data structure for an opened window.
Definition window_gui.h:273
Vehicle * CheckClickOnVehicle(const Viewport *vp, int x, int y)
Find the vehicle close to the clicked coordinates.
Definition vehicle.cpp:1248
int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (part) in pixels.
int GetVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (including all parts of the consist) in pixels.
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest=INVALID_VEHICLE)
Draws an image of a whole train.
Definition train_gui.cpp:93
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip=0)
Draws an image of a road vehicle chain.
uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
Definition vehicle_gui.h:74
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
Display list of cargo types of the engine, for the purchase information window.
TrainDetailsWindowTabs
The tabs in the train details window.
Definition vehicle_gui.h:25
@ TDW_TAB_CAPACITY
Tab with cargo capacity of the vehicles.
Definition vehicle_gui.h:28
@ TDW_TAB_TOTALS
Tab with sum of total cargo transported.
Definition vehicle_gui.h:29
@ TDW_TAB_INFO
Tab with name and value of the vehicles.
Definition vehicle_gui.h:27
@ TDW_TAB_CARGO
Tab with cargo carried by the vehicles.
Definition vehicle_gui.h:26
void DrawVehicleImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a vehicle chain.
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.
VehicleInvalidateWindowData
Special values for vehicle-related windows for the data parameter of InvalidateWindowData.
Definition vehicle_gui.h:34
@ VIWD_CONSIST_CHANGED
Vehicle composition was changed.
Definition vehicle_gui.h:37
@ VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
Definition vehicle_gui.h:38
@ VIWD_MODIFY_ORDERS
Other order modifications.
Definition vehicle_gui.h:36
@ VIWD_REMOVE_ALL_ORDERS
Removed / replaced all orders (after deleting / sharing).
Definition vehicle_gui.h:35
void DrawShipImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
Definition ship_gui.cpp:30
void DrawAircraftImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Definition vehicle_gui.h:97
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit=false)
Show the refit window for a vehicle.
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
Functions/classes shared between the different vehicle list GUIs.
Types related to vehicles.
EngineImageType
Visualisation contexts of vehicles and engines.
VehicleType
Available vehicle types.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
uint32_t VehicleID
The type all our vehicle IDs have.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Functions and type for generating vehicle lists.
Types related to windows.
WindowClass
Window classes.
Definition window_type.h:44
@ WC_ROADVEH_LIST
Road vehicle list; Window numbers:
@ WC_SHIPS_LIST
Ships list; Window numbers:
@ WC_TRAINS_LIST
Trains list; Window numbers:
@ WC_AIRCRAFT_LIST
Aircraft list; Window numbers: