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

## Enumerations
enum | VehicleViewWindowWidgets { VVW_WIDGET_CAPTION, VVW_WIDGET_VIEWPORT, VVW_WIDGET_START_STOP_VEH, VVW_WIDGET_CENTER_MAIN_VIEH, VVW_WIDGET_GOTO_DEPOT, VVW_WIDGET_REFIT_VEH, VVW_WIDGET_SHOW_ORDERS, VVW_WIDGET_SHOW_DETAILS, VVW_WIDGET_CLONE_VEH, VVW_WIDGET_SELECT_DEPOT_CLONE, VVW_WIDGET_SELECT_REFIT_TURN, VVW_WIDGET_TURN_AROUND, VVW_WIDGET_FORCE_PROCEED }
| Constants of vehicle view widget indices. More...
enum | TrainDetailsWindowTabs { TDW_TAB_CARGO = 0, TDW_TAB_INFO, TDW_TAB_CAPACITY, TDW_TAB_TOTALS }
| The tabs in the train details window. More...
enum | { VLW_STANDARD = 0 << 8, VLW_SHARED_ORDERS = 1 << 8, VLW_STATION_LIST = 2 << 8, VLW_DEPOT_LIST = 3 << 8, VLW_GROUP_LIST = 4 << 8, VLW_WAYPOINT_LIST = 5 << 8, VLW_MASK = 0x700 }
| Vehicle List Window type flags.
## Functions
void | ShowVehicleRefitWindow (const Vehicle *v, VehicleOrderID order, Window *parent)
| Show the refit window for a vehicle.
static bool | ValidVLWFlags (uint16 flags)
int | DrawVehiclePurchaseInfo (int left, int right, int y, EngineID engine_number)
| Draw the purchase info details of a vehicle at a given location.
void | DrawTrainImage (const Train *v, int left, int right, int y, VehicleID selection, int skip)
| Draws an image of a whole train.
void | DrawRoadVehImage (const Vehicle *v, int left, int right, int y, VehicleID selection)
| Draws an image of a road vehicle chain.
void | DrawShipImage (const Vehicle *v, int left, int right, int y, VehicleID selection)
| Draws an image of a ship.
void | DrawAircraftImage (const Vehicle *v, int left, int right, int y, VehicleID selection)
| Draws an image of an aircraft.
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.
void | ShowVehicleListWindow (const Vehicle *v)
void | ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, const Waypoint *wp)
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.
static WindowClass | GetWindowClassForVehicleType (VehicleType vt)
| Get WindowClass for vehicle list of given vehicle type.
void | ShowVehicleViewWindow (const Vehicle *v)
| Shows the vehicle view window of the given vehicle.
Vehicle * | CheckClickOnVehicle (const struct ViewPort *vp, int x, int y)

## Detailed Description

Functions related to the vehicle's GUIs.

Definition in file vehicle_gui.h.

## Enumeration Type Documentation

enum 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 42 of file vehicle_gui.h.

enum VehicleViewWindowWidgets

Constants of vehicle view widget indices.

Enumerator:

  VVW_WIDGET_VIEWPORT | Viewport widget.
  VVW_WIDGET_SELECT_DEPOT_CLONE | Selection widget between 'goto depot', and 'clone vehicle' buttons.
  VVW_WIDGET_SELECT_REFIT_TURN | Selection widget between 'refit' and 'turn around' buttons.

Definition at line 25 of file vehicle_gui.h.

## Function Documentation

void DrawAircraftImage | ( | const Vehicle * | v,
|  | int | left,
|  | int | right,
|  | int | y,
|  | VehicleID | selection |
| ) |  |  |

Draws an image of an aircraft.

Parameters:

  | v | Front vehicle
  | left | The minimum horizontal position
  | right | The maximum horizontal position
  | y | Vertical position to draw at
  | selection | Selected vehicle to draw a frame around

Definition at line 80 of file aircraft_gui.cpp.

References _dynlang, AIR_HELICOPTER, DIR_E, DIR_W, DrawFrameRect(), DrawSprite(), FR_BORDERONLY, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), Vehicle::GetImage(), GetVehiclePalette(), Sprite::height, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, ST_NORMAL, Vehicle::subtype, TD_RTL, DynamicLanguages::text_dir, Vehicle::vehstatus, Sprite::width, Sprite::x_offs, and Sprite::y_offs.

Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().

void DrawRoadVehImage | ( | const Vehicle * | v,
|  | int | left,
|  | int | right,
|  | int | y,
|  | VehicleID | selection |
| ) |  |  |

Draws an image of a road vehicle chain.

Parameters:

  | v | Front vehicle
  | left | The minimum horizontal position
  | right | The maximum horizontal position
  | y | Vertical position to draw at
  | selection | Selected vehicle to draw a frame around

Definition at line 132 of file roadveh_gui.cpp.

