OpenTTD
Data Structures | Enumerations | Functions
vehicle_gui.h File Reference

Functions related to the vehicle's GUIs. More...

#include "window_type.h"
#include "vehicle_type.h"
#include "order_type.h"
#include "station_type.h"
#include "engine_type.h"
#include "company_type.h"

Go to the source code of this file.

Data Structures

struct  VehicleCellSize
 Dimensions of a cell in the purchase/depot windows. More...
 

Enumerations

enum  TrainDetailsWindowTabs { TDW_TAB_CARGO = 0, TDW_TAB_INFO, TDW_TAB_CAPACITY, TDW_TAB_TOTALS }
 The tabs in the train details window. More...
 
enum  VehicleInvalidateWindowData { VIWD_REMOVE_ALL_ORDERS = -1, VIWD_MODIFY_ORDERS = -2, VIWD_CONSIST_CHANGED = -3, VIWD_AUTOREPLACE = -4 }
 Special values for vehicle-related windows for the data parameter of InvalidateWindowData. More...
 

Functions

void ShowVehicleRefitWindow (const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit=false)
 Show the refit window for a vehicle. More...
 
int DrawVehiclePurchaseInfo (int left, int right, int y, EngineID engine_number)
 Draw the purchase info details of a vehicle at a given location. More...
 
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. More...
 
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. More...
 
void DrawShipImage (const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
 Draws an image of a ship. More...
 
void DrawAircraftImage (const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
 Draws an image of an aircraft. More...
 
void ShowBuildVehicleWindow (TileIndex tile, VehicleType type)
 
uint ShowRefitOptionsList (int left, int right, int y, EngineID engine)
 Display list of cargo types of the engine, for the purchase information window.
 
StringID GetCargoSubtypeText (const Vehicle *v)
 Get the cargo subtype text from NewGRF for the vehicle details window. More...
 
void ShowVehicleListWindow (const Vehicle *v)
 
void ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type)
 
void ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, StationID station)
 
void ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, TileIndex depot_tile)
 
static uint GetVehicleHeight (VehicleType type)
 Get the height of a single vehicle in the GUIs. More...
 
int GetSingleVehicleWidth (const Vehicle *v, EngineImageType image_type)
 Get the width of a vehicle (part) in pixels. More...
 
int GetVehicleWidth (const Vehicle *v, EngineImageType image_type)
 Get the width of a vehicle (including all parts of the consist) in pixels. More...
 
VehicleCellSize GetVehicleImageCellSize (VehicleType type, EngineImageType image_type)
 Get the GUI cell size for a vehicle image. More...
 
static WindowClass GetWindowClassForVehicleType (VehicleType vt)
 Get WindowClass for vehicle list of given vehicle type. More...
 
void ShowVehicleViewWindow (const Vehicle *v)
 Shows the vehicle view window of the given vehicle. More...
 
bool VehicleClicked (const Vehicle *v)
 Dispatch a "vehicle selected" event if any window waits for it. More...
 
void StartStopVehicle (const Vehicle *v, bool texteffect)
 Executes CMD_START_STOP_VEHICLE for given vehicle. More...
 
VehicleCheckClickOnVehicle (const struct ViewPort *vp, int x, int y)
 
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. More...
 
void SetMouseCursorVehicle (const Vehicle *v, EngineImageType image_type)
 Set the mouse cursor to look like a vehicle. More...
 

Detailed Description

Functions related to the vehicle's GUIs.

Definition in file vehicle_gui.h.

Enumeration Type Documentation

◆ TrainDetailsWindowTabs

The tabs in the train details window.

Enumerator
TDW_TAB_CARGO 

Tab with cargo carried by the vehicles.

TDW_TAB_INFO 

Tab with name and value of the vehicles.

TDW_TAB_CAPACITY 

Tab with cargo capacity of the vehicles.

TDW_TAB_TOTALS 

Tab with sum of total cargo transported.

Definition at line 25 of file vehicle_gui.h.

◆ VehicleInvalidateWindowData

Special values for vehicle-related windows for the data parameter of InvalidateWindowData.

