OpenTTD Source  13.2.1
engine_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "window_gui.h"
12 #include "engine_base.h"
13 #include "command_func.h"
14 #include "strings_func.h"
15 #include "engine_gui.h"
16 #include "articulated_vehicles.h"
17 #include "vehicle_func.h"
18 #include "company_func.h"
19 #include "rail.h"
20 #include "road.h"
21 #include "settings_type.h"
22 #include "train.h"
23 #include "roadveh.h"
24 #include "ship.h"
25 #include "aircraft.h"
26 #include "engine_cmd.h"
27 #include "zoom_func.h"
28 
29 #include "widgets/engine_widget.h"
30 
31 #include "table/strings.h"
32 
33 #include "safeguards.h"
34 
41 {
42  const Engine *e = Engine::Get(engine);
43  switch (e->type) {
44  default: NOT_REACHED();
45  case VEH_ROAD:
46  return GetRoadTypeInfo(e->u.road.roadtype)->strings.new_engine;
47  case VEH_AIRCRAFT: return STR_ENGINE_PREVIEW_AIRCRAFT;
48  case VEH_SHIP: return STR_ENGINE_PREVIEW_SHIP;
49  case VEH_TRAIN:
50  return GetRailTypeInfo(e->u.rail.railtype)->strings.new_loco;
51  }
52 }
53 
54 static const NWidgetPart _nested_engine_preview_widgets[] = {
56  NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
57  NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_ENGINE_PREVIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
58  EndContainer(),
59  NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE),
60  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_EP_QUESTION), SetMinimalSize(300, 0), SetPadding(8, 8, 8, 8), SetFill(1, 0),
62  NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_EP_NO), SetDataTip(STR_QUIT_NO, STR_NULL), SetFill(1, 0),
63  NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_EP_YES), SetDataTip(STR_QUIT_YES, STR_NULL), SetFill(1, 0),
64  EndContainer(),
66  EndContainer(),
67 };
68 
70  int vehicle_space; // The space to show the vehicle image
71 
73  {
74  this->InitNested(window_number);
75 
76  /* There is no way to recover the window; so disallow closure via DEL; unless SHIFT+DEL */
77  this->flags |= WF_STICKY;
78  }
79 
80  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
81  {
82  if (widget != WID_EP_QUESTION) return;
83 
84  /* Get size of engine sprite, on loan from depot_gui.cpp */
85  EngineID engine = this->window_number;
86  EngineImageType image_type = EIT_PURCHASE;
87  uint x, y;
88  int x_offs, y_offs;
89 
90  const Engine *e = Engine::Get(engine);
91  switch (e->type) {
92  default: NOT_REACHED();
93  case VEH_TRAIN: GetTrainSpriteSize( engine, x, y, x_offs, y_offs, image_type); break;
94  case VEH_ROAD: GetRoadVehSpriteSize( engine, x, y, x_offs, y_offs, image_type); break;
95  case VEH_SHIP: GetShipSpriteSize( engine, x, y, x_offs, y_offs, image_type); break;
96  case VEH_AIRCRAFT: GetAircraftSpriteSize(engine, x, y, x_offs, y_offs, image_type); break;
97  }
98  this->vehicle_space = std::max<int>(ScaleSpriteTrad(40), y - y_offs);
99 
100  size->width = std::max(size->width, x - x_offs);
101  SetDParam(0, GetEngineCategoryName(engine));
102  size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + FONT_HEIGHT_NORMAL + this->vehicle_space;
103  SetDParam(0, engine);
104  size->height += GetStringHeight(GetEngineInfoString(engine), size->width);
105  }
106 
107  void DrawWidget(const Rect &r, int widget) const override
108  {
109  if (widget != WID_EP_QUESTION) return;
110 
111  EngineID engine = this->window_number;
112  SetDParam(0, GetEngineCategoryName(engine));
113  int y = DrawStringMultiLine(r, STR_ENGINE_PREVIEW_MESSAGE, TC_FROMSTRING, SA_HOR_CENTER | SA_TOP) + WidgetDimensions::scaled.vsep_wide;
114 
116  DrawString(r.left, r.right, y, STR_ENGINE_NAME, TC_BLACK, SA_HOR_CENTER);
117  y += FONT_HEIGHT_NORMAL;
118 
119  DrawVehicleEngine(r.left, r.right, this->width >> 1, y + this->vehicle_space / 2, engine, GetEnginePalette(engine, _local_company), EIT_PREVIEW);
120 
121  y += this->vehicle_space;
122  DrawStringMultiLine(r.left, r.right, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER);
123  }
124 
125  void OnClick(Point pt, int widget, int click_count) override
126  {
127  switch (widget) {
128  case WID_EP_YES:
129  Command<CMD_WANT_ENGINE_PREVIEW>::Post(this->window_number);
130  FALLTHROUGH;
131  case WID_EP_NO:
132  if (!_shift_pressed) this->Close();
133  break;
134  }
135  }
136 
137  void OnInvalidateData(int data = 0, bool gui_scope = true) override
138  {
139  if (!gui_scope) return;
140 
141  EngineID engine = this->window_number;
142  if (Engine::Get(engine)->preview_company != _local_company) this->Close();
143  }
144 };
145 
146 static WindowDesc _engine_preview_desc(
147  WDP_CENTER, "engine_preview", 0, 0,
150  _nested_engine_preview_widgets, lengthof(_nested_engine_preview_widgets)
151 );
152 
153 
154 void ShowEnginePreviewWindow(EngineID engine)
155 {
156  AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
157 }
158 
165 {
167  return cap.GetSum<uint>();
168 }
169 
170 static StringID GetTrainEngineInfoString(const Engine *e)
171 {
172  SetDParam(0, e->GetCost());
173  SetDParam(2, e->GetDisplayMaxSpeed());
174  SetDParam(3, e->GetPower());
175  SetDParam(1, e->GetDisplayWeight());
177 
178  SetDParam(4, e->GetRunningCost());
179 
180  uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
181  if (capacity != 0) {
183  SetDParam(6, capacity);
184  } else {
185  SetDParam(5, CT_INVALID);
186  }
187  return (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && GetRailTypeInfo(e->u.rail.railtype)->acceleration_type != 2) ? STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE : STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER;
188 }
189 
190 static StringID GetAircraftEngineInfoString(const Engine *e)
191 {
192  CargoID cargo = e->GetDefaultCargoType();
193  uint16 mail_capacity;
194  uint capacity = e->GetDisplayDefaultCapacity(&mail_capacity);
195  uint16 range = e->GetRange();
196 
197  uint i = 0;
198  SetDParam(i++, e->GetCost());
199  SetDParam(i++, e->GetDisplayMaxSpeed());
200  SetDParam(i++, e->GetAircraftTypeText());
201  if (range > 0) SetDParam(i++, range);
202  SetDParam(i++, cargo);
203  SetDParam(i++, capacity);
204 
205  if (mail_capacity > 0) {
206  SetDParam(i++, CT_MAIL);
207  SetDParam(i++, mail_capacity);
208  SetDParam(i++, e->GetRunningCost());
209  return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_CAP_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_CAP_RUNCOST;
210  } else {
211  SetDParam(i++, e->GetRunningCost());
212  return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_RUNCOST;
213  }
214 }
215 
216 static StringID GetRoadVehEngineInfoString(const Engine *e)
217 {
219  SetDParam(0, e->GetCost());
220  SetDParam(1, e->GetDisplayMaxSpeed());
221  uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
222  if (capacity != 0) {
224  SetDParam(3, capacity);
225  } else {
226  SetDParam(2, CT_INVALID);
227  }
228  SetDParam(4, e->GetRunningCost());
229  return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
230  } else {
231  SetDParam(0, e->GetCost());
232  SetDParam(2, e->GetDisplayMaxSpeed());
233  SetDParam(3, e->GetPower());
234  SetDParam(1, e->GetDisplayWeight());
236 
237  SetDParam(4, e->GetRunningCost());
238 
239  uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
240  if (capacity != 0) {
242  SetDParam(6, capacity);
243  } else {
244  SetDParam(5, CT_INVALID);
245  }
246  return STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE;
247  }
248 }
249 
250 static StringID GetShipEngineInfoString(const Engine *e)
251 {
252  SetDParam(0, e->GetCost());
253  SetDParam(1, e->GetDisplayMaxSpeed());
256  SetDParam(4, e->GetRunningCost());
257  return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
258 }
259 
260 
268 {
269  const Engine *e = Engine::Get(engine);
270 
271  switch (e->type) {
272  case VEH_TRAIN:
273  return GetTrainEngineInfoString(e);
274 
275  case VEH_ROAD:
276  return GetRoadVehEngineInfoString(e);
277 
278  case VEH_SHIP:
279  return GetShipEngineInfoString(e);
280 
281  case VEH_AIRCRAFT:
282  return GetAircraftEngineInfoString(e);
283 
284  default: NOT_REACHED();
285  }
286 }
287 
297 void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
298 {
299  const Engine *e = Engine::Get(engine);
300 
301  switch (e->type) {
302  case VEH_TRAIN:
303  DrawTrainEngine(left, right, preferred_x, y, engine, pal, image_type);
304  break;
305 
306  case VEH_ROAD:
307  DrawRoadVehEngine(left, right, preferred_x, y, engine, pal, image_type);
308  break;
309 
310  case VEH_SHIP:
311  DrawShipEngine(left, right, preferred_x, y, engine, pal, image_type);
312  break;
313 
314  case VEH_AIRCRAFT:
315  DrawAircraftEngine(left, right, preferred_x, y, engine, pal, image_type);
316  break;
317 
318  default: NOT_REACHED();
319  }
320 }
321 
328 {
329  if (el->size() < 2) return;
330  std::sort(el->begin(), el->end(), compare);
331 }
332 
340 void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, size_t begin, size_t num_items)
341 {
342  if (num_items < 2) return;
343  assert(begin < el->size());
344  assert(begin + num_items <= el->size());
345  std::sort(el->begin() + begin, el->begin() + begin + num_items, compare);
346 }
347 
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
GetEngineInfoString
StringID GetEngineInfoString(EngineID engine)
Get a multi-line string with some technical data, describing the engine.
Definition: engine_gui.cpp:267
RoadTypeInfo::new_engine
StringID new_engine
Name of an engine for this type of road in the engine preview GUI.
Definition: road.h:106
Engine::GetDisplayDefaultCapacity
uint GetDisplayDefaultCapacity(uint16 *mail_capacity=nullptr) const
Determines the default cargo capacity of an engine for display purposes.
Definition: engine_base.h:115
EnginePreviewWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: engine_gui.cpp:137
CargoArray::GetSum
const T GetSum() const
Get the sum of all cargo amounts.
Definition: cargo_type.h:122
EIT_PREVIEW
@ EIT_PREVIEW
Vehicle drawn in preview window, news, ...
Definition: vehicle_type.h:92
EnginePreviewWindow
Definition: engine_gui.cpp:69
Pool::PoolItem<&_engine_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
VehicleSettings::train_acceleration_model
uint8 train_acceleration_model
realistic acceleration for trains
Definition: settings_type.h:489
train.h
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
PackEngineNameDParam
uint64 PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32 extra_data=0)
Combine an engine ID and a name context to an engine name dparam.
Definition: engine_type.h:196
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:1143
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:144
EngList_SortTypeFunction
bool EngList_SortTypeFunction(const GUIEngineListItem &, const GUIEngineListItem &)
argument type for EngList_Sort.
Definition: engine_gui.h:33
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
EnginePreviewWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: engine_gui.cpp:107
GUIList< GUIEngineListItem, CargoID >
WC_ENGINE_PREVIEW
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
Definition: window_type.h:582
GetCapacityOfArticulatedParts
CargoArray GetCapacityOfArticulatedParts(EngineID engine)
Get the capacity of the parts of a given engine.
Definition: articulated_vehicles.cpp:139
Engine::GetDisplayMaxTractiveEffort
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
Definition: engine.cpp:420
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
EIT_PURCHASE
@ EIT_PURCHASE
Vehicle drawn in purchase list, autoreplace gui, ...
Definition: vehicle_type.h:91
CargoArray
Class for storing amounts of cargo.
Definition: cargo_type.h:82
WF_STICKY
@ WF_STICKY
Window is made sticky by user.
Definition: window_gui.h:174
EnginePreviewWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: engine_gui.cpp:125
ship.h
Engine::GetRunningCost
Money GetRunningCost() const
Return how much the running costs of this engine are.
Definition: engine.cpp:275
GetEngineCategoryName
StringID GetEngineCategoryName(EngineID engine)
Return the category of an engine.
Definition: engine_gui.cpp:40
zoom_func.h
aircraft.h
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:644
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:713
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition: vehicle_type.h:86
Engine
Definition: engine_base.h:36
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Engine::GetDefaultCargoType
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
Definition: engine_base.h:95
RoadVehicleInfo::roadtype
RoadType roadtype
Road type.
Definition: engine_type.h:127
GetEnginePalette
PaletteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
Definition: vehicle.cpp:2052
GetShipSpriteSize
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a ship sprite heading west (used for lists).
Definition: ship_cmd.cpp:114
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1814
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
engine_cmd.h
WID_EP_YES
@ WID_EP_YES
Yes button.
Definition: engine_widget.h:17
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:789
WindowDesc
High level window description.
Definition: window_gui.h:102
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
window_gui.h
Engine::GetDisplayMaxSpeed
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
Definition: engine.cpp:352
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:469
EngineID
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:21
DrawRoadVehEngine
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
Draw a road vehicle engine.
Definition: roadveh_cmd.cpp:147
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
SA_TOP
@ SA_TOP
Top align the text.
Definition: gfx_type.h:339
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1804
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
WID_EP_QUESTION
@ WID_EP_QUESTION
The container for the question.
Definition: engine_widget.h:15
ScaleSpriteTrad
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
Engine::GetDisplayWeight
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
Definition: engine.cpp:402
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
safeguards.h
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:239
rail.h
_shift_pressed
bool _shift_pressed
Is Shift pressed?
Definition: gfx.cpp:39
road.h
settings_type.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
Engine::GetCost
Money GetCost() const
Return how much a new engine costs.
Definition: engine.cpp:312
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:241
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:335
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:715
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
RailtypeInfo::acceleration_type
uint8 acceleration_type
Acceleration type of this rail type.
Definition: rail.h:223
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
vehicle_func.h
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
engine_gui.h
strings_func.h
GetAircraftSpriteSize
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of an aircraft sprite heading west (used for lists).
Definition: aircraft_cmd.cpp:247
VehicleSettings::roadveh_acceleration_model
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
Definition: settings_type.h:490
Engine::GetPower
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
Definition: engine.cpp:384
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
GetTrainSpriteSize
void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a train sprite heading west, or both heads (used for lists).
Definition: train_cmd.cpp:578
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
GetTotalCapacityOfArticulatedParts
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
Get the capacity of an engine with articulated parts.
Definition: engine_gui.cpp:164
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:18
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
GetRoadVehSpriteSize
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a road vehicle sprite heading west (used for lists).
Definition: roadveh_cmd.cpp:170
EngList_Sort
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
Definition: engine_gui.cpp:327
GetRoadTypeInfo
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:225
RailVehicleInfo::railtype
RailType railtype
Railtype, mangled if elrail is disabled.
Definition: engine_type.h:46
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
company_func.h
CommandHelper
Definition: command_func.h:94
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:344
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
RailtypeInfo::new_loco
StringID new_loco
Name of an engine for this type of rail in the engine preview GUI.
Definition: rail.h:178
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1191
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>)
Definition: engine_gui.cpp:340
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
engine_widget.h
engine_base.h
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
articulated_vehicles.h
GameSettings::vehicle
VehicleSettings vehicle
options for vehicles
Definition: settings_type.h:595
Window
Data structure for an opened window.
Definition: window_gui.h:213
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
RailtypeInfo::strings
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
Engine::GetRange
uint16 GetRange() const
Get the range of an aircraft type.
Definition: engine.cpp:447
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
EnginePreviewWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: engine_gui.cpp:80
CT_INVALID
@ CT_INVALID
Invalid cargo type.
Definition: cargo_type.h:69
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
WidgetDimensions::vsep_wide
int vsep_wide
Wide vertical spacing.
Definition: window_gui.h:62
WID_EP_NO
@ WID_EP_NO
No button.
Definition: engine_widget.h:16
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:91
Engine::GetAircraftTypeText
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
Definition: engine.cpp:461
DrawVehicleEngine
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
Draw an engine.
Definition: engine_gui.cpp:297
PreviewNews
@ PreviewNews
Name is shown in exclusive preview or newspaper.
Definition: engine_type.h:192
Engine::type
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
Definition: engine_base.h:55
RoadTypeInfo::strings
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
roadveh.h
Window::Close
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1107