OpenTTD Source  1.11.0-beta2
engine_gui.cpp File Reference
#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 "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. More...
 
void ShowEnginePreviewWindow (EngineID engine)
 
uint GetTotalCapacityOfArticulatedParts (EngineID engine)
 Get the capacity of an engine with articulated parts. More...
 
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. More...
 
void DrawVehicleEngine (int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 Draw an engine. More...
 
void EngList_Sort (GUIEngineList *el, EngList_SortTypeFunction compare)
 Sort all items using quick sort and given 'CompareItems' function. More...
 
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>) More...
 

Variables

static const NWidgetPart _nested_engine_preview_widgets []
 
static WindowDesc _engine_preview_desc (WDP_CENTER, "engine_preview", 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.

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
leftMinimum horizontal position to use for drawing the engine
rightMaximum horizontal position to use for drawing the engine
preferred_xHorizontal position to use for drawing the engine.
yVertical position to use for drawing the engine.
engineEngine to draw.
palPalette to use for drawing.

Definition at line 296 of file engine_gui.cpp.

◆ EngList_Sort()

void EngList_Sort ( GUIEngineList el,
EngList_SortTypeFunction  compare 
)

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

Parameters
ellist to be sorted
comparefunction for evaluation of the quicksort

Definition at line 326 of file engine_gui.cpp.

Referenced by ReplaceVehicleWindow::GenerateReplaceVehList().

◆ EngList_SortPartial()

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>)

Parameters
ellist to be sorted
comparefunction for evaluation of the quicksort
beginstart of sorting
num_itemscount of items to be sorted

Definition at line 339 of file engine_gui.cpp.

◆ GetEngineCategoryName()

StringID GetEngineCategoryName ( EngineID  engine)

Return the category of an engine.

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

Definition at line 38 of file engine_gui.cpp.

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

Referenced by EnginePreviewWindow::DrawWidget().

◆ GetEngineInfoString()

StringID GetEngineInfoString ( EngineID  engine)

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

Parameters
engineEngine to describe.
Returns
String describing the engine.
Postcondition
DParam array is set up for printing the string.

Definition at line 266 of file engine_gui.cpp.

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

◆ GetTotalCapacityOfArticulatedParts()

uint GetTotalCapacityOfArticulatedParts ( EngineID  engine)

Get the capacity of an engine with articulated parts.

Parameters
engineThe engine to get the capacity of.
Returns
The capacity.

Definition at line 163 of file engine_gui.cpp.

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

Referenced by RoadVehEngineCapacitySorter().

Variable Documentation

◆ _nested_engine_preview_widgets

const NWidgetPart _nested_engine_preview_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_ENGINE_PREVIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_EP_QUESTION), SetMinimalSize(300, 0), SetPadding(8, 8, 8, 8), SetFill(1, 0),
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),
}

Definition at line 52 of file engine_gui.cpp.

SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1045
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
WID_EP_YES
@ WID_EP_YES
Yes button.
Definition: engine_widget.h:17
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
WID_EP_QUESTION
@ WID_EP_QUESTION
The container for the question.
Definition: engine_widget.h:15
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1075
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
WID_EP_NO
@ WID_EP_NO
No button.
Definition: engine_widget.h:16