OpenTTD Source  1.10.3
group_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "textbuf_gui.h"
12 #include "command_func.h"
13 #include "vehicle_gui.h"
14 #include "vehicle_base.h"
15 #include "string_func.h"
16 #include "strings_func.h"
17 #include "window_func.h"
18 #include "vehicle_func.h"
19 #include "autoreplace_gui.h"
20 #include "company_func.h"
21 #include "widgets/dropdown_func.h"
22 #include "tilehighlight_func.h"
23 #include "vehicle_gui_base.h"
24 #include "core/geometry_func.hpp"
25 #include "company_base.h"
26 #include "company_gui.h"
27 
28 #include "widgets/group_widget.h"
29 
30 #include "table/sprites.h"
31 
32 #include "safeguards.h"
33 
34 static const int LEVEL_WIDTH = 10;
35 
37 
38 static const NWidgetPart _nested_group_widgets[] = {
39  NWidget(NWID_HORIZONTAL), // Window header
40  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
41  NWidget(WWT_CAPTION, COLOUR_GREY, WID_GL_CAPTION),
42  NWidget(WWT_SHADEBOX, COLOUR_GREY),
43  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
44  NWidget(WWT_STICKYBOX, COLOUR_GREY),
45  EndContainer(),
47  /* left part */
50  NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_ALL_VEHICLES), SetFill(1, 0), EndContainer(),
53  NWidget(WWT_MATRIX, COLOUR_GREY, WID_GL_LIST_GROUP), SetMatrixDataTip(1, 0, STR_GROUPS_CLICK_ON_GROUP_FOR_TOOLTIP),
56  EndContainer(),
57  NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_INFO), SetFill(1, 0), EndContainer(),
59  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_CREATE_GROUP), SetFill(0, 1),
60  SetDataTip(SPR_GROUP_CREATE_TRAIN, STR_GROUP_CREATE_TOOLTIP),
61  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_DELETE_GROUP), SetFill(0, 1),
62  SetDataTip(SPR_GROUP_DELETE_TRAIN, STR_GROUP_DELETE_TOOLTIP),
63  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_RENAME_GROUP), SetFill(0, 1),
64  SetDataTip(SPR_GROUP_RENAME_TRAIN, STR_GROUP_RENAME_TOOLTIP),
65  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_LIVERY_GROUP), SetFill(0, 1),
66  SetDataTip(SPR_GROUP_LIVERY_TRAIN, STR_GROUP_LIVERY_TOOLTIP),
67  NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
69  SetDataTip(SPR_GROUP_REPLACE_OFF_TRAIN, STR_GROUP_REPLACE_PROTECTION_TOOLTIP),
70  EndContainer(),
71  EndContainer(),
72  /* right part */
75  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_SORT_BY_ORDER), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
76  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_SORT_BY_DROPDOWN), SetMinimalSize(167, 12), SetDataTip(0x0, STR_TOOLTIP_SORT_CRITERIA),
77  NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(12, 12), SetResize(1, 0), EndContainer(),
78  EndContainer(),
82  EndContainer(),
83  NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(1, 0), SetFill(1, 1), SetResize(1, 0), EndContainer(),
86  SetDataTip(STR_BLACK_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
87  NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 1), SetResize(1, 0), EndContainer(),
89  SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
90  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_STOP_ALL), SetMinimalSize(12, 12), SetFill(0, 1),
91  SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
92  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_START_ALL), SetMinimalSize(12, 12), SetFill(0, 1),
93  SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
94  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
95  EndContainer(),
96  EndContainer(),
97  EndContainer(),
98 };
99 
101 private:
102  /* Columns in the group list */
103  enum ListColumns {
110 
111  VGC_END
112  };
113 
121  Scrollbar *group_sb;
122 
123  std::vector<int> indents;
124 
126 
127  void AddChildren(GUIGroupList *source, GroupID parent, int indent)
128  {
129  for (const Group *g : *source) {
130  if (g->parent != parent) continue;
131  this->groups.push_back(g);
132  this->indents.push_back(indent);
133  if (g->folded) {
134  /* Test if this group has children at all. If not, the folded flag should be cleared to avoid lingering unfold buttons in the list. */
135  auto child = std::find_if(source->begin(), source->end(), [g](const Group *child){ return child->parent == g->index; });
136  bool has_children = child != source->end();
137  Group::Get(g->index)->folded = has_children;
138  } else {
139  AddChildren(source, g->index, indent + 1);
140  }
141  }
142  }
143 
150  {
151  if (!this->groups.NeedRebuild()) return;
152 
153  this->groups.clear();
154  this->indents.clear();
155 
156  GUIGroupList list;
157 
158  for (const Group *g : Group::Iterate()) {
159  if (g->owner == owner && g->vehicle_type == this->vli.vtype) {
160  list.push_back(g);
161  }
162  }
163 
164  list.ForceResort();
165 
166  /* Sort the groups by their name */
167  const Group *last_group[2] = { nullptr, nullptr };
168  char last_name[2][64] = { "", "" };
169  list.Sort([&](const Group * const &a, const Group * const &b) {
170  if (a != last_group[0]) {
171  last_group[0] = a;
172  SetDParam(0, a->index);
173  GetString(last_name[0], STR_GROUP_NAME, lastof(last_name[0]));
174  }
175 
176  if (b != last_group[1]) {
177  last_group[1] = b;
178  SetDParam(0, b->index);
179  GetString(last_name[1], STR_GROUP_NAME, lastof(last_name[1]));
180  }
181 
182  int r = strnatcmp(last_name[0], last_name[1]); // Sort by name (natural sorting).
183  if (r == 0) return a->index < b->index;
184  return r < 0;
185  });
186 
187  AddChildren(&list, INVALID_GROUP, 0);
188 
189  this->groups.shrink_to_fit();
190  this->groups.RebuildDone();
191  }
192 
198  {
199  this->column_size[VGC_FOLD] = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
200  this->tiny_step_height = this->column_size[VGC_FOLD].height;
201 
202  this->column_size[VGC_NAME] = maxdim(GetStringBoundingBox(STR_GROUP_DEFAULT_TRAINS + this->vli.vtype), GetStringBoundingBox(STR_GROUP_ALL_TRAINS + this->vli.vtype));
203  this->column_size[VGC_NAME].width = max(170u, this->column_size[VGC_NAME].width);
204  this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_NAME].height);
205 
206  this->column_size[VGC_PROTECT] = GetSpriteSize(SPR_GROUP_REPLACE_PROTECT);
207  this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_PROTECT].height);
208 
209  this->column_size[VGC_AUTOREPLACE] = GetSpriteSize(SPR_GROUP_REPLACE_ACTIVE);
210  this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_AUTOREPLACE].height);
211 
212  this->column_size[VGC_PROFIT].width = 0;
213  this->column_size[VGC_PROFIT].height = 0;
214  static const SpriteID profit_sprites[] = {SPR_PROFIT_NA, SPR_PROFIT_NEGATIVE, SPR_PROFIT_SOME, SPR_PROFIT_LOT};
215  for (uint i = 0; i < lengthof(profit_sprites); i++) {
216  Dimension d = GetSpriteSize(profit_sprites[i]);
217  this->column_size[VGC_PROFIT] = maxdim(this->column_size[VGC_PROFIT], d);
218  }
219  this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_PROFIT].height);
220 
221  int num_vehicle = GetGroupNumVehicle(this->vli.company, ALL_GROUP, this->vli.vtype);
222  SetDParamMaxValue(0, num_vehicle, 3, FS_SMALL);
223  SetDParamMaxValue(1, num_vehicle, 3, FS_SMALL);
224  this->column_size[VGC_NUMBER] = GetStringBoundingBox(STR_GROUP_COUNT_WITH_SUBGROUP);
225  this->tiny_step_height = max(this->tiny_step_height, this->column_size[VGC_NUMBER].height);
226 
227  this->tiny_step_height += WD_MATRIX_TOP;
228 
229  return WD_FRAMERECT_LEFT + 8 +
230  this->column_size[VGC_FOLD].width + 2 +
231  this->column_size[VGC_NAME].width + 8 +
232  this->column_size[VGC_PROTECT].width + 2 +
233  this->column_size[VGC_AUTOREPLACE].width + 2 +
234  this->column_size[VGC_PROFIT].width + 2 +
235  this->column_size[VGC_NUMBER].width + 2 +
237  }
238 
249  void DrawGroupInfo(int y, int left, int right, GroupID g_id, int indent = 0, bool protection = false, bool has_children = false) const
250  {
251  /* Highlight the group if a vehicle is dragged over it */
252  if (g_id == this->group_over) {
253  GfxFillRect(left + WD_FRAMERECT_LEFT, y + WD_FRAMERECT_TOP, right - WD_FRAMERECT_RIGHT, y + this->tiny_step_height - WD_FRAMERECT_BOTTOM - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][7]);
254  }
255 
256  if (g_id == NEW_GROUP) return;
257 
258  /* draw the selected group in white, else we draw it in black */
259  TextColour colour = g_id == this->vli.index ? TC_WHITE : TC_BLACK;
260  const GroupStatistics &stats = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype);
261  bool rtl = _current_text_dir == TD_RTL;
262 
263  /* draw fold / unfold button */
264  int x = rtl ? right - WD_FRAMERECT_RIGHT - 8 - this->column_size[VGC_FOLD].width + 1 : left + WD_FRAMERECT_LEFT + 8;
265  if (has_children) {
266  DrawSprite(Group::Get(g_id)->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED, PAL_NONE, rtl ? x - indent : x + indent, y + (this->tiny_step_height - this->column_size[VGC_FOLD].height) / 2);
267  }
268 
269  /* draw group name */
270  StringID str;
271  if (IsAllGroupID(g_id)) {
272  str = STR_GROUP_ALL_TRAINS + this->vli.vtype;
273  } else if (IsDefaultGroupID(g_id)) {
274  str = STR_GROUP_DEFAULT_TRAINS + this->vli.vtype;
275  } else {
276  SetDParam(0, g_id);
277  str = STR_GROUP_NAME;
278  }
279  x = rtl ? x - 2 - this->column_size[VGC_NAME].width : x + 2 + this->column_size[VGC_FOLD].width;
280  DrawString(x + (rtl ? 0 : indent), x + this->column_size[VGC_NAME].width - 1 - (rtl ? indent : 0), y + (this->tiny_step_height - this->column_size[VGC_NAME].height) / 2, str, colour);
281 
282  /* draw autoreplace protection */
283  x = rtl ? x - 8 - this->column_size[VGC_PROTECT].width : x + 8 + this->column_size[VGC_NAME].width;
284  if (protection) DrawSprite(SPR_GROUP_REPLACE_PROTECT, PAL_NONE, x, y + (this->tiny_step_height - this->column_size[VGC_PROTECT].height) / 2);
285 
286  /* draw autoreplace status */
287  x = rtl ? x - 2 - this->column_size[VGC_AUTOREPLACE].width : x + 2 + this->column_size[VGC_PROTECT].width;
288  if (stats.autoreplace_defined) DrawSprite(SPR_GROUP_REPLACE_ACTIVE, stats.autoreplace_finished ? PALETTE_CRASH : PAL_NONE, x, y + (this->tiny_step_height - this->column_size[VGC_AUTOREPLACE].height) / 2);
289 
290  /* draw the profit icon */
291  x = rtl ? x - 2 - this->column_size[VGC_PROFIT].width : x + 2 + this->column_size[VGC_AUTOREPLACE].width;
292  SpriteID spr;
293  uint num_profit_vehicle = GetGroupNumProfitVehicle(this->vli.company, g_id, this->vli.vtype);
294  Money profit_last_year = GetGroupProfitLastYear(this->vli.company, g_id, this->vli.vtype);
295  if (num_profit_vehicle == 0) {
296  spr = SPR_PROFIT_NA;
297  } else if (profit_last_year < 0) {
298  spr = SPR_PROFIT_NEGATIVE;
299  } else if (profit_last_year < VEHICLE_PROFIT_THRESHOLD * num_profit_vehicle) {
300  spr = SPR_PROFIT_SOME;
301  } else {
302  spr = SPR_PROFIT_LOT;
303  }
304  DrawSprite(spr, PAL_NONE, x, y + (this->tiny_step_height - this->column_size[VGC_PROFIT].height) / 2);
305 
306  /* draw the number of vehicles of the group */
307  x = rtl ? x - 2 - this->column_size[VGC_NUMBER].width : x + 2 + this->column_size[VGC_PROFIT].width;
308  int num_vehicle_with_subgroups = GetGroupNumVehicle(this->vli.company, g_id, this->vli.vtype);
309  int num_vehicle = GroupStatistics::Get(this->vli.company, g_id, this->vli.vtype).num_vehicle;
310  if (IsAllGroupID(g_id) || IsDefaultGroupID(g_id) || num_vehicle_with_subgroups == num_vehicle) {
311  SetDParam(0, num_vehicle);
312  DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, STR_TINY_COMMA, colour, SA_RIGHT | SA_FORCE);
313  } else {
314  SetDParam(0, num_vehicle);
315  SetDParam(1, num_vehicle_with_subgroups - num_vehicle);
316  DrawString(x, x + this->column_size[VGC_NUMBER].width - 1, y + (this->tiny_step_height - this->column_size[VGC_NUMBER].height) / 2, STR_GROUP_COUNT_WITH_SUBGROUP, colour, SA_RIGHT | SA_FORCE);
317  }
318  }
319 
324  {
325  if (this->group_over == INVALID_GROUP) return;
326 
327  if (IsAllGroupID(this->group_over)) {
329  } else if (IsDefaultGroupID(this->group_over)) {
331  } else {
333  }
334  }
335 
336 public:
338  {
339  this->CreateNestedTree();
340 
341  this->vscroll = this->GetScrollbar(WID_GL_LIST_VEHICLE_SCROLLBAR);
342  this->group_sb = this->GetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR);
343 
344  switch (this->vli.vtype) {
345  default: NOT_REACHED();
346  case VEH_TRAIN: this->sorting = &_sorting.train; break;
347  case VEH_ROAD: this->sorting = &_sorting.roadveh; break;
348  case VEH_SHIP: this->sorting = &_sorting.ship; break;
349  case VEH_AIRCRAFT: this->sorting = &_sorting.aircraft; break;
350  }
351 
352  this->vli.index = ALL_GROUP;
353  this->vehicle_sel = INVALID_VEHICLE;
354  this->group_sel = INVALID_GROUP;
355  this->group_rename = INVALID_GROUP;
356  this->group_over = INVALID_GROUP;
357 
358  this->vehicles.SetListing(*this->sorting);
359  this->vehicles.ForceRebuild();
360  this->vehicles.NeedResort();
361 
362  this->BuildVehicleList();
363  this->SortVehicleList();
364 
365  this->groups.ForceRebuild();
366  this->groups.NeedResort();
367  this->BuildGroupList(vli.company);
368  this->group_sb->SetCount((uint)this->groups.size());
369 
370  this->GetWidget<NWidgetCore>(WID_GL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->vli.vtype;
371  this->GetWidget<NWidgetCore>(WID_GL_LIST_VEHICLE)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->vli.vtype;
372 
373  this->GetWidget<NWidgetCore>(WID_GL_CREATE_GROUP)->widget_data += this->vli.vtype;
374  this->GetWidget<NWidgetCore>(WID_GL_RENAME_GROUP)->widget_data += this->vli.vtype;
375  this->GetWidget<NWidgetCore>(WID_GL_DELETE_GROUP)->widget_data += this->vli.vtype;
376  this->GetWidget<NWidgetCore>(WID_GL_LIVERY_GROUP)->widget_data += this->vli.vtype;
377  this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->widget_data += this->vli.vtype;
378 
379  this->FinishInitNested(window_number);
380  this->owner = vli.company;
381  }
382 
384  {
385  *this->sorting = this->vehicles.GetListing();
386  }
387 
388  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
389  {
390  switch (widget) {
391  case WID_GL_LIST_GROUP: {
392  size->width = this->ComputeGroupInfoSize();
393  resize->height = this->tiny_step_height;
394 
395  /* Minimum height is the height of the list widget minus all and default vehicles... */
396  size->height = 4 * GetVehicleListHeight(this->vli.vtype, this->tiny_step_height) - 2 * this->tiny_step_height;
397 
398  /* ... minus the buttons at the bottom ... */
399  uint max_icon_height = GetSpriteSize(this->GetWidget<NWidgetCore>(WID_GL_CREATE_GROUP)->widget_data).height;
400  max_icon_height = max(max_icon_height, GetSpriteSize(this->GetWidget<NWidgetCore>(WID_GL_RENAME_GROUP)->widget_data).height);
401  max_icon_height = max(max_icon_height, GetSpriteSize(this->GetWidget<NWidgetCore>(WID_GL_DELETE_GROUP)->widget_data).height);
402  max_icon_height = max(max_icon_height, GetSpriteSize(this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->widget_data).height);
403 
404  /* ... minus the height of the group info ... */
405  max_icon_height += (FONT_HEIGHT_NORMAL * 3) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
406 
407  /* Get a multiple of tiny_step_height of that amount */
408  size->height = Ceil(size->height - max_icon_height, tiny_step_height);
409  break;
410  }
411 
412  case WID_GL_ALL_VEHICLES:
414  size->width = this->ComputeGroupInfoSize();
415  size->height = this->tiny_step_height;
416  break;
417 
418  case WID_GL_SORT_BY_ORDER: {
419  Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
420  d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
421  d.height += padding.height;
422  *size = maxdim(*size, d);
423  break;
424  }
425 
426  case WID_GL_LIST_VEHICLE:
427  this->ComputeGroupInfoSize();
428  resize->height = GetVehicleListHeight(this->vli.vtype, this->tiny_step_height);
429  size->height = 4 * resize->height;
430  break;
431 
433  Dimension d = this->GetActionDropdownSize(true, true);
434  d.height += padding.height;
435  d.width += padding.width;
436  *size = maxdim(*size, d);
437  break;
438  }
439 
440  case WID_GL_INFO: {
442  break;
443  }
444  }
445  }
446 
452  void OnInvalidateData(int data = 0, bool gui_scope = true) override
453  {
454  if (data == 0) {
455  /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
456  this->vehicles.ForceRebuild();
457  this->groups.ForceRebuild();
458  } else {
459  this->vehicles.ForceResort();
460  this->groups.ForceResort();
461  }
462 
463  /* Process ID-invalidation in command-scope as well */
464  if (this->group_rename != INVALID_GROUP && !Group::IsValidID(this->group_rename)) {
466  this->group_rename = INVALID_GROUP;
467  }
468 
469  if (!(IsAllGroupID(this->vli.index) || IsDefaultGroupID(this->vli.index) || Group::IsValidID(this->vli.index))) {
470  this->vli.index = ALL_GROUP;
471  HideDropDownMenu(this);
472  }
473  this->SetDirty();
474  }
475 
476  void SetStringParameters(int widget) const override
477  {
478  switch (widget) {
480  SetDParam(0, STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype);
481  break;
482 
483  case WID_GL_CAPTION:
484  /* If selected_group == DEFAULT_GROUP || ALL_GROUP, draw the standard caption
485  * We list all vehicles or ungrouped vehicles */
486  if (IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index)) {
487  SetDParam(0, STR_COMPANY_NAME);
488  SetDParam(1, this->vli.company);
489  SetDParam(2, this->vehicles.size());
490  SetDParam(3, this->vehicles.size());
491  } else {
492  uint num_vehicle = GetGroupNumVehicle(this->vli.company, this->vli.index, this->vli.vtype);
493 
494  SetDParam(0, STR_GROUP_NAME);
495  SetDParam(1, this->vli.index);
496  SetDParam(2, num_vehicle);
497  SetDParam(3, num_vehicle);
498  }
499  break;
500  }
501  }
502 
503  void OnPaint() override
504  {
505  /* If we select the all vehicles, this->list will contain all vehicles of the owner
506  * else this->list will contain all vehicles which belong to the selected group */
507  this->BuildVehicleList();
508  this->SortVehicleList();
509 
510  this->BuildGroupList(this->owner);
511 
512  this->group_sb->SetCount((uint)this->groups.size());
513  this->vscroll->SetCount((uint)this->vehicles.size());
514 
515  /* The drop down menu is out, *but* it may not be used, retract it. */
516  if (this->vehicles.size() == 0 && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) {
518  HideDropDownMenu(this);
519  }
520 
521  /* Disable all lists management button when the list is empty */
522  this->SetWidgetsDisabledState(this->vehicles.size() == 0 || _local_company != this->vli.company,
527 
528  /* Disable the group specific function when we select the default group or all vehicles */
529  this->SetWidgetsDisabledState(IsDefaultGroupID(this->vli.index) || IsAllGroupID(this->vli.index) || _local_company != this->vli.company,
535 
536  /* Disable remaining buttons for non-local companies
537  * Needed while changing _local_company, eg. by cheats
538  * All procedures (eg. move vehicle to another group)
539  * verify, whether you are the owner of the vehicle,
540  * so it doesn't have to be disabled
541  */
546 
547  /* If not a default group and the group has replace protection, show an enabled replace sprite. */
548  uint16 protect_sprite = SPR_GROUP_REPLACE_OFF_TRAIN;
549  if (!IsDefaultGroupID(this->vli.index) && !IsAllGroupID(this->vli.index) && Group::Get(this->vli.index)->replace_protection) protect_sprite = SPR_GROUP_REPLACE_ON_TRAIN;
550  this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->widget_data = protect_sprite + this->vli.vtype;
551 
552  /* Set text of sort by dropdown */
553  this->GetWidget<NWidgetCore>(WID_GL_SORT_BY_DROPDOWN)->widget_data = this->vehicle_sorter_names[this->vehicles.SortType()];
554 
555  this->DrawWidgets();
556  }
557 
558  void DrawWidget(const Rect &r, int widget) const override
559  {
560  switch (widget) {
561  case WID_GL_ALL_VEHICLES:
562  DrawGroupInfo(r.top + WD_FRAMERECT_TOP, r.left, r.right, ALL_GROUP);
563  break;
564 
566  DrawGroupInfo(r.top + WD_FRAMERECT_TOP, r.left, r.right, DEFAULT_GROUP);
567  break;
568 
569  case WID_GL_INFO: {
570  Money this_year = 0;
571  Money last_year = 0;
572  uint32 occupancy = 0;
573  size_t vehicle_count = this->vehicles.size();
574 
575  for (uint i = 0; i < vehicle_count; i++) {
576  const Vehicle *v = this->vehicles[i];
577  assert(v->owner == this->owner);
578 
579  this_year += v->GetDisplayProfitThisYear();
580  last_year += v->GetDisplayProfitLastYear();
581  occupancy += v->trip_occupancy;
582  }
583 
584  const int left = r.left + WD_FRAMERECT_LEFT + 8;
585  const int right = r.right - WD_FRAMERECT_RIGHT - 8;
586 
587  int y = r.top + WD_FRAMERECT_TOP;
588  DrawString(left, right, y, STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
589  SetDParam(0, this_year);
590  DrawString(left, right, y, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
591 
592  y += FONT_HEIGHT_NORMAL;
593  DrawString(left, right, y, STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK);
594  SetDParam(0, last_year);
595  DrawString(left, right, y, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
596 
597  y += FONT_HEIGHT_NORMAL;
598  DrawString(left, right, y, STR_GROUP_OCCUPANCY, TC_BLACK);
599  if (vehicle_count > 0) {
600  SetDParam(0, occupancy / vehicle_count);
601  DrawString(left, right, y, STR_GROUP_OCCUPANCY_VALUE, TC_BLACK, SA_RIGHT);
602  }
603 
604  break;
605  }
606 
607  case WID_GL_LIST_GROUP: {
608  int y1 = r.top + WD_FRAMERECT_TOP;
609  int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), (uint)this->groups.size());
610  for (int i = this->group_sb->GetPosition(); i < max; ++i) {
611  const Group *g = this->groups[i];
612 
613  assert(g->owner == this->owner);
614 
615  DrawGroupInfo(y1, r.left, r.right, g->index, this->indents[i] * LEVEL_WIDTH, g->replace_protection, g->folded || (i + 1 < (int)this->groups.size() && indents[i + 1] > this->indents[i]));
616 
617  y1 += this->tiny_step_height;
618  }
619  if ((uint)this->group_sb->GetPosition() + this->group_sb->GetCapacity() > this->groups.size()) {
620  DrawGroupInfo(y1, r.left, r.right, NEW_GROUP);
621  }
622  break;
623  }
624 
627  break;
628 
629  case WID_GL_LIST_VEHICLE:
630  if (this->vli.index != ALL_GROUP) {
631  /* Mark vehicles which are in sub-groups */
632  int y = r.top;
633  uint max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->vehicles.size());
634  for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
635  const Vehicle *v = this->vehicles[i];
636  if (v->group_id != this->vli.index) {
637  GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 2, _colour_gradient[COLOUR_GREY][3], FILLRECT_CHECKER);
638  }
639  y += this->resize.step_height;
640  }
641  }
642 
643  this->DrawVehicleListItems(this->vehicle_sel, this->resize.step_height, r);
644  break;
645  }
646  }
647 
648  static void DeleteGroupCallback(Window *win, bool confirmed)
649  {
650  if (confirmed) {
652  w->vli.index = ALL_GROUP;
653  DoCommandP(0, w->group_confirm, 0, CMD_DELETE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_DELETE));
654  }
655  }
656 
657  void OnClick(Point pt, int widget, int click_count) override
658  {
659  switch (widget) {
660  case WID_GL_SORT_BY_ORDER: // Flip sorting method ascending/descending
661  this->vehicles.ToggleSortOrder();
662  this->SetDirty();
663  break;
664 
665  case WID_GL_SORT_BY_DROPDOWN: // Select sorting criteria dropdown menu
666  ShowDropDownMenu(this, this->vehicle_sorter_names, this->vehicles.SortType(), WID_GL_SORT_BY_DROPDOWN, 0, (this->vli.vtype == VEH_TRAIN || this->vli.vtype == VEH_ROAD) ? 0 : (1 << 10));
667  return;
668 
669  case WID_GL_ALL_VEHICLES: // All vehicles button
670  if (!IsAllGroupID(this->vli.index)) {
671  this->vli.index = ALL_GROUP;
672  this->vehicles.ForceRebuild();
673  this->SetDirty();
674  }
675  break;
676 
677  case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles button
678  if (!IsDefaultGroupID(this->vli.index)) {
679  this->vli.index = DEFAULT_GROUP;
680  this->vehicles.ForceRebuild();
681  this->SetDirty();
682  }
683  break;
684 
685  case WID_GL_LIST_GROUP: { // Matrix Group
686  uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
687  if (id_g >= this->groups.size()) return;
688 
689  if (groups[id_g]->folded || (id_g + 1 < this->groups.size() && this->indents[id_g + 1] > this->indents[id_g])) {
690  /* The group has children, check if the user clicked the fold / unfold button. */
691  NWidgetCore *group_display = this->GetWidget<NWidgetCore>(widget);
692  int x = _current_text_dir == TD_RTL ?
693  group_display->pos_x + group_display->current_x - WD_FRAMERECT_RIGHT - 8 - this->indents[id_g] * LEVEL_WIDTH - this->column_size[VGC_FOLD].width :
694  group_display->pos_x + WD_FRAMERECT_LEFT + 8 + this->indents[id_g] * LEVEL_WIDTH;
695  if (click_count > 1 || (pt.x >= x && pt.x < (int)(x + this->column_size[VGC_FOLD].width))) {
696 
697  GroupID g = this->vli.index;
698  if (!IsAllGroupID(g) && !IsDefaultGroupID(g)) {
699  do {
700  g = Group::Get(g)->parent;
701  if (g == groups[id_g]->index) {
702  this->vli.index = g;
703  break;
704  }
705  } while (g != INVALID_GROUP);
706  }
707 
708  Group::Get(groups[id_g]->index)->folded = !groups[id_g]->folded;
709  this->groups.ForceRebuild();
710 
711  this->SetDirty();
712  break;
713  }
714  }
715 
716  this->group_sel = this->vli.index = this->groups[id_g]->index;
717 
718  SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
719 
720  this->vehicles.ForceRebuild();
721  this->SetDirty();
722  break;
723  }
724 
725  case WID_GL_LIST_VEHICLE: { // Matrix Vehicle
726  uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_VEHICLE);
727  if (id_v >= this->vehicles.size()) return; // click out of list bound
728 
729  const Vehicle *v = this->vehicles[id_v];
730  if (VehicleClicked(v)) break;
731 
732  this->vehicle_sel = v->index;
733 
734  if (_ctrl_pressed) {
735  this->SelectGroup(v->group_id);
736  }
737 
738  SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
740  _cursor.vehchain = true;
741 
742  this->SetDirty();
743  break;
744  }
745 
746  case WID_GL_CREATE_GROUP: { // Create a new group
747  DoCommandP(0, this->vli.vtype, this->vli.index, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup);
748  break;
749  }
750 
751  case WID_GL_DELETE_GROUP: { // Delete the selected group
752  this->group_confirm = this->vli.index;
753  ShowQuery(STR_QUERY_GROUP_DELETE_CAPTION, STR_GROUP_DELETE_QUERY_TEXT, this, DeleteGroupCallback);
754  break;
755  }
756 
757  case WID_GL_RENAME_GROUP: // Rename the selected roup
758  this->ShowRenameGroupWindow(this->vli.index, false);
759  break;
760 
761  case WID_GL_LIVERY_GROUP: // Set group livery
762  ShowCompanyLiveryWindow(this->owner, this->vli.index);
763  break;
764 
766  ShowBuildVehicleWindow(INVALID_TILE, this->vli.vtype);
767  break;
768 
771  break;
772  }
773 
774  case WID_GL_START_ALL:
775  case WID_GL_STOP_ALL: { // Start/stop all vehicles of the list
776  DoCommandP(0, (1 << 1) | (widget == WID_GL_START_ALL ? (1 << 0) : 0), this->vli.Pack(), CMD_MASS_START_STOP);
777  break;
778  }
779 
781  const Group *g = Group::GetIfValid(this->vli.index);
782  if (g != nullptr) {
784  }
785  break;
786  }
787  }
788  }
789 
790  void OnDragDrop_Group(Point pt, int widget)
791  {
792  const Group *g = Group::Get(this->group_sel);
793 
794  switch (widget) {
795  case WID_GL_ALL_VEHICLES: // All vehicles
796  case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
797  if (g->parent != INVALID_GROUP) {
798  DoCommandP(0, this->group_sel | (1 << 16), INVALID_GROUP, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT));
799  }
800 
801  this->group_sel = INVALID_GROUP;
802  this->group_over = INVALID_GROUP;
803  this->SetDirty();
804  break;
805 
806  case WID_GL_LIST_GROUP: { // Matrix group
807  uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
808  GroupID new_g = id_g >= this->groups.size() ? INVALID_GROUP : this->groups[id_g]->index;
809 
810  if (this->group_sel != new_g && g->parent != new_g) {
811  DoCommandP(0, this->group_sel | (1 << 16), new_g, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT));
812  }
813 
814  this->group_sel = INVALID_GROUP;
815  this->group_over = INVALID_GROUP;
816  this->SetDirty();
817  break;
818  }
819  }
820  }
821 
822  void OnDragDrop_Vehicle(Point pt, int widget)
823  {
824  switch (widget) {
825  case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
826  DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE));
827 
828  this->vehicle_sel = INVALID_VEHICLE;
829  this->group_over = INVALID_GROUP;
830 
831  this->SetDirty();
832  break;
833 
834  case WID_GL_LIST_GROUP: { // Matrix group
835  const VehicleID vindex = this->vehicle_sel;
836  this->vehicle_sel = INVALID_VEHICLE;
837  this->group_over = INVALID_GROUP;
838  this->SetDirty();
839 
840  uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
841  GroupID new_g = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
842 
843  DoCommandP(0, new_g, vindex | (_ctrl_pressed ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr);
844  break;
845  }
846 
847  case WID_GL_LIST_VEHICLE: { // Matrix vehicle
848  const VehicleID vindex = this->vehicle_sel;
849  this->vehicle_sel = INVALID_VEHICLE;
850  this->group_over = INVALID_GROUP;
851  this->SetDirty();
852 
853  uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_VEHICLE);
854  if (id_v >= this->vehicles.size()) return; // click out of list bound
855 
856  const Vehicle *v = this->vehicles[id_v];
857  if (!VehicleClicked(v) && vindex == v->index) {
859  }
860  break;
861  }
862  }
863  }
864 
865  void OnDragDrop(Point pt, int widget) override
866  {
867  if (this->vehicle_sel != INVALID_VEHICLE) OnDragDrop_Vehicle(pt, widget);
868  if (this->group_sel != INVALID_GROUP) OnDragDrop_Group(pt, widget);
869 
870  _cursor.vehchain = false;
871  }
872 
873  void OnQueryTextFinished(char *str) override
874  {
875  if (str != nullptr) DoCommandP(0, this->group_rename, 0, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_RENAME), nullptr, str);
876  this->group_rename = INVALID_GROUP;
877  }
878 
879  void OnResize() override
880  {
881  this->group_sb->SetCapacityFromWidget(this, WID_GL_LIST_GROUP);
882  this->vscroll->SetCapacityFromWidget(this, WID_GL_LIST_VEHICLE);
883  }
884 
885  void OnDropdownSelect(int widget, int index) override
886  {
887  switch (widget) {
889  this->vehicles.SetSortType(index);
890  break;
891 
893  assert(this->vehicles.size() != 0);
894 
895  switch (index) {
896  case ADI_REPLACE: // Replace window
897  ShowReplaceGroupVehicleWindow(this->vli.index, this->vli.vtype);
898  break;
899  case ADI_SERVICE: // Send for servicing
900  case ADI_DEPOT: { // Send to Depots
901  DoCommandP(0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : 0U), this->vli.Pack(), GetCmdSendToDepot(this->vli.vtype));
902  break;
903  }
904 
905  case ADI_ADD_SHARED: // Add shared Vehicles
906  assert(Group::IsValidID(this->vli.index));
907 
908  DoCommandP(0, this->vli.index, this->vli.vtype, CMD_ADD_SHARED_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE));
909  break;
910  case ADI_REMOVE_ALL: // Remove all Vehicles from the selected group
911  assert(Group::IsValidID(this->vli.index));
912 
913  DoCommandP(0, this->vli.index, 0, CMD_REMOVE_ALL_VEHICLES_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES));
914  break;
915  default: NOT_REACHED();
916  }
917  break;
918 
919  default: NOT_REACHED();
920  }
921 
922  this->SetDirty();
923  }
924 
925  void OnGameTick() override
926  {
927  if (this->groups.NeedResort() || this->vehicles.NeedResort()) {
928  this->SetDirty();
929  }
930  }
931 
932  void OnPlaceObjectAbort() override
933  {
934  /* abort drag & drop */
935  this->vehicle_sel = INVALID_VEHICLE;
937  this->group_over = INVALID_GROUP;
939  }
940 
941  void OnMouseDrag(Point pt, int widget) override
942  {
943  if (this->vehicle_sel == INVALID_VEHICLE && this->group_sel == INVALID_GROUP) return;
944 
945  /* A vehicle is dragged over... */
946  GroupID new_group_over = INVALID_GROUP;
947  switch (widget) {
948  case WID_GL_DEFAULT_VEHICLES: // ... the 'default' group.
949  new_group_over = DEFAULT_GROUP;
950  break;
951 
952  case WID_GL_LIST_GROUP: { // ... the list of custom groups.
953  uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP, 0, this->tiny_step_height);
954  new_group_over = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
955  break;
956  }
957  }
958 
959  /* Do not highlight when dragging over the current group */
960  if (this->vehicle_sel != INVALID_VEHICLE) {
961  if (Vehicle::Get(vehicle_sel)->group_id == new_group_over) new_group_over = INVALID_GROUP;
962  } else if (this->group_sel != INVALID_GROUP) {
963  if (this->group_sel == new_group_over || Group::Get(this->group_sel)->parent == new_group_over) new_group_over = INVALID_GROUP;
964  }
965 
966  /* Mark widgets as dirty if the group changed. */
967  if (new_group_over != this->group_over) {
969  this->group_over = new_group_over;
971  }
972  }
973 
974  void ShowRenameGroupWindow(GroupID group, bool empty)
975  {
976  assert(Group::IsValidID(group));
977  this->group_rename = group;
978  /* Show empty query for new groups */
979  StringID str = STR_EMPTY;
980  if (!empty) {
981  SetDParam(0, group);
982  str = STR_GROUP_NAME;
983  }
985  }
986 
993  {
994  if (this->vehicle_sel == vehicle) ResetObjectToPlace();
995  }
996 
1002  void SelectGroup(const GroupID g_id)
1003  {
1004  if (g_id == INVALID_GROUP || g_id == this->vli.index) return;
1005 
1006  this->vli.index = g_id;
1007  if (g_id != ALL_GROUP && g_id != DEFAULT_GROUP) {
1008  const Group *g = Group::Get(g_id);
1009  int id_g = find_index(this->groups, g);
1010  // The group's branch is maybe collapsed, so try to expand it
1011  if (id_g == -1) {
1012  for (auto pg = Group::GetIfValid(g->parent); pg != nullptr; pg = Group::GetIfValid(pg->parent)) {
1013  pg->folded = false;
1014  }
1015  this->groups.ForceRebuild();
1016  this->BuildGroupList(this->owner);
1017  this->group_sb->SetCount((uint)this->groups.size());
1018  id_g = find_index(this->groups, g);
1019  }
1020  this->group_sb->ScrollTowards(id_g);
1021  }
1022  this->vehicles.ForceRebuild();
1023  this->SetDirty();
1024  }
1025 
1026 };
1027 
1028 
1029 static WindowDesc _other_group_desc(
1030  WDP_AUTO, "list_groups", 460, 246,
1032  0,
1033  _nested_group_widgets, lengthof(_nested_group_widgets)
1034 );
1035 
1036 static WindowDesc _train_group_desc(
1037  WDP_AUTO, "list_groups_train", 525, 246,
1039  0,
1040  _nested_group_widgets, lengthof(_nested_group_widgets)
1041 );
1042 
1050 void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group = INVALID_GROUP, bool need_existing_window = false)
1051 {
1052  if (!Company::IsValidID(company)) return;
1053 
1054  const WindowNumber num = VehicleListIdentifier(VL_GROUP_LIST, vehicle_type, company).Pack();
1055  VehicleGroupWindow *w;
1056  if (vehicle_type == VEH_TRAIN) {
1057  w = AllocateWindowDescFront<VehicleGroupWindow>(&_train_group_desc, num, need_existing_window);
1058  } else {
1059  _other_group_desc.cls = GetWindowClassForVehicleType(vehicle_type);
1060  w = AllocateWindowDescFront<VehicleGroupWindow>(&_other_group_desc, num, need_existing_window);
1061  }
1062  if (w != nullptr) w->SelectGroup(group);
1063 }
1064 
1070 {
1071  ShowCompanyGroup(v->owner, v->type, v->group_id, true);
1072 }
1073 
1081 {
1082  return (VehicleGroupWindow *)FindWindowById(GetWindowClassForVehicleType(vt), VehicleListIdentifier(VL_GROUP_LIST, vt, owner).Pack());
1083 }
1084 
1094 void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
1095 {
1096  if (result.Failed()) return;
1097  assert(p1 <= VEH_AIRCRAFT);
1098 
1100  if (w != nullptr) w->ShowRenameGroupWindow(_new_group_id, true);
1101 }
1102 
1111 void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
1112 {
1113  if (result.Failed()) return;
1114  assert(Vehicle::IsValidID(GB(p2, 0, 20)));
1115 
1116  CcCreateGroup(result, 0, Vehicle::Get(GB(p2, 0, 20))->type, 0, cmd);
1117 }
1118 
1124 {
1125  /* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any group windows either
1126  * If that is the case, we can skip looping though the windows and save time
1127  */
1128  if (_special_mouse_mode != WSM_DRAGDROP) return;
1129 
1131  if (w != nullptr) w->UnselectVehicle(v->index);
1132 }
Functions related to OTTD&#39;s strings.
Owner
Enum for all companies/owners.
Definition: company_type.h:18
void DirtyHighlightedGroupWidget()
Mark the widget containing the currently highlighted group as dirty.
Definition: group_gui.cpp:323
void UnselectVehicle(VehicleID vehicle)
Tests whether a given vehicle is selected in the window, and unselects it if necessary.
Definition: group_gui.cpp:992
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:103
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition of stuff that is very close to a company, like the company struct itself.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:340
Manage vehicles dropdown list.
Definition: group_widget.h:21
uint32 widget_data
Data of the widget.
Definition: widget_type.h:303
bool replace_protection
If set to true, the global autoreplace have no effect on the group.
Definition: group.h:70
CompanyID company
The company associated with this list.
Definition: vehiclelist.h:32
The information about a vehicle list.
Definition: vehiclelist.h:29
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
Owner owner
Group Owner.
Definition: group.h:67
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:729
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:928
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:110
void OnPaint() override
The window must be repainted.
Definition: group_gui.cpp:503
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: group_gui.cpp:388
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
Definition: vehicle_base.h:564
Window * parent
Parent window.
Definition: window_gui.h:337
Group livery button.
Definition: group_widget.h:32
High level window description.
Definition: window_gui.h:166
Functions related to the autoreplace GUIs.
StringID tool_tip
Tooltip of the widget.
Definition: widget_type.h:304
int left
x position of left edge of the window
Definition: window_gui.h:317
bool vehchain
vehicle chain is dragged
Definition: gfx_type.h:144
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Definition: window.cpp:80
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
Train vehicle type.
Definition: vehicle_type.h:24
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
Scrollbar data structure.
Definition: widget_type.h:587
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:597
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
List of the groups.
Definition: group_widget.h:27
Dragging an object.
Definition: window_gui.h:906
Horizontal container.
Definition: widget_type.h:73
std::vector< int > indents
Indentation levels.
Definition: group_gui.cpp:123
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1133
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:52
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:536
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:1121
Ship vehicle type.
Definition: vehicle_type.h:26
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
GUIVehicleList vehicles
The list of vehicles.
Functions related to vehicles.
Types related to the group widgets.
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
void SelectGroup(const GroupID g_id)
Selects the specified group in the list.
Definition: group_gui.cpp:1002
Vehicle data structure.
Definition: vehicle_base.h:210
Tindex index
Index of this pool item.
Definition: pool_type.hpp:227
Close box (at top-left of a window)
Definition: widget_type.h:67
Offset at top of a matrix cell.
Definition: window_gui.h:78
Delete group button.
Definition: group_widget.h:30
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0...
List of the vehicles.
Definition: group_widget.h:18
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:963
#define lastof(x)
Get the last element of an fixed size array.
Definition: depend.cpp:48
bool autoreplace_finished
Have all autoreplacement finished?
Definition: group.h:29
uint GetGroupNumProfitVehicle(CompanyID company, GroupID id_g, VehicleType type)
Get the number of vehicles above profit minimum age in the group with GroupID id_g and its sub-groups...
Definition: group_cmd.cpp:818
Stuff related to the text buffer GUI.
Invalid window.
Definition: window_type.h:700
void OnDragDrop(Point pt, int widget) override
A dragged &#39;object&#39; has been released.
Definition: group_gui.cpp:865
Common return value for all commands.
Definition: command_type.h:23
All vehicles entry.
Definition: group_widget.h:25
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
Definition: vehicle_type.h:55
static T max(const T a, const T b)
Returns the maximum of two values.
Definition: math_func.hpp:24
VehicleID vehicle_sel
Selected vehicle.
Definition: group_gui.cpp:114
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:483
WindowClass cls
Class of the window,.
Definition: window_gui.h:175
void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Opens a &#39;Rename group&#39; window for newly created group.
Definition: group_gui.cpp:1094
uint ComputeGroupInfoSize()
Compute tiny_step_height and column_size.
Definition: group_gui.cpp:197
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1831
Functions related to the vehicle&#39;s GUIs.
void SetListing(Listing l)
Import sort conditions.
GroupID group_rename
Group being renamed, INVALID_GROUP if none.
Definition: group_gui.cpp:116
bool NeedRebuild() const
Check if a rebuild is needed.
delete a group
Definition: command_type.h:320
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:668
Force the alignment, i.e. don&#39;t swap for RTL languages.
Definition: gfx_func.h:106
bool Sort(Comp compare)
Sort the list.
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:908
void ForceRebuild()
Force that a rebuild is needed.
void ShowCompanyGroupForVehicle(const Vehicle *v)
Show the group window for the given vehicle.
Definition: group_gui.cpp:1069
Data structure for an opened window.
Definition: window_gui.h:276
alter a group
Definition: command_type.h:321
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:35
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1030
static const GroupID NEW_GROUP
Sentinel for a to-be-created group.
Definition: group_type.h:15
dragging items in the depot windows
enable the &#39;Default&#39; button ("\0" is returned)
Definition: textbuf_gui.h:21
static bool IsAllGroupID(GroupID id_g)
Checks if a GroupID stands for all vehicles of a company.
Definition: group.h:93
add all other shared vehicles to a group which are missing
Definition: command_type.h:323
static const uint MAX_LENGTH_GROUP_NAME_CHARS
The maximum length of a group name in characters including &#39;\0&#39;.
Definition: group_type.h:20
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group=INVALID_GROUP, bool need_existing_window=false)
Show the group window for the given company and vehicle type.
Definition: group_gui.cpp:1050
Functions related to low-level strings.
Stop all button.
Definition: group_widget.h:22
static const int LEVEL_WIDTH
Indenting width of a sub-group in pixels.
Definition: group_gui.cpp:34
remove all vehicles from a group
Definition: command_type.h:324
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX) ...
Definition: widget_type.h:63
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1957
void OnGameTick() override
Called once per (game) tick.
Definition: group_gui.cpp:925
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:493
Statistics and caches on the vehicles in a group.
Definition: group.h:24
Listing GetListing() const
Export current sort conditions.
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:1262
Dimension column_size[VGC_END]
Size of the columns in the group list.
Definition: group_gui.cpp:125
uint32 index
A vehicle list type specific index.
Definition: vehiclelist.h:33
Sort descending.
Definition: window_gui.h:225
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
Autoreplace active icon.
Definition: group_gui.cpp:107
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group)
Display the Action dropdown window.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:177
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1012
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:945
Definition of base types and functions in a cross-platform compatible way.
Tells that it&#39;s a mass send to depot command (type in VLW flag)
Definition: vehicle_type.h:67
the length of the string is counted in characters
Definition: textbuf_gui.h:22
A number of safeguards to prevent using unsafe methods.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:245
Group info.
Definition: group_widget.h:34
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
Geometry functions.
Simple depressed panel.
Definition: widget_type.h:48
void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Open rename window after adding a vehicle to a new group via drag and drop.
Definition: group_gui.cpp:1111
uint16 GroupID
Type for all group identifiers.
Definition: group_type.h:13
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button&#39;s up or down arrow symbol.
Definition: widget.cpp:636
uint step_height
Step-size of height resize changes.
Definition: window_gui.h:218
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:309
GUI Functions related to companies.
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: group_gui.cpp:657
static GroupStatistics & Get(CompanyID company, GroupID id_g, VehicleType type)
Returns the GroupStatistics for a specific group.
Definition: group_cmd.cpp:63
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:1112
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
uint GetGroupNumVehicle(CompanyID company, GroupID id_g, VehicleType type)
Get the number of vehicles in the group with GroupID id_g and its sub-groups.
Definition: group_cmd.cpp:801
static const GroupID INVALID_GROUP
Sentinel for invalid groups.
Definition: group_type.h:18
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:636
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
uint16 num_vehicle
Number of vehicles.
Definition: group.h:25
Owner owner
Which company owns the vehicle?
Definition: vehicle_base.h:271
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:536
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:40
Fold / Unfold button.
Definition: group_gui.cpp:104
Grid of rows and columns.
Definition: widget_type.h:57
static T min(const T a, const T b)
Returns the minimum of two values.
Definition: math_func.hpp:40
Create group button.
Definition: group_widget.h:29
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: group_gui.cpp:873
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: group_gui.cpp:558
Number of vehicles in the group.
Definition: group_gui.cpp:109
void SetSortType(uint8 n_type)
Set the sorttype of the list.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:656
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
void DrawGroupInfo(int y, int left, int right, GroupID g_id, int indent=0, bool protection=false, bool has_children=false) const
Draw a row in the group list.
Definition: group_gui.cpp:249
bool Failed() const
Did this command fail?
Definition: command_type.h:159
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1178
static const int WIDGET_LIST_END
indicate the end of widgets&#39; list for vararg functions
Definition: widget_type.h:20
Functions/classes shared between the different vehicle list GUIs.
Caption of the window.
Definition: group_widget.h:15
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
void BuildGroupList(Owner owner)
(Re)Build the group list.
Definition: group_gui.cpp:149
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:838
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: group_gui.cpp:932
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:283
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
int8 trip_occupancy
NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station).
Definition: vehicle_base.h:309
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
Definition: group_type.h:17
The vehicle will leave the depot right after arrival (service only)
Definition: vehicle_type.h:66
Functions related to companies.
Vehicle drawn in vehicle list, group list, ...
Definition: vehicle_type.h:89
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:3290
add a vehicle to a group
Definition: command_type.h:322
Scrollbar for the list.
Definition: group_widget.h:19
Both numeric and alphabetic and spaces and stuff.
Definition: string_type.h:27
Money GetGroupProfitLastYear(CompanyID company, GroupID id_g, VehicleType type)
Get last year&#39;s profit for the group with GroupID id_g and its sub-groups.
Definition: group_cmd.cpp:835
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:378
GroupID parent
Parent group.
Definition: group.h:76
Sort by dropdown list.
Definition: group_widget.h:17
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Definition: string.cpp:578
Autoreplace protect icon.
Definition: group_gui.cpp:106
Base class for all vehicles.
static VehicleGroupWindow * FindVehicleGroupWindow(VehicleType vt, Owner owner)
Finds a group list window determined by vehicle type and owner.
Definition: group_gui.cpp:1080
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
Definition: sprites.h:1587
uint32 Pack() const
Pack a VehicleListIdentifier in a single uint32.
Definition: vehiclelist.cpp:21
void DeleteGroupHighlightOfVehicle(const Vehicle *v)
Removes the highlight of a vehicle in a group window.
Definition: group_gui.cpp:1123
bool autoreplace_defined
Are any autoreplace rules set?
Definition: group.h:28
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:48
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here...
Sort ascending.
Definition: window_gui.h:224
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:104
bool folded
NOSAVE: Is this group folded in the group view?
Definition: group.h:74
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
Vertical container.
Definition: widget_type.h:75
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:997
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void OnMouseDrag(Point pt, int widget) override
An &#39;object&#39; is being dragged at the provided position, highlight the target if possible.
Definition: group_gui.cpp:941
Trains list; Window numbers:
Definition: window_type.h:301
VehicleType type
Type of vehicle.
Definition: vehicle_type.h:52
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:172
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.
Definition: vehicle_func.h:28
GroupID group_sel
Selected group (for drag/drop)
Definition: group_gui.cpp:115
Group data.
Definition: group.h:65
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: group_gui.cpp:476
create a new group
Definition: command_type.h:319
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
Bottom offset of the dropdown widget string.
Definition: window_gui.h:135
Functions related to commands.
Coordinates of a point in 2D.
set the autoreplace-protection for a group
Definition: command_type.h:325
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:908
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:45
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:318
Drop down list.
Definition: widget_type.h:68
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:620
Index of the small font in the font tables.
Definition: gfx_type.h:203
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
Definition: vehicle_gui.h:91
start/stop all vehicles (in a depot)
Definition: command_type.h:314
void OnResize() override
Called after the window got resized.
Definition: group_gui.cpp:879
Start all button.
Definition: group_widget.h:23
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable...
Definition: window_gui.h:324
Aircraft vehicle type.
Definition: vehicle_type.h:27
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:319
uint GetVehicleListHeight(VehicleType type, uint divisor)
Get the height of a vehicle in the vehicle list GUIs.
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:981
Replace protection button.
Definition: group_widget.h:33
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:83
GUIGroupList groups
List of groups.
Definition: group_gui.cpp:119
bool IsDescSortOrder() const
Check if the sort order is descending.
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:370
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:711
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:1971
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Definition: viewport.cpp:3353
Specification of a rectangle with absolute coordinates of all edges.
Vertical scrollbar.
Definition: widget_type.h:82
Text is written right-to-left by default.
Definition: strings_type.h:24
Right align the text (must be a single bit).
Definition: gfx_func.h:96
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:312
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
static uint Ceil(uint a, uint b)
Computes ceil(a / b) * b for non-negative a and b.
Definition: math_func.hpp:325
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: group_gui.cpp:452
Find a place automatically.
Definition: window_gui.h:154
uint tiny_step_height
Step height for the group list.
Definition: group_gui.cpp:120
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group)
Compute the size for the Action dropdown.
Listing * sorting
Pointer to the vehicle type related sorting.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Definition: sprites.h:1367
GroupID group_over
Group over which a vehicle is dragged, INVALID_GROUP if none.
Definition: group_gui.cpp:117
GroupID group_confirm
Group awaiting delete confirmation.
Definition: group_gui.cpp:118
VehicleType vtype
The vehicle type associated with this list.
Definition: vehiclelist.h:31
Rename group button.
Definition: group_widget.h:31
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1093
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:44
Default vehicles entry.
Definition: group_widget.h:26
Dimensions (a width and height) of a rectangle in 2D.
Query string window; Window numbers:
Definition: window_type.h:116
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: group_gui.cpp:885
This file contains all sprite-related enums and defines.
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
Definition: vehicle_base.h:570
Road vehicle type.
Definition: vehicle_type.h:25
int find_index(std::vector< T > const &vec, T const &item)
Helper function to get the index of an item Consider using std::set, std::unordered_set or std::flat_...
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:973
Top offset of the dropdown widget string.
Definition: window_gui.h:134
GroupID group_id
Index of group Pool array.
Definition: vehicle_base.h:324
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:320
Scrollbar for the list.
Definition: group_widget.h:28
Available vehicles.
Definition: group_widget.h:20
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:629
uint8 SortType() const
Get the sorttype of the list.
Definition: sortlist_type.h:94
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:199
Base class for a &#39;real&#39; widget.
Definition: widget_type.h:282
static const GroupID ALL_GROUP
All vehicles are in this group.
Definition: group_type.h:16