OpenTTD Source 20261112-master-gbcbec5e63f
train_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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "stdafx.h"
11#include "window_gui.h"
12#include "command_func.h"
13#include "train.h"
14#include "strings_func.h"
15#include "vehicle_func.h"
16#include "vehicle_gui.h"
17#include "zoom_func.h"
18#include "train_cmd.h"
19
20#include "table/strings.h"
21
22#include "safeguards.h"
23
30void CcBuildWagon(Commands, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray, TileIndex tile, EngineID, bool, CargoType, ClientID)
31{
32 if (result.Failed()) return;
33
34 /* find a locomotive in the depot. */
35 const Vehicle *found = nullptr;
36 /* The non-deterministic order returned from VehiclesOnTile() does not
37 * matter here as there must only be one locomotive for anything to happen. */
38 for (const Vehicle *v : VehiclesOnTile(tile)) {
39 if (v->type != VehicleType::Train) continue;
40
41 const Train *t = Train::From(v);
42 if (t->IsFrontEngine() && t->IsStoppedInDepot()) {
43 if (found != nullptr) return; // must be exactly one.
44 found = t;
45 }
46 }
47
48 /* if we found a loco, */
49 if (found != nullptr) {
50 found = found->Last();
51 /* put the new wagon at the end of the loco. */
52 Command<Commands::MoveRailVehicle>::Post(found->tile, new_veh_id, found->index, false);
53 InvalidateWindowClassesData(WindowClass::TrainList, 0);
54 }
55}
56
66static int HighlightDragPosition(int px, int max_width, int y, VehicleID selection, bool chain)
67{
68 bool rtl = _current_text_dir == TD_RTL;
69
70 assert(selection != VehicleID::Invalid());
71 int dragged_width = 0;
72 for (Train *t = Train::Get(selection); t != nullptr; t = chain ? t->Next() : (t->HasArticulatedPart() ? t->GetNextArticulatedPart() : nullptr)) {
73 dragged_width += t->GetDisplayImageWidth(nullptr);
74 }
75
76 int drag_hlight_left = rtl ? std::max(px - dragged_width + 1, 0) : px;
77 int drag_hlight_right = rtl ? px : std::min(px + dragged_width, max_width) - 1;
78 int drag_hlight_width = std::max(drag_hlight_right - drag_hlight_left + 1, 0);
79
80 if (drag_hlight_width > 0) {
81 int height = ScaleSpriteTrad(12);
82 int top = y - height / 2;
83 Rect r = {drag_hlight_left, top, drag_hlight_right, top + height - 1};
84 /* Sprite-scaling is used here as the area is from sprite size */
86 }
87
88 return drag_hlight_width;
89}
90
100void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
101{
102 bool rtl = _current_text_dir == TD_RTL;
103 Direction dir = rtl ? Direction::E : Direction::W;
104
105 DrawPixelInfo tmp_dpi;
106 /* Position of highlight box */
107 int highlight_l = 0;
108 int highlight_r = 0;
109 int max_width = r.Width();
110
111 if (!FillDrawPixelInfo(&tmp_dpi, r)) return;
112
113 {
114 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
115
116 bool do_overlays = ShowCargoIconOverlay();
117 /* List of overlays, only used if cargo icon overlays are enabled. */
118 static std::vector<CargoIconOverlay> overlays;
119
120 int px = rtl ? max_width + skip : -skip;
121 int y = r.Height() / 2;
122 bool sel_articulated = false;
123 bool dragging = (drag_dest != VehicleID::Invalid());
124 bool drag_at_end_of_train = (drag_dest == v->index); // Head index is used to mark dragging at end of train.
125 for (; v != nullptr && (rtl ? px > 0 : px < max_width); v = v->Next()) {
126 if (dragging && !drag_at_end_of_train && drag_dest == v->index) {
127 /* Highlight the drag-and-drop destination inside the train. */
128 int drag_hlight_width = HighlightDragPosition(px, max_width, y, selection, _cursor.vehchain);
129 px += rtl ? -drag_hlight_width : drag_hlight_width;
130 }
131
132 Point offset;
133 int width = Train::From(v)->GetDisplayImageWidth(&offset);
134
135 if (rtl ? px + width > 0 : px - width < max_width) {
138 v->GetImage(dir, image_type, &seq);
139 seq.Draw(px + (rtl ? -offset.x : offset.x), y + offset.y, pal, v->vehstatus.Test(VehState::Crashed));
140 }
141
142 if (!v->IsArticulatedPart()) sel_articulated = false;
143
144 if (v->index == selection) {
145 /* Set the highlight position */
146 highlight_l = rtl ? px - width : px;
147 highlight_r = rtl ? px - 1 : px + width - 1;
148 sel_articulated = true;
149 } else if ((_cursor.vehchain && highlight_r != 0) || sel_articulated) {
150 if (rtl) {
151 highlight_l -= width;
152 } else {
153 highlight_r += width;
154 }
155 }
156
157 if (do_overlays) AddCargoIconOverlay(overlays, px, width, v);
158 px += rtl ? -width : width;
159 }
160
161 if (do_overlays) {
162 DrawCargoIconOverlays(overlays, y);
163 overlays.clear();
164 }
165
166 if (dragging && drag_at_end_of_train) {
167 /* Highlight the drag-and-drop destination at the end of the train. */
168 HighlightDragPosition(px, max_width, y, selection, _cursor.vehchain);
169 }
170 }
171
172 if (highlight_l != highlight_r) {
173 /* Draw the highlight. Now done after drawing all the engines, as
174 * the next engine after the highlight could overlap it. */
175 int height = ScaleSpriteTrad(12);
176 Rect hr = {highlight_l, 0, highlight_r, height - 1};
178 }
179}
180
185 uint capacity;
186 uint amount;
187 StationID source;
188
194 inline bool operator == (const CargoSummaryItem &other) const
195 {
196 return !(this->cargo != other.cargo);
197 }
198};
199
200static const uint TRAIN_DETAILS_MIN_INDENT = 32;
201static const uint TRAIN_DETAILS_MAX_INDENT = 72;
202
204typedef std::vector<CargoSummaryItem> CargoSummary;
207
216static void TrainDetailsCargoTab(const CargoSummaryItem *item, int left, int right, int y)
217{
218 std::string str;
219 if (!IsValidCargoType(item->cargo)) {
220 str = GetString(STR_QUANTITY_N_A);
221 } else if (item->amount == 0) {
222 str = GetString(STR_VEHICLE_DETAILS_TRAIN_CARGO_EMPTY, item->cargo, item->capacity, item->subtype);
223 } else {
224 str = GetString(STR_VEHICLE_DETAILS_TRAIN_CARGO_FROM, item->cargo, item->amount, item->cargo, item->capacity, item->source, item->subtype);
225 }
226 DrawString(left, right, y, str, TextColour::LightBlue);
227}
228
237static void TrainDetailsInfoTab(const Vehicle *v, int left, int right, int y)
238{
239 std::string str;
240 if (RailVehInfo(v->engine_type)->railveh_type == RailVehicleType::Wagon) {
241 str = GetString(STR_VEHICLE_DETAILS_TRAIN_WAGON_VALUE, PackEngineNameDParam(v->engine_type, EngineNameContext::VehicleDetails), v->value);
242 } else {
243 str = GetString(STR_VEHICLE_DETAILS_TRAIN_ENGINE_BUILT_AND_VALUE, PackEngineNameDParam(v->engine_type, EngineNameContext::VehicleDetails), v->build_year, v->value);
244 }
245 DrawString(left, right, y, str);
246}
247
254{
255 summary.clear();
256 do {
257 if (!v->GetEngine()->CanCarryCargo()) continue;
258
259 CargoSummaryItem new_item;
260 new_item.cargo = v->cargo_cap > 0 ? v->cargo_type : INVALID_CARGO;
261 new_item.subtype = GetCargoSubtypeText(v);
262 if (!IsValidCargoType(new_item.cargo) && new_item.subtype == STR_EMPTY) continue;
263
264 auto item = std::ranges::find(summary, new_item);
265 if (item == std::end(summary)) {
266 item = summary.emplace(std::end(summary));
267 item->cargo = new_item.cargo;
268 item->subtype = new_item.subtype;
269 item->capacity = 0;
270 item->amount = 0;
271 item->source = StationID::Invalid();
272 }
273
274 item->capacity += v->cargo_cap;
275 item->amount += v->cargo.StoredCount();
276 if (item->source == StationID::Invalid()) item->source = v->cargo.GetFirstStation();
277 } while ((v = v->Next()) != nullptr && v->IsArticulatedPart());
278}
279
286{
287 uint length = 0;
288
289 do {
290 length += v->GetDisplayImageWidth();
291 } while ((v = v->Next()) != nullptr && v->IsArticulatedPart());
292
293 return length;
294}
295
303{
304 int num = 0;
305
306 if (det_tab == TDW_TAB_TOTALS) { // Total cargo tab
307 CargoArray max_cargo{};
308 for (const Vehicle *v = Vehicle::Get(veh_id); v != nullptr; v = v->Next()) {
309 max_cargo[v->cargo_type] += v->cargo_cap;
310 }
311
312 num = max_cargo.GetCount();
313 num += 2; // needs two more because the first line is the description string and the last is the feeder share
314 } else {
315 for (const Train *v = Train::Get(veh_id); v != nullptr; v = v->GetNextVehicle()) {
317 num += std::max(1u, (unsigned)_cargo_summary.size());
318
319 uint length = GetLengthOfArticulatedVehicle(v);
320 if (length > (uint)ScaleSpriteTrad(TRAIN_DETAILS_MAX_INDENT)) num++;
321 }
322 }
323
324 return num;
325}
326
336void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16_t vscroll_cap, TrainDetailsWindowTabs det_tab)
337{
338 bool rtl = _current_text_dir == TD_RTL;
339 int line_height = r.Height();
340 int sprite_y_offset = line_height / 2;
341 int text_y_offset = (line_height - GetCharacterHeight(FontSize::Normal)) / 2;
342
343 /* draw the first 3 details tabs */
344 if (det_tab != TDW_TAB_TOTALS) {
345 Direction dir = rtl ? Direction::E : Direction::W;
346 int x = rtl ? r.right : r.left;
347 for (; v != nullptr && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
349
350 /* Draw sprites */
351 uint dx = 0;
352 int px = x;
353 const Train *u = v;
354 do {
355 Point offset;
356 int width = u->GetDisplayImageWidth(&offset);
357 if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
358 int pitch = 0;
359 const Engine *e = Engine::Get(v->engine_type);
360 if (e->GetGRF() != nullptr) {
362 }
366 seq.Draw(px + (rtl ? -offset.x : offset.x), r.top - line_height * vscroll_pos + sprite_y_offset + pitch, pal, v->vehstatus.Test(VehState::Crashed));
367 }
368 px += rtl ? -width : width;
369 dx += width;
370 u = u->Next();
371 } while (u != nullptr && u->IsArticulatedPart());
372
373 bool separate_sprite_row = (dx > (uint)ScaleSpriteTrad(TRAIN_DETAILS_MAX_INDENT));
374 if (separate_sprite_row) {
375 vscroll_pos--;
376 dx = 0;
377 }
378
379 int sprite_width = std::max<int>(dx, ScaleSpriteTrad(TRAIN_DETAILS_MIN_INDENT)) + WidgetDimensions::scaled.hsep_normal;
380 Rect dr = r.Indent(sprite_width, rtl);
381 uint num_lines = std::max(1u, (unsigned)_cargo_summary.size());
382 for (uint i = 0; i < num_lines; i++) {
383 if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
384 int py = r.top - line_height * vscroll_pos + text_y_offset;
385 if (i > 0 || separate_sprite_row) {
386 if (vscroll_pos != 0) GfxFillRect(r.WithY(py - WidgetDimensions::scaled.matrix.top - 1, py - WidgetDimensions::scaled.matrix.top), GetColourGradient(Colours::Grey, Shade::Light));
387 }
388 switch (det_tab) {
389 case TDW_TAB_CARGO:
390 if (i < _cargo_summary.size()) {
391 TrainDetailsCargoTab(&_cargo_summary[i], dr.left, dr.right, py);
392 } else {
393 DrawString(dr.left, dr.right, py, STR_QUANTITY_N_A, TextColour::LightBlue);
394 }
395 break;
396
397 case TDW_TAB_INFO:
398 if (i == 0) TrainDetailsInfoTab(v, dr.left, dr.right, py);
399 break;
400
401 default: NOT_REACHED();
402 }
403 }
404 vscroll_pos--;
405 }
406 }
407 } else {
408 /* Draw Totals tab. */
409 int y = r.top;
410 CargoArray act_cargo{};
411 CargoArray max_cargo{};
412 Money feeder_share = 0;
413
414 for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
415 act_cargo[u->cargo_type] += u->cargo.StoredCount();
416 max_cargo[u->cargo_type] += u->cargo_cap;
417 feeder_share += u->cargo.GetFeederShare();
418 }
419
420 /* Draw the total vehicle length. */
421 uint train_length = CeilDiv(v->gcache.cached_total_length * 10, TILE_SIZE);
422 std::string str = GetString(STR_VEHICLE_DETAILS_TRAIN_LENGTH, train_length, /* digits for DECIMAL */ 1);
423 DrawString(r.left, r.right, y + text_y_offset, str);
424 y += line_height;
425
426 /* Draw the header for the total capacity. */
427 DrawString(r.left, r.right, y + text_y_offset, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_TEXT);
428 y += line_height;
429
430 /* Indent the total cargo capacity details */
431 Rect ir = r.Indent(WidgetDimensions::scaled.hsep_indent, rtl);
432 for (const CargoSpec *cs : _sorted_cargo_specs) {
433 CargoType cargo_type = cs->Index();
434 if (max_cargo[cargo_type] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
435 std::string str;
436 str = GetString(STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY, cargo_type, act_cargo[cargo_type], cargo_type, max_cargo[cargo_type]);
437 DrawString(ir.left, ir.right, y + text_y_offset, str);
438 y += line_height;
439 }
440 }
441 DrawString(r.left, r.right, y + text_y_offset, GetString(STR_VEHICLE_INFO_FEEDER_CARGO_VALUE, feeder_share));
442 }
443}
static constexpr CargoType INVALID_CARGO
Invalid marker for cargoes.
Definition cargo_type.h:83
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
Definition cargo_type.h:112
CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Common return value for all commands.
bool Failed() const
Did this command fail?
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
bool CanCarryCargo() const
Determines whether an engine can carry something.
Definition engine.cpp:196
StationID GetFirstStation() const
Returns the first station of the first cargo packet in this list.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
Iterate over all vehicles on a tile.
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
Functions related to commands.
Commands
List of commands.
Direction
Defines the 8 directions on the map.
PoolID< uint16_t, struct EngineIDTag, 64000, 0xFFFF > EngineID
Unique identification number of an engine.
Definition engine_type.h:25
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 StringParameter.
@ VehicleDetails
Name is shown in the vehicle details GUI.
@ Wagon
simple wagon, not motorized
Definition engine_type.h:33
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:88
int CentreBounds(int min, int max, int size)
Determine where to position a centred object.
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition gfx.cpp:111
int DrawString(int left, int right, int top, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:663
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition gfx.cpp:1567
@ Normal
Index of the normal font in the font tables.
Definition gfx_type.h:249
uint32_t PaletteID
The number of the palette.
Definition gfx_type.h:18
@ White
White.
Definition gfx_type.h:300
@ Grey
Grey.
Definition gfx_type.h:299
@ LightBlue
Light blue colour.
Definition gfx_type.h:331
#define Rect
Macro that prevents name conflicts between included headers.
#define Point
Macro that prevents name conflicts between included headers.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
ClientID
'Unique' identifier to be given to clients
PixelColour GetColourGradient(Colours colour, Shade shade)
Get colour gradient palette index.
Definition palette.cpp:393
@ Lightest
Lightest colour shade.
@ Light
Light colour shade.
A number of safeguards to prevent using unsafe methods.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
Definition sprites.h:1794
Definition of base types and functions in a cross-platform compatible way.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:423
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:55
Functions related to OTTD's strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Class for storing amounts of cargo.
Definition cargo_type.h:120
uint GetCount() const
Get the amount of cargos that have an amount.
Definition cargo_type.h:135
Specification of a cargo type.
Definition cargotype.h:76
Helper struct for the cargo details information.
StringID subtype
STR_EMPTY if none.
bool operator==(const CargoSummaryItem &other) const
Used by std::find() and similar functions.
uint amount
Amount that is carried.
uint capacity
Amount that can be carried.
StationID source
One of the source stations.
CargoType cargo
The cargo that is carried.
T y
Y coordinate.
T x
X coordinate.
Data about how and where to blit pixels.
Definition gfx_type.h:157
int traininfo_vehicle_pitch
Vertical offset for drawing train images in depot GUI and vehicle details.
Definition newgrf.h:166
uint16_t cached_total_length
Length of the whole vehicle (valid only for the first engine).
GroundVehicleCache gcache
Cache of often calculated values.
static Vehicle * Get(auto index)
int Width() const
Get width of Rect.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
int Height() const
Get height of Rect.
Rect WithY(int new_top, int new_bottom) const
Create a new Rect, replacing the top and bottom coordinates.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
Rect Expand(int s) const
Copy and expand Rect by s pixels.
T * Next() const
Get next vehicle in the chain.
static Train * From(Vehicle *v)
T * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
'Train' is either a loco or a wagon.
Definition train.h:97
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const override
Get the sprite to display the train.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
Sprite sequence for a vehicle part.
void Draw(int x, int y, PaletteID default_pal, bool force_pal) const
Draw the sprite sequence.
Definition vehicle.cpp:153
Vehicle data structure.
EngineID engine_type
The type of engine used for this vehicle.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
Definition vehicle.cpp:750
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
VehicleCargoList cargo
The cargo this vehicle is carrying.
uint16_t cargo_cap
total capacity
VehStates vehstatus
Status.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
CargoType cargo_type
type of cargo this vehicle is carrying
Money value
Value of the vehicle.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
Vehicle * Last() const
Get the last vehicle of this vehicle chain.
TileIndex tile
Current tile index.
TimerGameCalendar::Year build_year
Year the vehicle has been built.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
static constexpr uint TILE_SIZE
Tile size in world coordinates.
Definition tile_type.h:15
Base for the train class.
Command definitions related to trains.
void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
Draws an image of a whole train.
static int HighlightDragPosition(int px, int max_width, int y, VehicleID selection, bool chain)
Highlight the position where a rail vehicle is dragged over by drawing a light gray background.
Definition train_gui.cpp:66
static void TrainDetailsInfoTab(const Vehicle *v, int left, int right, int y)
Draw the details info tab for the given vehicle at the given position.
static uint GetLengthOfArticulatedVehicle(const Train *v)
Get the length of an articulated vehicle.
void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16_t vscroll_cap, TrainDetailsWindowTabs det_tab)
Draw the details for the given vehicle at the given position.
static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary &summary)
Collects the cargo transported.
static const uint TRAIN_DETAILS_MAX_INDENT
Maximum indent level in the train details window; wider than this and we start on a new line.
std::vector< CargoSummaryItem > CargoSummary
Container for the cargo summary information.
int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
Determines the number of lines in the train details window.
void CcBuildWagon(Commands, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray, TileIndex tile, EngineID, bool, CargoType, ClientID)
Callback for building wagons.
Definition train_gui.cpp:30
static CargoSummary _cargo_summary
Reused container of cargo details.
static const uint TRAIN_DETAILS_MIN_INDENT
Minimum indent level in the train details window.
static void TrainDetailsCargoTab(const CargoSummaryItem *item, int left, int right, int y)
Draw the details cargo tab for the given vehicle at the given position.
PaletteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
Definition vehicle.cpp:2179
@ Crashed
Vehicle is crashed.
Functions related to vehicles.
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
void DrawCargoIconOverlays(std::span< const CargoIconOverlay > overlays, int y)
Draw a list of cargo icon overlays.
void AddCargoIconOverlay(std::vector< CargoIconOverlay > &overlays, int x, int width, const Vehicle *v)
Add a cargo icon to the list of overlays.
bool ShowCargoIconOverlay()
Test if cargo icon overlays should be drawn.
Functions related to the vehicle's GUIs.
TrainDetailsWindowTabs
The tabs in the train details window.
Definition vehicle_gui.h:25
@ TDW_TAB_TOTALS
Tab with sum of total cargo transported.
Definition vehicle_gui.h:28
@ TDW_TAB_INFO
Tab with name and value of the vehicles.
Definition vehicle_gui.h:27
@ TDW_TAB_CARGO
Tab with cargo carried by the vehicles.
Definition vehicle_gui.h:26
EngineImageType
Visualisation contexts of vehicles and engines.
@ InDetails
Vehicle drawn in vehicle details, refit window, ...
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
@ Train
Train vehicle type.
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition widget.cpp:308
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition window.cpp:3395
Functions, definitions and such used only by the GUI.
@ BorderOnly
Draw border only, no background.
Definition window_gui.h:25
Functions related to zooming.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition zoom_func.h:107