# engine_gui.cpp File Reference

GUI to show engine related information. More...

`#include "stdafx.h"`
`#include "window_gui.h"`
`#include "gfx_func.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 "settings_type.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Data Structures
struct | EnginePreviewWindow
## Enumerations
enum | EnginePreviewWidgets { EPW_QUESTION, EPW_NO, EPW_YES }
| Widgets used for the engine preview window. More...
## Functions
StringID | GetEngineCategoryName (EngineID engine)
| Return the category of an engine.
void | ShowEnginePreviewWindow (EngineID engine)
uint | GetTotalCapacityOfArticulatedParts (EngineID engine)
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)
| 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, uint begin, uint num_items)
| Sort selected range of items (on indices @ <begin, begin+num_items-1>).
## Variables
static const NWidgetPart | _nested_engine_preview_widgets []
static const WindowDesc | _engine_preview_desc (WDP_CENTER, 0, 0, WC_ENGINE_PREVIEW, WC_NONE, WDF_CONSTRUCTION, _nested_engine_preview_widgets, lengthof(_nested_engine_preview_widgets))

## Detailed Description

GUI to show engine related information.

Definition in file engine_gui.cpp.

## Enumeration Type Documentation

enum EnginePreviewWidgets

Widgets used for the engine preview window.

Enumerator:

  EPW_QUESTION | The container for the question.
  EPW_NO | No button.
  EPW_YES | Yes button.

Definition at line 45 of file engine_gui.cpp.

## Function Documentation

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

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 251 of file engine_gui.cpp.

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

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

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

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

sort of the engine list

Parameters:

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

Definition at line 280 of file engine_gui.cpp.

References SmallVector< T, S >::Begin(), SmallVector< T, S >::Length(), and QSortT().

Referenced by ReplaceVehicleWindow::GenerateReplaceVehList().

void EngList_SortPartial | ( | GUIEngineList * | el,
|  | EngList_SortTypeFunction | compare,
|  | uint | begin,
|  | uint | num_items |
| ) |  |  |

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

sort of specified portion of the engine list

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 295 of file engine_gui.cpp.

References SmallVector< T, S >::Get(), and QSortT().

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 31 of file engine_gui.cpp.

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

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

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 221 of file engine_gui.cpp.

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

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

## Variable Documentation

const NWidgetPart _nested_engine_preview_widgets[]`[static]`

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(WWT_EMPTY, INVALID_COLOUR, EPW_QUESTION), SetMinimalSize(300, 0), SetPadding(8, 8, 8, 8), SetFill(1, 0),
        NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(85, 10, 85),
          NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, EPW_NO), SetDataTip(STR_QUIT_NO, STR_NULL), SetFill(1, 0),
          NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, EPW_YES), SetDataTip(STR_QUIT_YES, STR_NULL), SetFill(1, 0),
        EndContainer(),
        NWidget(NWID_SPACER), SetMinimalSize(0, 8),
      EndContainer(),
    }

Definition at line 51 of file engine_gui.cpp.