OpenTTD Source  14.0-beta1
autoreplace_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 "command_func.h"
12 #include "vehicle_gui.h"
13 #include "newgrf_engine.h"
14 #include "rail.h"
15 #include "road.h"
16 #include "strings_func.h"
17 #include "window_func.h"
18 #include "autoreplace_func.h"
19 #include "company_func.h"
20 #include "engine_base.h"
21 #include "window_gui.h"
22 #include "engine_gui.h"
23 #include "settings_func.h"
24 #include "core/geometry_func.hpp"
25 #include "rail_gui.h"
26 #include "road_gui.h"
27 #include "widgets/dropdown_func.h"
28 #include "autoreplace_cmd.h"
29 #include "group_cmd.h"
30 #include "settings_cmd.h"
31 
33 
34 #include "safeguards.h"
35 
36 void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group);
37 
38 static bool EngineNumberSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
39 {
40  return Engine::Get(a.engine_id)->list_position < Engine::Get(b.engine_id)->list_position;
41 }
42 
53 {
55  /* We don't have any of this engine type.
56  * Either we just sold the last one, we build a new one or we stopped replacing it.
57  * In all cases, we need to update the left list */
59  }
60 }
61 
67 {
68  InvalidateWindowData(WC_REPLACE_VEHICLE, type, 0); // Update the autoreplace window
69  InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
70 }
71 
72 static const StringID _start_replace_dropdown[] = {
73  STR_REPLACE_VEHICLES_NOW,
74  STR_REPLACE_VEHICLES_WHEN_OLD,
76 };
77 
81 class ReplaceVehicleWindow : public Window {
93  Scrollbar *vscroll[2];
94 
102  bool GenerateReplaceRailList(EngineID e, bool draw_left, bool show_engines)
103  {
104  const RailVehicleInfo *rvi = RailVehInfo(e);
105 
106  /* Ensure that the wagon/engine selection fits the engine. */
107  if ((rvi->railveh_type == RAILVEH_WAGON) == show_engines) return false;
108 
109  if (draw_left && this->sel_railtype != INVALID_RAILTYPE) {
110  /* Ensure that the railtype is specific to the selected one */
111  if (rvi->railtype != this->sel_railtype) return false;
112  }
113  return true;
114  }
115 
116  void AddChildren(const GUIEngineList &source, GUIEngineList &target, EngineID parent, int indent, int side)
117  {
118  for (const auto &item : source) {
119  if (item.variant_id != parent || item.engine_id == parent) continue;
120 
121  const Engine *e = Engine::Get(item.engine_id);
122  EngineDisplayFlags flags = item.flags;
124  target.emplace_back(e->display_last_variant == INVALID_ENGINE ? item.engine_id : e->display_last_variant, item.engine_id, flags, indent);
125 
126  /* Add variants if not folded */
128  /* Add this engine again as a child */
130  target.emplace_back(item.engine_id, item.engine_id, EngineDisplayFlags::None, indent + 1);
131  }
132  AddChildren(source, target, item.engine_id, indent + 1, side);
133  }
134  }
135  }
136 
141  void GenerateReplaceVehList(bool draw_left)
142  {
143  std::vector<EngineID> variants;
144  EngineID selected_engine = INVALID_ENGINE;
145  VehicleType type = (VehicleType)this->window_number;
146  byte side = draw_left ? 0 : 1;
147 
148  GUIEngineList list;
149 
150  for (const Engine *e : Engine::IterateType(type)) {
151  if (!draw_left && !this->show_hidden_engines && e->IsVariantHidden(_local_company)) continue;
152  EngineID eid = e->index;
153  switch (type) {
154  case VEH_TRAIN:
155  if (!this->GenerateReplaceRailList(eid, draw_left, this->replace_engines)) continue; // special rules for trains
156  break;
157 
158  case VEH_ROAD:
159  if (draw_left && this->sel_roadtype != INVALID_ROADTYPE) {
160  /* Ensure that the roadtype is specific to the selected one */
161  if (e->u.road.roadtype != this->sel_roadtype) continue;
162  }
163  break;
164 
165  default:
166  break;
167  }
168 
169  if (draw_left) {
170  const uint num_engines = GetGroupNumEngines(_local_company, this->sel_group, eid);
171 
172  /* Skip drawing the engines we don't have any of and haven't set for replacement */
173  if (num_engines == 0 && EngineReplacementForCompany(Company::Get(_local_company), eid, this->sel_group) == INVALID_ENGINE) continue;
174  } else {
175  if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
176  }
177 
178  list.emplace_back(eid, e->info.variant_id, (side == 0) ? EngineDisplayFlags::None : e->display_flags, 0);
179 
180  if (side == 1) {
181  EngineID parent = e->info.variant_id;
182  while (parent != INVALID_ENGINE) {
183  variants.push_back(parent);
184  parent = Engine::Get(parent)->info.variant_id;
185  }
186  }
187  if (eid == this->sel_engine[side]) selected_engine = eid; // The selected engine is still in the list
188  }
189 
190  if (side == 1) {
191  /* ensure primary engine of variant group is in list */
192  for (const auto &variant : variants) {
193  if (std::find(list.begin(), list.end(), variant) == list.end()) {
194  const Engine *e = Engine::Get(variant);
195  list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlags::Shaded, 0);
196  }
197  }
198  }
199 
200  this->sel_engine[side] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
201  if (draw_left) {
203  } else {
205  EngList_Sort(list, _engine_sort_functions[this->window_number][this->sort_criteria]);
206  }
207 
208  this->engines[side].clear();
209  if (side == 1) {
210  AddChildren(list, this->engines[side], INVALID_ENGINE, 0, side);
211  } else {
212  this->engines[side].swap(list);
213  }
214  }
215 
218  {
219  EngineID e = this->sel_engine[0];
220 
221  if (this->engines[0].NeedRebuild()) {
222  /* We need to rebuild the left engines list */
223  this->GenerateReplaceVehList(true);
224  this->vscroll[0]->SetCount(this->engines[0].size());
225  if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && !this->engines[0].empty()) {
226  this->sel_engine[0] = this->engines[0][0].engine_id;
227  }
228  }
229 
230  if (this->engines[1].NeedRebuild() || e != this->sel_engine[0]) {
231  /* Either we got a request to rebuild the right engines list, or the left engines list selected a different engine */
232  if (this->sel_engine[0] == INVALID_ENGINE) {
233  /* Always empty the right engines list when nothing is selected in the left engines list */
234  this->engines[1].clear();
235  this->sel_engine[1] = INVALID_ENGINE;
236  this->vscroll[1]->SetCount(this->engines[1].size());
237  } else {
238  if (this->reset_sel_engine && this->sel_engine[0] != INVALID_ENGINE) {
239  /* Select the current replacement for sel_engine[0]. */
240  const Company *c = Company::Get(_local_company);
241  this->sel_engine[1] = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group);
242  }
243  /* Regenerate the list on the right. Note: This resets sel_engine[1] to INVALID_ENGINE, if it is no longer available. */
244  this->GenerateReplaceVehList(false);
245  this->vscroll[1]->SetCount(this->engines[1].size());
246  if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
247  int position = 0;
248  for (const auto &item : this->engines[1]) {
249  if (item.engine_id == this->sel_engine[1]) break;
250  ++position;
251  }
252  this->vscroll[1]->ScrollTowards(position);
253  }
254  }
255  }
256  /* Reset the flags about needed updates */
257  this->engines[0].RebuildDone();
258  this->engines[1].RebuildDone();
259  this->reset_sel_engine = false;
260  }
261 
266  void ReplaceClick_StartReplace(bool replace_when_old)
267  {
268  EngineID veh_from = this->sel_engine[0];
269  EngineID veh_to = this->sel_engine[1];
270  Command<CMD_SET_AUTOREPLACE>::Post(this->sel_group, veh_from, veh_to, replace_when_old);
271  }
272 
277  {
278  /* Reset scrollbar positions */
279  this->vscroll[0]->SetPosition(0);
280  this->vscroll[1]->SetPosition(0);
281  /* Rebuild the lists */
282  this->engines[0].ForceRebuild();
283  this->engines[1].ForceRebuild();
284  this->reset_sel_engine = true;
285  this->SetDirty();
286  }
287 
288 public:
289  ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
290  {
291  this->sel_railtype = INVALID_RAILTYPE;
292  this->sel_roadtype = INVALID_ROADTYPE;
293  this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool)
294  this->engines[0].ForceRebuild();
295  this->engines[1].ForceRebuild();
296  this->reset_sel_engine = true;
297  this->details_height = ((vehicletype == VEH_TRAIN) ? 10 : 9);
298  this->sel_engine[0] = INVALID_ENGINE;
299  this->sel_engine[1] = INVALID_ENGINE;
300  this->show_hidden_engines = _engine_sort_show_hidden_engines[vehicletype];
301 
302  this->CreateNestedTree();
303  this->vscroll[0] = this->GetScrollbar(WID_RV_LEFT_SCROLLBAR);
304  this->vscroll[1] = this->GetScrollbar(WID_RV_RIGHT_SCROLLBAR);
305 
306  NWidgetCore *widget = this->GetWidget<NWidgetCore>(WID_RV_SHOW_HIDDEN_ENGINES);
307  widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype;
308  widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype;
309  widget->SetLowered(this->show_hidden_engines);
310  this->FinishInitNested(vehicletype);
311 
312  this->sort_criteria = _engine_sort_last_criteria[vehicletype];
313  this->descending_sort_order = _engine_sort_last_order[vehicletype];
314  this->owner = _local_company;
315  this->sel_group = id_g;
316  }
317 
318  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
319  {
320  switch (widget) {
322  Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
323  d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
324  d.height += padding.height;
325  *size = maxdim(*size, d);
326  break;
327  }
328 
329  case WID_RV_LEFT_MATRIX:
330  case WID_RV_RIGHT_MATRIX:
332  size->height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize->height;
333  break;
334 
335  case WID_RV_LEFT_DETAILS:
337  size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
338  break;
339 
341  StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
342  SetDParam(0, STR_CONFIG_SETTING_ON);
344  SetDParam(0, STR_CONFIG_SETTING_OFF);
345  d = maxdim(d, GetStringBoundingBox(str));
346  d.width += padding.width;
347  d.height += padding.height;
348  *size = maxdim(*size, d);
349  break;
350  }
351 
353  Dimension d = GetStringBoundingBox(STR_REPLACE_ENGINES);
354  d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS));
355  d.width += padding.width;
356  d.height += padding.height;
357  *size = maxdim(*size, d);
358  break;
359  }
360 
361  case WID_RV_INFO_TAB: {
362  Dimension d = GetStringBoundingBox(STR_REPLACE_NOT_REPLACING);
363  d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED));
364  d.width += padding.width;
365  d.height += padding.height;
366  *size = maxdim(*size, d);
367  break;
368  }
369 
371  Dimension d = {0, 0};
372  for (const RailType &rt : _sorted_railtypes) {
374  }
375  d.width += padding.width;
376  d.height += padding.height;
377  *size = maxdim(*size, d);
378  break;
379  }
380 
382  Dimension d = {0, 0};
383  for (const RoadType &rt : _sorted_roadtypes) {
385  }
386  d.width += padding.width;
387  d.height += padding.height;
388  *size = maxdim(*size, d);
389  break;
390  }
391 
392  case WID_RV_START_REPLACE: {
393  Dimension d = GetStringBoundingBox(STR_REPLACE_VEHICLES_START);
394  for (int i = 0; _start_replace_dropdown[i] != INVALID_STRING_ID; i++) {
395  d = maxdim(d, GetStringBoundingBox(_start_replace_dropdown[i]));
396  }
397  d.width += padding.width;
398  d.height += padding.height;
399  *size = maxdim(*size, d);
400  break;
401  }
402  }
403  }
404 
405  void SetStringParameters(WidgetID widget) const override
406  {
407  switch (widget) {
408  case WID_RV_CAPTION:
409  SetDParam(0, STR_REPLACE_VEHICLE_TRAIN + this->window_number);
410  switch (this->sel_group) {
411  case ALL_GROUP:
412  SetDParam(1, STR_GROUP_ALL_TRAINS + this->window_number);
413  break;
414 
415  case DEFAULT_GROUP:
416  SetDParam(1, STR_GROUP_DEFAULT_TRAINS + this->window_number);
417  break;
418 
419  default:
420  SetDParam(1, STR_GROUP_NAME);
421  SetDParam(2, sel_group);
422  break;
423  }
424  break;
425 
427  SetDParam(0, _engine_sort_listing[this->window_number][this->sort_criteria]);
428  break;
429 
431  bool remove_wagon;
432  const Group *g = Group::GetIfValid(this->sel_group);
433  if (g != nullptr) {
435  SetDParam(0, STR_GROUP_NAME);
436  SetDParam(1, sel_group);
437  } else {
438  const Company *c = Company::Get(_local_company);
439  remove_wagon = c->settings.renew_keep_length;
440  SetDParam(0, STR_GROUP_DEFAULT_TRAINS + this->window_number);
441  }
442  SetDParam(2, remove_wagon ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
443  break;
444  }
445 
447  SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
448  break;
449 
451  SetDParam(0, this->sel_railtype == INVALID_RAILTYPE ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(this->sel_railtype)->strings.replace_text);
452  break;
453 
455  SetDParam(0, this->sel_roadtype == INVALID_ROADTYPE ? STR_REPLACE_ALL_ROADTYPE : GetRoadTypeInfo(this->sel_roadtype)->strings.replace_text);
456  break;
457  }
458  }
459 
460  void DrawWidget(const Rect &r, WidgetID widget) const override
461  {
462  switch (widget) {
464  this->DrawSortButtonState(WID_RV_SORT_ASCENDING_DESCENDING, this->descending_sort_order ? SBS_DOWN : SBS_UP);
465  break;
466 
467  case WID_RV_INFO_TAB: {
468  const Company *c = Company::Get(_local_company);
469  StringID str;
470  if (this->sel_engine[0] != INVALID_ENGINE) {
471  if (!EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group)) {
472  str = STR_REPLACE_NOT_REPLACING;
473  } else {
474  bool when_old = false;
475  EngineID e = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group, &when_old);
476  str = when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME;
478  }
479  } else {
480  str = STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED;
481  }
482 
484  break;
485  }
486 
487  case WID_RV_LEFT_MATRIX:
488  case WID_RV_RIGHT_MATRIX: {
489  int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
490  EngineID start = static_cast<EngineID>(this->vscroll[side]->GetPosition()); // what is the offset for the start (scrolling)
491  EngineID end = static_cast<EngineID>(std::min<size_t>(this->vscroll[side]->GetCapacity() + start, this->engines[side].size()));
492 
493  /* Do the actual drawing */
494  DrawEngineList((VehicleType)this->window_number, r, this->engines[side], start, end, this->sel_engine[side], side == 0, this->sel_group);
495  break;
496  }
497  }
498  }
499 
500  void OnPaint() override
501  {
502  if (this->engines[0].NeedRebuild() || this->engines[1].NeedRebuild()) this->GenerateLists();
503 
505 
506  /* Disable the "Start Replacing" button if:
507  * Either engines list is empty
508  * or The selected replacement engine has a replacement (to prevent loops). */
510  this->sel_engine[0] == INVALID_ENGINE || this->sel_engine[1] == INVALID_ENGINE || EngineReplacementForCompany(c, this->sel_engine[1], this->sel_group) != INVALID_ENGINE);
511 
512  /* Disable the "Stop Replacing" button if:
513  * The left engines list (existing vehicle) is empty
514  * or The selected vehicle has no replacement set up */
515  this->SetWidgetDisabledState(WID_RV_STOP_REPLACE, this->sel_engine[0] == INVALID_ENGINE || !EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group));
516 
517  this->DrawWidgets();
518 
519  if (!this->IsShaded()) {
520  int needed_height = this->details_height;
521  /* Draw details panels. */
522  for (int side = 0; side < 2; side++) {
523  if (this->sel_engine[side] != INVALID_ENGINE) {
524  /* Use default engine details without refitting */
525  const Engine *e = Engine::Get(this->sel_engine[side]);
527  ted.cost = 0;
528  ted.FillDefaultCapacities(e);
529 
530  const Rect r = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS)->GetCurrentRect()
532  int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine[side], ted);
533  needed_height = std::max(needed_height, (text_end - r.top) / GetCharacterHeight(FS_NORMAL));
534  }
535  }
536  if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
537  this->details_height = needed_height;
538  this->ReInit();
539  return;
540  }
541  }
542  }
543 
544  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
545  {
546  switch (widget) {
548  this->descending_sort_order ^= true;
550  this->engines[1].ForceRebuild();
551  this->SetDirty();
552  break;
553 
555  this->show_hidden_engines ^= true;
557  this->engines[1].ForceRebuild();
558  this->SetWidgetLoweredState(widget, this->show_hidden_engines);
559  this->SetDirty();
560  break;
561 
563  DisplayVehicleSortDropDown(this, static_cast<VehicleType>(this->window_number), this->sort_criteria, WID_RV_SORT_DROPDOWN);
564  break;
565 
567  DropDownList list;
568  list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_ENGINES, 1, false));
569  list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_WAGONS, 0, false));
570  ShowDropDownList(this, std::move(list), this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
571  break;
572  }
573 
574  case WID_RV_RAIL_TYPE_DROPDOWN: // Railtype selection dropdown menu
575  ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, widget);
576  break;
577 
578  case WID_RV_ROAD_TYPE_DROPDOWN: // Roadtype selection dropdown menu
579  ShowDropDownList(this, GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), this->sel_roadtype, widget);
580  break;
581 
583  const Group *g = Group::GetIfValid(this->sel_group);
584  if (g != nullptr) {
586  } else {
587  // toggle renew_keep_length
588  Command<CMD_CHANGE_COMPANY_SETTING>::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1);
589  }
590  break;
591  }
592 
593  case WID_RV_START_REPLACE: { // Start replacing
594  if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
597  } else {
598  bool replacment_when_old = EngineHasReplacementWhenOldForCompany(Company::Get(_local_company), this->sel_engine[0], this->sel_group);
599  ShowDropDownMenu(this, _start_replace_dropdown, replacment_when_old ? 1 : 0, WID_RV_START_REPLACE, !this->replace_engines ? 1 << 1 : 0, 0);
600  }
601  break;
602  }
603 
604  case WID_RV_STOP_REPLACE: { // Stop replacing
605  EngineID veh_from = this->sel_engine[0];
606  Command<CMD_SET_AUTOREPLACE>::Post(this->sel_group, veh_from, INVALID_ENGINE, false);
607  break;
608  }
609 
610  case WID_RV_LEFT_MATRIX:
611  case WID_RV_RIGHT_MATRIX: {
612  byte click_side;
613  if (widget == WID_RV_LEFT_MATRIX) {
614  click_side = 0;
615  } else {
616  click_side = 1;
617  }
618 
620  const auto it = this->vscroll[click_side]->GetScrolledItemFromWidget(this->engines[click_side], pt.y, this, widget);
621  if (it != this->engines[click_side].end()) {
622  const auto &item = *it;
623  const Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.matrix).WithWidth(WidgetDimensions::scaled.hsep_indent * (item.indent + 1), _current_text_dir == TD_RTL);
624  if ((item.flags & EngineDisplayFlags::HasVariants) != EngineDisplayFlags::None && IsInsideMM(r.left, r.right, pt.x)) {
625  /* toggle folded flag on engine */
626  assert(item.variant_id != INVALID_ENGINE);
627  Engine *engine = Engine::Get(item.variant_id);
629 
630  InvalidateWindowData(WC_REPLACE_VEHICLE, (VehicleType)this->window_number, 0); // Update the autoreplace window
631  InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
632  return;
633  }
634  if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) e = item.engine_id;
635  }
636 
637  /* If Ctrl is pressed on the left side and we don't have any engines of the selected type, stop autoreplacing.
638  * This is most common when we have finished autoreplacing the engine and want to remove it from the list. */
639  if (click_side == 0 && _ctrl_pressed && e != INVALID_ENGINE &&
641  EngineID veh_from = e;
642  Command<CMD_SET_AUTOREPLACE>::Post(this->sel_group, veh_from, INVALID_ENGINE, false);
643  break;
644  }
645 
646  if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
647  this->sel_engine[click_side] = e;
648  if (click_side == 0) {
649  this->engines[1].ForceRebuild();
650  this->reset_sel_engine = true;
651  }
652  this->SetDirty();
653  break;
654  }
655  }
656  }
657 
658  void OnDropdownSelect(WidgetID widget, int index) override
659  {
660  switch (widget) {
662  if (this->sort_criteria != index) {
663  this->sort_criteria = index;
665  this->engines[1].ForceRebuild();
666  this->SetDirty();
667  }
668  break;
669 
671  RailType temp = (RailType)index;
672  if (temp == this->sel_railtype) return; // we didn't select a new one. No need to change anything
673  this->sel_railtype = temp;
674  this->OnRailRoadTypeChange();
675  break;
676  }
677 
679  RoadType temp = (RoadType)index;
680  if (temp == this->sel_roadtype) return; // we didn't select a new one. No need to change anything
681  this->sel_roadtype = temp;
682  this->OnRailRoadTypeChange();
683  break;
684  }
685 
687  this->replace_engines = index != 0;
688  this->engines[0].ForceRebuild();
689  this->reset_sel_engine = true;
690  this->SetDirty();
691  break;
692  }
693 
695  this->ReplaceClick_StartReplace(index != 0);
696  break;
697  }
698  }
699 
700  bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
701  {
702  if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false;
703 
704  if (Group::IsValidID(this->sel_group)) {
705  SetDParam(0, STR_REPLACE_REMOVE_WAGON_HELP);
706  GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_GROUP_HELP, close_cond, 1);
707  } else {
708  GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_HELP, close_cond);
709  }
710  return true;
711  }
712 
713  void OnResize() override
714  {
715  this->vscroll[0]->SetCapacityFromWidget(this, WID_RV_LEFT_MATRIX);
716  this->vscroll[1]->SetCapacityFromWidget(this, WID_RV_RIGHT_MATRIX);
717  }
718 
724  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
725  {
726  if (data != 0) {
727  /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
728  this->engines[0].ForceRebuild();
729  } else {
730  this->engines[1].ForceRebuild();
731  }
732  }
733 };
734 
735 static constexpr NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
737  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
738  NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
739  NWidget(WWT_SHADEBOX, COLOUR_GREY),
740  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
741  NWidget(WWT_STICKYBOX, COLOUR_GREY),
742  EndContainer(),
744  NWidget(WWT_PANEL, COLOUR_GREY),
745  NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
746  EndContainer(),
747  NWidget(WWT_PANEL, COLOUR_GREY),
748  NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
749  EndContainer(),
750  EndContainer(),
754  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_RAIL_TYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(STR_JUST_STRING, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0),
755  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN), SetDataTip(STR_JUST_STRING, STR_REPLACE_ENGINE_WAGON_SELECT_HELP),
756  EndContainer(),
757  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
758  EndContainer(),
761  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
762  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
763  EndContainer(),
765  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
766  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
767  EndContainer(),
768  EndContainer(),
769  EndContainer(),
771  NWidget(WWT_MATRIX, COLOUR_GREY, WID_RV_LEFT_MATRIX), SetMinimalSize(216, 0), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_REPLACE_HELP_LEFT_ARRAY), SetResize(1, 1), SetScrollbar(WID_RV_LEFT_SCROLLBAR),
773  NWidget(WWT_MATRIX, COLOUR_GREY, WID_RV_RIGHT_MATRIX), SetMinimalSize(216, 0), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_REPLACE_HELP_RIGHT_ARRAY), SetResize(1, 1), SetScrollbar(WID_RV_RIGHT_SCROLLBAR),
775  EndContainer(),
777  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
779  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
780  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_WAGONREMOVE_TOGGLE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP), SetFill(1, 0), SetResize(1, 0),
781  EndContainer(),
782  EndContainer(),
784  NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
785  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0),
786  EndContainer(),
787  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
788  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
789  EndContainer(),
790 };
791 
792 static WindowDesc _replace_rail_vehicle_desc(__FILE__, __LINE__,
793  WDP_AUTO, "replace_vehicle_train", 500, 140,
796  std::begin(_nested_replace_rail_vehicle_widgets), std::end(_nested_replace_rail_vehicle_widgets)
797 );
798 
799 static constexpr NWidgetPart _nested_replace_road_vehicle_widgets[] = {
801  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
802  NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
803  NWidget(WWT_SHADEBOX, COLOUR_GREY),
804  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
805  NWidget(WWT_STICKYBOX, COLOUR_GREY),
806  EndContainer(),
808  NWidget(WWT_PANEL, COLOUR_GREY),
809  NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
810  EndContainer(),
811  NWidget(WWT_PANEL, COLOUR_GREY),
812  NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
813  EndContainer(),
814  EndContainer(),
817  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_ROAD_TYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(STR_JUST_STRING, STR_REPLACE_HELP_ROADTYPE), SetFill(1, 0), SetResize(1, 0),
818  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
819  EndContainer(),
822  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
823  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
824  EndContainer(),
826  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
827  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
828  EndContainer(),
829  EndContainer(),
830  EndContainer(),
832  NWidget(WWT_MATRIX, COLOUR_GREY, WID_RV_LEFT_MATRIX), SetMinimalSize(216, 0), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_REPLACE_HELP_LEFT_ARRAY), SetResize(1, 1), SetScrollbar(WID_RV_LEFT_SCROLLBAR),
834  NWidget(WWT_MATRIX, COLOUR_GREY, WID_RV_RIGHT_MATRIX), SetMinimalSize(216, 0), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_REPLACE_HELP_RIGHT_ARRAY), SetResize(1, 1), SetScrollbar(WID_RV_RIGHT_SCROLLBAR),
836  EndContainer(),
838  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
839  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
840  EndContainer(),
842  NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
843  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0),
844  EndContainer(),
845  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
846  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
847  EndContainer(),
848 };
849 
850 static WindowDesc _replace_road_vehicle_desc(__FILE__, __LINE__,
851  WDP_AUTO, "replace_vehicle_road", 500, 140,
854  std::begin(_nested_replace_road_vehicle_widgets), std::end(_nested_replace_road_vehicle_widgets)
855 );
856 
857 static constexpr NWidgetPart _nested_replace_vehicle_widgets[] = {
859  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
860  NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetMinimalSize(433, 14), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
861  NWidget(WWT_SHADEBOX, COLOUR_GREY),
862  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
863  NWidget(WWT_STICKYBOX, COLOUR_GREY),
864  EndContainer(),
866  NWidget(WWT_PANEL, COLOUR_GREY),
867  NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
868  EndContainer(),
869  NWidget(WWT_PANEL, COLOUR_GREY),
870  NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP), SetFill(1, 1), SetMinimalSize(0, 12), SetResize(1, 0),
871  EndContainer(),
872  EndContainer(),
874  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
877  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
878  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
879  EndContainer(),
881  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
882  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
883  EndContainer(),
884  EndContainer(),
885  EndContainer(),
887  NWidget(WWT_MATRIX, COLOUR_GREY, WID_RV_LEFT_MATRIX), SetMinimalSize(216, 0), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_REPLACE_HELP_LEFT_ARRAY), SetResize(1, 1), SetScrollbar(WID_RV_LEFT_SCROLLBAR),
889  NWidget(WWT_MATRIX, COLOUR_GREY, WID_RV_RIGHT_MATRIX), SetMinimalSize(216, 0), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_REPLACE_HELP_RIGHT_ARRAY), SetResize(1, 1), SetScrollbar(WID_RV_RIGHT_SCROLLBAR),
891  EndContainer(),
893  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
894  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
895  EndContainer(),
897  NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
898  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0), EndContainer(),
899  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
900  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
901  EndContainer(),
902 };
903 
904 static WindowDesc _replace_vehicle_desc(__FILE__, __LINE__,
905  WDP_AUTO, "replace_vehicle", 456, 118,
908  std::begin(_nested_replace_vehicle_widgets), std::end(_nested_replace_vehicle_widgets)
909 );
910 
917 {
918  CloseWindowById(WC_REPLACE_VEHICLE, vehicletype);
919  WindowDesc *desc;
920  switch (vehicletype) {
921  case VEH_TRAIN: desc = &_replace_rail_vehicle_desc; break;
922  case VEH_ROAD: desc = &_replace_road_vehicle_desc; break;
923  default: desc = &_replace_vehicle_desc; break;
924  }
925  new ReplaceVehicleWindow(desc, vehicletype, id_g);
926 }
_engine_sort_functions
EngList_SortTypeFunction *const _engine_sort_functions[][11]
Sort functions for the vehicle sort criteria, for each vehicle type.
Definition: build_vehicle_gui.cpp:436
DisplayVehicleSortDropDown
void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selected, WidgetID button)
Display the dropdown for the vehicle sort criteria.
Definition: build_vehicle_gui.cpp:1098
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
INVALID_ENGINE
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
Definition: engine_type.h:205
Engine::IsVariantHidden
bool IsVariantHidden(CompanyID c) const
Check whether the engine variant chain is hidden in the GUI for the given company.
Definition: engine.cpp:485
InvalidateWindowData
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition: window.cpp:3200
EngineNumberSorter
static bool EngineNumberSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
Determines order of engines by engineID.
Definition: build_vehicle_gui.cpp:109
Engine::IterateType
static Pool::IterateWrapperFiltered< Engine, EngineTypeFilter > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.
Definition: engine_base.h:186
EngineDisplayFlags::HasVariants
@ HasVariants
Set if engine has variants.
EngineReplacementForCompany
EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old=nullptr)
Retrieve the engine replacement for the given company and original engine type.
Definition: autoreplace_func.h:39
WID_RV_SHOW_HIDDEN_ENGINES
@ WID_RV_SHOW_HIDDEN_ENGINES
Toggle whether to display the hidden vehicles.
Definition: autoreplace_widget.h:19
Pool::PoolItem<&_engine_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:335
vehicle_gui.h
GetRailTypeDropDownList
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
Definition: rail_gui.cpp:2377
ReplaceVehicleWindow::sel_group
GroupID sel_group
Group selected to replace.
Definition: autoreplace_gui.cpp:86
WID_RV_ROAD_TYPE_DROPDOWN
@ WID_RV_ROAD_TYPE_DROPDOWN
Dropdown to select roadtype.
Definition: autoreplace_widget.h:41
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
WID_RV_LEFT_DETAILS
@ WID_RV_LEFT_DETAILS
Details of the entry on the left.
Definition: autoreplace_widget.h:27
command_func.h
IsInsideMM
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:268
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WID_RV_TRAIN_ENGINEWAGON_DROPDOWN
@ WID_RV_TRAIN_ENGINEWAGON_DROPDOWN
Dropdown to select engines and/or wagons.
Definition: autoreplace_widget.h:37
ReplaceVehicleWindow::replace_engines
bool replace_engines
If true, engines are replaced, if false, wagons are replaced (only for trains).
Definition: autoreplace_gui.cpp:84
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
Pool::PoolItem<&_group_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:346
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:197
dropdown_func.h
GetRailTypeInfo
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:307
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
_engine_sort_last_order
bool _engine_sort_last_order[]
Last set direction of the sort order, for each vehicle type.
Definition: build_vehicle_gui.cpp:99
EngineDisplayFlags::IsFolded
@ IsFolded
Set if display of variants should be folded (hidden).
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
Scrollbar::ScrollTowards
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:821
ReplaceVehicleWindow::GenerateReplaceVehList
void GenerateReplaceVehList(bool draw_left)
Generate an engines list.
Definition: autoreplace_gui.cpp:141
_engine_sort_direction
bool _engine_sort_direction
false = descending, true = ascending.
Definition: build_vehicle_gui.cpp:97
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
GUIList< GUIEngineListItem, std::nullptr_t, CargoID >
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:59
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1141
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:210
EngineHasReplacementWhenOldForCompany
bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
Check if a company has a replacement set up for the given engine when it gets old.
Definition: autoreplace_func.h:63
NWidgetCore::widget_data
uint32_t widget_data
Data of the widget.
Definition: widget_type.h:379
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:234
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:61
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
SetMatrixDataTip
constexpr NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1174
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, WidgetID widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2334
Window::owner
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:310
NWidgetCore::tool_tip
StringID tool_tip
Tooltip of the widget.
Definition: widget_type.h:380
RoadTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: road.h:107
Engine
Definition: engine_base.h:37
NWidgetCore::SetLowered
void SetLowered(bool lowered)
Lower or raise the widget.
Definition: widget_type.h:414
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
RoadVehicleInfo::roadtype
RoadType roadtype
Road type.
Definition: engine_type.h:128
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:678
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:315
ReplaceVehicleWindow::engines
GUIEngineList engines[2]
Left and right list of engines.
Definition: autoreplace_gui.cpp:83
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
_engine_sort_show_hidden_engines
bool _engine_sort_show_hidden_engines[]
Last set 'show hidden engines' setting for each vehicle type.
Definition: build_vehicle_gui.cpp:100
WID_RV_INFO_TAB
@ WID_RV_INFO_TAB
Info tab.
Definition: autoreplace_widget.h:32
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:30
Scrollbar::GetPosition
uint16_t GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:720
ALL_GROUP
static const GroupID ALL_GROUP
All vehicles are in this group.
Definition: group_type.h:16
WID_RV_RAIL_TYPE_DROPDOWN
@ WID_RV_RAIL_TYPE_DROPDOWN
Dropdown to select railtype.
Definition: autoreplace_widget.h:36
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
Group
Group data.
Definition: group.h:72
ReplaceVehicleWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: autoreplace_gui.cpp:500
CompanySettings::renew_keep_length
bool renew_keep_length
sell some wagons if after autoreplace the train is longer than before
Definition: settings_type.h:612
ReplaceVehicleWindow::OnRailRoadTypeChange
void OnRailRoadTypeChange()
Perform tasks after rail or road type is changed.
Definition: autoreplace_gui.cpp:276
window_gui.h
Engine::display_last_variant
EngineID display_last_variant
NOSAVE client-side-only last variant selected.
Definition: engine_base.h:59
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:508
ReplaceVehicleWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: autoreplace_gui.cpp:713
RailVehicleInfo
Information about a rail vehicle.
Definition: engine_type.h:42
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1086
_engine_sort_listing
const StringID _engine_sort_listing[][12]
Dropdown menu strings for the vehicle sort criteria.
Definition: build_vehicle_gui.cpp:486
EngineHasReplacementForCompany
bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
Check if a company has a replacement set up for the given engine.
Definition: autoreplace_func.h:51
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:141
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
ReplaceVehicleWindow::sel_roadtype
RoadType sel_roadtype
Type of road selected. INVALID_ROADTYPE to show all.
Definition: autoreplace_gui.cpp:92
settings_func.h
newgrf_engine.h
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1244
Window::HandleButtonClick
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
Definition: window.cpp:591
ReplaceVehicleWindow::sel_engine
EngineID sel_engine[2]
Selected engine left and right.
Definition: autoreplace_gui.cpp:82
WID_RV_SORT_DROPDOWN
@ WID_RV_SORT_DROPDOWN
Dropdown for the sort criteria.
Definition: autoreplace_widget.h:20
DrawEngineList
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group)
Engine drawing loop.
Definition: build_vehicle_gui.cpp:1003
PackEngineNameDParam
uint64_t PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32_t extra_data=0)
Combine an engine ID and a name context to an engine name dparam.
Definition: engine_type.h:198
autoreplace_widget.h
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
ReplaceVehicleWindow::descending_sort_order
bool descending_sort_order
Order of sorting vehicles.
Definition: autoreplace_gui.cpp:89
WID_RV_RIGHT_DETAILS
@ WID_RV_RIGHT_DETAILS
Details of the entry on the right.
Definition: autoreplace_widget.h:28
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:110
Engine::display_flags
EngineDisplayFlags display_flags
NOSAVE client-side-only display flags for build engine list.
Definition: engine_base.h:58
WC_REPLACE_VEHICLE
@ WC_REPLACE_VEHICLE
Replace vehicle window; Window numbers:
Definition: window_type.h:218
autoreplace_cmd.h
EngineDisplayFlags::Shaded
@ Shaded
Set if engine should be masked.
road_gui.h
CompanyProperties::settings
CompanySettings settings
settings specific for each company
Definition: company_base.h:105
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:953
EngineDisplayFlags::None
@ None
No flag set.
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:322
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:49
safeguards.h
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:294
ReplaceVehicleWindow::GenerateLists
void GenerateLists()
Generate the lists.
Definition: autoreplace_gui.cpp:217
DEFAULT_GROUP
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
Definition: group_type.h:17
WID_RV_STOP_REPLACE
@ WID_RV_STOP_REPLACE
Stop Replacing button.
Definition: autoreplace_widget.h:33
TestedEngineDetails
Extra information about refitted cargo and capacity.
Definition: vehicle_gui.h:42
settings
fluid_settings_t * settings
FluidSynth settings handle.
Definition: fluidsynth.cpp:21
ReplaceVehicleWindow::details_height
int details_height
Minimal needed height of the details panels, in text lines (found so far).
Definition: autoreplace_gui.cpp:87
Rect::WithWidth
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Definition: geometry_type.hpp:185
rail.h
road.h
ReplaceVehicleWindow::GenerateReplaceRailList
bool GenerateReplaceRailList(EngineID e, bool draw_left, bool show_engines)
Figure out if an engine should be added to a list.
Definition: autoreplace_gui.cpp:102
ReplaceVehicleWindow::reset_sel_engine
bool reset_sel_engine
Also reset sel_engine while updating left and/or right and no valid engine selected.
Definition: autoreplace_gui.cpp:85
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
Scrollbar::GetScrolledItemFromWidget
Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Return an iterator pointing to the element of a scrolled widget that a user clicked in.
Definition: widget_type.h:845
ShowDropDownMenu
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
Definition: dropdown.cpp:386
stdafx.h
_engine_sort_last_criteria
byte _engine_sort_last_criteria[]
Last set sort criteria, for each vehicle type.
Definition: build_vehicle_gui.cpp:98
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:296
WID_RV_LEFT_SCROLLBAR
@ WID_RV_LEFT_SCROLLBAR
The scrollbar for the matrix on the left.
Definition: autoreplace_widget.h:24
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:339
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
RAILVEH_WAGON
@ RAILVEH_WAGON
simple wagon, not motorized
Definition: engine_type.h:29
GUIEngineListItem::engine_id
EngineID engine_id
Engine to display in build purchase list.
Definition: engine_gui.h:20
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
EngList_Sort
void EngList_Sort(GUIEngineList &el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
Definition: engine_gui.cpp:333
GetRoadTypeInfo
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:227
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:381
group_cmd.h
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
ReplaceVehicleWindow
Window for the autoreplacing of vehicles.
Definition: autoreplace_gui.cpp:81
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:395
rail_gui.h
SBS_DOWN
@ SBS_DOWN
Sort ascending.
Definition: window_gui.h:214
Window::DrawSortButtonState
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
Definition: widget.cpp:763
GuiShowTooltips
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount)
Shows a tooltip.
Definition: misc_gui.cpp:754
WID_RV_RIGHT_MATRIX
@ WID_RV_RIGHT_MATRIX
The matrix on the right.
Definition: autoreplace_widget.h:25
engine_gui.h
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:349
Group::flags
uint8_t flags
Group flags.
Definition: group.h:77
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:556
EngineDisplayFlags
EngineDisplayFlags
Flags used client-side in the purchase/autorenew engine list.
Definition: engine_base.h:26
WC_BUILD_VEHICLE
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
Definition: window_type.h:383
ShowReplaceGroupVehicleWindow
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
Definition: autoreplace_gui.cpp:916
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
geometry_func.hpp
InvalidateWindowClassesData
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Definition: window.cpp:3217
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
EngineInfo::variant_id
EngineID variant_id
Engine variant ID. If set, will be treated specially in purchase lists.
Definition: engine_type.h:159
ReplaceVehicleWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: autoreplace_gui.cpp:724
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition: widget_type.h:760
WID_RV_CAPTION
@ WID_RV_CAPTION
Caption of the window.
Definition: autoreplace_widget.h:15
settings_cmd.h
ReplaceVehicleWindow::show_hidden_engines
bool show_hidden_engines
Whether to show the hidden engines.
Definition: autoreplace_gui.cpp:90
TestedEngineDetails::cost
Money cost
Refit cost.
Definition: vehicle_gui.h:43
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:25
RailVehicleInfo::railtype
RailType railtype
Railtype, mangled if elrail is disabled.
Definition: engine_type.h:46
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1734
GroupID
uint16_t GroupID
Type for all group identifiers.
Definition: group_type.h:13
ReplaceVehicleWindow::sel_railtype
RailType sel_railtype
Type of rail tracks selected. INVALID_RAILTYPE to show all.
Definition: autoreplace_gui.cpp:91
GetGroupNumEngines
uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e)
Get the number of engines with EngineID id_e in the group with GroupID id_g and its sub-groups.
Definition: group_cmd.cpp:797
company_func.h
InvalidateAutoreplaceWindow
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
Rebuild the left autoreplace list if an engine is removed or added.
Definition: autoreplace_gui.cpp:52
WID_RV_LEFT_MATRIX
@ WID_RV_LEFT_MATRIX
The matrix on the left.
Definition: autoreplace_widget.h:23
CommandHelper
Definition: command_func.h:93
window_func.h
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1097
Window::SortButtonWidth
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:780
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:405
ReplaceVehicleWindow::sort_criteria
byte sort_criteria
Criteria of sorting vehicles.
Definition: autoreplace_gui.cpp:88
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:658
engine_base.h
CheckAutoreplaceValidity
bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
Checks some basic properties whether autoreplace is allowed.
Definition: autoreplace_cmd.cpp:60
WidgetDimensions::frametext
RectPadding frametext
Padding inside frame with text.
Definition: window_gui.h:43
EngineID
uint16_t EngineID
Unique identification number of an engine.
Definition: engine_type.h:21
Window
Data structure for an opened window.
Definition: window_gui.h:267
WID_RV_RIGHT_SCROLLBAR
@ WID_RV_RIGHT_SCROLLBAR
The scrollbar for the matrix on the right.
Definition: autoreplace_widget.h:26
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Pool::PoolItem<&_group_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:324
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
autoreplace_func.h
SBS_UP
@ SBS_UP
Sort descending.
Definition: window_gui.h:215
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:356
AddRemoveEngineFromAutoreplaceAndBuildWindows
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
When an engine is made buildable or is removed from being buildable, add/remove it from the build/aut...
Definition: autoreplace_gui.cpp:66
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
Company
Definition: company_base.h:116
WID_RV_SORT_ASCENDING_DESCENDING
@ WID_RV_SORT_ASCENDING_DESCENDING
Ascending/descending sort order button.
Definition: autoreplace_widget.h:18
RailTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: rail.h:180
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition: window_gui.h:42
WID_RV_START_REPLACE
@ WID_RV_START_REPLACE
Start Replacing button.
Definition: autoreplace_widget.h:31
DrawVehiclePurchaseInfo
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te)
Draw the purchase info details of a vehicle at a given location.
Definition: build_vehicle_gui.cpp:916
GetEngineListHeight
uint GetEngineListHeight(VehicleType type)
Get the height of a single 'entry' in the engine lists.
Definition: build_vehicle_gui.cpp:52
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:56
WID_RV_TRAIN_WAGONREMOVE_TOGGLE
@ WID_RV_TRAIN_WAGONREMOVE_TOGGLE
Button to toggle removing wagons.
Definition: autoreplace_widget.h:38
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:852
ReplaceVehicleWindow::ReplaceClick_StartReplace
void ReplaceClick_StartReplace(bool replace_when_old)
Handle click on the start replace button.
Definition: autoreplace_gui.cpp:266
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
Scrollbar::SetPosition
bool SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:790
GF_REPLACE_WAGON_REMOVAL
@ GF_REPLACE_WAGON_REMOVAL
If set, autoreplace will perform wagon removal on vehicles in this group.
Definition: group.h:67
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:72
PurchaseList
@ PurchaseList
Name is shown in the purchase list (including autoreplace window 'Available vehicles' panel).
Definition: engine_type.h:192
GUIEngineListItem
Definition: engine_gui.h:19
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103