OpenTTD
depot_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 "train.h"
14 #include "roadveh.h"
15 #include "ship.h"
16 #include "aircraft.h"
17 #include "gui.h"
18 #include "textbuf_gui.h"
19 #include "viewport_func.h"
20 #include "command_func.h"
21 #include "depot_base.h"
22 #include "spritecache.h"
23 #include "strings_func.h"
24 #include "vehicle_func.h"
25 #include "company_func.h"
26 #include "tilehighlight_func.h"
27 #include "window_gui.h"
28 #include "vehiclelist.h"
29 #include "order_backup.h"
30 #include "zoom_func.h"
31 
32 #include "widgets/depot_widget.h"
33 
34 #include "table/strings.h"
35 
36 #include "safeguards.h"
37 
38 /*
39  * Since all depot window sizes aren't the same, we need to modify sizes a little.
40  * It's done with the following arrays of widget indexes. Each of them tells if a widget side should be moved and in what direction.
41  * How long they should be moved and for what window types are controlled in ShowDepotWindow()
42  */
43 
47  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
48  NWidget(WWT_CAPTION, COLOUR_GREY, WID_D_CAPTION), SetDataTip(STR_DEPOT_CAPTION, STR_NULL),
49  NWidget(WWT_SHADEBOX, COLOUR_GREY),
50  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
51  NWidget(WWT_STICKYBOX, COLOUR_GREY),
52  EndContainer(),
56  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_D_SHOW_H_SCROLL),
57  NWidget(NWID_HSCROLLBAR, COLOUR_GREY, WID_D_H_SCROLL),
58  EndContainer(),
59  EndContainer(),
61  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_D_SELL), SetDataTip(0x0, STR_NULL), SetResize(0, 1), SetFill(0, 1),
63  NWidget(WWT_IMGBTN, COLOUR_GREY, WID_D_SELL_CHAIN), SetDataTip(SPR_SELL_CHAIN_TRAIN, STR_DEPOT_DRAG_WHOLE_TRAIN_TO_SELL_TOOLTIP), SetResize(0, 1), SetFill(0, 1),
64  EndContainer(),
65  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_D_SELL_ALL), SetDataTip(0x0, STR_NULL),
66  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_D_AUTOREPLACE), SetDataTip(0x0, STR_NULL),
67  EndContainer(),
68  NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_D_V_SCROLL),
69  EndContainer(),
71  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_D_BUILD), SetDataTip(0x0, STR_NULL), SetFill(1, 1), SetResize(1, 0),
72  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_D_CLONE), SetDataTip(0x0, STR_NULL), SetFill(1, 1), SetResize(1, 0),
73  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_D_LOCATION), SetDataTip(STR_BUTTON_LOCATION, STR_NULL), SetFill(1, 1), SetResize(1, 0),
74  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_D_SHOW_RENAME), // rename button
75  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_D_RENAME), SetDataTip(STR_BUTTON_RENAME, STR_DEPOT_RENAME_TOOLTIP), SetFill(1, 1), SetResize(1, 0),
76  EndContainer(),
77  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_D_VEHICLE_LIST), SetDataTip(0x0, STR_NULL), SetFill(0, 1),
78  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_D_STOP_ALL), SetDataTip(SPR_FLAG_VEH_STOPPED, STR_NULL), SetFill(0, 1),
79  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_D_START_ALL), SetDataTip(SPR_FLAG_VEH_RUNNING, STR_NULL), SetFill(0, 1),
80  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
81  EndContainer(),
82 };
83 
84 static WindowDesc _train_depot_desc(
85  WDP_AUTO, "depot_train", 362, 123,
87  0,
88  _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
89 );
90 
91 static WindowDesc _road_depot_desc(
92  WDP_AUTO, "depot_roadveh", 316, 97,
94  0,
95  _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
96 );
97 
98 static WindowDesc _ship_depot_desc(
99  WDP_AUTO, "depot_ship", 306, 99,
101  0,
102  _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
103 );
104 
105 static WindowDesc _aircraft_depot_desc(
106  WDP_AUTO, "depot_aircraft", 332, 99,
108  0,
109  _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
110 );
111 
112 extern void DepotSortList(VehicleList *list);
113 
122 void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
123 {
124  if (result.Failed()) return;
125 
126  const Vehicle *v = Vehicle::Get(_new_vehicle_id);
127 
129 }
130 
131 static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Vehicle *head)
132 {
133  const Vehicle *v = Vehicle::Get(sel);
134 
135  if (v == wagon) return;
136 
137  if (wagon == NULL) {
138  if (head != NULL) wagon = head->Last();
139  } else {
140  wagon = wagon->Previous();
141  if (wagon == NULL) return;
142  }
143 
144  if (wagon == v) return;
145 
146  DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == NULL ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
147 }
148 
152 
161 {
162  switch (image_type) {
163  case EIT_IN_DEPOT: return _base_block_sizes_depot[type];
164  case EIT_PURCHASE: return _base_block_sizes_purchase[type];
165  default: NOT_REACHED();
166  }
167 }
168 
169 static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_type)
170 {
171  int max_extend_left = 0;
172  int max_extend_right = 0;
173  uint max_height = 0;
174 
175  const Engine *e;
176  FOR_ALL_ENGINES_OF_TYPE(e, type) {
177  if (!e->IsEnabled()) continue;
178 
179  EngineID eid = e->index;
180  uint x, y;
181  int x_offs, y_offs;
182 
183  switch (type) {
184  default: NOT_REACHED();
185  case VEH_TRAIN: GetTrainSpriteSize( eid, x, y, x_offs, y_offs, image_type); break;
186  case VEH_ROAD: GetRoadVehSpriteSize( eid, x, y, x_offs, y_offs, image_type); break;
187  case VEH_SHIP: GetShipSpriteSize( eid, x, y, x_offs, y_offs, image_type); break;
188  case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y, x_offs, y_offs, image_type); break;
189  }
190  if (y > max_height) max_height = y;
191  if (-x_offs > max_extend_left) max_extend_left = -x_offs;
192  if ((int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
193  }
194 
195  int min_extend = ScaleGUITrad(16);
196  int max_extend = ScaleGUITrad(98);
197 
198  switch (image_type) {
199  case EIT_IN_DEPOT:
200  _base_block_sizes_depot[type].height = max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
201  _base_block_sizes_depot[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
202  _base_block_sizes_depot[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
203  break;
204  case EIT_PURCHASE:
205  _base_block_sizes_purchase[type].height = max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
206  _base_block_sizes_purchase[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
207  _base_block_sizes_purchase[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
208  break;
209 
210  default: NOT_REACHED();
211  }
212 }
213 
219 {
220  for (VehicleType vt = VEH_BEGIN; vt < VEH_COMPANY_END; vt++) {
221  InitBlocksizeForVehicles(vt, EIT_IN_DEPOT);
222  InitBlocksizeForVehicles(vt, EIT_PURCHASE);
223  }
224 
225  _consistent_train_width = TRAININFO_DEFAULT_VEHICLE_WIDTH;
226  bool first = true;
227  const Engine *e;
228  FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) {
229  if (!e->IsEnabled()) continue;
230 
231  uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
232  if (e->GetGRF() != NULL && is_custom_sprite(e->u.rail.image_index)) {
234  if (w != VEHICLEINFO_FULL_VEHICLE_WIDTH) {
235  /* Hopeless.
236  * This is a NewGRF vehicle that uses TRAININFO_DEFAULT_VEHICLE_WIDTH.
237  * If the vehicles are shorter than 8/8 we have fractional lengths, which are not consistent after rounding.
238  */
240  break;
241  }
242  }
243 
244  if (first) {
246  first = false;
247  } else if (w != _consistent_train_width) {
249  break;
250  }
251  }
252 }
253 
254 static void DepotSellAllConfirmationCallback(Window *w, bool confirmed);
255 const Sprite *GetAircraftSprite(EngineID engine);
256 
257 struct DepotWindow : Window {
258  VehicleID sel;
260  VehicleType type;
261  bool generate_list;
263  VehicleList vehicle_list;
264  VehicleList wagon_list;
265  uint unitnumber_digits;
266  uint num_columns;
268  Scrollbar *vscroll;
269 
270  DepotWindow(WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc)
271  {
272  assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type
273 
274  this->sel = INVALID_VEHICLE;
275  this->vehicle_over = INVALID_VEHICLE;
276  this->generate_list = true;
277  this->hovered_widget = -1;
278  this->type = type;
279  this->num_columns = 1; // for non-trains this gets set in FinishInitNested()
280  this->unitnumber_digits = 2;
281 
282  this->CreateNestedTree();
283  this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : NULL);
284  this->vscroll = this->GetScrollbar(WID_D_V_SCROLL);
285  /* Don't show 'rename button' of aircraft hangar */
286  this->GetWidget<NWidgetStacked>(WID_D_SHOW_RENAME)->SetDisplayedPlane(type == VEH_AIRCRAFT ? SZSP_NONE : 0);
287  /* Only train depots have a horizontal scrollbar and a 'sell chain' button */
288  if (type == VEH_TRAIN) this->GetWidget<NWidgetCore>(WID_D_MATRIX)->widget_data = 1 << MAT_COL_START;
289  this->GetWidget<NWidgetStacked>(WID_D_SHOW_H_SCROLL)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_HORIZONTAL);
290  this->GetWidget<NWidgetStacked>(WID_D_SHOW_SELL_CHAIN)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_NONE);
291  this->SetupWidgetData(type);
292  this->FinishInitNested(tile);
293 
294  this->owner = GetTileOwner(tile);
296  }
297 
298  ~DepotWindow()
299  {
302  }
303 
311  void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const
312  {
313  bool free_wagon = false;
314  int sprite_y = y + (this->resize.step_height - ScaleGUITrad(GetVehicleHeight(v->type))) / 2;
315 
316  bool rtl = _current_text_dir == TD_RTL;
317  int image_left = rtl ? left + this->count_width : left + this->header_width;
318  int image_right = rtl ? right - this->header_width : right - this->count_width;
319 
320  switch (v->type) {
321  case VEH_TRAIN: {
322  const Train *u = Train::From(v);
323  free_wagon = u->IsFreeWagon();
324 
325  uint x_space = free_wagon ?
326  ScaleGUITrad(_consistent_train_width != 0 ? _consistent_train_width : TRAININFO_DEFAULT_VEHICLE_WIDTH) :
327  0;
328 
329  DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
330  this->sel, EIT_IN_DEPOT, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
331 
332  /* Length of consist in tiles with 1 fractional digit (rounded up) */
334  SetDParam(1, 1);
335  DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_DECIMAL, TC_FROMSTRING, SA_RIGHT); // Draw the counter
336  break;
337  }
338 
339  case VEH_ROAD: DrawRoadVehImage( v, image_left, image_right, sprite_y, this->sel, EIT_IN_DEPOT); break;
340  case VEH_SHIP: DrawShipImage( v, image_left, image_right, sprite_y, this->sel, EIT_IN_DEPOT); break;
341  case VEH_AIRCRAFT: DrawAircraftImage(v, image_left, image_right, sprite_y, this->sel, EIT_IN_DEPOT); break;
342  default: NOT_REACHED();
343  }
344 
345  uint diff_x, diff_y;
346  if (v->IsGroundVehicle()) {
347  /* Arrange unitnumber and flag horizontally */
348  diff_x = this->flag_width + WD_FRAMERECT_LEFT;
349  diff_y = (this->resize.step_height - this->flag_height) / 2 - 2;
350  } else {
351  /* Arrange unitnumber and flag vertically */
352  diff_x = WD_FRAMERECT_LEFT;
354  }
355  int text_left = rtl ? right - this->header_width - 1 : left + diff_x;
356  int text_right = rtl ? right - diff_x : left + this->header_width - 1;
357 
358  if (free_wagon) {
359  DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE);
360  } else {
361  DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, rtl ? right - this->flag_width : left + WD_FRAMERECT_LEFT, y + diff_y);
362 
363  SetDParam(0, v->unitnumber);
364  DrawString(text_left, text_right, y + 2, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? STR_BLACK_COMMA : STR_RED_COMMA);
365  }
366  }
367 
368  void DrawWidget(const Rect &r, int widget) const
369  {
370  if (widget != WID_D_MATRIX) return;
371 
372  bool rtl = _current_text_dir == TD_RTL;
373 
374  /* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
375  const NWidgetCore *wid = this->GetWidget<NWidgetCore>(WID_D_MATRIX);
376 
377  /* Draw vertical separators at whole tiles.
378  * This only works in two cases:
379  * - All vehicles use VEHICLEINFO_FULL_VEHICLE_WIDTH as reference width.
380  * - All vehicles are 8/8. This cannot be checked for NewGRF, so instead we check for "all vehicles are original vehicles".
381  */
382  if (this->type == VEH_TRAIN && _consistent_train_width != 0) {
384  int col = _colour_gradient[wid->colour][4];
385  int image_left = rtl ? r.left + this->count_width : r.left + this->header_width;
386  int image_right = rtl ? r.right - this->header_width : r.right - this->count_width;
387  int first_line = w + (-this->hscroll->GetPosition()) % w;
388  if (rtl) {
389  for (int x = image_right - first_line; x >= image_left; x -= w) {
390  GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
391  }
392  } else {
393  for (int x = image_left + first_line; x <= image_right; x += w) {
394  GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
395  }
396  }
397  }
398 
399  uint16 rows_in_display = wid->current_y / wid->resize_y;
400 
401  uint16 num = this->vscroll->GetPosition() * this->num_columns;
402  int maxval = min(this->vehicle_list.Length(), num + (rows_in_display * this->num_columns));
403  int y;
404  for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows
405  for (byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
406  /* Draw all vehicles in the current row */
407  const Vehicle *v = this->vehicle_list[num];
408  if (this->num_columns == 1) {
409  this->DrawVehicleInDepot(v, r.left, r.right, y);
410  } else {
411  int x = r.left + (rtl ? (this->num_columns - i - 1) : i) * this->resize.step_width;
412  this->DrawVehicleInDepot(v, x, x + this->resize.step_width - 1, y);
413  }
414  }
415  }
416 
417  maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
418 
419  /* Draw the train wagons without an engine in front. */
420  for (; num < maxval; num++, y += this->resize.step_height) {
421  const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()];
422  this->DrawVehicleInDepot(v, r.left, r.right, y);
423  }
424  }
425 
426  void SetStringParameters(int widget) const
427  {
428  if (widget != WID_D_CAPTION) return;
429 
430  /* locate the depot struct */
431  TileIndex tile = this->window_number;
432  SetDParam(0, this->type);
433  SetDParam(1, (this->type == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(tile));
434  }
435 
437  const Vehicle *head;
438  const Vehicle *wagon;
439  };
440 
441  enum DepotGUIAction {
442  MODE_ERROR,
443  MODE_DRAG_VEHICLE,
444  MODE_SHOW_VEHICLE,
445  MODE_START_STOP,
446  };
447 
448  DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const
449  {
450  const NWidgetCore *matrix_widget = this->GetWidget<NWidgetCore>(WID_D_MATRIX);
451  /* In case of RTL the widgets are swapped as a whole */
452  if (_current_text_dir == TD_RTL) x = matrix_widget->current_x - x;
453 
454  uint xt = 0, xm = 0, ym = 0;
455  if (this->type == VEH_TRAIN) {
456  xm = x;
457  } else {
458  xt = x / this->resize.step_width;
459  xm = x % this->resize.step_width;
460  if (xt >= this->num_columns) return MODE_ERROR;
461  }
462  ym = y % this->resize.step_height;
463 
464  uint row = y / this->resize.step_height;
465  if (row >= this->vscroll->GetCapacity()) return MODE_ERROR;
466 
467  uint pos = ((row + this->vscroll->GetPosition()) * this->num_columns) + xt;
468 
469  if (this->vehicle_list.Length() + this->wagon_list.Length() <= pos) {
470  /* Clicking on 'line' / 'block' without a vehicle */
471  if (this->type == VEH_TRAIN) {
472  /* End the dragging */
473  d->head = NULL;
474  d->wagon = NULL;
475  return MODE_DRAG_VEHICLE;
476  } else {
477  return MODE_ERROR; // empty block, so no vehicle is selected
478  }
479  }
480 
481  bool wagon = false;
482  if (this->vehicle_list.Length() > pos) {
483  *veh = this->vehicle_list[pos];
484  /* Skip vehicles that are scrolled off the list */
485  if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
486  } else {
487  pos -= this->vehicle_list.Length();
488  *veh = this->wagon_list[pos];
489  /* free wagons don't have an initial loco. */
490  x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
491  wagon = true;
492  }
493 
494  const Train *v = NULL;
495  if (this->type == VEH_TRAIN) {
496  v = Train::From(*veh);
497  d->head = d->wagon = v;
498  }
499 
500  if (xm <= this->header_width) {
501  switch (this->type) {
502  case VEH_TRAIN:
503  if (wagon) return MODE_ERROR;
504  FALLTHROUGH;
505 
506  case VEH_ROAD:
507  if (xm <= this->flag_width) return MODE_START_STOP;
508  break;
509 
510  case VEH_SHIP:
511  case VEH_AIRCRAFT:
512  if (xm <= this->flag_width && ym >= (uint)(FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL)) return MODE_START_STOP;
513  break;
514 
515  default: NOT_REACHED();
516  }
517  return MODE_SHOW_VEHICLE;
518  }
519 
520  if (this->type != VEH_TRAIN) return MODE_DRAG_VEHICLE;
521 
522  /* Clicking on the counter */
523  if (xm >= matrix_widget->current_x - this->count_width) return wagon ? MODE_ERROR : MODE_SHOW_VEHICLE;
524 
525  /* Account for the header */
526  x -= this->header_width;
527 
528  /* find the vehicle in this row that was clicked */
529  for (; v != NULL; v = v->Next()) {
530  x -= v->GetDisplayImageWidth();
531  if (x < 0) break;
532  }
533 
534  d->wagon = (v != NULL ? v->GetFirstEnginePart() : NULL);
535 
536  return MODE_DRAG_VEHICLE;
537  }
538 
544  void DepotClick(int x, int y)
545  {
546  GetDepotVehiclePtData gdvp = { NULL, NULL };
547  const Vehicle *v = NULL;
548  DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
549 
550  if (this->type == VEH_TRAIN) v = gdvp.wagon;
551 
552  switch (mode) {
553  case MODE_ERROR: // invalid
554  return;
555 
556  case MODE_DRAG_VEHICLE: { // start dragging of vehicle
557  if (v != NULL && VehicleClicked(v)) return;
558 
559  VehicleID sel = this->sel;
560 
561  if (this->type == VEH_TRAIN && sel != INVALID_VEHICLE) {
562  this->sel = INVALID_VEHICLE;
563  TrainDepotMoveVehicle(v, sel, gdvp.head);
564  } else if (v != NULL) {
565  SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
567  _cursor.vehchain = _ctrl_pressed;
568 
569  this->sel = v->index;
570  this->SetDirty();
571  }
572  break;
573  }
574 
575  case MODE_SHOW_VEHICLE: // show info window
577  break;
578 
579  case MODE_START_STOP: // click start/stop flag
580  StartStopVehicle(v, false);
581  break;
582 
583  default: NOT_REACHED();
584  }
585  }
586 
594  {
595  this->GetWidget<NWidgetCore>(WID_D_STOP_ALL)->tool_tip = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type;
596  this->GetWidget<NWidgetCore>(WID_D_START_ALL)->tool_tip = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type;
597  this->GetWidget<NWidgetCore>(WID_D_SELL)->tool_tip = STR_DEPOT_TRAIN_SELL_TOOLTIP + type;
598  this->GetWidget<NWidgetCore>(WID_D_SELL_ALL)->tool_tip = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TOOLTIP + type;
599 
600  this->GetWidget<NWidgetCore>(WID_D_BUILD)->SetDataTip(STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON + type, STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP + type);
601  this->GetWidget<NWidgetCore>(WID_D_CLONE)->SetDataTip(STR_DEPOT_CLONE_TRAIN + type, STR_DEPOT_CLONE_TRAIN_DEPOT_INFO + type);
602 
603  this->GetWidget<NWidgetCore>(WID_D_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
604  this->GetWidget<NWidgetCore>(WID_D_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
605  this->GetWidget<NWidgetCore>(WID_D_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
606  this->GetWidget<NWidgetCore>(WID_D_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type;
607 
608  switch (type) {
609  default: NOT_REACHED();
610 
611  case VEH_TRAIN:
612  this->GetWidget<NWidgetCore>(WID_D_VEHICLE_LIST)->widget_data = STR_TRAIN;
613 
614  /* Sprites */
615  this->GetWidget<NWidgetCore>(WID_D_SELL)->widget_data = SPR_SELL_TRAIN;
616  this->GetWidget<NWidgetCore>(WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_TRAIN;
617  this->GetWidget<NWidgetCore>(WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_TRAIN;
618  break;
619 
620  case VEH_ROAD:
621  this->GetWidget<NWidgetCore>(WID_D_VEHICLE_LIST)->widget_data = STR_LORRY;
622 
623  /* Sprites */
624  this->GetWidget<NWidgetCore>(WID_D_SELL)->widget_data = SPR_SELL_ROADVEH;
625  this->GetWidget<NWidgetCore>(WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_ROADVEH;
626  this->GetWidget<NWidgetCore>(WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_ROADVEH;
627  break;
628 
629  case VEH_SHIP:
630  this->GetWidget<NWidgetCore>(WID_D_VEHICLE_LIST)->widget_data = STR_SHIP;
631 
632  /* Sprites */
633  this->GetWidget<NWidgetCore>(WID_D_SELL)->widget_data = SPR_SELL_SHIP;
634  this->GetWidget<NWidgetCore>(WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_SHIP;
635  this->GetWidget<NWidgetCore>(WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_SHIP;
636  break;
637 
638  case VEH_AIRCRAFT:
639  this->GetWidget<NWidgetCore>(WID_D_VEHICLE_LIST)->widget_data = STR_PLANE;
640 
641  /* Sprites */
642  this->GetWidget<NWidgetCore>(WID_D_SELL)->widget_data = SPR_SELL_AIRCRAFT;
643  this->GetWidget<NWidgetCore>(WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_AIRCRAFT;
644  this->GetWidget<NWidgetCore>(WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_AIRCRAFT;
645  break;
646  }
647  }
648 
649  uint count_width;
650  uint header_width;
651  uint flag_width;
652  uint flag_height;
653 
654  virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
655  {
656  switch (widget) {
657  case WID_D_MATRIX: {
658  uint min_height = 0;
659 
660  if (this->type == VEH_TRAIN) {
661  SetDParamMaxValue(0, 1000, 0, FS_SMALL);
662  SetDParam(1, 1);
663  this->count_width = GetStringBoundingBox(STR_TINY_BLACK_DECIMAL).width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
664  } else {
665  this->count_width = 0;
666  }
667 
668  SetDParamMaxDigits(0, this->unitnumber_digits);
669  Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
670  const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
671  this->flag_width = UnScaleGUI(spr->width) + WD_FRAMERECT_RIGHT;
672  this->flag_height = UnScaleGUI(spr->height);
673 
674  if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
675  min_height = max<uint>(unumber.height + WD_MATRIX_TOP, UnScaleGUI(spr->height));
676  this->header_width = unumber.width + this->flag_width + WD_FRAMERECT_LEFT;
677  } else {
678  min_height = unumber.height + UnScaleGUI(spr->height) + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
679  this->header_width = max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
680  }
681  int base_width = this->count_width + this->header_width;
682 
683  resize->height = max<uint>(GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).height, min_height);
684  if (this->type == VEH_TRAIN) {
685  resize->width = 1;
686  size->width = base_width + 2 * ScaleGUITrad(29); // about 2 parts
687  size->height = resize->height * 6;
688  } else {
689  resize->width = base_width + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_left + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_right;
690  size->width = resize->width * (this->type == VEH_ROAD ? 5 : 3);
691  size->height = resize->height * (this->type == VEH_ROAD ? 5 : 3);
692  }
693  fill->width = resize->width;
694  fill->height = resize->height;
695  break;
696  }
697  }
698  }
699 
705  virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
706  {
707  this->generate_list = true;
708  }
709 
710  virtual void OnPaint()
711  {
712  if (this->generate_list) {
713  /* Generate the vehicle list
714  * It's ok to use the wagon pointers for non-trains as they will be ignored */
715  BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
716  this->generate_list = false;
717  DepotSortList(&this->vehicle_list);
718 
719  uint new_unitnumber_digits = GetUnitNumberDigits(this->vehicle_list);
720  /* Only increase the size; do not decrease to prevent constant changes */
721  if (this->unitnumber_digits < new_unitnumber_digits) {
722  this->unitnumber_digits = new_unitnumber_digits;
723  this->ReInit();
724  }
725  }
726 
727  /* determine amount of items for scroller */
728  if (this->type == VEH_TRAIN) {
729  uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
730  for (uint num = 0; num < this->vehicle_list.Length(); num++) {
731  uint width = 0;
732  for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
733  width += v->GetDisplayImageWidth();
734  }
735  max_width = max(max_width, width);
736  }
737  /* Always have 1 empty row, so people can change the setting of the train */
738  this->vscroll->SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1);
739  /* Always make it longer than the longest train, so you can attach vehicles at the end, and also see the next vertical tile separator line */
740  this->hscroll->SetCount(max_width + ScaleGUITrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
741  } else {
742  this->vscroll->SetCount(CeilDiv(this->vehicle_list.Length(), this->num_columns));
743  }
744 
745  /* Setup disabled buttons. */
746  TileIndex tile = this->window_number;
750  WID_D_SELL,
753  WID_D_BUILD,
754  WID_D_CLONE,
755  WID_D_RENAME,
758 
759  this->DrawWidgets();
760  }
761 
762  virtual void OnClick(Point pt, int widget, int click_count)
763  {
764  switch (widget) {
765  case WID_D_MATRIX: { // List
766  NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_D_MATRIX);
767  this->DepotClick(pt.x - nwi->pos_x, pt.y - nwi->pos_y);
768  break;
769  }
770 
771  case WID_D_BUILD: // Build vehicle
773  ShowBuildVehicleWindow(this->window_number, this->type);
774  break;
775 
776  case WID_D_CLONE: // Clone button
779 
780  if (this->IsWidgetLowered(WID_D_CLONE)) {
781  static const CursorID clone_icons[] = {
782  SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
783  SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
784  };
785 
786  SetObjectToPlaceWnd(clone_icons[this->type], PAL_NONE, HT_VEHICLE, this);
787  } else {
789  }
790  break;
791 
792  case WID_D_LOCATION:
793  if (_ctrl_pressed) {
795  } else {
797  }
798  break;
799 
800  case WID_D_RENAME: // Rename button
801  SetDParam(0, this->type);
802  SetDParam(1, Depot::GetByTile((TileIndex)this->window_number)->index);
803  ShowQueryString(STR_DEPOT_NAME, STR_DEPOT_RENAME_DEPOT_CAPTION, MAX_LENGTH_DEPOT_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
804  break;
805 
806  case WID_D_STOP_ALL:
807  case WID_D_START_ALL: {
808  VehicleListIdentifier vli(VL_DEPOT_LIST, this->type, this->owner);
809  DoCommandP(this->window_number, (widget == WID_D_START_ALL ? (1 << 0) : 0), vli.Pack(), CMD_MASS_START_STOP);
810  break;
811  }
812 
813  case WID_D_SELL_ALL:
814  /* Only open the confirmation window if there are anything to sell */
815  if (this->vehicle_list.Length() != 0 || this->wagon_list.Length() != 0) {
816  TileIndex tile = this->window_number;
817  byte vehtype = this->type;
818 
819  SetDParam(0, vehtype);
820  SetDParam(1, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(tile));
821  ShowQuery(
822  STR_DEPOT_CAPTION,
823  STR_DEPOT_SELL_CONFIRMATION_TEXT,
824  this,
825  DepotSellAllConfirmationCallback
826  );
827  }
828  break;
829 
830  case WID_D_VEHICLE_LIST:
831  ShowVehicleListWindow(GetTileOwner(this->window_number), this->type, (TileIndex)this->window_number);
832  break;
833 
834  case WID_D_AUTOREPLACE:
835  DoCommandP(this->window_number, this->type, 0, CMD_DEPOT_MASS_AUTOREPLACE);
836  break;
837 
838  }
839  }
840 
841  virtual void OnQueryTextFinished(char *str)
842  {
843  if (str == NULL) return;
844 
845  /* Do depot renaming */
846  DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), NULL, str);
847  }
848 
849  virtual bool OnRightClick(Point pt, int widget)
850  {
851  if (widget != WID_D_MATRIX) return false;
852 
853  GetDepotVehiclePtData gdvp = { NULL, NULL };
854  const Vehicle *v = NULL;
855  NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_D_MATRIX);
856  DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp);
857 
858  if (this->type == VEH_TRAIN) v = gdvp.wagon;
859 
860  if (v == NULL || mode != MODE_DRAG_VEHICLE) return false;
861 
862  CargoArray capacity, loaded;
863 
864  /* Display info for single (articulated) vehicle, or for whole chain starting with selected vehicle */
865  bool whole_chain = (this->type == VEH_TRAIN && _ctrl_pressed);
866 
867  /* loop through vehicle chain and collect cargoes */
868  uint num = 0;
869  for (const Vehicle *w = v; w != NULL; w = w->Next()) {
870  if (w->cargo_cap > 0 && w->cargo_type < NUM_CARGO) {
871  capacity[w->cargo_type] += w->cargo_cap;
872  loaded [w->cargo_type] += w->cargo.StoredCount();
873  }
874 
875  if (w->type == VEH_TRAIN && !w->HasArticulatedPart()) {
876  num++;
877  if (!whole_chain) break;
878  }
879  }
880 
881  /* Build tooltipstring */
882  static char details[1024];
883  details[0] = '\0';
884  char *pos = details;
885 
886  for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
887  if (capacity[cargo_type] == 0) continue;
888 
889  SetDParam(0, cargo_type); // {CARGO} #1
890  SetDParam(1, loaded[cargo_type]); // {CARGO} #2
891  SetDParam(2, cargo_type); // {SHORTCARGO} #1
892  SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2
893  pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, lastof(details));
894  }
895 
896  /* Show tooltip window */
897  uint64 args[2];
898  args[0] = (whole_chain ? num : v->engine_type);
899  args[1] = (uint64)(size_t)details;
900  GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
901 
902  return true;
903  }
904 
910  virtual bool OnVehicleSelect(const Vehicle *v)
911  {
912  if (_ctrl_pressed) {
913  /* Share-clone, do not open new viewport, and keep tool active */
914  DoCommandP(this->window_number, v->index, 1, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), NULL);
915  } else {
916  /* Copy-clone, open viewport for new vehicle, and deselect the tool (assume player wants to changs things on new vehicle) */
917  if (DoCommandP(this->window_number, v->index, 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle)) {
919  }
920  }
921 
922  return true;
923  }
924 
925  virtual void OnPlaceObjectAbort()
926  {
927  /* abort clone */
928  this->RaiseWidget(WID_D_CLONE);
930 
931  /* abort drag & drop */
932  this->sel = INVALID_VEHICLE;
933  this->vehicle_over = INVALID_VEHICLE;
935 
936  if (this->hovered_widget != -1) {
937  this->SetWidgetLoweredState(this->hovered_widget, false);
938  this->SetWidgetDirty(this->hovered_widget);
939  this->hovered_widget = -1;
940  }
941  }
942 
943  virtual void OnMouseDrag(Point pt, int widget)
944  {
945  if (this->sel == INVALID_VEHICLE) return;
946  if (widget != this->hovered_widget) {
947  if (this->hovered_widget == WID_D_SELL || this->hovered_widget == WID_D_SELL_CHAIN) {
948  this->SetWidgetLoweredState(this->hovered_widget, false);
949  this->SetWidgetDirty(this->hovered_widget);
950  }
951  this->hovered_widget = widget;
952  if (this->hovered_widget == WID_D_SELL || this->hovered_widget == WID_D_SELL_CHAIN) {
953  this->SetWidgetLoweredState(this->hovered_widget, true);
954  this->SetWidgetDirty(this->hovered_widget);
955  }
956  }
957  if (this->type != VEH_TRAIN) return;
958 
959  /* A rail vehicle is dragged.. */
960  if (widget != WID_D_MATRIX) { // ..outside of the depot matrix.
961  if (this->vehicle_over != INVALID_VEHICLE) {
962  this->vehicle_over = INVALID_VEHICLE;
964  }
965  return;
966  }
967 
968  NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget);
969  const Vehicle *v = NULL;
970  GetDepotVehiclePtData gdvp = {NULL, NULL};
971 
972  if (this->GetVehicleFromDepotWndPt(pt.x - matrix->pos_x, pt.y - matrix->pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE) return;
973 
974  VehicleID new_vehicle_over = INVALID_VEHICLE;
975  if (gdvp.head != NULL) {
976  if (gdvp.wagon == NULL && gdvp.head->Last()->index != this->sel) { // ..at the end of the train.
977  /* NOTE: As a wagon can't be moved at the begin of a train, head index isn't used to mark a drag-and-drop
978  * destination inside a train. This head index is then used to indicate that a wagon is inserted at
979  * the end of the train.
980  */
981  new_vehicle_over = gdvp.head->index;
982  } else if (gdvp.wagon != NULL && gdvp.head != gdvp.wagon &&
983  gdvp.wagon->index != this->sel &&
984  gdvp.wagon->Previous()->index != this->sel) { // ..over an existing wagon.
985  new_vehicle_over = gdvp.wagon->index;
986  }
987  }
988 
989  if (this->vehicle_over == new_vehicle_over) return;
990 
991  this->vehicle_over = new_vehicle_over;
992  this->SetWidgetDirty(widget);
993  }
994 
995  virtual void OnDragDrop(Point pt, int widget)
996  {
997  switch (widget) {
998  case WID_D_MATRIX: {
999  const Vehicle *v = NULL;
1000  VehicleID sel = this->sel;
1001 
1002  this->sel = INVALID_VEHICLE;
1003  this->SetDirty();
1004 
1005  NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_D_MATRIX);
1006  if (this->type == VEH_TRAIN) {
1007  GetDepotVehiclePtData gdvp = { NULL, NULL };
1008 
1009  if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) {
1010  if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
1011  DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true,
1012  CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE));
1013  } else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
1014  this->vehicle_over = INVALID_VEHICLE;
1015  TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
1016  } else if (gdvp.head != NULL && gdvp.head->IsFrontEngine()) {
1017  ShowVehicleViewWindow(gdvp.head);
1018  }
1019  }
1020  } else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, NULL) == MODE_DRAG_VEHICLE && v != NULL && sel == v->index) {
1022  }
1023  break;
1024  }
1025 
1026  case WID_D_SELL: case WID_D_SELL_CHAIN: {
1027  if (this->IsWidgetDisabled(widget)) return;
1028  if (this->sel == INVALID_VEHICLE) return;
1029 
1030  this->HandleButtonClick(widget);
1031 
1032  const Vehicle *v = Vehicle::Get(this->sel);
1033  this->sel = INVALID_VEHICLE;
1034  this->SetDirty();
1035 
1036  int sell_cmd = (v->type == VEH_TRAIN && (widget == WID_D_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
1037  DoCommandP(v->tile, v->index | sell_cmd << 20 | MAKE_ORDER_BACKUP_FLAG, 0, GetCmdSellVeh(v->type));
1038  break;
1039  }
1040 
1041  default:
1042  this->sel = INVALID_VEHICLE;
1043  this->SetDirty();
1044  break;
1045  }
1046  this->hovered_widget = -1;
1047  _cursor.vehchain = false;
1048  }
1049 
1050  virtual void OnTimeout()
1051  {
1052  if (!this->IsWidgetDisabled(WID_D_SELL)) {
1053  this->RaiseWidget(WID_D_SELL);
1054  this->SetWidgetDirty(WID_D_SELL);
1055  }
1056  if (this->nested_array[WID_D_SELL] != NULL && !this->IsWidgetDisabled(WID_D_SELL_CHAIN)) {
1059  }
1060  }
1061 
1062  virtual void OnResize()
1063  {
1064  this->vscroll->SetCapacityFromWidget(this, WID_D_MATRIX);
1065  NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_D_MATRIX);
1066  if (this->type == VEH_TRAIN) {
1067  this->hscroll->SetCapacity(nwi->current_x - this->header_width - this->count_width);
1068  } else {
1069  this->num_columns = nwi->current_x / nwi->resize_x;
1070  }
1071  }
1072 
1074  {
1075  if (this->sel != INVALID_VEHICLE) {
1076  _cursor.vehchain = _ctrl_pressed;
1078  return ES_HANDLED;
1079  }
1080 
1081  return ES_NOT_HANDLED;
1082  }
1083 };
1084 
1085 static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)
1086 {
1087  if (confirmed) {
1088  DepotWindow *w = (DepotWindow*)win;
1089  TileIndex tile = w->window_number;
1090  byte vehtype = w->type;
1091  DoCommandP(tile, vehtype, 0, CMD_DEPOT_SELL_ALL_VEHICLES);
1092  }
1093 }
1094 
1101 {
1102  if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != NULL) return;
1103 
1104  WindowDesc *desc;
1105  switch (type) {
1106  default: NOT_REACHED();
1107  case VEH_TRAIN: desc = &_train_depot_desc; break;
1108  case VEH_ROAD: desc = &_road_depot_desc; break;
1109  case VEH_SHIP: desc = &_ship_depot_desc; break;
1110  case VEH_AIRCRAFT: desc = &_aircraft_depot_desc; break;
1111  }
1112 
1113  new DepotWindow(desc, tile, type);
1114 }
1115 
1121 {
1122  DepotWindow *w;
1123 
1124  /* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any depots either
1125  * If that is the case, we can skip looping though the windows and save time
1126  */
1127  if (_special_mouse_mode != WSM_DRAGDROP) return;
1128 
1129  w = dynamic_cast<DepotWindow*>(FindWindowById(WC_VEHICLE_DEPOT, v->tile));
1130  if (w != NULL) {
1131  if (w->sel == v->index) ResetObjectToPlace();
1132  }
1133 }
EventState
State of handling an event.
Definition: window_type.h:713
Colours colour
Colour of this widget.
Definition: widget_type.h:303
Functions related to OTTD&#39;s strings.
Road vehicle states.
Date max_age
Maximum age.
Definition: vehicle_base.h:259
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
Definition: vehicle_base.h:588
Vehicle is stopped by the player.
Definition: vehicle_base.h:33
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
rename a depot
Definition: command_type.h:248
static const uint MAX_LENGTH_DEPOT_NAME_CHARS
The maximum length of a depot name in characters including &#39;\0&#39;.
Definition: depot_type.h:18
virtual EventState OnCTRLStateChange()
The state of the control key has changed.
Definition: depot_gui.cpp:1073
The information about a vehicle list.
Definition: vehiclelist.h:31
ResizeInfo resize
Resize information.
Definition: window_gui.h:324
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
static uint _consistent_train_width
Whether trains of all lengths are consistently scaled. Either TRAININFO_DEFAULT_VEHICLE_WIDTH, VEHICLEINFO_FULL_VEHICLE_WIDTH, or 0.
Definition: depot_gui.cpp:151
uint resize_x
Horizontal resize step (0 means not resizable).
Definition: widget_type.h:166
List of vehicles.
Definition: depot_widget.h:32
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:455
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
Definition: zoom_func.h:72
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
Definition: ship_gui.cpp:34
Lowest bit of the number of columns.
Definition: widget_type.h:27
High level window description.
Definition: window_gui.h:168
Functions and type for generating vehicle lists.
bool IsEnabled() const
Checks whether the engine is a valid (non-articulated part of an) engine.
Definition: engine.cpp:152
int left
x position of left edge of the window
Definition: window_gui.h:319
bool vehchain
vehicle chain is dragged
Definition: gfx_type.h:146
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Definition: window.cpp:82
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:604
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:246
virtual void OnPaint()
The window must be repainted.
Definition: depot_gui.cpp:710
Scrollbar data structure.
Definition: widget_type.h:589
Build button.
Definition: depot_widget.h:27
Base for the train class.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:581
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
Dragging an object.
Definition: window_gui.h:911
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
Definition: depot_gui.cpp:925
Horizontal container.
Definition: widget_type.h:75
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
Definition: depot_gui.cpp:1100
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1114
The passed event is not handled.
Definition: window_type.h:715
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:53
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:520
Data structure describing a sprite.
Definition: spritecache.h:18
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Definition: misc_gui.cpp:1064
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:82
Depot view; Window numbers:
Definition: window_type.h:346
Maximal number of cargo types in a game.
Definition: cargo_type.h:66
void DeleteDepotHighlightOfVehicle(const Vehicle *v)
Removes the highlight of a vehicle in a depot window.
Definition: depot_gui.cpp:1120
Last company-ownable type.
Definition: vehicle_type.h:31
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
Definition: misc_gui.cpp:741
uint extend_right
Extend of the cell to the right.
Definition: vehicle_gui.h:74
Rename button.
Definition: depot_widget.h:31
Functions related to vehicles.
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:68
Build vehicle; Window numbers:
Definition: window_type.h:378
Vehicle data structure.
Definition: vehicle_base.h:212
Base for all depots (except hangars)
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
Definition: depot_gui.cpp:160
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:465
uint height
Vehicle cell height.
Definition: vehicle_gui.h:72
Tindex index
Index of this pool item.
Definition: pool_type.hpp:147
Close box (at top-left of a window)
Definition: widget_type.h:69
Offset at top of a matrix cell.
Definition: window_gui.h:80
void SetupWidgetData(VehicleType type)
Function to set up vehicle specific widgets (mainly sprites and strings).
Definition: depot_gui.cpp:593
Sell all button.
Definition: depot_widget.h:21
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons)
Generate a list of vehicles inside a depot.
Definition: vehiclelist.cpp:71
Base for aircraft.
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:50
virtual void OnMouseDrag(Point pt, int widget)
An &#39;object&#39; is being dragged at the provided position, highlight the target if possible.
Definition: depot_gui.cpp:943
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:979
uint num_columns
Number of columns.
Definition: depot_gui.cpp:266
Stuff related to the text buffer GUI.
The most basic (normal) sprite.
Definition: gfx_type.h:298
T * GetFirstEnginePart()
Get the first part of an articulated engine.
Common return value for all commands.
Definition: command_type.h:25
Vehicle drawn in purchase list, autoreplace gui, ...
Definition: vehicle_type.h:94
Vertical scrollbar.
Definition: depot_widget.h:24
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition: vehicle_type.h:59
Vehicle drawn in depot.
Definition: vehicle_type.h:91
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:89
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:485
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: depot_gui.cpp:762
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1812
static const uint TILE_SIZE
Tile size in world coordinates.
Definition: tile_type.h:15
Types related to the depot widgets.
Start all button.
Definition: depot_widget.h:34
Functions, definitions and such used only by the GUI.
void SetCapacity(int capacity)
Set the capacity of visible elements.
Definition: widget_type.h:686
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:670
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:910
Functions related to (drawing on) viewports.
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
static VehicleCellSize _base_block_sizes_purchase[VEH_COMPANY_END]
Cell size for vehicle images in the purchase list.
Definition: depot_gui.cpp:150
Data structure for an opened window.
Definition: window_gui.h:278
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:36
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1828
dragging items in the depot windows
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
Definition: tile_map.h:216
enable the &#39;Default&#39; button ("\0" is returned)
Definition: textbuf_gui.h:23
Aircraft vehicle type.
Definition: vehicle_type.h:29
virtual bool OnRightClick(Point pt, int widget)
A click with the right mouse button has been made on the window.
Definition: depot_gui.cpp:849
static const uint32 MAKE_ORDER_BACKUP_FLAG
Flag to pass to the vehicle construction command when an order should be preserved.
Definition: order_backup.h:31
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
Definition: window_gui.h:332
Offset at bottom of a matrix cell.
Definition: window_gui.h:81
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Definition: depot_gui.cpp:654
UnitID unitnumber
unit number, for display purposes only
Definition: vehicle_base.h:291
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
Definition: gfx_func.h:177
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX) ...
Definition: widget_type.h:65
uint Length() const
Get the number of items in the list.
Location button.
Definition: depot_widget.h:29
uint pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:178
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:495
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard &#39;yes&#39; and &#39;no&#39; buttons The window is aligned to the ce...
Definition: misc_gui.cpp:1205
static const NWidgetPart _nested_train_depot_widgets[]
Nested widget definition for train depots.
Definition: depot_gui.cpp:45
VehicleType
Available vehicle types.
Definition: vehicle_type.h:23
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:175
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:18
void SetStringParameters(int widget) const
Initialize string parameters for a widget.
Definition: depot_gui.cpp:426
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
Definition: tile_map.h:180
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:180
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
T * Next() const
Get next vehicle in the chain.
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:389
Definition of base types and functions in a cross-platform compatible way.
int hovered_widget
Index of the widget being hovered during drag/drop. -1 if no drag is in progress. ...
Definition: depot_gui.cpp:262
the length of the string is counted in characters
Definition: textbuf_gui.h:24
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
Show rename panel.
Definition: depot_widget.h:30
A number of safeguards to prevent using unsafe methods.
Horizontal scrollbar.
Definition: depot_widget.h:26
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition: math_func.hpp:316
virtual void OnResize()
Called after the window got resized.
Definition: depot_gui.cpp:1062
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:423
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).
virtual void OnTimeout()
Called when this window&#39;s timeout has been reached.
Definition: depot_gui.cpp:1050
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
Horizontal scrollbar.
Definition: widget_type.h:83
uint step_height
Step-size of height resize changes.
Definition: window_gui.h:220
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:311
uint traininfo_vehicle_width
Width (in pixels) of a 8/8 train vehicle in depot GUI and vehicle details.
Definition: newgrf.h:136
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:124
Functions related to order backups.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
Definition: vehicle_base.h:883
TileIndex tile
Current tile index.
Definition: vehicle_base.h:230
Show sell chain panel.
Definition: depot_widget.h:19
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Matrix of vehicles.
Definition: depot_widget.h:23
Baseclass for nested widgets.
Definition: widget_type.h:126
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:500
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:531
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
Road vehicle type.
Definition: vehicle_type.h:27
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:167
Grid of rows and columns.
Definition: widget_type.h:59
static T min(const T a, const T b)
Returns the minimum of two values.
Definition: math_func.hpp:42
uint pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:177
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:390
Clone button.
Definition: depot_widget.h:28
Functions to cache sprites in memory.
bool Failed() const
Did this command fail?
Definition: command_type.h:161
int GetDisplayImageWidth(Point *offset=NULL) const
Get the width of a train vehicle image in the GUI.
Definition: train_cmd.cpp:435
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Definition: depot_map.h:54
static const int WIDGET_LIST_END
indicate the end of widgets&#39; list for vararg functions
Definition: widget_type.h:22
Scrollbar * hscroll
Only for trains.
Definition: depot_gui.cpp:267
uint16 height
Height of the sprite.
Definition: spritecache.h:19
Ship vehicle type.
Definition: vehicle_type.h:28
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:139
force the autoreplace to take action in a given depot
Definition: command_type.h:316
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:968
void ShowExtraViewPortWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
&#39;Train&#39; is either a loco or a wagon.
Definition: train.h:88
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:700
virtual void OnDragDrop(Point pt, int widget)
A dragged &#39;object&#39; has been released.
Definition: depot_gui.cpp:995
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:40
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1146
Sell button.
Definition: depot_widget.h:18
uint16 width
Width of the sprite.
Definition: spritecache.h:20
Functions related to companies.
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Definition: station_map.h:29
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
Definition: viewport.cpp:3025
Class for storing amounts of cargo.
Definition: cargo_type.h:83
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition: depot_gui.cpp:705
Both numeric and alphabetic and spaces and stuff.
Definition: string_type.h:27
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
Definition: vehicle_base.h:471
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
Definition: engine_base.h:140
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:22
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
uint32 Pack() const
Pack a VehicleListIdentifier in a single uint32.
Definition: vehiclelist.cpp:23
Show horizontal scrollbar panel.
Definition: depot_widget.h:25
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:52
Caption of window.
Definition: depot_widget.h:17
void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const
Draw a vehicle in the depot window in the box with the top left corner at x,y.
Definition: depot_gui.cpp:311
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:108
Vertical container.
Definition: widget_type.h:77
turn a train around
Definition: command_type.h:223
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
uint16 cached_total_length
Length of the whole vehicle (valid only for the first engine).
Functions related to zooming.
void InitDepotWindowBlockSizes()
Set the size of the blocks in the window so we can be sure that they are big enough for the vehicle s...
Definition: depot_gui.cpp:218
Dimensions of a cell in the purchase/depot windows.
Definition: vehicle_gui.h:71
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:174
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).
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
Definition: vehicle_gui.h:62
uint step_width
Step-size of width resize changes.
Definition: window_gui.h:219
sell all vehicles which are in a given depot
Definition: command_type.h:315
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Definition: viewport.cpp:2133
Functions related to commands.
uint32 CursorID
The number of the cursor (sprite)
Definition: gfx_type.h:21
Coordinates of a point in 2D.
clone a vehicle
Definition: command_type.h:311
Stop all button.
Definition: depot_widget.h:33
Base for ships.
Index of the small font in the font tables.
Definition: gfx_type.h:205
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:622
start/stop all vehicles (in a depot)
Definition: command_type.h:313
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable...
Definition: window_gui.h:326
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:619
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
vehicle is accepted as target as well (bitmask)
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
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:321
Autoreplace button.
Definition: depot_widget.h:22
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
void DepotClick(int x, int y)
Handle click in the depot matrix.
Definition: depot_gui.cpp:544
virtual bool OnVehicleSelect(const Vehicle *v)
Clones a vehicle.
Definition: depot_gui.cpp:910
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:369
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget. ...
Definition: widget.cpp:1973
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Definition: viewport.cpp:3088
Specification of a rectangle with absolute coordinates of all edges.
Vertical scrollbar.
Definition: widget_type.h:84
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
The passed event is handled.
Definition: window_type.h:714
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a ship sprite heading west (used for lists).
Definition: ship_cmd.cpp:114
Text is written right-to-left by default.
Definition: strings_type.h:26
Right align the text (must be a single bit).
Definition: gfx_func.h:100
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:314
uint extend_left
Extend of the cell to the left.
Definition: vehicle_gui.h:73
static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]
Cell size for vehicle images in the depot view.
Definition: depot_gui.cpp:149
Functions related to tile highlights.
VehicleID vehicle_over
Rail vehicle over which another one is dragged, INVALID_VEHICLE if none.
Definition: depot_gui.cpp:259
Vehicle * Last()
Get the last vehicle of this vehicle chain.
Definition: vehicle_base.h:600
Find a place automatically.
Definition: window_gui.h:156
(Toggle) Button with image
Definition: widget_type.h:52
void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: depot_gui.cpp:368
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:80
move a rail vehicle (in the depot)
Definition: command_type.h:221
GUI functions that shouldn&#39;t be here.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Definition: sprites.h:1360
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
This is the Callback method after the cloning attempt of a vehicle.
Definition: depot_gui.cpp:122
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
Definition: depot_gui.cpp:841
Date age
Age in days.
Definition: vehicle_base.h:258
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:552
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1095
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
Definition: vehicle_func.h:91
VehicleTypeByte type
Type of vehicle.
Definition: vehicle_type.h:56
Dimensions (a width and height) of a rectangle in 2D.
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:429
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1243
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:64
Sell chain button.
Definition: depot_widget.h:20
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:834
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
Definition: date_type.h:32
GroundVehicleCache gcache
Cache of often calculated values.
(Toggle) Button with text
Definition: widget_type.h:55
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:631
Train vehicle type.
Definition: vehicle_type.h:26
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
Base class for a &#39;real&#39; widget.
Definition: widget_type.h:284