71 static const StringID _start_replace_dropdown[] = {
72 STR_REPLACE_VEHICLES_NOW,
73 STR_REPLACE_VEHICLES_WHEN_OLD,
105 if ((rvi->railveh_type ==
RAILVEH_WAGON) == show_engines)
return false;
107 if (draw_left && show_engines) {
109 if (rvi->railtype != this->sel_railtype)
return false;
123 byte side = draw_left ? 0 : 1;
129 FOR_ALL_ENGINES_OF_TYPE(e, type) {
144 if (eid == this->
sel_engine[side]) selected_engine = eid;
160 if (this->
engines[0].NeedRebuild()) {
218 memset(type_count, 0,
sizeof(type_count));
246 widget->
widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype;
247 widget->
tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype;
263 d.height += padding.height;
271 size->height = (this->window_number <=
VEH_ROAD ? 8 : 4) * resize->height;
276 size->height = this->details_height;
285 d.width += padding.width;
286 d.height += padding.height;
292 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
297 d.width += padding.width;
298 d.height += padding.height;
317 if (rti->
label == 0)
continue;
320 d.width += padding.width;
321 d.height += padding.height;
331 d.width += padding.width;
332 d.height += padding.height;
339 virtual void SetStringParameters(
int widget)
const
343 SetDParam(0, STR_REPLACE_VEHICLE_TRAIN + this->window_number);
344 switch (this->sel_group) {
346 SetDParam(1, STR_GROUP_ALL_TRAINS + this->window_number);
350 SetDParam(1, STR_GROUP_DEFAULT_TRAINS + this->window_number);
371 SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
376 virtual void DrawWidget(
const Rect &r,
int widget)
const
388 str = STR_REPLACE_NOT_REPLACING;
390 bool when_old =
false;
392 str = when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME;
396 str = STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED;
406 EngineID start = this->vscroll[side]->GetPosition();
407 EngineID end =
min(this->vscroll[side]->GetCapacity() + start, this->engines[side].Length());
411 &this->engines[side], start, end, this->sel_engine[side], side == 0, this->sel_group);
417 virtual void OnPaint()
419 if (this->engines[0].NeedRebuild() || this->engines[1].NeedRebuild()) this->GenerateLists();
445 if (!this->IsShaded()) {
446 int needed_height = this->details_height;
448 for (
int side = 0; side < 2; side++) {
456 if (needed_height != this->details_height) {
457 this->details_height = needed_height;
464 virtual void OnClick(
Point pt,
int widget,
int click_count)
468 this->descending_sort_order ^=
true;
470 this->engines[1].ForceRebuild();
475 this->show_hidden_engines ^=
true;
477 this->engines[1].ForceRebuild();
478 this->SetWidgetLoweredState(widget, this->show_hidden_engines);
487 this->replace_engines = !(this->replace_engines);
488 this->engines[0].ForceRebuild();
489 this->reset_sel_engine =
true;
502 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
504 ReplaceClick_StartReplace(
false);
513 EngineID veh_from = this->sel_engine[0];
526 uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y,
this, widget);
527 size_t engine_count = this->engines[click_side].Length();
530 if (e == this->sel_engine[click_side])
break;
531 this->sel_engine[click_side] = e;
532 if (click_side == 0) {
533 this->engines[1].ForceRebuild();
534 this->reset_sel_engine =
true;
542 virtual void OnDropdownSelect(
int widget,
int index)
546 if (this->sort_criteria != index) {
547 this->sort_criteria = index;
549 this->engines[1].ForceRebuild();
556 if (temp == sel_railtype)
return;
559 this->vscroll[0]->SetPosition(0);
560 this->vscroll[1]->SetPosition(0);
562 this->engines[0].ForceRebuild();
563 this->engines[1].ForceRebuild();
564 this->reset_sel_engine =
true;
570 this->ReplaceClick_StartReplace(index != 0);
575 virtual void OnResize()
586 virtual void OnInvalidateData(
int data = 0,
bool gui_scope =
true)
590 this->engines[0].ForceRebuild();
592 this->engines[1].ForceRebuild();
597 static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
607 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),
610 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),
627 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),
629 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),
653 WDP_AUTO,
"replace_vehicle_train", 500, 140,
656 _nested_replace_rail_vehicle_widgets,
lengthof(_nested_replace_rail_vehicle_widgets)
659 static const NWidgetPart _nested_replace_vehicle_widgets[] = {
669 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),
672 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),
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),
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),
700 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_RV_INFO_TAB),
SetMinimalSize(167, 12),
SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB),
SetResize(1, 0),
EndContainer(),
707 WDP_AUTO,
"replace_vehicle", 456, 118,
710 _nested_replace_vehicle_widgets,
lengthof(_nested_replace_vehicle_widgets)