OpenTTD Source  13.2.1
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 min, uint16 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->IsHidden(_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 
179  if (side == 1 && eid == this->sel_engine[0]) flags |= EngineDisplayFlags::Shaded;
180  list.emplace_back(eid, e->info.variant_id, flags, 0);
181 
182  if (side == 1 && e->info.variant_id != INVALID_ENGINE) variants.push_back(e->info.variant_id);
183  if (eid == this->sel_engine[side]) selected_engine = eid; // The selected engine is still in the list
184  }
185 
186  if (side == 1) {
187  /* ensure primary engine of variant group is in list */
188  for (const auto &variant : variants) {
189  if (std::find(list.begin(), list.end(), variant) == list.end()) {
190  const Engine *e = Engine::Get(variant);
191  list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlags::Shaded, 0);
192  }
193  }
194  }
195 
196  this->sel_engine[side] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
197  if (draw_left) {
199  } else {
201  EngList_Sort(&list, _engine_sort_functions[this->window_number][this->sort_criteria]);
202  }
203 
204  this->engines[side].clear();
205  if (side == 1) {
206  AddChildren(list, this->engines[side], INVALID_ENGINE, 0, side);
207  } else {
208  this->engines[side].swap(list);
209  }
210  }
211 
214  {
215  EngineID e = this->sel_engine[0];
216 
217  if (this->engines[0].NeedRebuild()) {
218  /* We need to rebuild the left engines list */
219  this->GenerateReplaceVehList(true);
220  this->vscroll[0]->SetCount((uint)this->engines[0].size());
221  if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].size() != 0) {
222  this->sel_engine[0] = this->engines[0][0].engine_id;
223  }
224  }
225 
226  if (this->engines[1].NeedRebuild() || e != this->sel_engine[0]) {
227  /* Either we got a request to rebuild the right engines list, or the left engines list selected a different engine */
228  if (this->sel_engine[0] == INVALID_ENGINE) {
229  /* Always empty the right engines list when nothing is selected in the left engines list */
230  this->engines[1].clear();
231  this->sel_engine[1] = INVALID_ENGINE;
232  } else {
233  if (this->reset_sel_engine && this->sel_engine[0] != INVALID_ENGINE) {
234  /* Select the current replacement for sel_engine[0]. */
235  const Company *c = Company::Get(_local_company);
236  this->sel_engine[1] = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group);
237  }
238  /* Regenerate the list on the right. Note: This resets sel_engine[1] to INVALID_ENGINE, if it is no longer available. */
239  this->GenerateReplaceVehList(false);
240  this->vscroll[1]->SetCount((uint)this->engines[1].size());
241  if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
242  int position = 0;
243  for (const auto &item : this->engines[1]) {
244  if (item.engine_id == this->sel_engine[1]) break;
245  ++position;
246  }
247  this->vscroll[1]->ScrollTowards(position);
248  }
249  }
250  }
251  /* Reset the flags about needed updates */
252  this->engines[0].RebuildDone();
253  this->engines[1].RebuildDone();
254  this->reset_sel_engine = false;
255  }
256 
261  void ReplaceClick_StartReplace(bool replace_when_old)
262  {
263  EngineID veh_from = this->sel_engine[0];
264  EngineID veh_to = this->sel_engine[1];
265  Command<CMD_SET_AUTOREPLACE>::Post(this->sel_group, veh_from, veh_to, replace_when_old);
266  }
267 
268 public:
269  ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
270  {
271  this->sel_railtype = INVALID_RAILTYPE;
272  this->sel_roadtype = INVALID_ROADTYPE;
273  this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool)
274  this->engines[0].ForceRebuild();
275  this->engines[1].ForceRebuild();
276  this->reset_sel_engine = true;
277  this->details_height = ((vehicletype == VEH_TRAIN) ? 10 : 9);
278  this->sel_engine[0] = INVALID_ENGINE;
279  this->sel_engine[1] = INVALID_ENGINE;
280  this->show_hidden_engines = _engine_sort_show_hidden_engines[vehicletype];
281 
282  this->CreateNestedTree();
283  this->vscroll[0] = this->GetScrollbar(WID_RV_LEFT_SCROLLBAR);
284  this->vscroll[1] = this->GetScrollbar(WID_RV_RIGHT_SCROLLBAR);
285 
286  NWidgetCore *widget = this->GetWidget<NWidgetCore>(WID_RV_SHOW_HIDDEN_ENGINES);
287  widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype;
288  widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype;
289  widget->SetLowered(this->show_hidden_engines);
290  this->FinishInitNested(vehicletype);
291 
292  if (vehicletype == VEH_TRAIN || vehicletype == VEH_ROAD) {
293  widget = this->GetWidget<NWidgetCore>(WID_RV_RAIL_ROAD_TYPE_DROPDOWN);
294  widget->tool_tip = STR_REPLACE_HELP_RAILTYPE + vehicletype;
295  }
296 
297  this->sort_criteria = _engine_sort_last_criteria[vehicletype];
298  this->descending_sort_order = _engine_sort_last_order[vehicletype];
299  this->owner = _local_company;
300  this->sel_group = id_g;
301  }
302 
303  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
304  {
305  switch (widget) {
307  Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
308  d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
309  d.height += padding.height;
310  *size = maxdim(*size, d);
311  break;
312  }
313 
314  case WID_RV_LEFT_MATRIX:
315  case WID_RV_RIGHT_MATRIX:
317  size->height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize->height;
318  break;
319 
320  case WID_RV_LEFT_DETAILS:
322  size->height = FONT_HEIGHT_NORMAL * this->details_height + padding.height;
323  break;
324 
326  StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
327  SetDParam(0, STR_CONFIG_SETTING_ON);
329  SetDParam(0, STR_CONFIG_SETTING_OFF);
330  d = maxdim(d, GetStringBoundingBox(str));
331  d.width += padding.width;
332  d.height += padding.height;
333  *size = maxdim(*size, d);
334  break;
335  }
336 
338  Dimension d = GetStringBoundingBox(STR_REPLACE_ENGINES);
339  d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS));
340  d.width += padding.width;
341  d.height += padding.height;
342  *size = maxdim(*size, d);
343  break;
344  }
345 
346  case WID_RV_INFO_TAB: {
347  Dimension d = GetStringBoundingBox(STR_REPLACE_NOT_REPLACING);
348  d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED));
349  d.width += padding.width;
350  d.height += padding.height;
351  *size = maxdim(*size, d);
352  break;
353  }
354 
356  Dimension d = {0, 0};
357  switch (this->window_number) {
358  case VEH_TRAIN:
359  for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
360  const RailtypeInfo *rti = GetRailTypeInfo(rt);
361  /* Skip rail type if it has no label */
362  if (rti->label == 0) continue;
364  }
365  break;
366 
367  case VEH_ROAD:
368  for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) {
369  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
370  /* Skip road type if it has no label */
371  if (rti->label == 0) continue;
373  }
374  break;
375 
376  default: NOT_REACHED();
377  }
378  d.width += padding.width;
379  d.height += padding.height;
380  *size = maxdim(*size, d);
381  break;
382  }
383 
384  case WID_RV_START_REPLACE: {
385  Dimension d = GetStringBoundingBox(STR_REPLACE_VEHICLES_START);
386  for (int i = 0; _start_replace_dropdown[i] != INVALID_STRING_ID; i++) {
387  d = maxdim(d, GetStringBoundingBox(_start_replace_dropdown[i]));
388  }
389  d.width += padding.width;
390  d.height += padding.height;
391  *size = maxdim(*size, d);
392  break;
393  }
394  }
395  }
396 
397  void SetStringParameters(int widget) const override
398  {
399  switch (widget) {
400  case WID_RV_CAPTION:
401  SetDParam(0, STR_REPLACE_VEHICLE_TRAIN + this->window_number);
402  switch (this->sel_group) {
403  case ALL_GROUP:
404  SetDParam(1, STR_GROUP_ALL_TRAINS + this->window_number);
405  break;
406 
407  case DEFAULT_GROUP:
408  SetDParam(1, STR_GROUP_DEFAULT_TRAINS + this->window_number);
409  break;
410 
411  default:
412  SetDParam(1, STR_GROUP_NAME);
413  SetDParam(2, sel_group);
414  break;
415  }
416  break;
417 
419  SetDParam(0, _engine_sort_listing[this->window_number][this->sort_criteria]);
420  break;
421 
423  bool remove_wagon;
424  const Group *g = Group::GetIfValid(this->sel_group);
425  if (g != nullptr) {
427  SetDParam(0, STR_GROUP_NAME);
428  SetDParam(1, sel_group);
429  } else {
430  const Company *c = Company::Get(_local_company);
431  remove_wagon = c->settings.renew_keep_length;
432  SetDParam(0, STR_GROUP_DEFAULT_TRAINS + this->window_number);
433  }
434  SetDParam(2, remove_wagon ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
435  break;
436  }
437 
439  SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
440  break;
441  }
442  }
443 
444  void DrawWidget(const Rect &r, int widget) const override
445  {
446  switch (widget) {
448  this->DrawSortButtonState(WID_RV_SORT_ASCENDING_DESCENDING, this->descending_sort_order ? SBS_DOWN : SBS_UP);
449  break;
450 
451  case WID_RV_INFO_TAB: {
452  const Company *c = Company::Get(_local_company);
453  StringID str;
454  if (this->sel_engine[0] != INVALID_ENGINE) {
455  if (!EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group)) {
456  str = STR_REPLACE_NOT_REPLACING;
457  } else {
458  bool when_old = false;
459  EngineID e = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group, &when_old);
460  str = when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME;
462  }
463  } else {
464  str = STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED;
465  }
466 
468  break;
469  }
470 
471  case WID_RV_LEFT_MATRIX:
472  case WID_RV_RIGHT_MATRIX: {
473  int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
474  EngineID start = static_cast<EngineID>(this->vscroll[side]->GetPosition()); // what is the offset for the start (scrolling)
475  EngineID end = static_cast<EngineID>(std::min<size_t>(this->vscroll[side]->GetCapacity() + start, this->engines[side].size()));
476 
477  /* Do the actual drawing */
478  DrawEngineList((VehicleType)this->window_number, r, this->engines[side], start, end, this->sel_engine[side], side == 0, this->sel_group);
479  break;
480  }
481  }
482  }
483 
484  void OnPaint() override
485  {
486  if (this->engines[0].NeedRebuild() || this->engines[1].NeedRebuild()) this->GenerateLists();
487 
489 
490  /* Disable the "Start Replacing" button if:
491  * Either engines list is empty
492  * or The selected replacement engine has a replacement (to prevent loops). */
493  this->SetWidgetDisabledState(WID_RV_START_REPLACE,
494  this->sel_engine[0] == INVALID_ENGINE || this->sel_engine[1] == INVALID_ENGINE || EngineReplacementForCompany(c, this->sel_engine[1], this->sel_group) != INVALID_ENGINE);
495 
496  /* Disable the "Stop Replacing" button if:
497  * The left engines list (existing vehicle) is empty
498  * or The selected vehicle has no replacement set up */
499  this->SetWidgetDisabledState(WID_RV_STOP_REPLACE, this->sel_engine[0] == INVALID_ENGINE || !EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group));
500 
501  switch (this->window_number) {
502  case VEH_TRAIN:
503  /* Show the selected railtype in the pulldown menu */
504  this->GetWidget<NWidgetCore>(WID_RV_RAIL_ROAD_TYPE_DROPDOWN)->widget_data = sel_railtype == INVALID_RAILTYPE ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(sel_railtype)->strings.replace_text;
505  break;
506 
507  case VEH_ROAD:
508  /* Show the selected roadtype in the pulldown menu */
509  this->GetWidget<NWidgetCore>(WID_RV_RAIL_ROAD_TYPE_DROPDOWN)->widget_data = sel_roadtype == INVALID_ROADTYPE ? STR_REPLACE_ALL_ROADTYPE : GetRoadTypeInfo(sel_roadtype)->strings.replace_text;
510  break;
511 
512  default: break;
513  }
514 
515  this->DrawWidgets();
516 
517  if (!this->IsShaded()) {
518  int needed_height = this->details_height;
519  /* Draw details panels. */
520  for (int side = 0; side < 2; side++) {
521  if (this->sel_engine[side] != INVALID_ENGINE) {
522  /* Use default engine details without refitting */
523  const Engine *e = Engine::Get(this->sel_engine[side]);
525  ted.cost = 0;
526  ted.FillDefaultCapacities(e);
527 
528  const Rect r = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS)->GetCurrentRect()
530  int text_end = DrawVehiclePurchaseInfo(r.left, r.right, r.top, this->sel_engine[side], ted);
531  needed_height = std::max(needed_height, (text_end - r.top) / FONT_HEIGHT_NORMAL);
532  }
533  }
534  if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
535  this->details_height = needed_height;
536  this->ReInit();
537  return;
538  }
539  }
540  }
541 
542  void OnClick(Point pt, int widget, int click_count) override
543  {
544  switch (widget) {
546  this->descending_sort_order ^= true;
547  _engine_sort_last_order[this->window_number] = this->descending_sort_order;
548  this->engines[1].ForceRebuild();
549  this->SetDirty();
550  break;
551 
553  this->show_hidden_engines ^= true;
554  _engine_sort_show_hidden_engines[this->window_number] = this->show_hidden_engines;
555  this->engines[1].ForceRebuild();
556  this->SetWidgetLoweredState(widget, this->show_hidden_engines);
557  this->SetDirty();
558  break;
559 
561  DisplayVehicleSortDropDown(this, static_cast<VehicleType>(this->window_number), this->sort_criteria, WID_RV_SORT_DROPDOWN);
562  break;
563 
565  DropDownList list;
566  list.emplace_back(new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false));
567  list.emplace_back(new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false));
568  ShowDropDownList(this, std::move(list), this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
569  break;
570  }
571 
572  case WID_RV_RAIL_ROAD_TYPE_DROPDOWN: // Rail/roadtype selection dropdown menu
573  switch (this->window_number) {
574  case VEH_TRAIN:
576  break;
577 
578  case VEH_ROAD:
579  ShowDropDownList(this, GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), sel_roadtype, WID_RV_RAIL_ROAD_TYPE_DROPDOWN);
580  break;
581  }
582  break;
583 
585  const Group *g = Group::GetIfValid(this->sel_group);
586  if (g != nullptr) {
588  } else {
589  // toggle renew_keep_length
590  Command<CMD_CHANGE_COMPANY_SETTING>::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1);
591  }
592  break;
593  }
594 
595  case WID_RV_START_REPLACE: { // Start replacing
596  if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
597  this->HandleButtonClick(WID_RV_START_REPLACE);
598  ReplaceClick_StartReplace(false);
599  } else {
600  bool replacment_when_old = EngineHasReplacementWhenOldForCompany(Company::Get(_local_company), this->sel_engine[0], this->sel_group);
601  ShowDropDownMenu(this, _start_replace_dropdown, replacment_when_old ? 1 : 0, WID_RV_START_REPLACE, !this->replace_engines ? 1 << 1 : 0, 0);
602  }
603  break;
604  }
605 
606  case WID_RV_STOP_REPLACE: { // Stop replacing
607  EngineID veh_from = this->sel_engine[0];
608  Command<CMD_SET_AUTOREPLACE>::Post(this->sel_group, veh_from, INVALID_ENGINE, false);
609  break;
610  }
611 
612  case WID_RV_LEFT_MATRIX:
613  case WID_RV_RIGHT_MATRIX: {
614  byte click_side;
615  if (widget == WID_RV_LEFT_MATRIX) {
616  click_side = 0;
617  } else {
618  click_side = 1;
619  }
620  uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y, this, widget);
621  size_t engine_count = this->engines[click_side].size();
622 
624  if (i < engine_count) {
625  const auto &item = this->engines[click_side][i];
626  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);
627  if ((item.flags & EngineDisplayFlags::HasVariants) != EngineDisplayFlags::None && IsInsideMM(r.left, r.right, pt.x)) {
628  /* toggle folded flag on engine */
629  assert(item.variant_id != INVALID_ENGINE);
630  Engine *engine = Engine::Get(item.variant_id);
632 
633  InvalidateWindowData(WC_REPLACE_VEHICLE, (VehicleType)this->window_number, 0); // Update the autoreplace window
634  InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
635  return;
636  }
637  if ((item.flags & EngineDisplayFlags::Shaded) == EngineDisplayFlags::None) e = item.engine_id;
638  }
639 
640  /* If Ctrl is pressed on the left side and we don't have any engines of the selected type, stop autoreplacing.
641  * This is most common when we have finished autoreplacing the engine and want to remove it from the list. */
642  if (click_side == 0 && _ctrl_pressed && e != INVALID_ENGINE &&
643  (GetGroupNumEngines(_local_company, sel_group, e) == 0 || GetGroupNumEngines(_local_company, ALL_GROUP, e) == 0)) {
644  EngineID veh_from = e;
645  Command<CMD_SET_AUTOREPLACE>::Post(this->sel_group, veh_from, INVALID_ENGINE, false);
646  break;
647  }
648 
649  if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
650  this->sel_engine[click_side] = e;
651  if (click_side == 0) {
652  this->engines[1].ForceRebuild();
653  this->reset_sel_engine = true;
654  }
655  this->SetDirty();
656  break;
657  }
658  }
659  }
660 
661  void OnDropdownSelect(int widget, int index) override
662  {
663  switch (widget) {
665  if (this->sort_criteria != index) {
666  this->sort_criteria = index;
667  _engine_sort_last_criteria[this->window_number] = this->sort_criteria;
668  this->engines[1].ForceRebuild();
669  this->SetDirty();
670  }
671  break;
672 
674  switch (this->window_number) {
675  case VEH_TRAIN: {
676  RailType temp = (RailType)index;
677  if (temp == sel_railtype) return; // we didn't select a new one. No need to change anything
678  sel_railtype = temp;
679  break;
680  }
681 
682  case VEH_ROAD: {
683  RoadType temp = (RoadType)index;
684  if (temp == sel_roadtype) return; // we didn't select a new one. No need to change anything
685  sel_roadtype = temp;
686  break;
687  }
688 
689  default: NOT_REACHED();
690  }
691 
692  /* Reset scrollbar positions */
693  this->vscroll[0]->SetPosition(0);
694  this->vscroll[1]->SetPosition(0);
695  /* Rebuild the lists */
696  this->engines[0].ForceRebuild();
697  this->engines[1].ForceRebuild();
698  this->reset_sel_engine = true;
699  this->SetDirty();
700  break;
701 
703  this->replace_engines = index != 0;
704  this->engines[0].ForceRebuild();
705  this->reset_sel_engine = true;
706  this->SetDirty();
707  break;
708  }
709 
711  this->ReplaceClick_StartReplace(index != 0);
712  break;
713  }
714  }
715 
716  bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
717  {
718  if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false;
719 
720  if (Group::IsValidID(this->sel_group)) {
721  uint64 params[1];
722  params[0] = STR_REPLACE_REMOVE_WAGON_HELP;
723  GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_GROUP_HELP, 1, params, close_cond);
724  } else {
725  GuiShowTooltips(this, STR_REPLACE_REMOVE_WAGON_HELP, 0, nullptr, close_cond);
726  }
727  return true;
728  }
729 
730  void OnResize() override
731  {
732  this->vscroll[0]->SetCapacityFromWidget(this, WID_RV_LEFT_MATRIX);
733  this->vscroll[1]->SetCapacityFromWidget(this, WID_RV_RIGHT_MATRIX);
734  }
735 
741  void OnInvalidateData(int data = 0, bool gui_scope = true) override
742  {
743  if (data != 0) {
744  /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
745  this->engines[0].ForceRebuild();
746  } else {
747  this->engines[1].ForceRebuild();
748  }
749  }
750 };
751 
752 static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
754  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
755  NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
756  NWidget(WWT_SHADEBOX, COLOUR_GREY),
757  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
758  NWidget(WWT_STICKYBOX, COLOUR_GREY),
759  EndContainer(),
761  NWidget(WWT_PANEL, COLOUR_GREY),
762  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),
763  EndContainer(),
764  NWidget(WWT_PANEL, COLOUR_GREY),
765  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),
766  EndContainer(),
767  EndContainer(),
771  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_RAIL_ROAD_TYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0),
772  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_REPLACE_ENGINE_WAGON_SELECT_HELP),
773  EndContainer(),
774  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
775  EndContainer(),
778  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
779  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
780  EndContainer(),
782  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
783  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
784  EndContainer(),
785  EndContainer(),
786  EndContainer(),
788  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),
790  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),
792  EndContainer(),
794  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
796  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
797  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),
798  EndContainer(),
799  EndContainer(),
801  NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
802  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0),
803  EndContainer(),
804  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
805  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
806  EndContainer(),
807 };
808 
809 static WindowDesc _replace_rail_vehicle_desc(
810  WDP_AUTO, "replace_vehicle_train", 500, 140,
813  _nested_replace_rail_vehicle_widgets, lengthof(_nested_replace_rail_vehicle_widgets)
814 );
815 
816 static const NWidgetPart _nested_replace_road_vehicle_widgets[] = {
818  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
819  NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
820  NWidget(WWT_SHADEBOX, COLOUR_GREY),
821  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
822  NWidget(WWT_STICKYBOX, COLOUR_GREY),
823  EndContainer(),
825  NWidget(WWT_PANEL, COLOUR_GREY),
826  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),
827  EndContainer(),
828  NWidget(WWT_PANEL, COLOUR_GREY),
829  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),
830  EndContainer(),
831  EndContainer(),
834  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_RAIL_ROAD_TYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0),
835  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
836  EndContainer(),
839  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
840  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
841  EndContainer(),
843  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
844  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
845  EndContainer(),
846  EndContainer(),
847  EndContainer(),
849  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),
851  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),
853  EndContainer(),
855  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
856  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
857  EndContainer(),
859  NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
860  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0),
861  EndContainer(),
862  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
863  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
864  EndContainer(),
865 };
866 
867 static WindowDesc _replace_road_vehicle_desc(
868  WDP_AUTO, "replace_vehicle_road", 500, 140,
871  _nested_replace_road_vehicle_widgets, lengthof(_nested_replace_road_vehicle_widgets)
872 );
873 
874 static const NWidgetPart _nested_replace_vehicle_widgets[] = {
876  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
877  NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetMinimalSize(433, 14), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
878  NWidget(WWT_SHADEBOX, COLOUR_GREY),
879  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
880  NWidget(WWT_STICKYBOX, COLOUR_GREY),
881  EndContainer(),
883  NWidget(WWT_PANEL, COLOUR_GREY),
884  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),
885  EndContainer(),
886  NWidget(WWT_PANEL, COLOUR_GREY),
887  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),
888  EndContainer(),
889  EndContainer(),
891  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
894  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
895  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
896  EndContainer(),
898  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
899  NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
900  EndContainer(),
901  EndContainer(),
902  EndContainer(),
904  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),
906  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),
908  EndContainer(),
910  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
911  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
912  EndContainer(),
914  NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
915  NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0), EndContainer(),
916  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
917  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
918  EndContainer(),
919 };
920 
921 static WindowDesc _replace_vehicle_desc(
922  WDP_AUTO, "replace_vehicle", 456, 118,
925  _nested_replace_vehicle_widgets, lengthof(_nested_replace_vehicle_widgets)
926 );
927 
934 {
935  CloseWindowById(WC_REPLACE_VEHICLE, vehicletype);
936  WindowDesc *desc;
937  switch (vehicletype) {
938  case VEH_TRAIN: desc = &_replace_rail_vehicle_desc; break;
939  case VEH_ROAD: desc = &_replace_road_vehicle_desc; break;
940  default: desc = &_replace_vehicle_desc; break;
941  }
942  new ReplaceVehicleWindow(desc, vehicletype, id_g);
943 }
_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:437
INVALID_ENGINE
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
Definition: engine_type.h:203
RoadTypeInfo
Definition: road.h:76
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:3254
IsInsideMM
static 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:230
EngineNumberSorter
static bool EngineNumberSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
Determines order of engines by engineID.
Definition: build_vehicle_gui.cpp:109
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
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:173
WID_RV_TRAIN_ENGINEWAGON_DROPDOWN
@ WID_RV_TRAIN_ENGINEWAGON_DROPDOWN
Dropdown to select engines and/or wagons.
Definition: autoreplace_widget.h:39
EngineDisplayFlags::HasVariants
@ HasVariants
Set if engine has variants.
Pool::PoolItem<&_engine_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
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:2240
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1210
ReplaceVehicleWindow::sel_group
GroupID sel_group
Group selected to replace.
Definition: autoreplace_gui.cpp:86
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
PackEngineNameDParam
uint64 PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32 extra_data=0)
Combine an engine ID and a name context to an engine name dparam.
Definition: engine_type.h:196
WID_RV_SHOW_HIDDEN_ENGINES
@ WID_RV_SHOW_HIDDEN_ENGINES
Toggle whether to display the hidden vehicles.
Definition: autoreplace_widget.h:19
WID_RV_RAIL_ROAD_TYPE_DROPDOWN
@ WID_RV_RAIL_ROAD_TYPE_DROPDOWN
Dropdown menu about the rail/roadtype.
Definition: autoreplace_widget.h:36
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:64
Pool::PoolItem<&_group_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:348
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:319
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:144
dropdown_func.h
ReplaceVehicleWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: autoreplace_gui.cpp:397
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:92
WID_RV_SORT_ASCENDING_DESCENDING
@ WID_RV_SORT_ASCENDING_DESCENDING
Ascending/descending sort order button.
Definition: autoreplace_widget.h:18
WID_RV_SORT_DROPDOWN
@ WID_RV_SORT_DROPDOWN
Dropdown for the sort criteria.
Definition: autoreplace_widget.h:20
_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
ReplaceVehicleWindow::OnTooltip
bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
Event to display a custom tooltip.
Definition: autoreplace_gui.cpp:716
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:59
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:780
ReplaceVehicleWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: autoreplace_gui.cpp:741
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
GUIList< GUIEngineListItem, CargoID >
RailtypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: rail.h:177
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
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:99
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1775
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
EngineReplacementForCompany
static 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
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
RailtypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:124
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:717
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:997
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:644
Window::owner
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:253
WID_RV_RIGHT_DETAILS
@ WID_RV_RIGHT_DETAILS
Details of the entry on the right.
Definition: autoreplace_widget.h:28
NWidgetCore::tool_tip
StringID tool_tip
Tooltip of the widget.
Definition: widget_type.h:341
RoadTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: road.h:105
Engine
Definition: engine_base.h:36
NWidgetCore::SetLowered
void SetLowered(bool lowered)
Lower or raise the widget.
Definition: widget_type.h:374
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:2353
RoadVehicleInfo::roadtype
RoadType roadtype
Road type.
Definition: engine_type.h:127
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:636
WID_RV_INFO_TAB
@ WID_RV_INFO_TAB
Info tab.
Definition: autoreplace_widget.h:32
ReplaceVehicleWindow::engines
GUIEngineList engines[2]
Left and right list of engines.
Definition: autoreplace_gui.cpp:83
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
_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
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
WID_RV_STOP_REPLACE
@ WID_RV_STOP_REPLACE
Stop Replacing button.
Definition: autoreplace_widget.h:33
NWidgetCore::widget_data
uint32 widget_data
Data of the widget.
Definition: widget_type.h:340
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:890
DisplayVehicleSortDropDown
void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selected, int button)
Display the dropdown for the vehicle sort criteria.
Definition: build_vehicle_gui.cpp:1072
ALL_GROUP
static const GroupID ALL_GROUP
All vehicles are in this group.
Definition: group_type.h:16
WindowDesc
High level window description.
Definition: window_gui.h:102
ReplaceVehicleWindow::UpdateWidgetSize
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: autoreplace_gui.cpp:303
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
Group
Group data.
Definition: group.h:74
ReplaceVehicleWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: autoreplace_gui.cpp:484
CompanySettings::renew_keep_length
bool renew_keep_length
sell some wagons if after autoreplace the train is longer than before
Definition: settings_type.h:580
window_gui.h
Engine::display_last_variant
EngineID display_last_variant
NOSAVE client-side-only last variant selected.
Definition: engine_base.h:58
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:469
WID_RV_RIGHT_SCROLLBAR
@ WID_RV_RIGHT_SCROLLBAR
The scrollbar for the matrix on the right.
Definition: autoreplace_widget.h:26
EngineID
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:21
ReplaceVehicleWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: autoreplace_gui.cpp:730
RailVehicleInfo
Information about a rail vehicle.
Definition: engine_type.h:42
_engine_sort_listing
const StringID _engine_sort_listing[][12]
Dropdown menu strings for the vehicle sort criteria.
Definition: build_vehicle_gui.cpp:487
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:90
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
WID_RV_RIGHT_MATRIX
@ WID_RV_RIGHT_MATRIX
The matrix on the right.
Definition: autoreplace_widget.h:25
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
ReplaceVehicleWindow::sel_roadtype
RoadType sel_roadtype
Type of road selected. INVALID_ROADTYPE to show all.
Definition: autoreplace_gui.cpp:92
GuiShowTooltips
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
Definition: misc_gui.cpp:773
settings_func.h
newgrf_engine.h
ReplaceVehicleWindow::sel_engine
EngineID sel_engine[2]
Selected engine left and right.
Definition: autoreplace_gui.cpp:82
autoreplace_widget.h
ReplaceVehicleWindow::descending_sort_order
bool descending_sort_order
Order of sorting vehicles.
Definition: autoreplace_gui.cpp:89
WID_RV_LEFT_DETAILS
@ WID_RV_LEFT_DETAILS
Details of the entry on the left.
Definition: autoreplace_widget.h:27
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:444
Engine::display_flags
EngineDisplayFlags display_flags
NOSAVE client-side-only display flags for build engine list.
Definition: engine_base.h:57
WC_REPLACE_VEHICLE
@ WC_REPLACE_VEHICLE
Replace vehicle window; Window numbers:
Definition: window_type.h:211
SetMatrixDataTip
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:1129
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:106
EngineDisplayFlags::None
@ None
No flag set.
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:266
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
safeguards.h
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:239
ReplaceVehicleWindow::GenerateLists
void GenerateLists()
Generate the lists.
Definition: autoreplace_gui.cpp:213
DEFAULT_GROUP
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
Definition: group_type.h:17
TestedEngineDetails
Extra information about refitted cargo and capacity.
Definition: vehicle_gui.h:41
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:179
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
ShowDropDownMenu
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
Definition: dropdown.cpp:481
ReplaceVehicleWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: autoreplace_gui.cpp:661
Group::flags
uint8 flags
Group flags.
Definition: group.h:79
WID_RV_LEFT_SCROLLBAR
@ WID_RV_LEFT_SCROLLBAR
The scrollbar for the matrix on the left.
Definition: autoreplace_widget.h:24
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:241
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
WID_RV_START_REPLACE
@ WID_RV_START_REPLACE
Start Replacing button.
Definition: autoreplace_widget.h:31
DrawEngineList
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
Engine drawing loop.
Definition: build_vehicle_gui.cpp:990
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:335
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:75
ReplaceVehicleWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: autoreplace_gui.cpp:444
group_cmd.h
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
ReplaceVehicleWindow
Window for the autoreplacing of vehicles.
Definition: autoreplace_gui.cpp:81
rail_gui.h
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
SBS_DOWN
@ SBS_DOWN
Sort ascending.
Definition: window_gui.h:160
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
engine_gui.h
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
Engine::IsHidden
bool IsHidden(CompanyID c) const
Check whether the engine is hidden in the GUI for the given company.
Definition: engine_base.h:135
GroupID
uint16 GroupID
Type for all group identifiers.
Definition: group_type.h:13
EngineDisplayFlags
EngineDisplayFlags
Flags used client-side in the purchase/autorenew engine list.
Definition: engine_base.h:25
WC_BUILD_VEHICLE
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
Definition: window_type.h:376
RoadTypeInfo::label
RoadTypeLabel label
Unique 32 bit road type identifier.
Definition: road.h:145
ShowReplaceGroupVehicleWindow
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
Definition: autoreplace_gui.cpp:933
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
WID_RV_LEFT_MATRIX
@ WID_RV_LEFT_MATRIX
The matrix on the left.
Definition: autoreplace_widget.h:23
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition: rail_type.h:33
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:3271
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
EngineInfo::variant_id
EngineID variant_id
Engine variant ID. If set, will be treated specially in purchase lists.
Definition: engine_type.h:158
RailtypeInfo::label
RailTypeLabel label
Unique 32 bit rail type identifier.
Definition: rail.h:233
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:678
EngList_Sort
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
Definition: engine_gui.cpp:327
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:42
GetRoadTypeInfo
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:225
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
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:1791
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:775
company_func.h
WidgetDimensions::framerect
RectPadding framerect
Offsets within frame area.
Definition: window_gui.h:47
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
CommandHelper
Definition: command_func.h:94
window_func.h
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
PurchaseList
@ PurchaseList
Name is shown in the purchase list (including autoreplace window).
Definition: engine_type.h:191
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
Scrollbar::SetCapacityFromWidget
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:2427
Window::SortButtonWidth
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:907
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1191
ReplaceVehicleWindow::sort_criteria
byte sort_criteria
Criteria of sorting vehicles.
Definition: autoreplace_gui.cpp:88
engine_base.h
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
CheckAutoreplaceValidity
bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
Checks some basic properties whether autoreplace is allowed.
Definition: autoreplace_cmd.cpp:59
Window
Data structure for an opened window.
Definition: window_gui.h:213
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:380
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:326
RailtypeInfo::strings
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
WidgetDimensions::frametext
RectPadding frametext
Offsets within a text frame area.
Definition: window_gui.h:48
WID_RV_TRAIN_WAGONREMOVE_TOGGLE
@ WID_RV_TRAIN_WAGONREMOVE_TOGGLE
Button to toggle removing wagons.
Definition: autoreplace_widget.h:40
autoreplace_func.h
SBS_UP
@ SBS_UP
Sort descending.
Definition: window_gui.h:161
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:316
GF_REPLACE_WAGON_REMOVAL
@ GF_REPLACE_WAGON_REMOVAL
If set, autoreplace will perform wagon removal on vehicles in this group.
Definition: group.h:69
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
WID_RV_CAPTION
@ WID_RV_CAPTION
Caption of the window.
Definition: autoreplace_widget.h:15
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
Company
Definition: company_base.h:117
EngineHasReplacementForCompany
static 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
ROADTYPE_BEGIN
@ ROADTYPE_BEGIN
Used for iterations.
Definition: road_type.h:23
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:902
EngineHasReplacementWhenOldForCompany
static 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
GetEngineListHeight
uint GetEngineListHeight(VehicleType type)
Get the height of a single 'entry' in the engine lists.
Definition: build_vehicle_gui.cpp:49
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:49
ReplaceVehicleWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: autoreplace_gui.cpp:542
ReplaceVehicleWindow::ReplaceClick_StartReplace
void ReplaceClick_StartReplace(bool replace_when_old)
Handle click on the start replace button.
Definition: autoreplace_gui.cpp:261
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
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:749
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
GUIEngineListItem
Definition: engine_gui.h:19
RoadTypeInfo::strings
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
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:62
RAILTYPE_BEGIN
@ RAILTYPE_BEGIN
Used for iterations.
Definition: rail_type.h:28