OpenTTD Source: src/autoreplace_gui.cpp Source File

OpenTTD Source 1.11.0-RC1

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
29 #include "widgets/autoreplace_widget.h"
30
31 #include "safeguards.h"
32
33 void DrawEngineList(VehicleType type, int x, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group);
34
35 static bool EngineNumberSorter(const EngineID &a, const EngineID &b)
36 {
37 return Engine::Get(a)->list_position < Engine::Get(b)->list_position;
38 }
39
49 void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
50 {
51 if (GetGroupNumEngines(_local_company, id_g, e) == 0 || GetGroupNumEngines(_local_company, ALL_GROUP, e) == 0) {
52 /* We don't have any of this engine type.
53 * Either we just sold the last one, we build a new one or we stopped replacing it.
54 * In all cases, we need to update the left list */
55 InvalidateWindowData(WC_REPLACE_VEHICLE, Engine::Get(e)->type, 1);
56 }
57 }
58
63 void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
64 {
65 InvalidateWindowData(WC_REPLACE_VEHICLE, type, 0); // Update the autoreplace window
66 InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
67 }
68
69 static const StringID _start_replace_dropdown[] = {
70 STR_REPLACE_VEHICLES_NOW,
71 STR_REPLACE_VEHICLES_WHEN_OLD,
72 INVALID_STRING_ID
73 };
74
78 class ReplaceVehicleWindow : public Window {
79 EngineID sel_engine[2];
80 GUIEngineList engines[2];
81 bool replace_engines;
82 bool reset_sel_engine;
83 GroupID sel_group;
84 int details_height;
85 byte sort_criteria;
86 bool descending_sort_order;
87 bool show_hidden_engines;
88 RailType sel_railtype;
89 RoadType sel_roadtype;
90 Scrollbar *vscroll[2];
91
99 bool GenerateReplaceRailList(EngineID e, bool draw_left, bool show_engines)
100 {
101 const RailVehicleInfo *rvi = RailVehInfo(e);
102
103 /* Ensure that the wagon/engine selection fits the engine. */
104 if ((rvi->railveh_type == RAILVEH_WAGON) == show_engines) return false;
105
106 if (draw_left && this->sel_railtype != INVALID_RAILTYPE) {
107 /* Ensure that the railtype is specific to the selected one */
108 if (rvi->railtype != this->sel_railtype) return false;
109 }
110 return true;
111 }
112
113
118 void GenerateReplaceVehList(bool draw_left)
119 {
120 EngineID selected_engine = INVALID_ENGINE;
121 VehicleType type = (VehicleType)this->window_number;
122 byte side = draw_left ? 0 : 1;
123
124 GUIEngineList *list = &this->engines[side];
125 list->clear();
126
127 for (const Engine *e : Engine::IterateType(type)) {
128 if (!draw_left && !this->show_hidden_engines && e->IsHidden(_local_company)) continue;
129 EngineID eid = e->index;
130 switch (type) {
131 case VEH_TRAIN:
132 if (!this->GenerateReplaceRailList(eid, draw_left, this->replace_engines)) continue; // special rules for trains
133 break;
134
135 case VEH_ROAD:
136 if (draw_left && this->sel_roadtype != INVALID_ROADTYPE) {
137 /* Ensure that the roadtype is specific to the selected one */
138 if (e->u.road.roadtype != this->sel_roadtype) continue;
139 }
140 break;
141
142 default:
143 break;
144 }
145
146 if (draw_left) {
147 const uint num_engines = GetGroupNumEngines(_local_company, this->sel_group, eid);
148
149 /* Skip drawing the engines we don't have any of and haven't set for replacement */
150 if (num_engines == 0 && EngineReplacementForCompany(Company::Get(_local_company), eid, this->sel_group) == INVALID_ENGINE) continue;
151 } else {
152 if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
153 }
154
155 list->push_back(eid);
156 if (eid == this->sel_engine[side]) selected_engine = eid; // The selected engine is still in the list
157 }
158 this->sel_engine[side] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
159 if (draw_left) {
160 EngList_Sort(list, &EngineNumberSorter);
161 } else {
162 _engine_sort_direction = this->descending_sort_order;
163 EngList_Sort(list, _engine_sort_functions[this->window_number][this->sort_criteria]);
164 }
165 }
166
168 void GenerateLists()
169 {
170 EngineID e = this->sel_engine[0];
171
172 if (this->engines[0].NeedRebuild()) {
173 /* We need to rebuild the left engines list */
174 this->GenerateReplaceVehList(true);
175 this->vscroll[0]->SetCount((uint)this->engines[0].size());
176 if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->engines[0].size() != 0) {
177 this->sel_engine[0] = this->engines[0][0];
178 }
179 }
180
181 if (this->engines[1].NeedRebuild() || e != this->sel_engine[0]) {
182 /* Either we got a request to rebuild the right engines list, or the left engines list selected a different engine */
183 if (this->sel_engine[0] == INVALID_ENGINE) {
184 /* Always empty the right engines list when nothing is selected in the left engines list */
185 this->engines[1].clear();
186 this->sel_engine[1] = INVALID_ENGINE;
187 } else {
188 if (this->reset_sel_engine && this->sel_engine[0] != INVALID_ENGINE) {
189 /* Select the current replacement for sel_engine[0]. */
190 const Company *c = Company::Get(_local_company);
191 this->sel_engine[1] = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group);
192 }
193 /* Regenerate the list on the right. Note: This resets sel_engine[1] to INVALID_ENGINE, if it is no longer available. */
194 this->GenerateReplaceVehList(false);
195 this->vscroll[1]->SetCount((uint)this->engines[1].size());
196 if (this->reset_sel_engine && this->sel_engine[1] != INVALID_ENGINE) {
197 int position = 0;
198 for (EngineID &eid : this->engines[1]) {
199 if (eid == this->sel_engine[1]) break;
200 ++position;
201 }
202 this->vscroll[1]->ScrollTowards(position);
203 }
204 }
205 }
206 /* Reset the flags about needed updates */
207 this->engines[0].RebuildDone();
208 this->engines[1].RebuildDone();
209 this->reset_sel_engine = false;
210 }
211
216 void ReplaceClick_StartReplace(bool replace_when_old)
217 {
218 EngineID veh_from = this->sel_engine[0];
219 EngineID veh_to = this->sel_engine[1];
220 DoCommandP(0, (replace_when_old ? 1 : 0) | (this->sel_group << 16), veh_from + (veh_to << 16), CMD_SET_AUTOREPLACE);
221 }
222
223 public:
224 ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
225 {
226 this->sel_railtype = INVALID_RAILTYPE;
227 this->sel_roadtype = INVALID_ROADTYPE;
228 this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool)
229 this->engines[0].ForceRebuild();
230 this->engines[1].ForceRebuild();
231 this->reset_sel_engine = true;
232 this->details_height = ((vehicletype == VEH_TRAIN) ? 10 : 9) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
233 this->sel_engine[0] = INVALID_ENGINE;
234 this->sel_engine[1] = INVALID_ENGINE;
235 this->show_hidden_engines = _engine_sort_show_hidden_engines[vehicletype];
236
237 this->CreateNestedTree();
238 this->vscroll[0] = this->GetScrollbar(WID_RV_LEFT_SCROLLBAR);
239 this->vscroll[1] = this->GetScrollbar(WID_RV_RIGHT_SCROLLBAR);
240
241 NWidgetCore *widget = this->GetWidget<NWidgetCore>(WID_RV_SHOW_HIDDEN_ENGINES);
242 widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype;
243 widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype;
244 widget->SetLowered(this->show_hidden_engines);
245 this->FinishInitNested(vehicletype);
246
247 if (vehicletype == VEH_TRAIN || vehicletype == VEH_ROAD) {
248 widget = this->GetWidget<NWidgetCore>(WID_RV_RAIL_ROAD_TYPE_DROPDOWN);
249 widget->tool_tip = STR_REPLACE_HELP_RAILTYPE + vehicletype;
250 }
251
252 this->sort_criteria = _engine_sort_last_criteria[vehicletype];
253 this->descending_sort_order = _engine_sort_last_order[vehicletype];
254 this->owner = _local_company;
255 this->sel_group = id_g;
256 }
257
258 void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
259 {
260 switch (widget) {
261 case WID_RV_SORT_ASCENDING_DESCENDING: {
262 Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
263 d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
264 d.height += padding.height;
265 *size = maxdim(*size, d);
266 break;
267 }
268
269 case WID_RV_LEFT_MATRIX:
270 case WID_RV_RIGHT_MATRIX:
271 resize->height = GetEngineListHeight((VehicleType)this->window_number);
272 size->height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize->height;
273 break;
274
275 case WID_RV_LEFT_DETAILS:
276 case WID_RV_RIGHT_DETAILS:
277 size->height = this->details_height;
278 break;
279
280 case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
281 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
282 SetDParam(0, STR_CONFIG_SETTING_ON);
283 Dimension d = GetStringBoundingBox(str);
284 SetDParam(0, STR_CONFIG_SETTING_OFF);
285 d = maxdim(d, GetStringBoundingBox(str));
286 d.width += padding.width;
287 d.height += padding.height;
288 *size = maxdim(*size, d);
289 break;
290 }
291
292 case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
293 Dimension d = GetStringBoundingBox(STR_REPLACE_ENGINES);
294 d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS));
295 d.width += padding.width;
296 d.height += padding.height;
297 *size = maxdim(*size, d);
298 break;
299 }
300
301 case WID_RV_INFO_TAB: {
302 Dimension d = GetStringBoundingBox(STR_REPLACE_NOT_REPLACING);
303 d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED));
304 d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
305 d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
306 *size = maxdim(*size, d);
307 break;
308 }
309
310 case WID_RV_RAIL_ROAD_TYPE_DROPDOWN: {
311 Dimension d = {0, 0};
312 switch (this->window_number) {
313 case VEH_TRAIN:
314 for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
315 const RailtypeInfo *rti = GetRailTypeInfo(rt);
316 /* Skip rail type if it has no label */
317 if (rti->label == 0) continue;
318 d = maxdim(d, GetStringBoundingBox(rti->strings.replace_text));
319 }
320 break;
321
322 case VEH_ROAD:
323 for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) {
324 const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
325 /* Skip road type if it has no label */
326 if (rti->label == 0) continue;
327 d = maxdim(d, GetStringBoundingBox(rti->strings.replace_text));
328 }
329 break;
330
331 default: NOT_REACHED();
332 }
333 d.width += padding.width;
334 d.height += padding.height;
335 *size = maxdim(*size, d);
336 break;
337 }
338
339 case WID_RV_START_REPLACE: {
340 Dimension d = GetStringBoundingBox(STR_REPLACE_VEHICLES_START);
341 for (int i = 0; _start_replace_dropdown[i] != INVALID_STRING_ID; i++) {
342 d = maxdim(d, GetStringBoundingBox(_start_replace_dropdown[i]));
343 }
344 d.width += padding.width;
345 d.height += padding.height;
346 *size = maxdim(*size, d);
347 break;
348 }
349 }
350 }
351
352 void SetStringParameters(int widget) const override
353 {
354 switch (widget) {
355 case WID_RV_CAPTION:
356 SetDParam(0, STR_REPLACE_VEHICLE_TRAIN + this->window_number);
357 switch (this->sel_group) {
358 case ALL_GROUP:
359 SetDParam(1, STR_GROUP_ALL_TRAINS + this->window_number);
360 break;
361
362 case DEFAULT_GROUP:
363 SetDParam(1, STR_GROUP_DEFAULT_TRAINS + this->window_number);
364 break;
365
366 default:
367 SetDParam(1, STR_GROUP_NAME);
368 SetDParam(2, sel_group);
369 break;
370 }
371 break;
372
373 case WID_RV_SORT_DROPDOWN:
374 SetDParam(0, _engine_sort_listing[this->window_number][this->sort_criteria]);
375 break;
376
377 case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
378 const Company *c = Company::Get(_local_company);
379 SetDParam(0, c->settings.renew_keep_length ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
380 break;
381 }
382
383 case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN:
384 SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
385 break;
386 }
387 }
388
389 void DrawWidget(const Rect &r, int widget) const override
390 {
391 switch (widget) {
392 case WID_RV_SORT_ASCENDING_DESCENDING:
393 this->DrawSortButtonState(WID_RV_SORT_ASCENDING_DESCENDING, this->descending_sort_order ? SBS_DOWN : SBS_UP);
394 break;
395
396 case WID_RV_INFO_TAB: {
397 const Company *c = Company::Get(_local_company);
398 StringID str;
399 if (this->sel_engine[0] != INVALID_ENGINE) {
400 if (!EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group)) {
401 str = STR_REPLACE_NOT_REPLACING;
402 } else {
403 bool when_old = false;
404 EngineID e = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group, &when_old);
405 str = when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME;
406 SetDParam(0, e);
407 }
408 } else {
409 str = STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED;
410 }
411
412 DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_BLACK, SA_HOR_CENTER);
413 break;
414 }
415
416 case WID_RV_LEFT_MATRIX:
417 case WID_RV_RIGHT_MATRIX: {
418 int side = (widget == WID_RV_LEFT_MATRIX) ? 0 : 1;
419 EngineID start = static_cast<EngineID>(this->vscroll[side]->GetPosition()); // what is the offset for the start (scrolling)
420 EngineID end = static_cast<EngineID>(std::min<size_t>(this->vscroll[side]->GetCapacity() + start, this->engines[side].size()));
421
422 /* Do the actual drawing */
423 DrawEngineList((VehicleType)this->window_number, r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP,
424 &this->engines[side], start, end, this->sel_engine[side], side == 0, this->sel_group);
425 break;
426 }
427 }
428 }
429
430 void OnPaint() override
431 {
432 if (this->engines[0].NeedRebuild() || this->engines[1].NeedRebuild()) this->GenerateLists();
433
434 Company *c = Company::Get(_local_company);
435
436 /* Disable the "Start Replacing" button if:
437 * Either engines list is empty
438 * or The selected replacement engine has a replacement (to prevent loops). */
439 this->SetWidgetDisabledState(WID_RV_START_REPLACE,
440 this->sel_engine[0] == INVALID_ENGINE || this->sel_engine[1] == INVALID_ENGINE || EngineReplacementForCompany(c, this->sel_engine[1], this->sel_group) != INVALID_ENGINE);
441
442 /* Disable the "Stop Replacing" button if:
443 * The left engines list (existing vehicle) is empty
444 * or The selected vehicle has no replacement set up */
445 this->SetWidgetDisabledState(WID_RV_STOP_REPLACE, this->sel_engine[0] == INVALID_ENGINE || !EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group));
446
447 switch (this->window_number) {
448 case VEH_TRAIN:
449 /* Show the selected railtype in the pulldown menu */
450 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;
451 break;
452
453 case VEH_ROAD:
454 /* Show the selected roadtype in the pulldown menu */
455 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;
456 break;
457
458 default: break;
459 }
460
461 this->DrawWidgets();
462
463 if (!this->IsShaded()) {
464 int needed_height = this->details_height;
465 /* Draw details panels. */
466 for (int side = 0; side < 2; side++) {
467 if (this->sel_engine[side] != INVALID_ENGINE) {
468 /* Use default engine details without refitting */
469 const Engine *e = Engine::Get(this->sel_engine[side]);
470 TestedEngineDetails ted;
471 ted.cost = 0;
472 ted.cargo = e->GetDefaultCargoType();
473 ted.capacity = e->GetDisplayDefaultCapacity(&ted.mail_capacity);
474
475 NWidgetBase *nwi = this->GetWidget<NWidgetBase>(side == 0 ? WID_RV_LEFT_DETAILS : WID_RV_RIGHT_DETAILS);
476 int text_end = DrawVehiclePurchaseInfo(nwi->pos_x + WD_FRAMETEXT_LEFT, nwi->pos_x + nwi->current_x - WD_FRAMETEXT_RIGHT,
477 nwi->pos_y + WD_FRAMERECT_TOP, this->sel_engine[side], ted);
478 needed_height = std::max(needed_height, text_end - (int)nwi->pos_y + WD_FRAMERECT_BOTTOM);
479 }
480 }
481 if (needed_height != this->details_height) { // Details window are not high enough, enlarge them.
482 this->details_height = needed_height;
483 this->ReInit();
484 return;
485 }
486 }
487 }
488
489 void OnClick(Point pt, int widget, int click_count) override
490 {
491 switch (widget) {
492 case WID_RV_SORT_ASCENDING_DESCENDING:
493 this->descending_sort_order ^= true;
494 _engine_sort_last_order[this->window_number] = this->descending_sort_order;
495 this->engines[1].ForceRebuild();
496 this->SetDirty();
497 break;
498
499 case WID_RV_SHOW_HIDDEN_ENGINES:
500 this->show_hidden_engines ^= true;
501 _engine_sort_show_hidden_engines[this->window_number] = this->show_hidden_engines;
502 this->engines[1].ForceRebuild();
503 this->SetWidgetLoweredState(widget, this->show_hidden_engines);
504 this->SetDirty();
505 break;
506
507 case WID_RV_SORT_DROPDOWN:
508 DisplayVehicleSortDropDown(this, static_cast<VehicleType>(this->window_number), this->sort_criteria, WID_RV_SORT_DROPDOWN);
509 break;
510
511 case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
512 DropDownList list;
513 list.emplace_back(new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false));
514 list.emplace_back(new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false));
515 ShowDropDownList(this, std::move(list), this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
516 break;
517 }
518
519 case WID_RV_RAIL_ROAD_TYPE_DROPDOWN: // Rail/roadtype selection dropdown menu
520 switch (this->window_number) {
521 case VEH_TRAIN:
522 ShowDropDownList(this, GetRailTypeDropDownList(true, true), sel_railtype, WID_RV_RAIL_ROAD_TYPE_DROPDOWN);
523 break;
524
525 case VEH_ROAD:
526 ShowDropDownList(this, GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), sel_roadtype, WID_RV_RAIL_ROAD_TYPE_DROPDOWN);
527 break;
528 }
529 break;
530
531 case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length
532 DoCommandP(0, GetCompanySettingIndex("company.renew_keep_length"), Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING);
533 break;
534
535 case WID_RV_START_REPLACE: { // Start replacing
536 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
537 this->HandleButtonClick(WID_RV_START_REPLACE);
538 ReplaceClick_StartReplace(false);
539 } else {
540 bool replacment_when_old = EngineHasReplacementWhenOldForCompany(Company::Get(_local_company), this->sel_engine[0], this->sel_group);
541 ShowDropDownMenu(this, _start_replace_dropdown, replacment_when_old ? 1 : 0, WID_RV_START_REPLACE, !this->replace_engines ? 1 << 1 : 0, 0);
542 }
543 break;
544 }
545
546 case WID_RV_STOP_REPLACE: { // Stop replacing
547 EngineID veh_from = this->sel_engine[0];
548 DoCommandP(0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16), CMD_SET_AUTOREPLACE);
549 break;
550 }
551
552 case WID_RV_LEFT_MATRIX:
553 case WID_RV_RIGHT_MATRIX: {
554 byte click_side;
555 if (widget == WID_RV_LEFT_MATRIX) {
556 click_side = 0;
557 } else {
558 click_side = 1;
559 }
560 uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y, this, widget);
561 size_t engine_count = this->engines[click_side].size();
562
563 EngineID e = engine_count > i ? this->engines[click_side][i] : INVALID_ENGINE;
564 if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
565 this->sel_engine[click_side] = e;
566 if (click_side == 0) {
567 this->engines[1].ForceRebuild();
568 this->reset_sel_engine = true;
569 }
570 this->SetDirty();
571 break;
572 }
573 }
574 }
575
576 void OnDropdownSelect(int widget, int index) override
577 {
578 switch (widget) {
579 case WID_RV_SORT_DROPDOWN:
580 if (this->sort_criteria != index) {
581 this->sort_criteria = index;
582 _engine_sort_last_criteria[this->window_number] = this->sort_criteria;
583 this->engines[1].ForceRebuild();
584 this->SetDirty();
585 }
586 break;
587
588 case WID_RV_RAIL_ROAD_TYPE_DROPDOWN:
589 switch (this->window_number) {
590 case VEH_TRAIN: {
591 RailType temp = (RailType)index;
592 if (temp == sel_railtype) return; // we didn't select a new one. No need to change anything
593 sel_railtype = temp;
594 break;
595 }
596
597 case VEH_ROAD: {
598 RoadType temp = (RoadType)index;
599 if (temp == sel_roadtype) return; // we didn't select a new one. No need to change anything
600 sel_roadtype = temp;
601 break;
602 }
603
604 default: NOT_REACHED();
605 }
606
607 /* Reset scrollbar positions */
608 this->vscroll[0]->SetPosition(0);
609 this->vscroll[1]->SetPosition(0);
610 /* Rebuild the lists */
611 this->engines[0].ForceRebuild();
612 this->engines[1].ForceRebuild();
613 this->reset_sel_engine = true;
614 this->SetDirty();
615 break;
616
617 case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
618 this->replace_engines = index != 0;
619 this->engines[0].ForceRebuild();
620 this->reset_sel_engine = true;
621 this->SetDirty();
622 break;
623 }
624
625 case WID_RV_START_REPLACE:
626 this->ReplaceClick_StartReplace(index != 0);
627 break;
628 }
629 }
630
631 void OnResize() override
632 {
633 this->vscroll[0]->SetCapacityFromWidget(this, WID_RV_LEFT_MATRIX);
634 this->vscroll[1]->SetCapacityFromWidget(this, WID_RV_RIGHT_MATRIX);
635 }
636
642 void OnInvalidateData(int data = 0, bool gui_scope = true) override
643 {
644 if (data != 0) {
645 /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
646 this->engines[0].ForceRebuild();
647 } else {
648 this->engines[1].ForceRebuild();
649 }
650 }
651 };
652
653 static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
654 NWidget(NWID_HORIZONTAL),
655 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
656 NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
657 NWidget(WWT_SHADEBOX, COLOUR_GREY),
658 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
659 NWidget(WWT_STICKYBOX, COLOUR_GREY),
660 EndContainer(),
661 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
662 NWidget(WWT_PANEL, COLOUR_GREY),
663 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),
664 EndContainer(),
665 NWidget(WWT_PANEL, COLOUR_GREY),
666 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),
667 EndContainer(),
668 EndContainer(),
669 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
670 NWidget(NWID_VERTICAL),
671 NWidget(NWID_HORIZONTAL),
672 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),
673 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_REPLACE_ENGINE_WAGON_SELECT_HELP),
674 EndContainer(),
675 NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
676 EndContainer(),
677 NWidget(NWID_VERTICAL),
678 NWidget(NWID_HORIZONTAL),
679 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
680 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
681 EndContainer(),
682 NWidget(NWID_HORIZONTAL),
683 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
684 NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
685 EndContainer(),
686 EndContainer(),
687 EndContainer(),
688 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
689 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),
690 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_LEFT_SCROLLBAR),
691 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),
692 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_RIGHT_SCROLLBAR),
693 EndContainer(),
694 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
695 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
696 NWidget(NWID_VERTICAL),
697 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
698 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),
699 EndContainer(),
700 EndContainer(),
701 NWidget(NWID_HORIZONTAL),
702 NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
703 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0),
704 EndContainer(),
705 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
706 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
707 EndContainer(),
708 };
709
710 static WindowDesc _replace_rail_vehicle_desc(
711 WDP_AUTO, "replace_vehicle_train", 500, 140,
712 WC_REPLACE_VEHICLE, WC_NONE,
713 WDF_CONSTRUCTION,
714 _nested_replace_rail_vehicle_widgets, lengthof(_nested_replace_rail_vehicle_widgets)
715 );
716
717 static const NWidgetPart _nested_replace_road_vehicle_widgets[] = {
718 NWidget(NWID_HORIZONTAL),
719 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
720 NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
721 NWidget(WWT_SHADEBOX, COLOUR_GREY),
722 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
723 NWidget(WWT_STICKYBOX, COLOUR_GREY),
724 EndContainer(),
725 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
726 NWidget(WWT_PANEL, COLOUR_GREY),
727 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),
728 EndContainer(),
729 NWidget(WWT_PANEL, COLOUR_GREY),
730 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),
731 EndContainer(),
732 EndContainer(),
733 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
734 NWidget(NWID_VERTICAL),
735 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),
736 NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
737 EndContainer(),
738 NWidget(NWID_VERTICAL),
739 NWidget(NWID_HORIZONTAL),
740 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
741 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
742 EndContainer(),
743 NWidget(NWID_HORIZONTAL),
744 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
745 NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
746 EndContainer(),
747 EndContainer(),
748 EndContainer(),
749 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
750 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),
751 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_LEFT_SCROLLBAR),
752 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),
753 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_RIGHT_SCROLLBAR),
754 EndContainer(),
755 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
756 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
757 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
758 EndContainer(),
759 NWidget(NWID_HORIZONTAL),
760 NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
761 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0),
762 EndContainer(),
763 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
764 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
765 EndContainer(),
766 };
767
768 static WindowDesc _replace_road_vehicle_desc(
769 WDP_AUTO, "replace_vehicle_road", 500, 140,
770 WC_REPLACE_VEHICLE, WC_NONE,
771 WDF_CONSTRUCTION,
772 _nested_replace_road_vehicle_widgets, lengthof(_nested_replace_road_vehicle_widgets)
773 );
774
775 static const NWidgetPart _nested_replace_vehicle_widgets[] = {
776 NWidget(NWID_HORIZONTAL),
777 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
778 NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetMinimalSize(433, 14), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
779 NWidget(WWT_SHADEBOX, COLOUR_GREY),
780 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
781 NWidget(WWT_STICKYBOX, COLOUR_GREY),
782 EndContainer(),
783 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
784 NWidget(WWT_PANEL, COLOUR_GREY),
785 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),
786 EndContainer(),
787 NWidget(WWT_PANEL, COLOUR_GREY),
788 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),
789 EndContainer(),
790 EndContainer(),
791 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
792 NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
793 NWidget(NWID_VERTICAL),
794 NWidget(NWID_HORIZONTAL),
795 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
796 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_SORT_DROPDOWN), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
797 EndContainer(),
798 NWidget(NWID_HORIZONTAL),
799 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_RV_SHOW_HIDDEN_ENGINES), SetDataTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP),
800 NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
801 EndContainer(),
802 EndContainer(),
803 EndContainer(),
804 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
805 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),
806 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_LEFT_SCROLLBAR),
807 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),
808 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_RV_RIGHT_SCROLLBAR),
809 EndContainer(),
810 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
811 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
812 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
813 EndContainer(),
814 NWidget(NWID_HORIZONTAL),
815 NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
816 NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0), EndContainer(),
817 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
818 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
819 EndContainer(),
820 };
821
822 static WindowDesc _replace_vehicle_desc(
823 WDP_AUTO, "replace_vehicle", 456, 118,
824 WC_REPLACE_VEHICLE, WC_NONE,
825 WDF_CONSTRUCTION,
826 _nested_replace_vehicle_widgets, lengthof(_nested_replace_vehicle_widgets)
827 );
828
834 void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
835 {
836 DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype);
837 WindowDesc *desc;
838 switch (vehicletype) {
839 case VEH_TRAIN: desc = &_replace_rail_vehicle_desc; break;
840 case VEH_ROAD: desc = &_replace_road_vehicle_desc; break;
841 default: desc = &_replace_vehicle_desc; break;
842 }
843 new ReplaceVehicleWindow(desc, vehicletype, id_g);
844 }
_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:432
Engine::GetDisplayDefaultCapacity
uint GetDisplayDefaultCapacity(uint16 *mail_capacity=nullptr) const
Determines the default cargo capacity of an engine for display purposes.
Definition: engine_base.h:99
INVALID_ENGINE
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
Definition: engine_type.h:174
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
RoadTypeInfo
Definition: road.h:75
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:3321
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:157
WID_RV_TRAIN_ENGINEWAGON_DROPDOWN
@ WID_RV_TRAIN_ENGINEWAGON_DROPDOWN
Dropdown to select engines and/or wagons.
Definition: autoreplace_widget.h:39
Pool::PoolItem<&_engine_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
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:2131
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1094
ReplaceVehicleWindow::sel_group
GroupID sel_group
Group selected to replace.
Definition: autoreplace_gui.cpp:83
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
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
RoadTypeInfo::strings
struct RoadTypeInfo::@44 strings
Strings associated with the rail type.
ReplaceVehicleWindow::replace_engines
bool replace_engines
If true, engines are replaced, if false, wagons are replaced (only for trains).
Definition: autoreplace_gui.cpp:81
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:309
CMD_SET_AUTOREPLACE
@ CMD_SET_AUTOREPLACE
set an autoreplace entry
Definition: command_type.h:312
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:208
dropdown_func.h
ReplaceVehicleWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: autoreplace_gui.cpp:352
WID_RV_SORT_ASCENDING_DESCENDING
@ WID_RV_SORT_ASCENDING_DESCENDING
Ascending/descending sort order button.
Definition: autoreplace_widget.h:18
TestedEngineDetails::mail_capacity
uint16 mail_capacity
Mail capacity if available.
Definition: vehicle_gui.h:43
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:95
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:730
ReplaceVehicleWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: autoreplace_gui.cpp:642
ReplaceVehicleWindow::GenerateReplaceVehList
void GenerateReplaceVehList(bool draw_left)
Generate an engines list.
Definition: autoreplace_gui.cpp:118
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1966
_engine_sort_direction
bool _engine_sort_direction
false = descending, true = ascending.
Definition: build_vehicle_gui.cpp:93
GUIList< EngineID, CargoID >
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
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:100
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:1832
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
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:669
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:929
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
TestedEngineDetails::cargo
CargoID cargo
Cargo type.
Definition: vehicle_gui.h:41
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:640
Window::owner
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:324
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:305
RoadTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: road.h:104
Engine
Definition: engine_base.h:21
NWidgetCore::SetLowered
void SetLowered(bool lowered)
Lower or raise the widget.
Definition: widget_type.h:336
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_func.h:97
Engine::GetDefaultCargoType
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
Definition: engine_base.h:79
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:588
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:70
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:80
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:199
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
_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:96
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
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:304
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:842
TestedEngineDetails::capacity
uint capacity
Cargo capacity.
Definition: vehicle_gui.h:42
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:1025
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:166
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:258
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
ReplaceVehicleWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: autoreplace_gui.cpp:430
CompanySettings::renew_keep_length
bool renew_keep_length
sell some wagons if after autoreplace the train is longer than before
Definition: settings_type.h:553
window_gui.h
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
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:631
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:482
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:154
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:322
ReplaceVehicleWindow::sel_roadtype
RoadType sel_roadtype
Type of road selected. INVALID_ROADTYPE to show all.
Definition: autoreplace_gui.cpp:89
settings_func.h
newgrf_engine.h
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
ReplaceVehicleWindow::sel_engine
EngineID sel_engine[2]
Selected engine left and right.
Definition: autoreplace_gui.cpp:79
autoreplace_widget.h
ReplaceVehicleWindow::descending_sort_order
bool descending_sort_order
Order of sorting vehicles.
Definition: autoreplace_gui.cpp:86
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
GetCompanySettingIndex
uint GetCompanySettingIndex(const char *name)
Get the index in the _company_settings array of a setting.
Definition: settings.cpp:2064
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
WID_RV_LEFT_DETAILS
@ WID_RV_LEFT_DETAILS
Details of the entry on the left.
Definition: autoreplace_widget.h:27
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
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:453
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:1031
road_gui.h
_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
ReplaceVehicleWindow::GenerateLists
void GenerateLists()
Generate the lists.
Definition: autoreplace_gui.cpp:168
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:39
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 (found so far).
Definition: autoreplace_gui.cpp:84
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:99
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:82
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:494
ROADTYPE_BEGIN
@ ROADTYPE_BEGIN
Used for iterations.
Definition: road_type.h:23
ReplaceVehicleWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: autoreplace_gui.cpp:576
WID_RV_LEFT_SCROLLBAR
@ WID_RV_LEFT_SCROLLBAR
The scrollbar for the matrix on the left.
Definition: autoreplace_widget.h:24
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:71
stdafx.h
_engine_sort_last_criteria
byte _engine_sort_last_criteria[]
Last set sort criteria, for each vehicle type.
Definition: build_vehicle_gui.cpp:94
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:312
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
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
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
RAILVEH_WAGON
@ RAILVEH_WAGON
simple wagon, not motorized
Definition: engine_type.h:29
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
DrawEngineList
void DrawEngineList(VehicleType type, int x, int r, int y, 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:963
ReplaceVehicleWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: autoreplace_gui.cpp:389
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:78
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:224
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
engine_gui.h
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
GroupID
uint16 GroupID
Type for all group identifiers.
Definition: group_type.h:13
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
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:144
ShowReplaceGroupVehicleWindow
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
Definition: autoreplace_gui.cpp:834
Scrollbar::SetPosition
void SetPosition(int position)
Sets the position of the first visible element.
Definition: widget_type.h:700
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:179
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:1113
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:3339
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
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:630
EngList_Sort
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
Definition: engine_gui.cpp:326
ReplaceVehicleWindow::show_hidden_engines
bool show_hidden_engines
Whether to show the hidden engines.
Definition: autoreplace_gui.cpp:87
TestedEngineDetails::cost
Money cost
Refit cost.
Definition: vehicle_gui.h:40
GetRoadTypeInfo
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:224
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1848
ReplaceVehicleWindow::sel_railtype
RailType sel_railtype
Type of rail tracks selected. INVALID_RAILTYPE to show all.
Definition: autoreplace_gui.cpp:88
RailtypeInfo::strings
struct RailtypeInfo::@41 strings
Strings associated with the rail type.
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:784
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:49
window_func.h
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:367
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:1980
Window::SortButtonWidth
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Definition: widget.cpp:656
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:176
ReplaceVehicleWindow::sort_criteria
byte sort_criteria
Criteria of sorting vehicles.
Definition: autoreplace_gui.cpp:85
engine_base.h
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
CheckAutoreplaceValidity
bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
Checks some basic properties whether autoreplace is allowed.
Definition: autoreplace_cmd.cpp:54
Window
Data structure for an opened window.
Definition: window_gui.h:276
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
EngineNumberSorter
static bool EngineNumberSorter(const EngineID &a, const EngineID &b)
Determines order of engines by engineID.
Definition: build_vehicle_gui.cpp:105
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:225
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:282
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:63
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
WID_RV_CAPTION
@ WID_RV_CAPTION
Caption of the window.
Definition: autoreplace_widget.h:15
Company
Definition: company_base.h:110
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:172
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
Company::settings
CompanySettings settings
settings specific for each company
Definition: company_base.h:122
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:873
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
CMD_CHANGE_COMPANY_SETTING
@ CMD_CHANGE_COMPANY_SETTING
change a company setting
Definition: command_type.h:310
GetEngineListHeight
uint GetEngineListHeight(VehicleType type)
Get the height of a single 'entry' in the engine lists.
Definition: build_vehicle_gui.cpp:45
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:489
ReplaceVehicleWindow::ReplaceClick_StartReplace
void ReplaceClick_StartReplace(bool replace_when_old)
Handle click on the start replace button.
Definition: autoreplace_gui.cpp:216
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
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
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