# build_vehicle_gui.cpp File Reference

GUI for building vehicles. More...

`#include "train.h"`
`#include "roadveh.h"`
`#include "ship.h"`
`#include "aircraft.h"`
`#include "articulated_vehicles.h"`
`#include "textbuf_gui.h"`
`#include "command_func.h"`
`#include "company_func.h"`
`#include "vehicle_gui.h"`
`#include "newgrf_engine.h"`
`#include "group.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "date_func.h"`
`#include "vehicle_func.h"`
`#include "gfx_func.h"`
`#include "widgets/dropdown_func.h"`
`#include "window_gui.h"`
`#include "engine_gui.h"`
`#include "settings_type.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Data Structures
struct | BuildVehicleWindow
## 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
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 | EngineCostSorter (const void *a, const void *b)
static int CDECL | EngineSpeedSorter (const void *a, const void *b)
static int CDECL | EnginePowerSorter (const void *a, const void *b)
static int CDECL | EngineRunningCostSorter (const void *a, const void *b)
static int CDECL | TrainEnginePowerVsRunningCostSorter (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 | RoadVehEngineCapacitySorter (const void *a, const void *b)
static int CDECL | ShipEngineCapacitySorter (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)
static int | DrawShipPurchaseInfo (int x, int y, EngineID engine_number, const ShipVehicleInfo *svi, bool refittable)
static int | DrawAircraftPurchaseInfo (int x, int y, EngineID engine_number, const AircraftVehicleInfo *avi, bool refittable)
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 | DrawVehicleEngine (VehicleType type, int x, int y, EngineID engine, SpriteID pal)
void | DrawEngineList (VehicleType type, int x, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, int count_location, GroupID selected_group)
| Engine drawing loop.
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 (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|WDF_CONSTRUCTION, _build_vehicle_widgets)

## Detailed Description

GUI for building vehicles.

Definition in file build_vehicle_gui.cpp.

## Function Documentation

void DrawEngineList | ( | VehicleType | type,
|  | int | x,
|  | int | r,
|  | int | y,
|  | const GUIEngineList * | eng_list,
|  | uint16 | min,
|  | uint16 | max,
|  | EngineID | selected_id,
|  | int | count_location,
|  | 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
  | count_location | Offset to print the engine count (used by autoreplace). 0 means it's off

Definition at line 635 of file build_vehicle_gui.cpp.

References DrawStringRightAligned(), DrawStringTruncated(), GetEnginePalette(), and GetGroupNumEngines().

Referenced by ReplaceVehicleWindow::OnPaint().

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

References ConvertDateToYMD(), DrawString(), IsArticulatedVehicleRefittable(), RAILVEH_WAGON, ShowAdditionalText(), ShowRefitOptionsList(), and YearMonthDay::year.

Referenced by ReplaceVehicleWindow::OnPaint().

## Variable Documentation

const Widget _build_vehicle_widgets[]`[static]`

Initial value:

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

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

Definition at line 43 of file build_vehicle_gui.cpp.