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.

## Enumerations
enum | TrainDetailsWindowTabs { TDW_TAB_CARGO = 0, TDW_TAB_INFO, TDW_TAB_CAPACITY, TDW_TAB_TOTALS }
| The tabs in the train details window. More...
## Functions
void | ShowVehicleRefitWindow (const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit=false)
| Show the refit window for a vehicle.
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, EngineImageType image_type, int skip, VehicleID drag_dest=INVALID_VEHICLE)
| Draws an image of a whole train.
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.
void | DrawShipImage (const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
| Draws an image of a ship.
void | DrawAircraftImage (const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
| 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)
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.
int | GetVehicleWidth (Vehicle *v, EngineImageType image_type)
| Get the width of a vehicle (including all parts of the consist) in pixels.
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.
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.
Vehicle * | CheckClickOnVehicle (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.

## 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 25 of file vehicle_gui.h.

## Function Documentation

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

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 _current_text_dir, 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, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, PALETTE_CRASH, ST_NORMAL, Vehicle::subtype, UnScaleByZoom(), Vehicle::vehstatus, Sprite::width, Sprite::x_offs, Sprite::y_offs, and ZOOM_LVL_GUI.

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

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:

  | 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 128 of file roadveh_gui.cpp.

References _current_text_dir, DIR_E, DrawFrameRect(), DrawSprite(), FillDrawPixelInfo(), FR_BORDERONLY, SpecializedVehicle< RoadVehicle, Type >::From(), GetVehiclePalette(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SpecializedVehicle< T, Type >::Next(), and PALETTE_CRASH.

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

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

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 32 of file ship_gui.cpp.

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

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

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:

  | 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)
  | drag_dest | The vehicle another one is dragged over, `INVALID_VEHICLE` if none.

Definition at line 89 of file train_gui.cpp.

References _current_text_dir, DIR_E, DrawFrameRect(), DrawSprite(), FillDrawPixelInfo(), FR_BORDERONLY, SpecializedVehicle< Train, Type >::From(), Train::GetDisplayImageWidth(), GetVehiclePalette(), HighlightDragPosition(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, SpecializedVehicle< T, Type >::Next(), PALETTE_CRASH, and CursorVars::vehchain.

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

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:

  | 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 1214 of file vehicle_gui.cpp.

References DrawAircraftImage(), DrawRoadVehImage(), DrawShipImage(), DrawTrainImage(), SpecializedVehicle< Train, Type >::From(), BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by BaseVehicleListWindow::DrawVehicleListItems(), VehicleDetailsWindow::DrawWidget(), and RefitWindow::DrawWidget().

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 789 of file build_vehicle_gui.cpp.

References ConvertDateToYMD(), CT_INVALID, DAYS_IN_LEAP_YEAR, DrawString(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::GetLifeLengthInDays(), Engine::intro_date, IsArticulatedVehicleRefittable(), RAILVEH_WAGON, Engine::reliability, 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 957 of file vehicle_gui.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_CARGO_SUFFIX, CBM_VEHICLE_CARGO_SUFFIX, Vehicle::engine_type, ErrorUnknownCallbackResult(), Vehicle::GetGRF(), Vehicle::GetGRFID(), 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 54 of file vehicle_gui.h.

References VEH_ROAD, and VEH_TRAIN.

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

int GetVehicleWidth | ( | Vehicle * | v,
|  | EngineImageType | image_type |
| ) |  |  |

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

Parameters:

  | v | Vehicle to get the width for.

Returns:
  Width of the vehicle.

Definition at line 2652 of file vehicle_gui.cpp.

References _current_text_dir, DIR_E, DIR_W, SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< Train, Type >::From(), Train::GetDisplayImageWidth(), Vehicle::GetImage(), SpecializedVehicle< T, Type >::Next(), ST_NORMAL, BaseVehicle::type, UnScaleByZoom(), VEH_ROAD, VEH_TRAIN, Sprite::width, and ZOOM_LVL_GUI.

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

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

References VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by Vehicle::BeginLoading(), CmdAddSharedVehicleGroup(), CmdAddVehicleGroup(), CmdBuildVehicle(), CmdCloneOrder(), CmdCreateGroup(), CmdDeleteGroup(), CmdMoveOrder(), CmdRefitVehicle(), CmdRemoveAllVehiclesGroup(), CmdRenameDepot(), CmdRenameGroup(), CmdSetGroupReplaceProtection(), CmdStartStopVehicle(), Vehicle::Crash(), DecloneOrder(), DeleteOrder(), FindVehicleGroupWindow(), InsertOrder(), LoadUnloadVehicle(), Vehicle::PreDestructor(), ProcessOrders(), Vehicle::RemoveFromShared(), ShowCompanyGroup(), and Depot::~Depot().

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

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
  | auto_refit | Choose cargo for auto-refitting

Definition at line 920 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 VehicleViewWindow::OnClick(), and OrdersWindow::OrderClick_Refit().

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

Shows the vehicle view window of the given vehicle.

Definition at line 2601 of file vehicle_gui.cpp.

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

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

void StartStopVehicle | ( | const Vehicle * | v,
|  | bool | texteffect |
| ) |  |  |

Executes CMD_START_STOP_VEHICLE for given vehicle.

Parameters:

  | v | Vehicle to start/stop
  | texteffect | Should a texteffect be shown?

Definition at line 2229 of file vehicle_gui.cpp.

References CcStartStopVehicle(), DoCommandP(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::IsPrimaryVehicle(), Vehicle::tile, and BaseVehicle::type.

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

bool VehicleClicked | ( | const Vehicle * | v | ) |

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

Parameters:

  | v | selected vehicle;

Returns:
  did any window accept vehicle selection?

Definition at line 2611 of file vehicle_gui.cpp.

References Vehicle::First(), TileHighlightData::GetCallbackWnd(), HT_VEHICLE, Vehicle::IsPrimaryVehicle(), Window::OnVehicleSelect(), and TileHighlightData::place_mode.

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