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;
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()) {
229 widget->
widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype;
230 widget->
tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype;
246 d.height += padding.height;
254 size->height = (this->window_number <=
VEH_ROAD ? 8 : 4) * resize->height;
259 size->height = this->details_height;
268 d.width += padding.width;
269 d.height += padding.height;
277 d.width += padding.width;
278 d.height += padding.height;
297 if (rti->
label == 0)
continue;
300 d.width += padding.width;
301 d.height += padding.height;
311 d.width += padding.width;
312 d.height += padding.height;
319 virtual void SetStringParameters(
int widget)
const
323 SetDParam(0, STR_REPLACE_VEHICLE_TRAIN + this->window_number);
324 switch (this->sel_group) {
326 SetDParam(1, STR_GROUP_ALL_TRAINS + this->window_number);
330 SetDParam(1, STR_GROUP_DEFAULT_TRAINS + this->window_number);
351 SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
356 virtual void DrawWidget(
const Rect &r,
int widget)
const
368 str = STR_REPLACE_NOT_REPLACING;
370 bool when_old =
false;
372 str = when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME;
376 str = STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED;
386 EngineID start = this->vscroll[side]->GetPosition();
387 EngineID end =
min(this->vscroll[side]->GetCapacity() + start, this->engines[side].Length());
391 &this->engines[side], start, end, this->sel_engine[side], side == 0, this->sel_group);
397 virtual void OnPaint()
399 if (this->engines[0].NeedRebuild() || this->engines[1].NeedRebuild()) this->GenerateLists();
421 if (!this->IsShaded()) {
422 int needed_height = this->details_height;
424 for (
int side = 0; side < 2; side++) {
432 if (needed_height != this->details_height) {
433 this->details_height = needed_height;
440 virtual void OnClick(
Point pt,
int widget,
int click_count)
444 this->descending_sort_order ^=
true;
446 this->engines[1].ForceRebuild();
451 this->show_hidden_engines ^=
true;
453 this->engines[1].ForceRebuild();
454 this->SetWidgetLoweredState(widget, this->show_hidden_engines);
479 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
481 ReplaceClick_StartReplace(
false);
490 EngineID veh_from = this->sel_engine[0];
503 uint i = this->vscroll[click_side]->GetScrolledRowFromWidget(pt.y,
this, widget);
504 size_t engine_count = this->engines[click_side].Length();
507 if (e == this->sel_engine[click_side])
break;
508 this->sel_engine[click_side] = e;
509 if (click_side == 0) {
510 this->engines[1].ForceRebuild();
511 this->reset_sel_engine =
true;
519 virtual void OnDropdownSelect(
int widget,
int index)
523 if (this->sort_criteria != index) {
524 this->sort_criteria = index;
526 this->engines[1].ForceRebuild();
533 if (temp == sel_railtype)
return;
536 this->vscroll[0]->SetPosition(0);
537 this->vscroll[1]->SetPosition(0);
539 this->engines[0].ForceRebuild();
540 this->engines[1].ForceRebuild();
541 this->reset_sel_engine =
true;
547 this->replace_engines = index != 0;
548 this->engines[0].ForceRebuild();
549 this->reset_sel_engine =
true;
555 this->ReplaceClick_StartReplace(index != 0);
560 virtual void OnResize()
571 virtual void OnInvalidateData(
int data = 0,
bool gui_scope =
true)
575 this->engines[0].ForceRebuild();
577 this->engines[1].ForceRebuild();
582 static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
592 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),
595 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),
601 NWidget(
WWT_DROPDOWN, COLOUR_GREY,
WID_RV_TRAIN_RAILTYPE_DROPDOWN),
SetMinimalSize(136, 12),
SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE),
SetFill(1, 0),
SetResize(1, 0),
618 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),
620 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),
627 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),
640 WDP_AUTO,
"replace_vehicle_train", 500, 140,
643 _nested_replace_rail_vehicle_widgets,
lengthof(_nested_replace_rail_vehicle_widgets)
646 static const NWidgetPart _nested_replace_vehicle_widgets[] = {
656 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),
659 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),
676 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),
678 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),
687 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_RV_INFO_TAB),
SetMinimalSize(167, 12),
SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB),
SetResize(1, 0),
EndContainer(),
694 WDP_AUTO,
"replace_vehicle", 456, 118,
697 _nested_replace_vehicle_widgets,
lengthof(_nested_replace_vehicle_widgets)