# vehicle_gui.cpp File Reference

The base GUI for all vehicles. More...

`#include "stdafx.h"`
`#include "debug.h"`
`#include "company_func.h"`
`#include "gui.h"`
`#include "textbuf_gui.h"`
`#include "command_func.h"`
`#include "vehicle_gui.h"`
`#include "vehicle_gui_base.h"`
`#include "viewport_func.h"`
`#include "newgrf_engine.h"`
`#include "newgrf_text.h"`
`#include "waypoint_base.h"`
`#include "roadveh.h"`
`#include "train.h"`
`#include "aircraft.h"`
`#include "depot_base.h"`
`#include "group_gui.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "vehicle_func.h"`
`#include "autoreplace_gui.h"`
`#include "string_func.h"`
`#include "widgets/dropdown_func.h"`
`#include "timetable.h"`
`#include "vehiclelist.h"`
`#include "articulated_vehicles.h"`
`#include "cargotype.h"`
`#include "spritecache.h"`
`#include "core/geometry_func.hpp"`
`#include "company_base.h"`
`#include "engine_base.h"`
`#include "engine_func.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Data Structures

struct | RefitOption
| Option to refit a vehicle chain. More...
struct | RefitWindow
| Refit cargo window. More...
struct | VehicleListWindow
| Window for the (old) vehicle listing. More...
struct | VehicleDetailsWindow
| Class for managing the vehicle details window. More...
struct | VehicleViewWindow
| Window manager class for viewing a vehicle. More...

## Typedefs

typedef SmallVector < RefitOption, 32 > | RefitList

## Enumerations

enum | VehicleRefitWidgets { VRW_CAPTION, VRW_SELECTHEADER, VRW_MATRIX, VRW_SCROLLBAR, VRW_INFOPANEL, VRW_REFITBUTTON }
| Widget numbers of the vehicle refit window. More...
enum | VehicleListWindowWidgets { VLW_WIDGET_CAPTION, VLW_WIDGET_SORT_ORDER, VLW_WIDGET_SORT_BY_PULLDOWN, VLW_WIDGET_LIST, VLW_WIDGET_SCROLLBAR, VLW_WIDGET_HIDE_BUTTONS, VLW_WIDGET_AVAILABLE_VEHICLES, VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN, VLW_WIDGET_STOP_ALL, VLW_WIDGET_START_ALL }

enum

VehicleDetailsWindowWidgets {
VLD_WIDGET_CAPTION, VLD_WIDGET_RENAME_VEHICLE, VLD_WIDGET_TOP_DETAILS, VLD_WIDGET_INCREASE_SERVICING_INTERVAL,
VLD_WIDGET_DECREASE_SERVICING_INTERVAL, VLD_WIDGET_SERVICING_INTERVAL, VLD_WIDGET_MIDDLE_DETAILS, VLD_WIDGET_MATRIX,
VLD_WIDGET_SCROLLBAR, VLD_WIDGET_DETAILS_CARGO_CARRIED, VLD_WIDGET_DETAILS_TRAIN_VEHICLES, VLD_WIDGET_DETAILS_CAPACITY_OF_EACH,
VLD_WIDGET_DETAILS_TOTAL_CARGO
}

| Constants of vehicle details widget indices.
enum | VehicleCommandTranslation { VCT_CMD_START_STOP = 0, VCT_CMD_CLONE_VEH, VCT_CMD_TURN_AROUND }
| Command indices for the _vehicle_command_translation_table. More...

## Functions

void | DepotSortList (VehicleList *list)
static void | DrawVehicleProfitButton (const Vehicle *v, int x, int y)
| draw the vehicle profit button in the vehicle list window.
byte | GetBestFittingSubType (Vehicle *v_from, Vehicle *v_for)
| Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.
static void | BuildRefitList (const Vehicle *v, RefitList *refit_list)
| Collects all (cargo, subcargo) refit-options of a vehicle chain.
static void | DrawVehicleRefitWindow (const RefitList &list, int sel, uint pos, uint rows, uint delta, const Rect &r)
| Draw the list of available refit options for a consist and highlight the selected refit option (if any).
void | ShowVehicleRefitWindow (const Vehicle *v, VehicleOrderID order, Window *parent)
| Show the refit window for a vehicle.
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.
static int CDECL | VehicleNumberSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by their number.
static int CDECL | VehicleNameSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by their name.
static int CDECL | VehicleAgeSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by their age.
static int CDECL | VehicleProfitThisYearSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by this year profit.
static int CDECL | VehicleProfitLastYearSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by last year profit.
static int CDECL | VehicleCargoSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by their cargo.
static int CDECL | VehicleReliabilitySorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by their reliability.
static int CDECL | VehicleMaxSpeedSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by their max speed.
static int CDECL | VehicleModelSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by model.
static int CDECL | VehicleValueSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehciles by their value.
static int CDECL | VehicleLengthSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by their length.
static int CDECL | VehicleTimeToLiveSorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by the time they can still live.
static int CDECL | VehicleTimetableDelaySorter (const Vehicle *const *a, const Vehicle *const *b)
| Sort vehicles by the timetable delay.
void | InitializeGUI ()
static void | ChangeVehicleWindow (WindowClass window_class, VehicleID from_index, VehicleID to_index)
| Assign a vehicle window a new vehicle.
void | ChangeVehicleViewWindow (VehicleID from_index, VehicleID to_index)
| Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.
static void | DrawSmallOrderList (const Vehicle *v, int left, int right, int y, VehicleOrderID start=0)
static void | DrawVehicleImage (const Vehicle *v, int left, int right, int y, VehicleID selection, int skip)
| Draws an image of a vehicle chain.
uint | GetVehicleListHeight (VehicleType type, uint divisor)
| Get the height of a vehicle in the vehicle list GUIs.
static void | ShowVehicleListWindowLocal (CompanyID company, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number)
void | ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type)
void | ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, const Waypoint *wp)
void | ShowVehicleListWindow (const Vehicle *v)
void | ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, StationID station)
void | ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, TileIndex depot_tile)
| assert_compile (VLD_WIDGET_DETAILS_CARGO_CARRIED==VLD_WIDGET_DETAILS_CARGO_CARRIED+TDW_TAB_CARGO)
| assert_compile (VLD_WIDGET_DETAILS_TRAIN_VEHICLES==VLD_WIDGET_DETAILS_CARGO_CARRIED+TDW_TAB_INFO)
| assert_compile (VLD_WIDGET_DETAILS_CAPACITY_OF_EACH==VLD_WIDGET_DETAILS_CARGO_CARRIED+TDW_TAB_CAPACITY)
| assert_compile (VLD_WIDGET_DETAILS_TOTAL_CARGO==VLD_WIDGET_DETAILS_CARGO_CARRIED+TDW_TAB_TOTALS)
int | GetTrainDetailsWndVScroll (VehicleID veh_id, TrainDetailsWindowTabs det_tab)
| Determines the number of lines in the train details window.
void | DrawTrainDetails (const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
| Draw the details for the given vehicle at the given position.
void | DrawRoadVehDetails (const Vehicle *v, int left, int right, int y)
| Draw the details for the given vehicle at the given position.
void | DrawShipDetails (const Vehicle *v, int left, int right, int y)
| Draw the details for the given vehicle at the given position.
void | DrawAircraftDetails (const Aircraft *v, int left, int right, int y)
| Draw the details for the given vehicle at the given position.
static void | ShowVehicleDetailsWindow (const Vehicle *v)
| Shows the vehicle details window of the given vehicle.
| assert_compile (VEH_TRAIN==0)
| assert_compile (VEH_ROAD==1)
| assert_compile (VEH_SHIP==2)
| assert_compile (VEH_AIRCRAFT==3)
static bool | IsVehicleRefitable (const Vehicle *v)
| Checks whether the vehicle may be refitted at the moment.
void | ShowVehicleViewWindow (const Vehicle *v)
| Shows the vehicle view window of the given vehicle.
void | StopGlobalFollowVehicle (const Vehicle *v)
void | CcBuildPrimaryVehicle (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
| This is the Callback method after the construction attempt of a primary vehicle.

## Variables

Sorting | _sorting
static GUIVehicleList::SortFunction | VehicleNumberSorter
static GUIVehicleList::SortFunction | VehicleNameSorter
static GUIVehicleList::SortFunction | VehicleAgeSorter
static GUIVehicleList::SortFunction | VehicleProfitThisYearSorter
static GUIVehicleList::SortFunction | VehicleProfitLastYearSorter
static GUIVehicleList::SortFunction | VehicleCargoSorter
static GUIVehicleList::SortFunction | VehicleReliabilitySorter
static GUIVehicleList::SortFunction | VehicleMaxSpeedSorter
static GUIVehicleList::SortFunction | VehicleModelSorter
static GUIVehicleList::SortFunction | VehicleValueSorter
static GUIVehicleList::SortFunction | VehicleLengthSorter
static GUIVehicleList::SortFunction | VehicleTimeToLiveSorter
static GUIVehicleList::SortFunction | VehicleTimetableDelaySorter
static const Vehicle * | _last_vehicle [2] = { NULL, NULL }
static const uint | MAX_REFIT_CYCLE = 256
| Maximum number of refit cycles we try, to prevent infinite loops.
static const NWidgetPart | _nested_vehicle_refit_widgets []
static const WindowDesc | _vehicle_refit_desc (WDP_AUTO, 240, 174, WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS|WDF_CONSTRUCTION, _nested_vehicle_refit_widgets, lengthof(_nested_vehicle_refit_widgets))
static const NWidgetPart | _nested_vehicle_list []
static WindowDesc | _vehicle_list_desc (WDP_AUTO, 260, 246, WC_INVALID, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_list, lengthof(_nested_vehicle_list))
static const NWidgetPart | _nested_nontrain_vehicle_details_widgets []
| Vehicle details widgets (other than train).
static const NWidgetPart | _nested_train_vehicle_details_widgets []
| Train details widgets.
static const WindowDesc | _train_vehicle_details_desc (WDP_AUTO, 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS, _nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets))
| Vehicle details window descriptor.
static const WindowDesc | _nontrain_vehicle_details_desc (WDP_AUTO, 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS, _nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets))
| Vehicle details window descriptor for other vehicles than a train.
static const NWidgetPart | _nested_vehicle_view_widgets []
| Vehicle view widgets.
static const WindowDesc | _vehicle_view_desc (WDP_AUTO, 250, 116, WC_VEHICLE_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
| Vehicle view window descriptor for all vehicles but trains.
static const WindowDesc | _train_view_desc (WDP_AUTO, 250, 134, WC_VEHICLE_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
| Vehicle view window descriptor for trains.
static const ZoomLevel | _vehicle_view_zoom_levels []
| Zoom levels for vehicle views indexed by vehicle type.
static const int | VV_INITIAL_VIEWPORT_WIDTH = 226
static const int | VV_INITIAL_VIEWPORT_HEIGHT = 84
static const int | VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102
static const uint32 | _vehicle_command_translation_table [][4]
| Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type.

## Detailed Description

The base GUI for all vehicles.

Definition in file vehicle_gui.cpp.

## Enumeration Type Documentation

enum VehicleCommandTranslation

Command indices for the _vehicle_command_translation_table.

Definition at line 1773 of file vehicle_gui.cpp.

enum VehicleRefitWidgets

Widget numbers of the vehicle refit window.

Definition at line 346 of file vehicle_gui.cpp.

## Function Documentation

static void BuildRefitList | ( | const Vehicle * | v,
|  | RefitList * | refit_list |
| ) |  |  | `[static]`

Collects all (cargo, subcargo) refit-options of a vehicle chain.

Parameters:

  | v | front vehicle
  | refit_list | container to store result

Definition at line 246 of file vehicle_gui.cpp.

References CALLBACK_FAILED, EngineInfo::callback_mask, Engine::CanCarryCargo(), RefitOption::cargo, Vehicle::cargo_subtype, Vehicle::cargo_type, CBID_VEHICLE_CARGO_SUFFIX, CBM_VEHICLE_CARGO_SUFFIX, SmallVector< T, S >::Clear(), RefitOption::engine, Vehicle::First(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetVehicleCallback(), HasBit(), SmallVector< T, S >::Include(), CargoSpec::Index(), Vehicle::InvalidateNewGRFCache(), Vehicle::Next(), RefitOption::subtype, BaseVehicle::type, RefitOption::value, VEH_ROAD, and VEH_TRAIN.

Referenced by RefitWindow::OnPaint().

void CcBuildPrimaryVehicle | ( | const CommandCost & | result,
|  | TileIndex | tile,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

This is the Callback method after the construction attempt of a primary vehicle.

Parameters:

  | result | indicates completion (or not) of the operation
  | tile | unused
  | p1 | unused
  | p2 | unused

Definition at line 2150 of file vehicle_gui.cpp.

References CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), RestoreVehicleOrders(), ShowVehicleViewWindow(), and Vehicle::tile.

Referenced by BuildVehicleWindow::OnClick().

void ChangeVehicleViewWindow | ( | VehicleID | from_index,
|  | VehicleID | to_index |
| ) |  |  |

Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.

Parameters:

  | from_index | the old vehicle ID
  | to_index | the new vehicle ID

Definition at line 741 of file vehicle_gui.cpp.

References ChangeVehicleWindow().

Referenced by CopyHeadSpecificThings().

static void ChangeVehicleWindow | ( | WindowClass | window_class,
|  | VehicleID | from_index,
|  | VehicleID | to_index |
| ) |  |  | `[inline, static]`

Assign a vehicle window a new vehicle.

Parameters:

  | window_class | WindowClass to search for
  | from_index | the old vehicle ID
  | to_index | the new vehicle ID

Definition at line 726 of file vehicle_gui.cpp.

References FindWindowById(), ViewportData::follow_vehicle, INVALID_VEHICLE, Window::InvalidateData(), Window::viewport, and Window::window_number.

Referenced by ChangeVehicleViewWindow().

void DrawAircraftDetails | ( | const Aircraft * | v,
|  | int | left,
|  | int | right,
|  | int | y |
| ) |  |  |

Draw the details for the given vehicle at the given position.

Parameters:

  | v | current vehicle
  | left | The left most coordinate to draw
  | right | The right most coordinate to draw
  | y | The y coordinate

Definition at line 32 of file aircraft_gui.cpp.

References Vehicle::cargo_cap, DrawString(), FONT_HEIGHT_NORMAL, GetCargoSubtypeText(), SpecializedVehicle< T, Type >::Next(), SA_LEFT, SA_STRIP, and SetDParam().

Referenced by VehicleDetailsWindow::DrawVehicleDetails().

void DrawRoadVehDetails | ( | const Vehicle * | v,
|  | int | left,
|  | int | right,
|  | int | y |
| ) |  |  |

Draw the details for the given vehicle at the given position.

Parameters:

  | v | current vehicle
  | left | The left most coordinate to draw
  | right | The right most coordinate to draw
  | y | The y coordinate

Definition at line 32 of file roadveh_gui.cpp.

References Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CargoList< Tinst >::Count(), DrawString(), CargoList< Tinst >::Empty(), VehicleCargoList::FeederShare(), FONT_HEIGHT_NORMAL, SpecializedVehicle< RoadVehicle, VEH_ROAD >::From(), GetCargoSubtypeText(), RoadVehicle::HasArticulatedPart(), lastof, Vehicle::Next(), NUM_CARGO, SA_LEFT, SA_STRIP, SetDParam(), CargoList< Tinst >::Source(), strecat(), and Vehicle::value.

Referenced by VehicleDetailsWindow::DrawVehicleDetails().

void DrawShipDetails | ( | const Vehicle * | v,
|  | int | left,
|  | int | right,
|  | int | y |
| ) |  |  |

Draw the details for the given vehicle at the given position.

Parameters:

  | v | current vehicle
  | left | The left most coordinate to draw
  | right | The right most coordinate to draw
  | y | The y coordinate

Definition at line 57 of file ship_gui.cpp.

References Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CargoList< Tinst >::Count(), DrawString(), CargoList< Tinst >::Empty(), VehicleCargoList::FeederShare(), FONT_HEIGHT_NORMAL, GetCargoSubtypeText(), SA_LEFT, SA_STRIP, SetDParam(), CargoList< Tinst >::Source(), and Vehicle::value.

Referenced by VehicleDetailsWindow::DrawVehicleDetails().

void DrawTrainDetails | ( | const Train * | v,
|  | int | left,
|  | int | right,
|  | int | y,
|  | int | vscroll_pos,
|  | uint16 | vscroll_cap,
|  | TrainDetailsWindowTabs | det_tab |
| ) |  |  |

Draw the details for the given vehicle at the given position.

Parameters:

  | v | current vehicle
  | left | The left most coordinate to draw
  | right | The right most coordinate to draw
  | y | The y coordinate
  | vscroll_pos | Position of scrollbar
  | vscroll_cap | Number of lines currently displayed
  | det_tab | Selected details tab

Definition at line 297 of file train_gui.cpp.

References _colour_gradient, _dynlang, _settings_game, DIR_E, DIR_W, DrawSprite(), DrawString(), FONT_HEIGHT_NORMAL, VehicleSettings::freight_trains, FreightWagonMult(), GetCargoSummaryOfArticulatedVehicle(), Train::GetDisplayImageWidth(), Train::GetImage(), Train::GetNextVehicle(), GetVehiclePalette(), GfxFillRect(), Train::IsArticulatedPart(), SmallVector< T, S >::Length(), max(), SpecializedVehicle< T, Type >::Next(), NUM_CARGO, SetDParam(), TD_RTL, TDW_TAB_CAPACITY, TDW_TAB_CARGO, TDW_TAB_INFO, TDW_TAB_TOTALS, DynamicLanguages::text_dir, TRAIN_DETAILS_MAX_INDENT, TRAIN_DETAILS_MIN_INDENT, TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TrainDetailsInfoTab(), GameSettings::vehicle, Vehicle::vehstatus, WD_MATRIX_BOTTOM, and WD_MATRIX_TOP.

Referenced by VehicleDetailsWindow::DrawVehicleDetails().

static void DrawVehicleImage | ( | const Vehicle * | v,
|  | int | left,
|  | int | right,
|  | int | y,
|  | VehicleID | selection,
|  | int | skip |
| ) |  |  | `[static]`

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

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

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

static void DrawVehicleProfitButton | ( | const Vehicle * | v,
|  | int | x,
|  | int | y |
| ) |  |  | `[static]`

draw the vehicle profit button in the vehicle list window.

Definition at line 143 of file vehicle_gui.cpp.

References DAYS_IN_YEAR, DrawSprite(), and Vehicle::GetDisplayProfitLastYear().

Referenced by BaseVehicleListWindow::DrawVehicleListItems().

static void DrawVehicleRefitWindow | ( | const RefitList & | list,
|  | int | sel,
|  | uint | pos,
|  | uint | rows,
|  | uint | delta,
|  | const Rect & | r |
| ) |  |  | `[static]`

Draw the list of available refit options for a consist and highlight the selected refit option (if any).

Parameters:

  | *list | First vehicle in consist to get the refit-options of
  | sel | Selected refit cargo-type in the window
  | pos | Position of the selected item in caller widow
  | rows | Number of rows(capacity) in caller window
  | delta | Step height in caller window
  | r | Rectangle of the matrix widget.

Definition at line 322 of file vehicle_gui.cpp.

References CALLBACK_FAILED, RefitOption::cargo, DrawString(), RefitOption::engine, CargoSpec::Get(), GetEngineGRFID(), GetGRFStringID(), SmallVector< T, S >::Length(), CargoSpec::name, SetDParam(), RefitOption::value, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, and WD_MATRIX_TOP.

Referenced by RefitWindow::DrawWidget().

byte GetBestFittingSubType | ( | Vehicle * | v_from,
|  | Vehicle * | v_for |
| ) |  |  |

Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.

Assuming they are going to carry the same cargo ofcourse!

Parameters:

  | v_from | the vehicle to match the subtype from
  | v_for | the vehicle to get the subtype for

Returns:
  the best sub type

Definition at line 170 of file vehicle_gui.cpp.

References CALLBACK_FAILED, EngineInfo::callback_mask, Engine::CanCarryCargo(), Vehicle::cargo_subtype, Vehicle::cargo_type, CBID_VEHICLE_CARGO_SUFFIX, CBM_VEHICLE_CARGO_SUFFIX, Vehicle::First(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetCargoSubtypeText(), GetVehicleCallback(), HasBit(), and Vehicle::InvalidateNewGRFCache().

Referenced by BuildReplacementVehicle(), and CmdCloneVehicle().

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().

int GetTrainDetailsWndVScroll | ( | VehicleID | veh_id,
|  | TrainDetailsWindowTabs | det_tab |
| ) |  |  |

Determines the number of lines in the train details window.

Parameters:

  | veh_id | Train
  | det_tab | Selected details tab

Returns:
  Number of line

Definition at line 254 of file train_gui.cpp.

References SpecializedVehicle< Train, VEH_TRAIN >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetCargoSummaryOfArticulatedVehicle(), GetLengthOfArticulatedVehicle(), Train::GetNextVehicle(), SmallVector< T, S >::Length(), max(), NUM_CARGO, TDW_TAB_TOTALS, and TRAIN_DETAILS_MAX_INDENT.

Referenced by VehicleDetailsWindow::OnPaint().

uint GetVehicleListHeight | ( | VehicleType | type,
|  | uint | divisor |
| ) |  |  |

Get the height of a vehicle in the vehicle list GUIs.

Parameters:

  | type | the vehicle type to look at
  | divisor | the resulting height must be dividable by this

Returns:
  the height

Definition at line 857 of file vehicle_gui.cpp.

References FONT_HEIGHT_SMALL, GetVehicleHeight(), max(), and VEH_SHIP.

Referenced by VehicleListWindow::UpdateWidgetSize(), and VehicleGroupWindow::UpdateWidgetSize().

static bool IsVehicleRefitable | ( | const Vehicle * | v | ) | `[static]`

Checks whether the vehicle may be refitted at the moment.

Definition at line 1802 of file vehicle_gui.cpp.

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

Referenced by VehicleViewWindow::OnPaint().

static void ShowVehicleDetailsWindow | ( | const Vehicle * | v | ) | `[static]`

Shows the vehicle details window of the given vehicle.

Definition at line 1684 of file vehicle_gui.cpp.

References _nontrain_vehicle_details_desc, _train_vehicle_details_desc, DeleteWindowById(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, BaseVehicle::type, and VEH_TRAIN.

Referenced by VehicleViewWindow::OnClick().

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 2128 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().

## Variable Documentation

const NWidgetPart _nested_nontrain_vehicle_details_widgets[]`[static]`

Initial value:

     {
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_CLOSEBOX, COLOUR_GREY),
        NWidget(WWT_CAPTION, COLOUR_GREY, VLD_WIDGET_CAPTION), SetDataTip(STR_VEHICLE_DETAILS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
        NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VLD_WIDGET_RENAME_VEHICLE), SetMinimalSize(40, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_VEHICLE_NAME_BUTTON, STR_NULL ),
        NWidget(WWT_SHADEBOX, COLOUR_GREY),
        NWidget(WWT_STICKYBOX, COLOUR_GREY),
      EndContainer(),
      NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_TOP_DETAILS), SetMinimalSize(405, 42), SetResize(1, 0), EndContainer(),
      NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_MIDDLE_DETAILS), SetMinimalSize(405, 45), SetResize(1, 0), EndContainer(),
      NWidget(NWID_HORIZONTAL),
        NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, VLD_WIDGET_DECREASE_SERVICING_INTERVAL), SetFill(0, 1),
            SetDataTip(AWV_DECREASE, STR_VEHICLE_DETAILS_DECREASE_SERVICING_INTERVAL_TOOLTIP),
        NWidget(NWID_BUTTON_ARROW, COLOUR_GREY, VLD_WIDGET_INCREASE_SERVICING_INTERVAL), SetFill(0, 1),
            SetDataTip(AWV_INCREASE, STR_VEHICLE_DETAILS_INCREASE_SERVICING_INTERVAL_TOOLTIP),
        NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_SERVICING_INTERVAL), SetFill(1, 1), SetResize(1, 0), EndContainer(),
        NWidget(WWT_RESIZEBOX, COLOUR_GREY),
      EndContainer(),
    }

Vehicle details widgets (other than train).

Definition at line 1323 of file vehicle_gui.cpp.

const NWidgetPart _nested_train_vehicle_details_widgets[]`[static]`

Train details widgets.

Definition at line 1344 of file vehicle_gui.cpp.

const NWidgetPart _nested_vehicle_refit_widgets[]`[static]`

Initial value:

     {
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_CLOSEBOX, COLOUR_GREY),
        NWidget(WWT_CAPTION, COLOUR_GREY, VRW_CAPTION), SetDataTip(STR_REFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
      EndContainer(),
      NWidget(WWT_TEXTBTN, COLOUR_GREY, VRW_SELECTHEADER), SetDataTip(STR_REFIT_TITLE, STR_NULL), SetResize(1, 0),

      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_MATRIX, COLOUR_GREY, VRW_MATRIX), SetMinimalSize(228, 112), SetResize(1, 14), SetFill(1, 1), SetDataTip(0x801, STR_NULL),
        NWidget(WWT_SCROLLBAR, COLOUR_GREY, VRW_SCROLLBAR),
      EndContainer(),
      NWidget(WWT_PANEL, COLOUR_GREY, VRW_INFOPANEL), SetMinimalTextLines(2, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 0), EndContainer(),
      NWidget(NWID_HORIZONTAL),
        NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VRW_REFITBUTTON), SetFill(1, 0), SetResize(1, 0),
        NWidget(WWT_RESIZEBOX, COLOUR_GREY),
      EndContainer(),
    }

Definition at line 475 of file vehicle_gui.cpp.

const NWidgetPart _nested_vehicle_view_widgets[]`[static]`

Vehicle view widgets.

Definition at line 1695 of file vehicle_gui.cpp.

const WindowDesc _nontrain_vehicle_details_desc(WDP_AUTO, 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS, _nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets))`[static]`

Vehicle details window descriptor for other vehicles than a train.

Referenced by ShowVehicleDetailsWindow().

const WindowDesc _train_vehicle_details_desc(WDP_AUTO, 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS, _nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets))`[static]`

Vehicle details window descriptor.

Referenced by ShowVehicleDetailsWindow().

const WindowDesc _train_view_desc(WDP_AUTO, 250, 134, WC_VEHICLE_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))`[static]`

Vehicle view window descriptor for trains.

Only minimum_height and default_height are different for train view.

Referenced by ShowVehicleViewWindow().

const uint32 _vehicle_command_translation_table[][4]`[static]`

Initial value:

     {
      {
        CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_TRAIN),
        CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE),
        CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_SHIP),
        CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_AIRCRAFT)
      },
      {
        CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN),
        CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_ROAD_VEHICLE),
        CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_SHIP),
        CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_AIRCRAFT)
      },
      {
        CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN),
        CMD_TURN_ROADVEH            | CMD_MSG(STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN),
        0xffffffff,
        0xffffffff
      },
    }

Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type.

Definition at line 1780 of file vehicle_gui.cpp.

const WindowDesc _vehicle_view_desc(WDP_AUTO, 250, 116, WC_VEHICLE_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))`[static]`

Vehicle view window descriptor for all vehicles but trains.

Referenced by ShowVehicleViewWindow().

const ZoomLevel _vehicle_view_zoom_levels[]`[static]`

Initial value:

     {
      ZOOM_LVL_TRAIN,
      ZOOM_LVL_ROADVEH,
      ZOOM_LVL_SHIP,
      ZOOM_LVL_AIRCRAFT,
    }

Zoom levels for vehicle views indexed by vehicle type.

Definition at line 1760 of file vehicle_gui.cpp.

const uint MAX_REFIT_CYCLE = 256`[static]`

Maximum number of refit cycles we try, to prevent infinite loops.

And we store only a byte anyway

Definition at line 161 of file vehicle_gui.cpp.