Enumerator
VIWD_REMOVE_ALL_ORDERS 

Removed / replaced all orders (after deleting / sharing).

VIWD_MODIFY_ORDERS 

Other order modifications.

VIWD_CONSIST_CHANGED 

Vehicle composition was changed.

VIWD_AUTOREPLACE 

Autoreplace replaced the vehicle.

Definition at line 33 of file vehicle_gui.h.

Function Documentation

◆ DrawAircraftImage()

void DrawAircraftImage ( const Vehicle v,
int  left,
int  right,
int  y,
VehicleID  selection,
EngineImageType  image_type 
)

Draws an image of an aircraft.

Parameters
vFront vehicle
leftThe minimum horizontal position
rightThe maximum horizontal position
yVertical position to draw at
selectionSelected vehicle to draw a frame around

Definition at line 82 of file aircraft_gui.cpp.

◆ DrawRoadVehImage()

void DrawRoadVehImage ( const Vehicle v,
int  left,
int  right,
int  y,
VehicleID  selection,
EngineImageType  image_type,
int  skip 
)

Draws an image of a road vehicle chain.

Parameters
vFront vehicle
leftThe minimum horizontal position
rightThe maximum horizontal position
yVertical position to draw at
selectionSelected vehicle to draw a frame around
skipNumber of pixels to skip at the front (for scrolling)

Definition at line 131 of file roadveh_gui.cpp.

◆ DrawShipImage()

void DrawShipImage ( const Vehicle v,
int  left,
int  right,
int  y,
VehicleID  selection,
EngineImageType  image_type 
)

Draws an image of a ship.

Parameters
vFront vehicle
leftThe minimum horizontal position
rightThe maximum horizontal position
yVertical position to draw at
selectionSelected vehicle to draw a frame around

Definition at line 34 of file ship_gui.cpp.

◆ DrawTrainImage()

void DrawTrainImage ( const Train v,
int  left,
int  right,
int  y,
VehicleID  selection,
EngineImageType  image_type,
int  skip,
VehicleID  drag_dest 
)

Draws an image of a whole train.

Parameters
vFront vehicle
leftThe minimum horizontal position
rightThe maximum horizontal position
yVertical position to draw at
selectionSelected vehicle to draw a frame around
skipNumber of pixels to skip at the front (for scrolling)
drag_destThe vehicle another one is dragged over, INVALID_VEHICLE if none.

Definition at line 94 of file train_gui.cpp.

◆ 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.

Parameters
vFront vehicle
leftThe minimum horizontal position
rightThe maximum horizontal position
yVertical position to draw at
selectionSelected vehicle to draw a frame around
skipNumber of pixels to skip at the front (for scrolling)

Definition at line 1333 of file vehicle_gui.cpp.

Referenced by RefitWindow::DrawWidget().

◆ DrawVehiclePurchaseInfo()

int DrawVehiclePurchaseInfo ( int  left,
int  right,
int  y,
EngineID  engine_number 
)

Draw the purchase info details of a vehicle at a given location.

Parameters
left,right,ylocation where to draw the info
engine_numberthe engine of which to draw the info of
Returns
y after drawing all the text

Definition at line 812 of file build_vehicle_gui.cpp.

Referenced by ReplaceVehicleWindow::OnPaint(), and BuildVehicleWindow::OnPaint().

◆ GetCargoSubtypeText()

StringID GetCargoSubtypeText ( const Vehicle v)

Get the cargo subtype text from NewGRF for the vehicle details window.

Definition at line 1072 of file vehicle_gui.cpp.

References HasBit().

Referenced by RefitWindow::BuildRefitList(), GetBestFittingSubType(), and GetCargoSummaryOfArticulatedVehicle().

◆ GetSingleVehicleWidth()

int GetSingleVehicleWidth ( const Vehicle v,
EngineImageType  image_type 
)

◆ GetVehicleHeight()

static uint GetVehicleHeight ( VehicleType  type)
inlinestatic

Get the height of a single vehicle in the GUIs.

Parameters
typethe vehicle type to look at
Returns
the height

