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