OpenTTD Source: src/engine_gui.cpp File Reference

OpenTTD Source 15.0-beta1

Data Structures | Functions | Variables
engine_gui.cpp File Reference

GUI to show engine related information. More...

`#include "stdafx.h"`
`#include "window_gui.h"`
`#include "engine_base.h"`
`#include "command_func.h"`
`#include "strings_func.h"`
`#include "engine_gui.h"`
`#include "articulated_vehicles.h"`
`#include "vehicle_func.h"`
`#include "company_func.h"`
`#include "rail.h"`
`#include "road.h"`
`#include "settings_type.h"`
`#include "train.h"`
`#include "roadveh.h"`
`#include "ship.h"`
`#include "aircraft.h"`
`#include "engine_cmd.h"`
`#include "zoom_func.h"`
`#include "widgets/engine_widget.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | EnginePreviewWindow

## Functions
StringID | GetEngineCategoryName (EngineID engine)
| Return the category of an engine.
void | ShowEnginePreviewWindow (EngineID engine)
uint | GetTotalCapacityOfArticulatedParts (EngineID engine)
| Get the capacity of an engine with articulated parts.
static StringID | GetTrainEngineInfoString (const Engine *e)
static StringID | GetAircraftEngineInfoString (const Engine *e)
static StringID | GetRoadVehEngineInfoString (const Engine *e)
static StringID | GetShipEngineInfoString (const Engine *e)
StringID | GetEngineInfoString (EngineID engine)
| Get a multi-line string with some technical data, describing the engine.
void | DrawVehicleEngine (int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
| Draw an engine.
void | EngList_Sort (GUIEngineList &el, EngList_SortTypeFunction compare)
| Sort all items using quick sort and given 'CompareItems' function.
void | EngList_SortPartial (GUIEngineList &el, EngList_SortTypeFunction compare, size_t begin, size_t num_items)
| Sort selected range of items (on indices @ <begin, begin+num_items-1>)

## Variables
static constexpr NWidgetPart | _nested_engine_preview_widgets []
static WindowDesc | _engine_preview_desc (WDP_CENTER, nullptr, 0, 0, WC_ENGINE_PREVIEW, WC_NONE, WDF_CONSTRUCTION, _nested_engine_preview_widgets)

## Detailed Description

GUI to show engine related information.

Definition in file engine_gui.cpp.

## Function Documentation

## ◆ DrawVehicleEngine()

void DrawVehicleEngine | ( | int | left,
|  | int | right,
|  | int | preferred_x,
|  | int | y,
|  | EngineID | engine,
|  | PaletteID | pal,
|  | EngineImageType | image_type
| ) |  |

Draw an engine.

Parameters

  left | Minimum horizontal position to use for drawing the engine
  right | Maximum horizontal position to use for drawing the engine
  preferred_x | Horizontal position to use for drawing the engine.
  y | Vertical position to use for drawing the engine.
  engine | Engine to draw.
  pal | Palette to use for drawing.

Definition at line 303 of file engine_gui.cpp.

References DrawRoadVehEngine(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by DrawEngineList(), EnginePreviewWindow::DrawWidget(), and NewsWindow::DrawWidget().

## ◆ EngList_Sort()

void EngList_Sort | ( | GUIEngineList & | el,
|  | EngList_SortTypeFunction | compare
| ) |  |

Sort all items using quick sort and given 'CompareItems' function.

Parameters

  el | list to be sorted
  compare | function for evaluation of the quicksort

Definition at line 333 of file engine_gui.cpp.

Referenced by ReplaceVehicleWindow::GenerateReplaceVehList().

## ◆ EngList_SortPartial()

void EngList_SortPartial | ( | GUIEngineList & | el,
|  | EngList_SortTypeFunction | compare,
|  | size_t | begin,
|  | size_t | num_items
| ) |  |

Sort selected range of items (on indices @ <begin, begin+num_items-1>)

Parameters

  el | list to be sorted
  compare | function for evaluation of the quicksort
  begin | start of sorting
  num_items | count of items to be sorted

Definition at line 346 of file engine_gui.cpp.

## ◆ GetAircraftEngineInfoString()

static StringID GetAircraftEngineInfoString | ( | const Engine * | e | ) |
| static

Definition at line 193 of file engine_gui.cpp.

## ◆ GetEngineCategoryName()

StringID GetEngineCategoryName | ( | EngineID | engine | ) |

Return the category of an engine.

Parameters

  engine | Engine to examine.

Returns
  String describing the category ("road veh", "train". "airplane", or "ship") of the engine.

Definition at line 40 of file engine_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetRailTypeInfo(), GetRoadTypeInfo(), RoadTypeInfo::new_engine, RailTypeInfo::new_loco, RailVehicleInfo::railtype, RoadVehicleInfo::roadtype, RailTypeInfo::strings, RoadTypeInfo::strings, Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by EnginePreviewWindow::DrawWidget(), NewVehicleAvailable(), and EnginePreviewWindow::UpdateWidgetSize().

## ◆ GetEngineInfoString()

StringID GetEngineInfoString | ( | EngineID | engine | ) |

Get a multi-line string with some technical data, describing the engine.

Parameters

  engine | Engine to describe.

Returns
  String describing the engine.

Postcondition
  `DParam` array is set up for printing the string.

Definition at line 273 of file engine_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by EnginePreviewWindow::DrawWidget(), NewsWindow::DrawWidget(), EnginePreviewWindow::UpdateWidgetSize(), and NewsWindow::UpdateWidgetSize().

## ◆ GetRoadVehEngineInfoString()

static StringID GetRoadVehEngineInfoString | ( | const Engine * | e | ) |
| static

Definition at line 220 of file engine_gui.cpp.

## ◆ GetShipEngineInfoString()

static StringID GetShipEngineInfoString | ( | const Engine * | e | ) |
| static

Definition at line 250 of file engine_gui.cpp.

## ◆ GetTotalCapacityOfArticulatedParts()

uint GetTotalCapacityOfArticulatedParts | ( | EngineID | engine | ) |

Get the capacity of an engine with articulated parts.

Parameters

  engine | The engine to get the capacity of.

Returns
  The capacity.

Definition at line 165 of file engine_gui.cpp.

References GetCapacityOfArticulatedParts(), and CargoArray::GetSum().

Referenced by RoadVehEngineCapacitySorter(), and TrainEngineCapacitySorter().

## ◆ GetTrainEngineInfoString()

static StringID GetTrainEngineInfoString | ( | const Engine * | e | ) |
| static

Definition at line 171 of file engine_gui.cpp.

## ◆ ShowEnginePreviewWindow()

void ShowEnginePreviewWindow | ( | EngineID | engine | ) |

Definition at line 155 of file engine_gui.cpp.

## Variable Documentation

## ◆ _nested_engine_preview_widgets

constexpr NWidgetPart _nested_engine_preview_widgets[]
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_ENGINE_PREVIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE),
NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.modalpopup),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_EP_QUESTION), SetMinimalSize(300, 0), SetFill(1, 0),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(85, WidgetDimensions::unscaled.hsep_wide, 85),
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_EP_NO), SetDataTip(STR_QUIT_NO, STR_NULL), SetFill(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_EP_YES), SetDataTip(STR_QUIT_YES, STR_NULL), SetFill(1, 0),
EndContainer(),
EndContainer(),
EndContainer(),
}
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:96
WID_EP_QUESTION
@ WID_EP_QUESTION
The container for the question.
Definition engine_widget.h:15
WID_EP_NO
@ WID_EP_NO
No button.
Definition engine_widget.h:16
WID_EP_YES
@ WID_EP_YES
Yes button.
Definition engine_widget.h:17
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1181
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1271
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1228
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition widget_type.h:1202
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition widget_type.h:1137
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1320
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1191
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition widget_type.h:524
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition widget_type.h:113
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:75
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:50
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:61
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:77
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:69
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:48

Definition at line 54 of file engine_gui.cpp.