OpenTTD

train_gui.cpp
Go to the documentation of this file.
1 /* $Id: train_gui.cpp 27936 2017-12-10 13:45:53Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #include "stdafx.h"
13 #include "window_gui.h"
14 #include "command_func.h"
15 #include "train.h"
16 #include "strings_func.h"
17 #include "vehicle_func.h"
18 #include "zoom_func.h"
19
20 #include "table/strings.h"
21
22 #include "safeguards.h"
23
31 void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
32 {
33 if (result.Failed()) return;
34
35 /* find a locomotive in the depot. */
36 const Vehicle *found = NULL;
37 const Train *t;
38 FOR_ALL_TRAINS(t) {
39 if (t->IsFrontEngine() && t->tile == tile && t->IsStoppedInDepot()) {
40 if (found != NULL) return; // must be exactly one.
41 found = t;
42 }
43 }
44
45 /* if we found a loco, */
46 if (found != NULL) {
47 found = found->Last();
48 /* put the new wagon at the end of the loco. */
49 DoCommandP(0, _new_vehicle_id, found->index, CMD_MOVE_RAIL_VEHICLE);
50 InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
51 }
52 }
53
62 static int HighlightDragPosition(int px, int max_width, VehicleID selection, bool chain)
63 {
64 bool rtl = _current_text_dir == TD_RTL;
65
66 assert(selection != INVALID_VEHICLE);
67 int dragged_width = 0;
68 for (Train *t = Train::Get(selection); t != NULL; t = chain ? t->Next() : (t->HasArticulatedPart() ? t->GetNextArticulatedPart() : NULL)) {
69 dragged_width += t->GetDisplayImageWidth(NULL);
70 }
71
72 int drag_hlight_left = rtl ? max(px - dragged_width + 1, 0) : px;
73 int drag_hlight_right = rtl ? px : min(px + dragged_width, max_width) - 1;
74 int drag_hlight_width = max(drag_hlight_right - drag_hlight_left + 1, 0);
75
76 if (drag_hlight_width > 0) {
77 GfxFillRect(drag_hlight_left + WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP + 1,
78 drag_hlight_right - WD_FRAMERECT_RIGHT, ScaleGUITrad(13) - WD_FRAMERECT_BOTTOM, _colour_gradient[COLOUR_GREY][7]);
79 }
80
81 return drag_hlight_width;
82 }
83
94 void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
95 {
96 bool rtl = _current_text_dir == TD_RTL;
97 Direction dir = rtl ? DIR_E : DIR_W;
98
99 DrawPixelInfo tmp_dpi, *old_dpi;
100 /* Position of highlight box */
101 int highlight_l = 0;
102 int highlight_r = 0;
103 int max_width = right - left + 1;
104 int height = ScaleGUITrad(14);
105
106 if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, height)) return;
107
108 old_dpi = _cur_dpi;
109 _cur_dpi = &tmp_dpi;
110
111 int px = rtl ? max_width + skip : -skip;
112 bool sel_articulated = false;
113 bool dragging = (drag_dest != INVALID_VEHICLE);
114 bool drag_at_end_of_train = (drag_dest == v->index); // Head index is used to mark dragging at end of train.
115 for (; v != NULL && (rtl ? px > 0 : px < max_width); v = v->Next()) {
116 if (dragging && !drag_at_end_of_train && drag_dest == v->index) {
117 /* Highlight the drag-and-drop destination inside the train. */
118 int drag_hlight_width = HighlightDragPosition(px, max_width, selection, _cursor.vehchain);
119 px += rtl ? -drag_hlight_width : drag_hlight_width;
120 }
121
122 Point offset;
123 int width = Train::From(v)->GetDisplayImageWidth(&offset);
124
125 if (rtl ? px + width > 0 : px - width < max_width) {
126 PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
127 VehicleSpriteSeq seq;
128 v->GetImage(dir, image_type, &seq);
129 seq.Draw(px + (rtl ? -offset.x : offset.x), height / 2 + offset.y, pal, (v->vehstatus & VS_CRASHED) != 0);
130 }
131
132 if (!v->IsArticulatedPart()) sel_articulated = false;
133
134 if (v->index == selection) {
135 /* Set the highlight position */
136 highlight_l = rtl ? px - width : px;
137 highlight_r = rtl ? px - 1 : px + width - 1;
138 sel_articulated = true;
139 } else if ((_cursor.vehchain && highlight_r != 0) || sel_articulated) {
140 if (rtl) {
141 highlight_l -= width;
142 } else {
143 highlight_r += width;
144 }
145 }
146
147 px += rtl ? -width : width;
148 }
149
150 if (dragging && drag_at_end_of_train) {
151 /* Highlight the drag-and-drop destination at the end of the train. */
152 HighlightDragPosition(px, max_width, selection, _cursor.vehchain);
153 }
154
155 if (highlight_l != highlight_r) {
156 /* Draw the highlight. Now done after drawing all the engines, as
157 * the next engine after the highlight could overlap it. */
158 DrawFrameRect(highlight_l, 0, highlight_r, height - 1, COLOUR_WHITE, FR_BORDERONLY);
159 }
160
161 _cur_dpi = old_dpi;
162 }
163
165 struct CargoSummaryItem {
166 CargoID cargo;
167 StringID subtype;
168 uint capacity;
169 uint amount;
170 StationID source;
171
173 inline bool operator != (const CargoSummaryItem &other) const
174 {
175 return this->cargo != other.cargo || this->subtype != other.subtype;
176 }
177 };
178
179 static const uint TRAIN_DETAILS_MIN_INDENT = 32;
180 static const uint TRAIN_DETAILS_MAX_INDENT = 72;
181
183 typedef SmallVector<CargoSummaryItem, 2> CargoSummary;
185 static CargoSummary _cargo_summary;
186
195 static void TrainDetailsCargoTab(const CargoSummaryItem *item, int left, int right, int y)
196 {
197 StringID str;
198 if (item->amount > 0) {
199 SetDParam(0, item->cargo);
200 SetDParam(1, item->amount);
201 SetDParam(2, item->source);
202 SetDParam(3, _settings_game.vehicle.freight_trains);
203 str = FreightWagonMult(item->cargo) > 1 ? STR_VEHICLE_DETAILS_CARGO_FROM_MULT : STR_VEHICLE_DETAILS_CARGO_FROM;
204 } else {
205 SetDParam(0, STR_QUANTITY_N_A);
206 str = item->cargo == INVALID_CARGO ? STR_LTBLUE_STRING : STR_VEHICLE_DETAILS_CARGO_EMPTY;
207 }
208
209 DrawString(left, right, y, str);
210 }
211
220 static void TrainDetailsInfoTab(const Vehicle *v, int left, int right, int y)
221 {
222 if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
223 SetDParam(0, v->engine_type);
224 SetDParam(1, v->value);
225 DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_WAGON_VALUE);
226 } else {
227 SetDParam(0, v->engine_type);
228 SetDParam(1, v->build_year);
229 SetDParam(2, v->value);
230 DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_ENGINE_BUILT_AND_VALUE);
231 }
232 }
233
242 static void TrainDetailsCapacityTab(const CargoSummaryItem *item, int left, int right, int y)
243 {
244 StringID str;
245 if (item->cargo != INVALID_CARGO) {
246 SetDParam(0, item->cargo);
247 SetDParam(1, item->capacity);
248 SetDParam(4, item->subtype);
249 SetDParam(5, _settings_game.vehicle.freight_trains);
250 str = FreightWagonMult(item->cargo) > 1 ? STR_VEHICLE_INFO_CAPACITY_MULT : STR_VEHICLE_INFO_CAPACITY;
251 } else {
252 /* Draw subtype only */
253 SetDParam(0, item->subtype);
254 str = STR_VEHICLE_INFO_NO_CAPACITY;
255 }
256 DrawString(left, right, y, str);
257 }
258
264 static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *summary)
265 {
266 summary->Clear();
267 do {
268 if (!v->GetEngine()->CanCarryCargo()) continue;
269
270 CargoSummaryItem new_item;
271 new_item.cargo = v->cargo_cap > 0 ? v->cargo_type : INVALID_CARGO;
272 new_item.subtype = GetCargoSubtypeText(v);
273 if (new_item.cargo == INVALID_CARGO && new_item.subtype == STR_EMPTY) continue;
274
275 CargoSummaryItem *item = summary->Find(new_item);
276 if (item == summary->End()) {
277 item = summary->Append();
278 item->cargo = new_item.cargo;
279 item->subtype = new_item.subtype;
280 item->capacity = 0;
281 item->amount = 0;
282 item->source = INVALID_STATION;
283 }
284
285 item->capacity += v->cargo_cap;
286 item->amount += v->cargo.StoredCount();
287 if (item->source == INVALID_STATION) item->source = v->cargo.Source();
288 } while ((v = v->Next()) != NULL && v->IsArticulatedPart());
289 }
290
296 static uint GetLengthOfArticulatedVehicle(const Train *v)
297 {
298 uint length = 0;
299
300 do {
301 length += v->GetDisplayImageWidth();
302 } while ((v = v->Next()) != NULL && v->IsArticulatedPart());
303
304 return length;
305 }
306
313 int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
314 {
315 int num = 0;
316
317 if (det_tab == TDW_TAB_TOTALS) { // Total cargo tab
318 CargoArray act_cargo;
319 CargoArray max_cargo;
320 for (const Vehicle *v = Vehicle::Get(veh_id); v != NULL; v = v->Next()) {
321 act_cargo[v->cargo_type] += v->cargo.StoredCount();
322 max_cargo[v->cargo_type] += v->cargo_cap;
323 }
324
325 /* Set scroll-amount separately from counting, as to not compute num double
326 * for more carriages of the same type
327 */
328 for (CargoID i = 0; i < NUM_CARGO; i++) {
329 if (max_cargo[i] > 0) num++; // only count carriages that the train has
330 }
331 num++; // needs one more because first line is description string
332 } else {
333 for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) {
334 GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
335 num += max(1u, _cargo_summary.Length());
336
337 uint length = GetLengthOfArticulatedVehicle(v);
338 if (length > TRAIN_DETAILS_MAX_INDENT) num++;
339 }
340 }
341
342 return num;
343 }
344
356 void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
357 {
358 /* get rid of awkward offset */
359 y -= WD_MATRIX_TOP;
360
361 int sprite_height = ScaleGUITrad(GetVehicleHeight(VEH_TRAIN));
362 int line_height = max(sprite_height, WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
363 int sprite_y_offset = line_height / 2;
364 int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2;
365
366 /* draw the first 3 details tabs */
367 if (det_tab != TDW_TAB_TOTALS) {
368 bool rtl = _current_text_dir == TD_RTL;
369 Direction dir = rtl ? DIR_E : DIR_W;
370 int x = rtl ? right : left;
371 for (; v != NULL && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
372 GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
373
374 /* Draw sprites */
375 uint dx = 0;
376 int px = x;
377 const Train *u = v;
378 do {
379 Point offset;
380 int width = u->GetDisplayImageWidth(&offset);
381 if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
382 int pitch = 0;
383 const Engine *e = Engine::Get(v->engine_type);
384 if (e->GetGRF() != NULL) {
385 pitch = ScaleGUITrad(e->GetGRF()->traininfo_vehicle_pitch);
386 }
387 PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
388 VehicleSpriteSeq seq;
389 u->GetImage(dir, EIT_IN_DETAILS, &seq);
390 seq.Draw(px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + pitch, pal, (v->vehstatus & VS_CRASHED) != 0);
391 }
392 px += rtl ? -width : width;
393 dx += width;
394 u = u->Next();
395 } while (u != NULL && u->IsArticulatedPart());
396
397 bool separate_sprite_row = (dx > (uint)ScaleGUITrad(TRAIN_DETAILS_MAX_INDENT));
398 if (separate_sprite_row) {
399 vscroll_pos--;
400 dx = 0;
401 }
402
403 uint num_lines = max(1u, _cargo_summary.Length());
404 for (uint i = 0; i < num_lines; i++) {
405 int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
406 int data_left = left + (rtl ? 0 : sprite_width);
407 int data_right = right - (rtl ? sprite_width : 0);
408 if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
409 int py = y - line_height * vscroll_pos + text_y_offset;
410 if (i > 0 || separate_sprite_row) {
411 if (vscroll_pos != 0) GfxFillRect(left, py - WD_MATRIX_TOP - 1, right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]);
412 }
413 switch (det_tab) {
414 case TDW_TAB_CARGO:
415 if (i < _cargo_summary.Length()) {
416 TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
417 } else {
418 DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
419 }
420 break;
421
422 case TDW_TAB_INFO:
423 if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py);
424 break;
425
426 case TDW_TAB_CAPACITY:
427 if (i < _cargo_summary.Length()) {
428 TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
429 } else {
430 SetDParam(0, STR_EMPTY);
431 DrawString(data_left, data_right, py, STR_VEHICLE_INFO_NO_CAPACITY);
432 }
433 break;
434
435 default: NOT_REACHED();
436 }
437 }
438 vscroll_pos--;
439 }
440 }
441 } else {
442 CargoArray act_cargo;
443 CargoArray max_cargo;
444 Money feeder_share = 0;
445
446 for (const Vehicle *u = v; u != NULL; u = u->Next()) {
447 act_cargo[u->cargo_type] += u->cargo.StoredCount();
448 max_cargo[u->cargo_type] += u->cargo_cap;
449 feeder_share += u->cargo.FeederShare();
450 }
451
452 /* draw total cargo tab */
453 DrawString(left, right, y + text_y_offset, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_TEXT);
454 y += line_height;
455
456 for (CargoID i = 0; i < NUM_CARGO; i++) {
457 if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
458 SetDParam(0, i); // {CARGO} #1
459 SetDParam(1, act_cargo[i]); // {CARGO} #2
460 SetDParam(2, i); // {SHORTCARGO} #1
461 SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
462 SetDParam(4, _settings_game.vehicle.freight_trains);
463 DrawString(left, right, y + text_y_offset, FreightWagonMult(i) > 1 ? STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_MULT : STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY);
464 y += line_height;
465 }
466 }
467 SetDParam(0, feeder_share);
468 DrawString(left, right, y + text_y_offset, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
469 }
470 }
VehicleCargoList::Source
StationID Source() const
Returns source of the first cargo packet in this list.
Definition: cargopacket.h:337
SpecializedVehicle< Train, Type >::Get
static Train * Get(size_t index)
Gets vehicle with given index.
Definition: vehicle_base.h:1094
strings_func.h
Functions related to OTTD&#39;s strings.
GameSettings::vehicle
VehicleSettings vehicle
options for vehicles
Definition: settings_type.h:552
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:20
Vehicle::cargo
VehicleCargoList cargo
The cargo this vehicle is carrying.
Definition: vehicle_base.h:309
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
Vehicle::value
Money value
Value of the vehicle.
Definition: vehicle_base.h:241
CargoSummaryItem::subtype
StringID subtype
STR_EMPTY if none.
Definition: train_gui.cpp:167
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:156
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen...
Definition: gfx.cpp:112
GetCargoSummaryOfArticulatedVehicle
static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *summary)
Collects the cargo transported.
Definition: train_gui.cpp:264
DIR_E
East.
Definition: direction_type.h:30
CursorVars::vehchain
bool vehchain
vehicle chain is dragged
Definition: gfx_type.h:146
Pool::PoolItem<&_vehicle_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:246
Engine::CanCarryCargo
bool CanCarryCargo() const
Determines whether an engine can carry something.
Definition: engine.cpp:173
GetLengthOfArticulatedVehicle
static uint GetLengthOfArticulatedVehicle(const Train *v)
Get the length of an articulated vehicle.
Definition: train_gui.cpp:296
train.h
Base for the train class.
WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
CargoSummaryItem
Helper struct for the cargo details information.
Definition: train_gui.cpp:165
_colour_gradient
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:53
ScaleGUITrad
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:82
TDW_TAB_CAPACITY
Tab with cargo capacity of the vehicles.
Definition: vehicle_gui.h:28
Vehicle::IsStoppedInDepot
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
Definition: vehicle_base.h:517
GetTrainDetailsWndVScroll
int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
Determines the number of lines in the train details window.
Definition: train_gui.cpp:313
CargoSummaryItem::capacity
uint capacity
Amount that can be carried.
Definition: train_gui.cpp:168
vehicle_func.h
Functions related to vehicles.
Train::GetImage
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Get the sprite to display the train.
Definition: train_cmd.cpp:485
VehicleSpriteSeq::Draw
void Draw(int x, int y, PaletteID default_pal, bool force_pal) const
Draw the sprite sequence.
Definition: vehicle.cpp:127
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:212
SmallVector::Clear
void Clear()
Remove all items from the list.
Definition: smallvec_type.hpp:98
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:147
WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:80
GetVehiclePalette
PaletteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
Definition: vehicle.cpp:1954
TRAIN_DETAILS_MIN_INDENT
static const uint TRAIN_DETAILS_MIN_INDENT
Minimum indent level in the train details window.
Definition: train_gui.cpp:179
SmallVector
Simple vector template class.
Definition: smallvec_type.hpp:29
CommandCost
Common return value for all commands.
Definition: command_type.h:25
INVALID_VEHICLE
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition: vehicle_type.h:57
max
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:26
Vehicle::vehstatus
byte vehstatus
Status.
Definition: vehicle_base.h:317
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition: vehicle_type.h:87
VehicleCargoList::StoredCount
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
Definition: cargopacket.h:366
SpecializedVehicle< Train, Type >::From
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Definition: vehicle_base.h:1113
SmallVector::End
const T * End() const
Get the pointer behind the last valid item (const)
Definition: smallvec_type.hpp:292
Vehicle::GetEngine
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
Definition: vehicle.cpp:743
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:26
window_gui.h
Functions, definitions and such used only by the GUI.
FillDrawPixelInfo
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:1480
CargoSummaryItem::source
StationID source
One of the source stations.
Definition: train_gui.cpp:170
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:177
SmallVector::Append
T * Append(uint to_add=1)
Append an item and return it.
Definition: smallvec_type.hpp:134
InvalidateWindowClassesData
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:3238
EIT_IN_DETAILS
Vehicle drawn in vehicle details, refit window, ...
Definition: vehicle_type.h:90
Vehicle::cargo_cap
uint16 cargo_cap
total capacity
Definition: vehicle_base.h:307
VehicleSettings::freight_trains
uint8 freight_trains
value to multiply the weight of cargo by
Definition: settings_type.h:460
VS_CRASHED
Vehicle is crashed.
Definition: vehicle_base.h:39
GRFFile::traininfo_vehicle_pitch
int traininfo_vehicle_pitch
Vertical offset for draing train images in depot GUI and vehicle details.
Definition: newgrf.h:135
CcBuildWagon
void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
Callback for building wagons.
Definition: train_gui.cpp:31
WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
Definition: window_gui.h:81
SmallVector::Length
uint Length() const
Get the number of items in the list.
Definition: smallvec_type.hpp:262
DIR_W
West.
Definition: direction_type.h:34
VehicleID
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:18
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:180
SpecializedVehicle::Next
T * Next() const
Get next vehicle in the chain.
Definition: vehicle_base.h:1028
RAILVEH_WAGON
simple wagon, not motorized
Definition: engine_type.h:30
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
DrawTrainImage
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
Draws an image of a whole train.
Definition: train_gui.cpp:94
Vehicle::IsArticulatedPart
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
Definition: vehicle_base.h:891
safeguards.h
A number of safeguards to prevent using unsafe methods.
DrawTrainDetails
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
Draw the details for the given vehicle at the given position.
Definition: train_gui.cpp:356
Vehicle::cargo_type
CargoID cargo_type
type of cargo this vehicle is carrying
Definition: vehicle_base.h:305
_cargo_summary
static CargoSummary _cargo_summary
Reused container of cargo details.
Definition: train_gui.cpp:185
Vehicle::IsFrontEngine
bool IsFrontEngine() const
Check if the vehicle is a front engine.
Definition: vehicle_base.h:882
TrainDetailsCapacityTab
static void TrainDetailsCapacityTab(const CargoSummaryItem *item, int left, int right, int y)
Draw the details capacity tab for the given vehicle at the given position.
Definition: train_gui.cpp:242
Vehicle::tile
TileIndex tile
Current tile index.
Definition: vehicle_base.h:230
SmallVector::Find
const T * Find(const T &item) const
Search for the first occurrence of an item.
Definition: smallvec_type.hpp:167
WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
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:499
VehicleSpriteSeq
Sprite sequence for a vehicle part.
Definition: vehicle_base.h:130
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:527
min
static T min(const T a, const T b)
Returns the minimum of two values.
Definition: math_func.hpp:42
TrainDetailsInfoTab
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.
Definition: train_gui.cpp:220
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:161
TDW_TAB_CARGO
Tab with cargo carried by the vehicles.
Definition: vehicle_gui.h:26
Train::GetDisplayImageWidth
int GetDisplayImageWidth(Point *offset=NULL) const
Get the width of a train vehicle image in the GUI.
Definition: train_cmd.cpp:455
FR_BORDERONLY
Draw border only, no background.
Definition: window_gui.h:30
Vehicle::build_year
Year build_year
Year the vehicle has been built.
Definition: vehicle_base.h:257
Engine
Definition: engine_base.h:23
HighlightDragPosition
static int HighlightDragPosition(int px, int max_width, VehicleID selection, bool chain)
Highlight the position where a rail vehicle is dragged over by drawing a light gray background...
Definition: train_gui.cpp:62
Train
&#39;Train&#39; is either a loco or a wagon.
Definition: train.h:88
NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:66
TRAIN_DETAILS_MAX_INDENT
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...
Definition: train_gui.cpp:180
TrainDetailsWindowTabs
TrainDetailsWindowTabs
The tabs in the train details window.
Definition: vehicle_gui.h:25
CargoArray
Class for storing amounts of cargo.
Definition: cargo_type.h:74
Engine::GetGRF
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
Definition: engine_base.h:140
FreightWagonMult
byte FreightWagonMult(CargoID cargo)
Return the cargo weight multiplier to use for a rail vehicle.
Definition: train_cmd.cpp:87
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
PALETTE_CRASH
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
Definition: sprites.h:1569
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:52
TDW_TAB_TOTALS
Tab with sum of total cargo transported.
Definition: vehicle_gui.h:29
WC_TRAINS_LIST
Trains list; Window numbers:
Definition: window_type.h:303
zoom_func.h
Functions related to zooming.
INVALID_CARGO
static const byte INVALID_CARGO
Constant representing invalid cargo.
Definition: cargotype.h:53
SpecializedVehicle::GetNextVehicle
T * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
Definition: vehicle_base.h:1072
GetVehicleHeight
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
Definition: vehicle_gui.h:62
command_func.h
Functions related to commands.
CargoSummaryItem::cargo
CargoID cargo
The cargo that is carried.
Definition: train_gui.cpp:166
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:28
CargoSummary
SmallVector< CargoSummaryItem, 2 > CargoSummary
Container for the cargo summary information.
Definition: train_gui.cpp:183
WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
Vehicle::engine_type
EngineID engine_type
The type of engine used for this vehicle.
Definition: vehicle_base.h:288
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:26
Vehicle::Last
Vehicle * Last()
Get the last vehicle of this vehicle chain.
Definition: vehicle_base.h:601
CargoSummaryItem::operator!=
bool operator!=(const CargoSummaryItem &other) const
Used by CargoSummary::Find() and similar functions.
Definition: train_gui.cpp:173
GetCargoSubtypeText
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
Definition: vehicle_gui.cpp:1072
TrainDetailsCargoTab
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.
Definition: train_gui.cpp:195
CMD_MOVE_RAIL_VEHICLE
move a rail vehicle (in the depot)
Definition: command_type.h:221
WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
CargoSummaryItem::amount
uint amount
Amount that is carried.
Definition: train_gui.cpp:169
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
TDW_TAB_INFO
Tab with name and value of the vehicles.
Definition: vehicle_gui.h:27
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:201