# build_vehicle_gui.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "train.h"`
`#include "roadveh.h"`
`#include "ship.h"`
`#include "aircraft.h"`
`#include "debug.h"`
`#include "gui.h"`
`#include "articulated_vehicles.h"`
`#include "textbuf_gui.h"`
`#include "station.h"`
`#include "command_func.h"`
`#include "engine.h"`
`#include "player_func.h"`
`#include "depot.h"`
`#include "airport.h"`
`#include "vehicle_gui.h"`
`#include "newgrf_engine.h"`
`#include "cargotype.h"`
`#include "group.h"`
`#include "road_map.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "date_func.h"`
`#include "vehicle_func.h"`
`#include "settings_type.h"`
`#include "gfx_func.h"`
`#include "widgets/dropdown_func.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Data Structures
struct | buildvehicle_d
## Enumerations
enum | BuildVehicleWidgets { BUILD_VEHICLE_WIDGET_CLOSEBOX = 0, BUILD_VEHICLE_WIDGET_CAPTION, BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING, BUILD_VEHICLE_WIDGET_SORT_DROPDOWN, BUILD_VEHICLE_WIDGET_LIST, BUILD_VEHICLE_WIDGET_SCROLLBAR, BUILD_VEHICLE_WIDGET_PANEL, BUILD_VEHICLE_WIDGET_BUILD, BUILD_VEHICLE_WIDGET_RENAME, BUILD_VEHICLE_WIDGET_RESIZE, BUILD_VEHICLE_WIDGET_END }
## Functions
| assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(buildvehicle_d))
static void | SetupWindowStrings (Window *w, VehicleType type)
static int CDECL | EngineNumberSorter (const void *a, const void *b)
static int CDECL | EngineIntroDateSorter (const void *a, const void *b)
static int CDECL | EngineNameSorter (const void *a, const void *b)
static int CDECL | EngineReliabilitySorter (const void *a, const void *b)
static int CDECL | TrainEngineCostSorter (const void *a, const void *b)
static int CDECL | TrainEngineSpeedSorter (const void *a, const void *b)
static int CDECL | TrainEnginePowerSorter (const void *a, const void *b)
static int CDECL | TrainEngineRunningCostSorter (const void *a, const void *b)
static int CDECL | TrainEnginePowerVsRunningCostSorter (const void *a, const void *b)
static int CDECL | TrainEngineNumberSorter (const void *a, const void *b)
static int CDECL | TrainEngineCapacitySorter (const void *a, const void *b)
static int CDECL | TrainEnginesThenWagonsSorter (const void *a, const void *b)
static int CDECL | RoadVehEngineCostSorter (const void *a, const void *b)
static int CDECL | RoadVehEngineSpeedSorter (const void *a, const void *b)
static int CDECL | RoadVehEngineRunningCostSorter (const void *a, const void *b)
static int CDECL | RoadVehEngineCapacitySorter (const void *a, const void *b)
static int CDECL | ShipEngineCostSorter (const void *a, const void *b)
static int CDECL | ShipEngineSpeedSorter (const void *a, const void *b)
static int CDECL | ShipEngineRunningCostSorter (const void *a, const void *b)
static int CDECL | ShipEngineCapacitySorter (const void *a, const void *b)
static int CDECL | AircraftEngineCostSorter (const void *a, const void *b)
static int CDECL | AircraftEngineSpeedSorter (const void *a, const void *b)
static int CDECL | AircraftEngineRunningCostSorter (const void *a, const void *b)
static int CDECL | AircraftEngineCargoSorter (const void *a, const void *b)
static int | DrawCargoCapacityInfo (int x, int y, EngineID engine, VehicleType type, bool refittable)
static int | DrawRailWagonPurchaseInfo (int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
static int | DrawRailEnginePurchaseInfo (int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
static int | DrawRoadVehPurchaseInfo (int x, int y, EngineID engine_number, const RoadVehicleInfo *rvi)
static int | DrawShipPurchaseInfo (int x, int y, EngineID engine_number, const ShipVehicleInfo *svi)
static int | DrawAircraftPurchaseInfo (int x, int y, EngineID engine_number, const AircraftVehicleInfo *avi)
int | DrawVehiclePurchaseInfo (int x, int y, uint w, EngineID engine_number)
| Draw the purchase info details of a vehicle at a given location.
static void | GenerateBuildTrainList (Window *w)
static void | GenerateBuildRoadVehList (Window *w)
static void | GenerateBuildShipList (Window *w)
static void | GenerateBuildAircraftList (Window *w)
static void | GenerateBuildList (Window *w)
static void | DrawVehicleEngine (VehicleType type, int x, int y, EngineID engine, SpriteID pal)
void | DrawEngineList (VehicleType type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
| Engine drawing loop.
static void | DrawBuildVehicleWindow (Window *w)
static void | BuildVehicleClickEvent (Window *w, WindowEvent *e)
static void | NewVehicleWndProc (Window *w, WindowEvent *e)
void | ShowBuildVehicleWindow (TileIndex tile, VehicleType type)
## Variables
static const Widget | _build_vehicle_widgets []
static bool | _internal_sort_order
static byte | _last_sort_criteria [] = {0, 0, 0, 0}
static bool | _last_sort_order [] = {false, false, false, false}
static EngList_SortTypeFunction *const | _sorter [][10]
static const StringID | _sort_listing [][11]
static const WindowDesc | _build_vehicle_desc

## Detailed Description

Definition in file build_vehicle_gui.cpp.

## Function Documentation

void DrawEngineList | ( | VehicleType | type,
|  | int | x,
|  | int | y,
|  | const EngineList | eng_list,
|  | uint16 | min,
|  | uint16 | max,
|  | EngineID | selected_id,
|  | bool | show_count,
|  | GroupID | selected_group |
| ) |  |  |

Engine drawing loop.

Parameters:

  | type | Type of vehicle (VEH_*)
  | x,y | Where should the list start
  | eng_list | What engines to draw
  | min | where to start in the list
  | max | where in the list to end
  | selected_id | what engine to highlight as selected, if any
  | show_count | Display the number of vehicles (used by autoreplace)

Definition at line 946 of file build_vehicle_gui.cpp.

References EngList_Count(), GetEnginePalette(), and GetGroupNumEngines().

int DrawVehiclePurchaseInfo | ( | int | x,
|  | int | y,
|  | uint | w,
|  | EngineID | engine_number |
| ) |  |  |

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

Parameters:

  | x,y | location where to draw the info
  | w | how wide are the text allowed to be (size of widget/window to Draw in)
  | engine_number | the engine of which to draw the info of

Returns:
  y after drawing all the text

Definition at line 723 of file build_vehicle_gui.cpp.

References ConvertDateToYMD(), RAILVEH_WAGON, ShowAdditionalText(), and ShowRefitOptionsList().

## Variable Documentation

const WindowDesc _build_vehicle_desc`[static]`

Initial value:

     {
      WDP_AUTO, WDP_AUTO, 240, 174, 240, 256,
      WC_BUILD_VEHICLE, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
      _build_vehicle_widgets,
      NewVehicleWndProc
    }

Definition at line 1175 of file build_vehicle_gui.cpp.

const Widget _build_vehicle_widgets[]`[static]`

Initial value:

     {
      {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW },
      {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   239,     0,    13, 0x0,                     STR_018C_WINDOW_TITLE_DRAG_THIS },
      { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, STR_SORT_BY,             STR_SORT_ORDER_TIP},
      {   WWT_DROPDOWN,  RESIZE_RIGHT,    14,    81,   239,    14,    25, 0x0,                     STR_SORT_CRITERIA_TIP},
      {     WWT_MATRIX,     RESIZE_RB,    14,     0,   227,    26,    39, 0x101,                   STR_NULL },
      {  WWT_SCROLLBAR,    RESIZE_LRB,    14,   228,   239,    26,    39, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST },
      {      WWT_PANEL,    RESIZE_RTB,    14,     0,   239,    40,   161, 0x0,                     STR_NULL },

      { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   114,   162,   173, 0x0,                     STR_NULL },
      { WWT_PUSHTXTBTN,    RESIZE_RTB,    14,   115,   227,   162,   173, 0x0,                     STR_NULL },
      {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   228,   239,   162,   173, 0x0,                     STR_RESIZE_BUTTON },
      {   WIDGETS_END},
    }

Definition at line 68 of file build_vehicle_gui.cpp.