OpenTTD Source: src/build_vehicle_gui.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
build_vehicle_gui.cpp File Reference

GUI for building vehicles. More...

`#include "stdafx.h"`
`#include "engine_base.h"`
`#include "engine_func.h"`
`#include "station_base.h"`
`#include "network/network.h"`
`#include "articulated_vehicles.h"`
`#include "textbuf_gui.h"`
`#include "command_func.h"`
`#include "company_func.h"`
`#include "vehicle_gui.h"`
`#include "newgrf_badge.h"`
`#include "newgrf_badge_config.h"`
`#include "newgrf_badge_gui.h"`
`#include "newgrf_engine.h"`
`#include "newgrf_text.h"`
`#include "group.h"`
`#include "string_func.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "timer/timer_game_calendar.h"`
`#include "vehicle_func.h"`
`#include "dropdown_type.h"`
`#include "dropdown_func.h"`
`#include "engine_gui.h"`
`#include "cargotype.h"`
`#include "core/geometry_func.hpp"`
`#include "autoreplace_func.h"`
`#include "engine_cmd.h"`
`#include "train_cmd.h"`
`#include "vehicle_cmd.h"`
`#include "zoom_func.h"`
`#include "querystring_gui.h"`
`#include "stringfilter_type.h"`
`#include "hotkeys.h"`
`#include "widgets/build_vehicle_widget.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | BuildVehicleWindow
| GUI for building vehicles. More...

## Functions
uint | GetEngineListHeight (VehicleType type)
| Get the height of a single 'entry' in the engine lists.
static bool | EngineNumberSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by engineID.
static bool | EngineIntroDateSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by introduction date.
static bool | EngineNameSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by name.
static bool | EngineReliabilitySorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by reliability.
static bool | EngineCostSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by purchase cost.
static bool | EngineSpeedSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by speed.
static bool | EnginePowerSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by power.
static bool | EngineTractiveEffortSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by tractive effort.
static bool | EngineRunningCostSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by running costs.
static bool | EnginePowerVsRunningCostSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of engines by running costs.
static bool | TrainEngineCapacitySorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of train engines by capacity.
static bool | TrainEnginesThenWagonsSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of train engines by engine / wagon.
static bool | RoadVehEngineCapacitySorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of road vehicles by capacity.
static bool | ShipEngineCapacitySorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of ships by capacity.
static bool | AircraftEngineCargoSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of aircraft by cargo.
static bool | AircraftRangeSorter (const GUIEngineListItem &a, const GUIEngineListItem &b)
| Determines order of aircraft by range.
static bool | CargoAndEngineFilter (const GUIEngineListItem *item, const CargoType cargo_type)
| Filters vehicles by cargo and engine (in case of rail vehicle).
static uint | GetCargoWeight (const CargoArray &cap, VehicleType vtype)
static int | DrawCargoCapacityInfo (int left, int right, int y, TestedEngineDetails &te, bool refittable)
static int | DrawRailWagonPurchaseInfo (int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi, TestedEngineDetails &te)
static int | DrawRailEnginePurchaseInfo (int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi, TestedEngineDetails &te)
static int | DrawRoadVehPurchaseInfo (int left, int right, int y, EngineID engine_number, TestedEngineDetails &te)
static int | DrawShipPurchaseInfo (int left, int right, int y, EngineID engine_number, bool refittable, TestedEngineDetails &te)
static int | DrawAircraftPurchaseInfo (int left, int right, int y, EngineID engine_number, bool refittable, TestedEngineDetails &te)
| Draw aircraft specific details in the buy window.
static std::optional< std::string > | GetNewGRFAdditionalText (EngineID engine)
| Try to get the NewGRF engine additional text callback as an optional std::string.
static uint | ShowAdditionalText (int left, int right, int y, EngineID engine)
| Display additional text from NewGRF in the purchase information window.
int | DrawVehiclePurchaseInfo (int left, int right, int y, EngineID engine_number, TestedEngineDetails &te)
| Draw the purchase info details of a vehicle at a given location.
static void | DrawEngineBadgeColumn (const Rect &r, int column_group, const GUIBadgeClasses &badge_classes, const Engine *e, PaletteID remap)
void | DrawEngineList (VehicleType type, const Rect &r, const GUIEngineList &eng_list, const Scrollbar &sb, EngineID selected_id, bool show_count, GroupID selected_group, const GUIBadgeClasses &badge_classes)
| Engine drawing loop.
void | DisplayVehicleSortDropDown (Window *w, VehicleType vehicle_type, int selected, WidgetID button)
| Display the dropdown for the vehicle sort criteria.
void | GUIEngineListAddChildren (GUIEngineList &dst, const GUIEngineList &src, EngineID parent, uint8_t indent)
| Add children to GUI engine list to build a hierarchical tree.
void | ShowBuildVehicleWindow (TileIndex tile, VehicleType type)

## Variables
static constexpr std::initializer_list< NWidgetPart > | _nested_build_vehicle_widgets
bool | _engine_sort_direction
| `false` = descending, `true` = ascending.
uint8_t | _engine_sort_last_criteria [] = {0, 0, 0, 0}
| Last set sort criteria, for each vehicle type.
bool | _engine_sort_last_order [] = {false, false, false, false}
| Last set direction of the sort order, for each vehicle type.
bool | _engine_sort_show_hidden_engines [] = {false, false, false, false}
| Last set 'show hidden engines' setting for each vehicle type.
static CargoType | _engine_sort_last_cargo_criteria [] = {CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY}
| Last set filter criteria, for each vehicle type.
static EngineID | _last_engine [2] = { EngineID::Invalid(), EngineID::Invalid() }
EngList_SortTypeFunction *const | _engine_sort_functions [][11]
| Sort functions for the vehicle sort criteria, for each vehicle type.
const std::initializer_list< const StringID > | _engine_sort_listing []
| Dropdown menu strings for the vehicle sort criteria.
static GUIEngineList::FilterFunction *const | _engine_filter_funcs []
static WindowDesc | _build_vehicle_desc (WDP_AUTO, "build_vehicle", 240, 268, WC_BUILD_VEHICLE, WC_NONE, WindowDefaultFlag::Construction, _nested_build_vehicle_widgets, &BuildVehicleWindow::hotkeys)

## Detailed Description

GUI for building vehicles.

Definition in file build_vehicle_gui.cpp.

## Function Documentation

## ◆ AircraftEngineCargoSorter()

static bool AircraftEngineCargoSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of aircraft by cargo.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 400 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), and Engine::GetDisplayDefaultCapacity().

## ◆ AircraftRangeSorter()

static bool AircraftRangeSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of aircraft by range.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 428 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

## ◆ CargoAndEngineFilter()

static bool CargoAndEngineFilter | ( | const GUIEngineListItem * | item,
|  | const CargoType | cargo_type
| ) |  |
| static

Filters vehicles by cargo and engine (in case of rail vehicle).

Definition at line 541 of file build_vehicle_gui.cpp.

References _standard_cargo_mask, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ENGINES, CargoFilterCriteria::CF_NONE, GUIEngineListItem::engine_id, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GetUnionOfArticulatedRefitMasks(), and HasBit().

Referenced by BuildVehicleWindow::FilterSingleEngine().

## ◆ DisplayVehicleSortDropDown()

void DisplayVehicleSortDropDown | ( | Window * | w,
|  | VehicleType | vehicle_type,
|  | int | selected,
|  | WidgetID | button
| ) |  |

Display the dropdown for the vehicle sort criteria.

Parameters

  w | Parent window (holds the dropdown button).
  vehicle_type | Vehicle type being sorted.
  selected | Currently selected sort criterium.
  button | Widget button.

Definition at line 1099 of file build_vehicle_gui.cpp.

References _engine_sort_listing, _settings_game, VehicleSettings::roadveh_acceleration_model, SetBit(), ShowDropDownMenu(), VehicleSettings::train_acceleration_model, VEH_ROAD, VEH_TRAIN, and GameSettings::vehicle.

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

## ◆ DrawAircraftPurchaseInfo()

static int DrawAircraftPurchaseInfo | ( | int | left,
|  | int | right,
|  | int | y,
|  | EngineID | engine_number,
|  | bool | refittable,
|  | TestedEngineDetails & | te
| ) |  |
| static

Draw aircraft specific details in the buy window.

Parameters

  left | Left edge of the window to draw in.
  right | Right edge of the window to draw in.
  y | Top of the area to draw in.
  engine_number | Engine to display.
  refittable | If set, the aircraft can be refitted.

Returns
  Bottom of the used area.

Definition at line 774 of file build_vehicle_gui.cpp.

References TestedEngineDetails::capacity, TestedEngineDetails::cargo, TestedEngineDetails::cost, DrawString(), FS_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), Engine::GetAircraftTypeText(), GetCharacterHeight(), Engine::GetCost(), Engine::GetDisplayMaxSpeed(), Engine::GetRange(), Engine::GetRunningCost(), GetString(), TestedEngineDetails::mail_capacity, PackVelocity(), Engine::type, and TimerGameEconomy::UsingWallclockUnits().

Referenced by DrawVehiclePurchaseInfo().

## ◆ DrawCargoCapacityInfo()

static int DrawCargoCapacityInfo | ( | int | left,
|  | int | right,
|  | int | y,
|  | TestedEngineDetails & | te,
|  | bool | refittable
| ) |  |
| static

Definition at line 572 of file build_vehicle_gui.cpp.

## ◆ DrawEngineBadgeColumn()

static void DrawEngineBadgeColumn | ( | const Rect & | r,
|  | int | column_group,
|  | const GUIBadgeClasses & | badge_classes,
|  | const Engine * | e,
|  | PaletteID | remap
| ) |  |
| static

Definition at line 951 of file build_vehicle_gui.cpp.

## ◆ DrawEngineList()

void DrawEngineList | ( | VehicleType | type,
|  | const Rect & | r,
|  | const GUIEngineList & | eng_list,
|  | const Scrollbar & | sb,
|  | EngineID | selected_id,
|  | bool | show_count,
|  | GroupID | selected_group,
|  | const GUIBadgeClasses & | badge_classes
| ) |  |

Engine drawing loop.

Parameters

  type | Type of vehicle (VEH_*)
  r | The Rect of the list
  eng_list | What engines to draw
  sb | Scrollbar of list.
  selected_id | what engine to highlight as selected, if any
  show_count | Whether to show the amount of engines or not
  selected_group | the group to list the engines of

Definition at line 966 of file build_vehicle_gui.cpp.

References _current_text_dir, _local_company, AutoreplaceVehicleInUse, CentreBounds(), Engine::company_hidden, DrawString(), DrawVehicleEngine(), EIT_PURCHASE, EngineHasReplacementForCompany(), VehicleCellSize::extend_left, VehicleCellSize::extend_right, FS_NORMAL, FS_SMALL, WidgetDimensions::fullbevel, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetCharacterHeight(), GetColourGradient(), GetEngineListHeight(), GetEnginePalette(), GetGroupNumEngines(), GetScaledSpriteSize(), GetSpriteSize(), GetString(), GetStringBoundingBox(), GetVehicleImageCellSize(), Scrollbar::GetVisibleRangeIterators(), HasBit(), HasVariants, Rect::Height(), WidgetDimensions::hsep_indent, WidgetDimensions::hsep_normal, Rect::Indent(), IsFolded, PackEngineNameDParam(), PALETTE_CRASH, PurchaseList, SA_CENTER, SA_FORCE, SA_RIGHT, WidgetDimensions::scaled, ScaleSpriteTrad(), Shaded, Rect::Shrink(), TC_FORCED, TC_NO_SHADE, TD_RTL, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Rect::Translate(), Rect::WithHeight(), Rect::WithWidth(), and Rect::WithY().

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

## ◆ DrawRailEnginePurchaseInfo()

static int DrawRailEnginePurchaseInfo | ( | int | left,
|  | int | right,
|  | int | y,
|  | EngineID | engine_number,
|  | const RailVehicleInfo * | rvi,
|  | TestedEngineDetails & | te
| ) |  |
| static

Definition at line 623 of file build_vehicle_gui.cpp.

## ◆ DrawRailWagonPurchaseInfo()

static int DrawRailWagonPurchaseInfo | ( | int | left,
|  | int | right,
|  | int | y,
|  | EngineID | engine_number,
|  | const RailVehicleInfo * | rvi,
|  | TestedEngineDetails & | te
| ) |  |
| static

Definition at line 586 of file build_vehicle_gui.cpp.

## ◆ DrawRoadVehPurchaseInfo()

static int DrawRoadVehPurchaseInfo | ( | int | left,
|  | int | right,
|  | int | y,
|  | EngineID | engine_number,
|  | TestedEngineDetails & | te
| ) |  |
| static

Definition at line 680 of file build_vehicle_gui.cpp.

## ◆ DrawShipPurchaseInfo()

static int DrawShipPurchaseInfo | ( | int | left,
|  | int | right,
|  | int | y,
|  | EngineID | engine_number,
|  | bool | refittable,
|  | TestedEngineDetails & | te
| ) |  |
| static

Definition at line 723 of file build_vehicle_gui.cpp.

## ◆ DrawVehiclePurchaseInfo()

int DrawVehiclePurchaseInfo | ( | int | left,
|  | int | right,
|  | int | y,
|  | EngineID | engine_number,
|  | TestedEngineDetails & | te
| ) |  |

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

References _settings_client, TimerGameCalendar::ConvertDateToYMD(), TimerGame< struct Calendar >::DateToYear(), DrawAircraftPurchaseInfo(), DrawString(), FS_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GetCharacterHeight(), GetGRFConfig(), Engine::GetGRFID(), Engine::GetLifeLengthInDays(), GRFConfig::GetName(), GetString(), ClientSettings::gui, Engine::intro_date, IsArticulatedVehicleRefittable(), RAILVEH_WAGON, Engine::reliability, GUISettings::show_newgrf_name, ShowAdditionalText(), ShowRefitOptionsList(), ToPercent16(), Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

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

## ◆ EngineCostSorter()

static bool EngineCostSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by purchase cost.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 193 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

## ◆ EngineIntroDateSorter()

static bool EngineIntroDateSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by introduction date.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 129 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

## ◆ EngineNameSorter()

static bool EngineNameSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by name.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 149 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), GetString(), PackEngineNameDParam(), PurchaseList, and StrNaturalCompare().

## ◆ EngineNumberSorter()

static bool EngineNumberSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by engineID.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 116 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

Referenced by AircraftEngineCargoSorter(), AircraftRangeSorter(), EngineCostSorter(), EngineIntroDateSorter(), EngineNameSorter(), EnginePowerSorter(), EnginePowerVsRunningCostSorter(), EngineReliabilitySorter(), EngineRunningCostSorter(), EngineSpeedSorter(), EngineTractiveEffortSorter(), RoadVehEngineCapacitySorter(), ShipEngineCapacitySorter(), TrainEngineCapacitySorter(), and TrainEnginesThenWagonsSorter().

## ◆ EnginePowerSorter()

static bool EnginePowerSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by power.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 227 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

## ◆ EnginePowerVsRunningCostSorter()

static bool EnginePowerVsRunningCostSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by running costs.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 278 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), EngineRunningCostSorter(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), Engine::GetPower(), and Engine::GetRunningCost().

## ◆ EngineReliabilitySorter()

static bool EngineReliabilitySorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by reliability.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 176 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

## ◆ EngineRunningCostSorter()

static bool EngineRunningCostSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by running costs.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 261 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

Referenced by EnginePowerVsRunningCostSorter().

## ◆ EngineSpeedSorter()

static bool EngineSpeedSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by speed.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 210 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

## ◆ EngineTractiveEffortSorter()

static bool EngineTractiveEffortSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of engines by tractive effort.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 244 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get().

## ◆ GetCargoWeight()

static uint GetCargoWeight | ( | const CargoArray & | cap,
|  | VehicleType | vtype
| ) |  |
| static

Definition at line 557 of file build_vehicle_gui.cpp.

## ◆ GetEngineListHeight()

uint GetEngineListHeight | ( | VehicleType | type | ) |

Get the height of a single 'entry' in the engine lists.

Parameters

  type | the vehicle type to get the height of

Returns
  the height for the entry

Definition at line 56 of file build_vehicle_gui.cpp.

References EIT_PURCHASE, FS_NORMAL, GetCharacterHeight(), GetVehicleImageCellSize(), and WidgetDimensions::scaled.

Referenced by DrawEngineList(), ReplaceVehicleWindow::UpdateWidgetSize(), and BuildVehicleWindow::UpdateWidgetSize().

## ◆ GetNewGRFAdditionalText()

static std::optional< std::string > GetNewGRFAdditionalText | ( | EngineID | engine | ) |
| static

Try to get the NewGRF engine additional text callback as an optional std::string.

Parameters

  engine | The engine whose additional text to get.

Returns
  The std::string if present, otherwise std::nullopt.

Definition at line 820 of file build_vehicle_gui.cpp.

References CALLBACK_FAILED, CBID_VEHICLE_ADDITIONAL_TEXT, ErrorUnknownCallbackResult(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GetGRFStringWithTextStack(), GetVehicleCallback(), and GRFSTR_MISC_GRF_TEXT.

Referenced by BuildVehicleWindow::FilterByText(), and ShowAdditionalText().

## ◆ GUIEngineListAddChildren()

void GUIEngineListAddChildren | ( | GUIEngineList & | dst,
|  | const GUIEngineList & | src,
|  | EngineID | parent,
|  | uint8_t | indent
| ) |  |

Add children to GUI engine list to build a hierarchical tree.

Parameters

  dst | Destination list.
  src | Source list.
  parent | Current tree parent (set by self with recursion).
  indent | Current tree indentation level (set by self with recursion).

Definition at line 1122 of file build_vehicle_gui.cpp.

References Engine::display_last_variant, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GUIEngineListAddChildren(), HasVariants, IsFolded, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), and Shaded.

Referenced by ReplaceVehicleWindow::GenerateReplaceVehList(), and GUIEngineListAddChildren().

## ◆ RoadVehEngineCapacitySorter()

static bool RoadVehEngineCapacitySorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of road vehicles by capacity.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 359 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and GetTotalCapacityOfArticulatedParts().

## ◆ ShipEngineCapacitySorter()

static bool ShipEngineCapacitySorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of ships by capacity.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 378 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), and Engine::GetDisplayDefaultCapacity().

## ◆ ShowAdditionalText()

static uint ShowAdditionalText | ( | int | left,
|  | int | right,
|  | int | y,
|  | EngineID | engine
| ) |  |
| static

Display additional text from NewGRF in the purchase information window.

Parameters

  left | Left border of text bounding box
  right | Right border of text bounding box
  y | Top border of text bounding box
  engine | Engine to query the additional purchase information for

Returns
  Bottom border of text bounding box

Definition at line 846 of file build_vehicle_gui.cpp.

References DrawStringMultiLine(), and GetNewGRFAdditionalText().

Referenced by DrawVehiclePurchaseInfo().

## ◆ ShowBuildVehicleWindow()

void ShowBuildVehicleWindow | ( | TileIndex | tile,
|  | VehicleType | type
| ) |  |

Definition at line 1977 of file build_vehicle_gui.cpp.

## ◆ TrainEngineCapacitySorter()

static bool TrainEngineCapacitySorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of train engines by capacity.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 320 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), GetTotalCapacityOfArticulatedParts(), and RAILVEH_MULTIHEAD.

## ◆ TrainEnginesThenWagonsSorter()

static bool TrainEnginesThenWagonsSorter | ( | const GUIEngineListItem & | a,
|  | const GUIEngineListItem & | b
| ) |  |
| static

Determines order of train engines by engine / wagon.

Parameters

  a | first engine to compare
  b | second engine to compare

Returns
  for descending order: returns true if a < b. Vice versa for ascending order

Definition at line 340 of file build_vehicle_gui.cpp.

References _engine_sort_direction, GUIEngineListItem::engine_id, EngineNumberSorter(), and RAILVEH_WAGON.

## Variable Documentation

## ◆ _engine_filter_funcs

GUIEngineList::FilterFunction* const _engine_filter_funcs[]
| static

Initial value:
= {
&CargoAndEngineFilter,
}
CargoAndEngineFilter
static bool CargoAndEngineFilter(const GUIEngineListItem *item, const CargoType cargo_type)
Filters vehicles by cargo and engine (in case of rail vehicle).
Definition build_vehicle_gui.cpp:541

Definition at line 553 of file build_vehicle_gui.cpp.

## ◆ _engine_sort_direction

bool _engine_sort_direction

`false` = descending, `true` = ascending.

Definition at line 104 of file build_vehicle_gui.cpp.

Referenced by AircraftEngineCargoSorter(), AircraftRangeSorter(), EngineCostSorter(), EngineIntroDateSorter(), EngineNameSorter(), EngineNumberSorter(), EnginePowerSorter(), EnginePowerVsRunningCostSorter(), EngineReliabilitySorter(), EngineRunningCostSorter(), EngineSpeedSorter(), EngineTractiveEffortSorter(), ReplaceVehicleWindow::GenerateReplaceVehList(), RoadVehEngineCapacitySorter(), ShipEngineCapacitySorter(), TrainEngineCapacitySorter(), and TrainEnginesThenWagonsSorter().

## ◆ _engine_sort_functions

EngList_SortTypeFunction* const _engine_sort_functions[][11]

Sort functions for the vehicle sort criteria, for each vehicle type.

Definition at line 441 of file build_vehicle_gui.cpp.

Referenced by ReplaceVehicleWindow::GenerateReplaceVehList().

## ◆ _engine_sort_last_cargo_criteria

CargoType _engine_sort_last_cargo_criteria[] = {CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_ANY}
| static

Last set filter criteria, for each vehicle type.

Definition at line 108 of file build_vehicle_gui.cpp.

Referenced by BuildVehicleWindow::OnDropdownSelect().

## ◆ _engine_sort_last_criteria

uint8_t _engine_sort_last_criteria[] = {0, 0, 0, 0}

Last set sort criteria, for each vehicle type.

Definition at line 105 of file build_vehicle_gui.cpp.

Referenced by BuildVehicleWindow::OnDropdownSelect(), ReplaceVehicleWindow::OnDropdownSelect(), and BuildVehicleWindow::OnInvalidateData().

## ◆ _engine_sort_last_order

bool _engine_sort_last_order[] = {false, false, false, false}

Last set direction of the sort order, for each vehicle type.

Definition at line 106 of file build_vehicle_gui.cpp.

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

## ◆ _engine_sort_listing

const std::initializer_list<const StringID> _engine_sort_listing[]

Dropdown menu strings for the vehicle sort criteria.

Definition at line 491 of file build_vehicle_gui.cpp.

Referenced by DisplayVehicleSortDropDown(), ReplaceVehicleWindow::GetWidgetString(), and BuildVehicleWindow::GetWidgetString().

## ◆ _engine_sort_show_hidden_engines

bool _engine_sort_show_hidden_engines[] = {false, false, false, false}

Last set 'show hidden engines' setting for each vehicle type.

Definition at line 107 of file build_vehicle_gui.cpp.

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

## ◆ _last_engine

EngineID _last_engine[2] = { EngineID::Invalid(), EngineID::Invalid() }
| static

Definition at line 141 of file build_vehicle_gui.cpp.

## ◆ _nested_build_vehicle_widgets

constexpr std::initializer_list<NWidgetPart> _nested_build_vehicle_widgets
| staticconstexpr

Definition at line 61 of file build_vehicle_gui.cpp.