Add UI setting to control whether cargo filter drop down is shown

This commit is contained in:
Jonathan G Rennison
2017-10-17 00:16:10 +01:00
parent f3c95dd9a7
commit 097cf9b0b1
10 changed files with 58 additions and 5 deletions

View File

@@ -237,6 +237,16 @@ void BaseVehicleListWindow::OnInit()
this->SetCargoFilterArray();
}
void BaseVehicleListWindow::CheckCargoFilterEnableState(int plane_widget, bool re_init, bool possible)
{
NWidgetStacked *sel = this->GetWidget<NWidgetStacked>(plane_widget);
const int plane = (possible && _settings_client.gui.show_veh_list_cargo_filter) ? 0 : SZSP_NONE;
if (plane != sel->shown_plane) {
sel->SetDisplayedPlane(plane);
if (re_init) this->ReInit();
}
}
/**
* Compute the size for the Action dropdown.
* @param show_autoreplace If true include the autoreplace item.
@@ -1695,7 +1705,7 @@ public:
this->CreateNestedTree();
this->GetWidget<NWidgetStacked>(WID_VL_FILTER_BY_CARGO_SEL)->SetDisplayedPlane((this->vli.type == VL_SHARED_ORDERS || this->vli.type == VL_SINGLE_VEH) ? SZSP_NONE : 0);
this->CheckCargoFilterEnableState(WID_VL_FILTER_BY_CARGO_SEL, false, this->vli.type != VL_SHARED_ORDERS && this->vli.type != VL_SINGLE_VEH);
this->vscroll = this->GetScrollbar(WID_VL_SCROLLBAR);
@@ -2032,10 +2042,13 @@ public:
this->vehicles.ForceRebuild();
if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.Length() == 1) {
delete this;
return;
}
} else {
this->vehicles.ForceResort();
}
this->CheckCargoFilterEnableState(WID_VL_FILTER_BY_CARGO_SEL, true, this->vli.type != VL_SHARED_ORDERS && this->vli.type != VL_SINGLE_VEH);
}
};