|
|
|
@ -161,6 +161,15 @@ Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bo
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether the Action dropdown window should be shown/available.
|
|
|
|
|
* @return Whether available
|
|
|
|
|
*/
|
|
|
|
|
bool BaseVehicleListWindow::ShouldShowActionDropdownList() const
|
|
|
|
|
{
|
|
|
|
|
return this->vehicles.Length() != 0 || (this->vli.vtype == VEH_TRAIN && _settings_client.gui.show_adv_tracerestrict_features);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Display the Action dropdown window.
|
|
|
|
|
* @param show_autoreplace If true include the autoreplace item.
|
|
|
|
@ -170,14 +179,15 @@ Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bo
|
|
|
|
|
DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group)
|
|
|
|
|
{
|
|
|
|
|
DropDownList *list = new DropDownList();
|
|
|
|
|
bool disable = this->vehicles.Length() == 0;
|
|
|
|
|
|
|
|
|
|
if (show_autoreplace) *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, false);
|
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, false);
|
|
|
|
|
*list->Append() = new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, false);
|
|
|
|
|
if (show_autoreplace) *list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, disable);
|
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, disable);
|
|
|
|
|
*list->Append() = new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, disable);
|
|
|
|
|
|
|
|
|
|
if (show_group) {
|
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, false);
|
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, ADI_REMOVE_ALL, false);
|
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, disable);
|
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_GROUP_REMOVE_ALL_VEHICLES, ADI_REMOVE_ALL, disable);
|
|
|
|
|
}
|
|
|
|
|
if (this->vli.vtype == VEH_TRAIN && _settings_client.gui.show_adv_tracerestrict_features) {
|
|
|
|
|
*list->Append() = new DropDownListStringItem(STR_TRACE_RESTRICT_SLOT_MANAGE, ADI_TRACERESTRICT_SLOT_MGMT, false);
|
|
|
|
@ -1590,7 +1600,7 @@ public:
|
|
|
|
|
this->BuildVehicleList();
|
|
|
|
|
this->SortVehicleList();
|
|
|
|
|
|
|
|
|
|
if (this->vehicles.Length() == 0 && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) {
|
|
|
|
|
if (!this->ShouldShowActionDropdownList() && this->IsWidgetLowered(WID_VL_MANAGE_VEHICLES_DROPDOWN)) {
|
|
|
|
|
HideDropDownMenu(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1604,8 +1614,8 @@ public:
|
|
|
|
|
}
|
|
|
|
|
if (this->owner == _local_company) {
|
|
|
|
|
this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD);
|
|
|
|
|
this->SetWidgetDisabledState(WID_VL_MANAGE_VEHICLES_DROPDOWN, !this->ShouldShowActionDropdownList());
|
|
|
|
|
this->SetWidgetsDisabledState(this->vehicles.Length() == 0,
|
|
|
|
|
WID_VL_MANAGE_VEHICLES_DROPDOWN,
|
|
|
|
|
WID_VL_STOP_ALL,
|
|
|
|
|
WID_VL_START_ALL,
|
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
@ -1645,7 +1655,7 @@ public:
|
|
|
|
|
|
|
|
|
|
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
|
|
|
|
|
DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier::UnPack(this->window_number).type == VL_STANDARD, false);
|
|
|
|
|
ShowDropDownList(this, list, 0, WID_VL_MANAGE_VEHICLES_DROPDOWN);
|
|
|
|
|
ShowDropDownList(this, list, -1, WID_VL_MANAGE_VEHICLES_DROPDOWN);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1663,7 +1673,7 @@ public:
|
|
|
|
|
this->vehicles.SetSortType(index);
|
|
|
|
|
break;
|
|
|
|
|
case WID_VL_MANAGE_VEHICLES_DROPDOWN:
|
|
|
|
|
assert(this->vehicles.Length() != 0);
|
|
|
|
|
assert(this->ShouldShowActionDropdownList());
|
|
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
|
case ADI_REPLACE: // Replace window
|
|
|
|
|