Definition at line 62 of file vehicle_gui.h.

References GetSingleVehicleWidth(), GetVehicleWidth(), VEH_ROAD, and VEH_TRAIN.

Referenced by GetVehicleListHeight(), and RefitWindow::UpdateWidgetSize().

◆ GetVehicleImageCellSize()

VehicleCellSize GetVehicleImageCellSize ( VehicleType  type,
EngineImageType  image_type 
)

Get the GUI cell size for a vehicle image.

Parameters
typeVehicle type to get the size for.
image_typeImage type to get size for.
Precondition
image_type == EIT_IN_DEPOT || image_type == EIT_PURCHASE
Returns
Cell dimensions for the vehicle and image type.

Definition at line 159 of file depot_gui.cpp.

References EIT_IN_DEPOT, and EIT_PURCHASE.

Referenced by GetEngineListHeight(), and BuildVehicleWindow::UpdateWidgetSize().

◆ GetVehicleWidth()

int GetVehicleWidth ( const Vehicle v,
EngineImageType  image_type 
)

Get the width of a vehicle (including all parts of the consist) in pixels.

Parameters
vVehicle to get the width for.
Returns
Width of the vehicle.

Definition at line 2863 of file vehicle_gui.cpp.

References GetSingleVehicleWidth(), Vehicle::Next(), BaseVehicle::type, VEH_ROAD, and VEH_TRAIN.

Referenced by GetVehicleHeight(), and RefitWindow::OnResize().

◆ GetWindowClassForVehicleType()

static WindowClass GetWindowClassForVehicleType ( VehicleType  vt)
inlinestatic

Get WindowClass for vehicle list of given vehicle type.

Parameters
vtvehicle type to check
Returns
corresponding window class
Note
works only for company buildable vehicle types

Definition at line 85 of file vehicle_gui.h.

Referenced by CmdAddSharedVehicleGroup(), CmdRemoveAllVehiclesGroup(), CmdRenameDepot(), CmdRenameVehicle(), CmdSetGroupReplaceProtection(), CmdStartStopVehicle(), DecloneOrder(), FindVehicleGroupWindow(), and WaypointWindow::WaypointWindow().

◆ SetMouseCursorVehicle()

void SetMouseCursorVehicle ( const Vehicle v,
EngineImageType  image_type 
)

Set the mouse cursor to look like a vehicle.

Parameters
vVehicle
image_typeType of vehicle image to use.

Definition at line 2881 of file vehicle_gui.cpp.

References _current_text_dir, and TD_RTL.

◆ ShowVehicleRefitWindow()

void ShowVehicleRefitWindow ( const Vehicle v,
VehicleOrderID  order,
Window parent,
bool  auto_refit 
)

Show the refit window for a vehicle.

Parameters
*vThe vehicle to show the refit window for
orderof the vehicle to assign refit to, or INVALID_VEH_ORDER_ID to refit the vehicle now
parentthe parent window of the refit window
auto_refitChoose cargo for auto-refitting

Definition at line 1035 of file vehicle_gui.cpp.

References DeleteWindowById(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Window::parent, and WC_VEHICLE_REFIT.

Referenced by OrdersWindow::OrderClick_Refit().

◆ ShowVehicleViewWindow()

void ShowVehicleViewWindow ( const Vehicle v)

◆ StartStopVehicle()

void StartStopVehicle ( const Vehicle v,
bool  texteffect 
)

Executes CMD_START_STOP_VEHICLE for given vehicle.

Parameters
vVehicle to start/stop
texteffectShould a texteffect be shown?

Definition at line 2401 of file vehicle_gui.cpp.

Referenced by VehicleViewWindow::OnClick().

◆ VehicleClicked()

bool VehicleClicked ( const Vehicle v)

Dispatch a "vehicle selected" event if any window waits for it.

Parameters
vselected vehicle;
Returns
did any window accept vehicle selection?

Definition at line 2798 of file vehicle_gui.cpp.

Referenced by DepotWindow::DepotClick(), and VehicleListWindow::OnClick().