References _dynlang, DIR_E, DIR_W, DrawFrameRect(), DrawSprite(), FR_BORDERONLY, SpecializedVehicle< RoadVehicle, VEH_ROAD >::From(), RoadVehicle::GetDisplayImageWidth(), RoadVehicle::GetImage(), GetVehiclePalette(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, SpecializedVehicle< T, Type >::Next(), TD_RTL, DynamicLanguages::text_dir, and Vehicle::vehstatus.

Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().

void DrawShipImage | ( | const Vehicle * | v,
|  | int | left,
|  | int | right,
|  | int | y,
|  | VehicleID | selection |
| ) |  |  |

Draws an image of a ship.

Parameters:

  | v | Front vehicle
  | left | The minimum horizontal position
  | right | The maximum horizontal position
  | y | Vertical position to draw at
  | selection | Selected vehicle to draw a frame around

Definition at line 31 of file ship_gui.cpp.

References _dynlang, DIR_E, DIR_W, DrawFrameRect(), DrawSprite(), FR_BORDERONLY, Vehicle::GetImage(), GetVehiclePalette(), Sprite::height, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, ST_NORMAL, TD_RTL, DynamicLanguages::text_dir, Sprite::width, Sprite::x_offs, and Sprite::y_offs.

Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().

void DrawTrainImage | ( | const Train * | v,
|  | int | left,
|  | int | right,
|  | int | y,
|  | VehicleID | selection,
|  | int | skip |
| ) |  |  |

Draws an image of a whole train.

Parameters:

  | v | Front vehicle
  | left | The minimum horizontal position
  | right | The maximum horizontal position
  | y | Vertical position to draw at
  | selection | Selected vehicle to draw a frame around
  | skip | Number of pixels to skip at the front (for scrolling)

Definition at line 60 of file train_gui.cpp.

References _dynlang, DIR_E, DIR_W, DrawFrameRect(), DrawSprite(), FillDrawPixelInfo(), FR_BORDERONLY, SpecializedVehicle< Train, VEH_TRAIN >::From(), Train::GetDisplayImageWidth(), GetVehiclePalette(), SpecializedVehicle< T, Type >::Next(), TD_RTL, DynamicLanguages::text_dir, and CursorVars::vehchain.

Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().

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,y | location where to draw the info
  | engine_number | the engine of which to draw the info of

Returns:
  y after drawing all the text

Definition at line 617 of file build_vehicle_gui.cpp.

References ConvertDateToYMD(), CT_INVALID, DAYS_IN_LEAP_YEAR, DrawString(), FONT_HEIGHT_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetLifeLengthInDays(), IsArticulatedVehicleRefittable(), RAILVEH_WAGON, SetDParam(), ShowAdditionalText(), ShowRefitOptionsList(), ToPercent16(), Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, and YearMonthDay::year.

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

StringID GetCargoSubtypeText | ( | const Vehicle * | v | ) |

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

Definition at line 564 of file vehicle_gui.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_CARGO_SUFFIX, CBM_VEHICLE_CARGO_SUFFIX, GetEngineGRFID(), GetGRFStringID(), GetVehicleCallback(), and HasBit().

Referenced by DrawAircraftDetails(), DrawRoadVehDetails(), DrawShipDetails(), GetBestFittingSubType(), and GetCargoSummaryOfArticulatedVehicle().

static uint GetVehicleHeight | ( | VehicleType | type | ) | `[inline, static]`

Get the height of a single vehicle in the GUIs.

Parameters:

  | type | the vehicle type to look at

Returns:
  the height

Definition at line 88 of file vehicle_gui.h.

References VEH_ROAD, and VEH_TRAIN.

Referenced by DepotWindow::DrawVehicleInDepot(), GetEngineListHeight(), GetVehicleListHeight(), and InitDepotWindowBlockSizes().

static WindowClass GetWindowClassForVehicleType | ( | VehicleType | vt | ) | `[inline, static]`

Get WindowClass for vehicle list of given vehicle type.

Parameters:

  | vt | vehicle type to check

Returns:
  corresponding window class

Note:
  works only for company buildable vehicle types

Definition at line 98 of file vehicle_gui.h.

References VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by CmdAddSharedVehicleGroup(), CmdAddVehicleGroup(), CmdCloneOrder(), CmdCreateGroup(), CmdDeleteGroup(), CmdDeleteOrder(), CmdInsertOrder(), CmdMoveOrder(), CmdRemoveAllVehiclesGroup(), CmdRenameGroup(), CmdSetGroupReplaceProtection(), CmdStartStopVehicle(), Vehicle::Crash(), DecloneOrder(), FindVehicleGroupWindow(), LoadUnloadVehicle(), Vehicle::PreDestructor(), ProcessOrders(), and Vehicle::RemoveFromShared().

void ShowVehicleRefitWindow | ( | const Vehicle * | v,
|  | VehicleOrderID | order,
|  | Window * | parent |
| ) |  |  |

Show the refit window for a vehicle.

Parameters:

  | *v | The vehicle to show the refit window for
  | order | of the vehicle ( ? )
  | parent | the parent window of the refit window

Definition at line 505 of file vehicle_gui.cpp.

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

Referenced by VehicleViewWindow::OnClick(), and OrdersWindow::OrderClick_Refit().

void ShowVehicleViewWindow | ( | const Vehicle * | v | ) |

Shows the vehicle view window of the given vehicle.

Definition at line 2183 of file vehicle_gui.cpp.

References _train_view_desc, _vehicle_view_desc, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, BaseVehicle::type, and VEH_TRAIN.

Referenced by CcBuildPrimaryVehicle(), CcCloneVehicle(), CmdSellRailWagon(), DepotWindow::DepotClick(), VehicleListWindow::OnClick(), VehicleGroupWindow::OnDragDrop(), and DepotWindow::OnDragDrop().