OpenTTD Source: src/engine_gui.cpp Source File

OpenTTD Source 14.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
40 StringID GetEngineCategoryName(EngineID engine)
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 constexpr NWidgetPart _nested_engine_preview_widgets[] = {
55 NWidget(NWID_HORIZONTAL),
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(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.modalpopup),
61 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_EP_QUESTION), SetMinimalSize(300, 0), SetFill(1, 0),
62 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(85, WidgetDimensions::unscaled.hsep_wide, 85),
63 NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_EP_NO), SetDataTip(STR_QUIT_NO, STR_NULL), SetFill(1, 0),
64 NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_EP_YES), SetDataTip(STR_QUIT_YES, STR_NULL), SetFill(1, 0),
65 EndContainer(),
66 EndContainer(),
67 EndContainer(),
68 };
69
70 struct EnginePreviewWindow : Window {
71 int vehicle_space; // The space to show the vehicle image
72
73 EnginePreviewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
74 {
75 this->InitNested(window_number);
76
77 /* There is no way to recover the window; so disallow closure via DEL; unless SHIFT+DEL */
78 this->flags |= WF_STICKY;
79 }
80
81 void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
82 {
83 if (widget != WID_EP_QUESTION) return;
84
85 /* Get size of engine sprite, on loan from depot_gui.cpp */
86 EngineID engine = this->window_number;
87 EngineImageType image_type = EIT_PURCHASE;
88 uint x, y;
89 int x_offs, y_offs;
90
91 const Engine *e = Engine::Get(engine);
92 switch (e->type) {
93 default: NOT_REACHED();
94 case VEH_TRAIN: GetTrainSpriteSize( engine, x, y, x_offs, y_offs, image_type); break;
95 case VEH_ROAD: GetRoadVehSpriteSize( engine, x, y, x_offs, y_offs, image_type); break;
96 case VEH_SHIP: GetShipSpriteSize( engine, x, y, x_offs, y_offs, image_type); break;
97 case VEH_AIRCRAFT: GetAircraftSpriteSize(engine, x, y, x_offs, y_offs, image_type); break;
98 }
99 this->vehicle_space = std::max<int>(ScaleSpriteTrad(40), y - y_offs);
100
101 size->width = std::max(size->width, x + std::abs(x_offs));
102 SetDParam(0, GetEngineCategoryName(engine));
103 size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space;
104 SetDParam(0, engine);
105 size->height += GetStringHeight(GetEngineInfoString(engine), size->width);
106 }
107
108 void DrawWidget(const Rect &r, WidgetID widget) const override
109 {
110 if (widget != WID_EP_QUESTION) return;
111
112 EngineID engine = this->window_number;
113 SetDParam(0, GetEngineCategoryName(engine));
114 int y = DrawStringMultiLine(r, STR_ENGINE_PREVIEW_MESSAGE, TC_FROMSTRING, SA_HOR_CENTER | SA_TOP) + WidgetDimensions::scaled.vsep_wide;
115
116 SetDParam(0, PackEngineNameDParam(engine, EngineNameContext::PreviewNews));
117 DrawString(r.left, r.right, y, STR_ENGINE_NAME, TC_BLACK, SA_HOR_CENTER);
118 y += GetCharacterHeight(FS_NORMAL);
119
120 DrawVehicleEngine(r.left, r.right, this->width >> 1, y + this->vehicle_space / 2, engine, GetEnginePalette(engine, _local_company), EIT_PREVIEW);
121
122 y += this->vehicle_space;
123 DrawStringMultiLine(r.left, r.right, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER);
124 }
125
126 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
127 {
128 switch (widget) {
129 case WID_EP_YES:
130 Command<CMD_WANT_ENGINE_PREVIEW>::Post(this->window_number);
131 [[fallthrough]];
132 case WID_EP_NO:
133 if (!_shift_pressed) this->Close();
134 break;
135 }
136 }
137
138 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
139 {
140 if (!gui_scope) return;
141
142 EngineID engine = this->window_number;
143 if (Engine::Get(engine)->preview_company != _local_company) this->Close();
144 }
145 };
146
147 static WindowDesc _engine_preview_desc(__FILE__, __LINE__,
148 WDP_CENTER, nullptr, 0, 0,
149 WC_ENGINE_PREVIEW, WC_NONE,
150 WDF_CONSTRUCTION,
151 std::begin(_nested_engine_preview_widgets), std::end(_nested_engine_preview_widgets)
152 );
153
154
155 void ShowEnginePreviewWindow(EngineID engine)
156 {
157 AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
158 }
159
165 uint GetTotalCapacityOfArticulatedParts(EngineID engine)
166 {
167 CargoArray cap = GetCapacityOfArticulatedParts(engine);
168 return cap.GetSum<uint>();
169 }
170
171 static StringID GetTrainEngineInfoString(const Engine *e)
172 {
173 SetDParam(0, STR_ENGINE_PREVIEW_COST_WEIGHT);
174 SetDParam(1, e->GetCost());
175 SetDParam(2, e->GetDisplayWeight());
176
177 SetDParam(3, (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && GetRailTypeInfo(e->u.rail.railtype)->acceleration_type != 2) ? STR_ENGINE_PREVIEW_SPEED_POWER_MAX_TE : STR_ENGINE_PREVIEW_SPEED_POWER);
178 SetDParam(4, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
179 SetDParam(5, e->GetPower());
180 SetDParam(6, e->GetDisplayMaxTractiveEffort());
181
182 SetDParam(7, TimerGameEconomy::UsingWallclockUnits() ? STR_ENGINE_PREVIEW_RUNCOST_PERIOD : STR_ENGINE_PREVIEW_RUNCOST_YEAR);
183 SetDParam(8, e->GetRunningCost());
184
185 SetDParam(9, STR_ENGINE_PREVIEW_CAPACITY);
186 uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
187 SetDParam(10, capacity != 0 ? e->GetDefaultCargoType() : INVALID_CARGO);
188 SetDParam(11, capacity);
189
190 return STR_ENGINE_PREVIEW_TEXT4;
191 }
192
193 static StringID GetAircraftEngineInfoString(const Engine *e)
194 {
195 CargoID cargo = e->GetDefaultCargoType();
196 uint16_t mail_capacity;
197 uint capacity = e->GetDisplayDefaultCapacity(&mail_capacity);
198 uint16_t range = e->GetRange();
199
200 SetDParam(0, STR_ENGINE_PREVIEW_COST_MAX_SPEED);
201 SetDParam(1, e->GetCost());
202 SetDParam(2, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
203
204 SetDParam(3, range > 0 ? STR_ENGINE_PREVIEW_TYPE_RANGE : STR_ENGINE_PREVIEW_TYPE);
205 SetDParam(4, e->GetAircraftTypeText());
206 SetDParam(5, range);
207
208 SetDParam(7, TimerGameEconomy::UsingWallclockUnits() ? STR_ENGINE_PREVIEW_RUNCOST_PERIOD : STR_ENGINE_PREVIEW_RUNCOST_YEAR);
209 SetDParam(8, e->GetRunningCost());
210
211 SetDParam(9, mail_capacity > 0 ? STR_ENGINE_PREVIEW_CAPACITY_2 : STR_ENGINE_PREVIEW_CAPACITY);
212 SetDParam(10, cargo);
213 SetDParam(11, capacity);
214 SetDParam(12, GetCargoIDByLabel(CT_MAIL));
215 SetDParam(13, mail_capacity);
216
217 return STR_ENGINE_PREVIEW_TEXT4;
218 }
219
220 static StringID GetRoadVehEngineInfoString(const Engine *e)
221 {
222 SetDParam(7, TimerGameEconomy::UsingWallclockUnits() ? STR_ENGINE_PREVIEW_RUNCOST_PERIOD : STR_ENGINE_PREVIEW_RUNCOST_YEAR);
223 SetDParam(8, e->GetRunningCost());
224
225 SetDParam(9, STR_ENGINE_PREVIEW_CAPACITY);
226 uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
227 SetDParam(10, capacity != 0 ? e->GetDefaultCargoType() : INVALID_CARGO);
228 SetDParam(11, capacity);
229
230 if (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) {
231 SetDParam(0, STR_ENGINE_PREVIEW_COST_MAX_SPEED);
232 SetDParam(1, e->GetCost());
233 SetDParam(2, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
234
235 return STR_ENGINE_PREVIEW_TEXT3;
236 } else {
237 SetDParam(0, STR_ENGINE_PREVIEW_COST_WEIGHT);
238 SetDParam(1, e->GetCost());
239 SetDParam(2, e->GetDisplayWeight());
240
241 SetDParam(3, STR_ENGINE_PREVIEW_SPEED_POWER_MAX_TE);
242 SetDParam(4, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
243 SetDParam(5, e->GetPower());
244 SetDParam(6, e->GetDisplayMaxTractiveEffort());
245
246 return STR_ENGINE_PREVIEW_TEXT4;
247 }
248 }
249
250 static StringID GetShipEngineInfoString(const Engine *e)
251 {
252 SetDParam(0, STR_ENGINE_PREVIEW_COST_MAX_SPEED);
253 SetDParam(1, e->GetCost());
254 SetDParam(2, PackVelocity(e->GetDisplayMaxSpeed(), e->type));
255
256 SetDParam(7, TimerGameEconomy::UsingWallclockUnits() ? STR_ENGINE_PREVIEW_RUNCOST_PERIOD : STR_ENGINE_PREVIEW_RUNCOST_YEAR);
257 SetDParam(8, e->GetRunningCost());
258
259 SetDParam(9, STR_ENGINE_PREVIEW_CAPACITY);
260 SetDParam(10, e->GetDefaultCargoType());
261 SetDParam(11, e->GetDisplayDefaultCapacity());
262
263 return STR_ENGINE_PREVIEW_TEXT3;
264 }
265
266
273 StringID GetEngineInfoString(EngineID engine)
274 {
275 const Engine *e = Engine::Get(engine);
276
277 switch (e->type) {
278 case VEH_TRAIN:
279 return GetTrainEngineInfoString(e);
280
281 case VEH_ROAD:
282 return GetRoadVehEngineInfoString(e);
283
284 case VEH_SHIP:
285 return GetShipEngineInfoString(e);
286
287 case VEH_AIRCRAFT:
288 return GetAircraftEngineInfoString(e);
289
290 default: NOT_REACHED();
291 }
292 }
293
303 void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
304 {
305 const Engine *e = Engine::Get(engine);
306
307 switch (e->type) {
308 case VEH_TRAIN:
309 DrawTrainEngine(left, right, preferred_x, y, engine, pal, image_type);
310 break;
311
312 case VEH_ROAD:
313 DrawRoadVehEngine(left, right, preferred_x, y, engine, pal, image_type);
314 break;
315
316 case VEH_SHIP:
317 DrawShipEngine(left, right, preferred_x, y, engine, pal, image_type);
318 break;
319
320 case VEH_AIRCRAFT:
321 DrawAircraftEngine(left, right, preferred_x, y, engine, pal, image_type);
322 break;
323
324 default: NOT_REACHED();
325 }
326 }
327
333 void EngList_Sort(GUIEngineList &el, EngList_SortTypeFunction compare)
334 {
335 if (el.size() < 2) return;
336 std::sort(el.begin(), el.end(), compare);
337 }
338
346 void EngList_SortPartial(GUIEngineList &el, EngList_SortTypeFunction compare, size_t begin, size_t num_items)
347 {
348 if (num_items < 2) return;
349 assert(begin < el.size());
350 assert(begin + num_items <= el.size());
351 std::sort(el.begin() + begin, el.begin() + begin + num_items, compare);
352 }
353
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:273
RoadTypeInfo::new_engine
StringID new_engine
Name of an engine for this type of road in the engine preview GUI.
Definition: road.h:108
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1143
CargoArray::GetSum
const T GetSum() const
Get the sum of all cargo amounts.
Definition: cargo_type.h:120
EIT_PREVIEW
@ EIT_PREVIEW
Vehicle drawn in preview window, news, ...
Definition: vehicle_type.h:91
EnginePreviewWindow
Definition: engine_gui.cpp:70
Pool::PoolItem<&_engine_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:339
train.h
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:197
GetRailTypeInfo
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:307
Engine::GetDisplayDefaultCapacity
uint GetDisplayDefaultCapacity(uint16_t *mail_capacity=nullptr) const
Determines the default cargo capacity of an engine for display purposes.
Definition: engine_base.h:116
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:63
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
RailTypeInfo::new_loco
StringID new_loco
Name of an engine for this type of rail in the engine preview GUI.
Definition: rail.h:181
GUIList< GUIEngineListItem, std::nullptr_t, CargoID >
WC_ENGINE_PREVIEW
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
Definition: window_type.h:595
GetCapacityOfArticulatedParts
CargoArray GetCapacityOfArticulatedParts(EngineID engine)
Get the capacity of the parts of a given engine.
Definition: articulated_vehicles.cpp:141
Engine::GetDisplayMaxTractiveEffort
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
Definition: engine.cpp:426
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:238
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
EIT_PURCHASE
@ EIT_PURCHASE
Vehicle drawn in purchase list, autoreplace gui, ...
Definition: vehicle_type.h:90
CargoArray
Class for storing amounts of cargo.
Definition: cargo_type.h:114
WF_STICKY
@ WF_STICKY
Window is made sticky by user.
Definition: window_gui.h:228
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1048
ship.h
Engine::GetRunningCost
Money GetRunningCost() const
Return how much the running costs of this engine are.
Definition: engine.cpp:281
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1153
GetEngineCategoryName
StringID GetEngineCategoryName(EngineID engine)
Return the category of an engine.
Definition: engine_gui.cpp:40
zoom_func.h
aircraft.h
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
TimerGameEconomy::UsingWallclockUnits
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Definition: timer_game_economy.cpp:97
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition: vehicle_type.h:85
Engine
Definition: engine_base.h:37
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
RailTypeInfo::strings
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
Engine::GetDefaultCargoType
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
Definition: engine_base.h:96
RoadVehicleInfo::roadtype
RoadType roadtype
Road type.
Definition: engine_type.h:128
PaletteID
uint32_t PaletteID
The number of the palette.
Definition: gfx_type.h:18
GetEnginePalette
PaletteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
Definition: vehicle.cpp:2135
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:121
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1757
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1040
engine_cmd.h
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
VehicleSettings::train_acceleration_model
uint8_t train_acceleration_model
realistic acceleration for trains
Definition: settings_type.h:517
window_gui.h
Engine::GetDisplayMaxSpeed
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
Definition: engine.cpp:358
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:510
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:1190
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:149
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
PreviewNews
@ PreviewNews
Name is shown in exclusive preview or newspaper.
Definition: engine_type.h:194
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:732
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
SA_TOP
@ SA_TOP
Top align the text.
Definition: gfx_type.h:343
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1747
PackEngineNameDParam
uint64_t PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32_t extra_data=0)
Combine an engine ID and a name context to an engine name dparam.
Definition: engine_type.h:199
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:110
WID_EP_NO
@ WID_EP_NO
No button.
Definition: engine_widget.h:16
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
Engine::GetDisplayWeight
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
Definition: engine.cpp:408
WID_EP_QUESTION
@ WID_EP_QUESTION
The container for the question.
Definition: engine_widget.h:15
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1260
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:50
safeguards.h
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:294
GetStringHeight
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:701
rail.h
_shift_pressed
bool _shift_pressed
Is Shift pressed?
Definition: gfx.cpp:38
road.h
settings_type.h
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
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:318
WID_EP_YES
@ WID_EP_YES
Yes button.
Definition: engine_widget.h:17
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:296
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:339
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
EngList_Sort
void EngList_Sort(GUIEngineList &el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
Definition: engine_gui.cpp:333
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
GetRoadTypeInfo
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:227
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
VehicleSettings::roadveh_acceleration_model
uint8_t roadveh_acceleration_model
realistic acceleration for road vehicles
Definition: settings_type.h:518
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:771
vehicle_func.h
engine_gui.h
strings_func.h
WidgetDimensions::vsep_wide
int vsep_wide
Wide vertical spacing.
Definition: window_gui.h:62
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:249
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:1222
abs
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:23
Engine::GetPower
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
Definition: engine.cpp:390
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:581
GetTotalCapacityOfArticulatedParts
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
Get the capacity of an engine with articulated parts.
Definition: engine_gui.cpp:165
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
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:172
ScaleSpriteTrad
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
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:346
RailVehicleInfo::railtype
RailType railtype
Railtype, mangled if elrail is disabled.
Definition: engine_type.h:46
PackVelocity
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
Definition: strings_func.h:74
RoadTypeInfo::strings
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
company_func.h
CommandHelper
Definition: command_func.h:93
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:348
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1099
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:654
engine_widget.h
engine_base.h
articulated_vehicles.h
GameSettings::vehicle
VehicleSettings vehicle
options for vehicles
Definition: settings_type.h:626
EngineID
uint16_t EngineID
Unique identification number of an engine.
Definition: engine_type.h:21
Window
Data structure for an opened window.
Definition: window_gui.h:267
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1164
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:75
RailTypeInfo::acceleration_type
uint8_t acceleration_type
Acceleration type of this rail type.
Definition: rail.h:226
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:142
Engine::GetAircraftTypeText
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
Definition: engine.cpp:467
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:303
Engine::type
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
Definition: engine_base.h:56
Engine::GetRange
uint16_t GetRange() const
Get the range of an aircraft type.
Definition: engine.cpp:453
EnginePreviewWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: engine_gui.cpp:138
roadveh.h