Show manage slots in veh/group window drop down even when no vehicles.

pull/16/head^2
Jonathan G Rennison 7 years ago
parent 7dbf99fa33
commit 870216d27c

@ -484,16 +484,16 @@ public:
this->vscroll->SetCount(this->vehicles.Length());
/* The drop down menu is out, *but* it may not be used, retract it. */
if (this->vehicles.Length() == 0 && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) {
if (!this->ShouldShowActionDropdownList() && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) {
this->RaiseWidget(WID_GL_MANAGE_VEHICLES_DROPDOWN);
HideDropDownMenu(this);
}
/* Disable all lists management button when the list is empty */
this->SetWidgetDisabledState(WID_GL_MANAGE_VEHICLES_DROPDOWN, !this->ShouldShowActionDropdownList() || _local_company != this->vli.company);
this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != this->vli.company,
WID_GL_STOP_ALL,
WID_GL_START_ALL,
WID_GL_MANAGE_VEHICLES_DROPDOWN,
WIDGET_LIST_END);
/* Disable the group specific function when we select the default group or all vehicles */
@ -703,7 +703,7 @@ public:
case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
DropDownList *list = this->BuildActionDropdownList(true, Group::IsValidID(this->vli.index));
ShowDropDownList(this, list, 0, WID_GL_MANAGE_VEHICLES_DROPDOWN);
ShowDropDownList(this, list, -1, WID_GL_MANAGE_VEHICLES_DROPDOWN);
break;
}
@ -826,7 +826,7 @@ public:
break;
case WID_GL_MANAGE_VEHICLES_DROPDOWN:
assert(this->vehicles.Length() != 0);
assert(this->ShouldShowActionDropdownList());
switch (index) {
case ADI_REPLACE: // Replace window

@ -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

@ -48,6 +48,7 @@ struct BaseVehicleListWindow : public Window {
void SortVehicleList();
void BuildVehicleList();
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group);
bool ShouldShowActionDropdownList() const;
DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group);
};

Loading…
Cancel
Save