Show manage slots in veh/group window drop down even when no vehicles.
This commit is contained in:
@@ -484,16 +484,16 @@ public:
|
|||||||
this->vscroll->SetCount(this->vehicles.Length());
|
this->vscroll->SetCount(this->vehicles.Length());
|
||||||
|
|
||||||
/* The drop down menu is out, *but* it may not be used, retract it. */
|
/* 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);
|
this->RaiseWidget(WID_GL_MANAGE_VEHICLES_DROPDOWN);
|
||||||
HideDropDownMenu(this);
|
HideDropDownMenu(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable all lists management button when the list is empty */
|
/* 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,
|
this->SetWidgetsDisabledState(this->vehicles.Length() == 0 || _local_company != this->vli.company,
|
||||||
WID_GL_STOP_ALL,
|
WID_GL_STOP_ALL,
|
||||||
WID_GL_START_ALL,
|
WID_GL_START_ALL,
|
||||||
WID_GL_MANAGE_VEHICLES_DROPDOWN,
|
|
||||||
WIDGET_LIST_END);
|
WIDGET_LIST_END);
|
||||||
|
|
||||||
/* Disable the group specific function when we select the default group or all vehicles */
|
/* 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: {
|
case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
|
||||||
DropDownList *list = this->BuildActionDropdownList(true, Group::IsValidID(this->vli.index));
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,7 +826,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_MANAGE_VEHICLES_DROPDOWN:
|
case WID_GL_MANAGE_VEHICLES_DROPDOWN:
|
||||||
assert(this->vehicles.Length() != 0);
|
assert(this->ShouldShowActionDropdownList());
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case ADI_REPLACE: // Replace window
|
case ADI_REPLACE: // Replace window
|
||||||
|
@@ -161,6 +161,15 @@ Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bo
|
|||||||
return d;
|
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.
|
* Display the Action dropdown window.
|
||||||
* @param show_autoreplace If true include the autoreplace item.
|
* @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 *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group)
|
||||||
{
|
{
|
||||||
DropDownList *list = new DropDownList();
|
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);
|
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, false);
|
*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, false);
|
*list->Append() = new DropDownListStringItem(this->vehicle_depot_name[this->vli.vtype], ADI_DEPOT, disable);
|
||||||
|
|
||||||
if (show_group) {
|
if (show_group) {
|
||||||
*list->Append() = new DropDownListStringItem(STR_GROUP_ADD_SHARED_VEHICLE, ADI_ADD_SHARED, 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, false);
|
*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) {
|
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);
|
*list->Append() = new DropDownListStringItem(STR_TRACE_RESTRICT_SLOT_MANAGE, ADI_TRACERESTRICT_SLOT_MGMT, false);
|
||||||
@@ -1590,7 +1600,7 @@ public:
|
|||||||
this->BuildVehicleList();
|
this->BuildVehicleList();
|
||||||
this->SortVehicleList();
|
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);
|
HideDropDownMenu(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1604,8 +1614,8 @@ public:
|
|||||||
}
|
}
|
||||||
if (this->owner == _local_company) {
|
if (this->owner == _local_company) {
|
||||||
this->SetWidgetDisabledState(WID_VL_AVAILABLE_VEHICLES, this->vli.type != VL_STANDARD);
|
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,
|
this->SetWidgetsDisabledState(this->vehicles.Length() == 0,
|
||||||
WID_VL_MANAGE_VEHICLES_DROPDOWN,
|
|
||||||
WID_VL_STOP_ALL,
|
WID_VL_STOP_ALL,
|
||||||
WID_VL_START_ALL,
|
WID_VL_START_ALL,
|
||||||
WIDGET_LIST_END);
|
WIDGET_LIST_END);
|
||||||
@@ -1645,7 +1655,7 @@ public:
|
|||||||
|
|
||||||
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
|
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
|
||||||
DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier::UnPack(this->window_number).type == VL_STANDARD, false);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1663,7 +1673,7 @@ public:
|
|||||||
this->vehicles.SetSortType(index);
|
this->vehicles.SetSortType(index);
|
||||||
break;
|
break;
|
||||||
case WID_VL_MANAGE_VEHICLES_DROPDOWN:
|
case WID_VL_MANAGE_VEHICLES_DROPDOWN:
|
||||||
assert(this->vehicles.Length() != 0);
|
assert(this->ShouldShowActionDropdownList());
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case ADI_REPLACE: // Replace window
|
case ADI_REPLACE: // Replace window
|
||||||
|
@@ -48,6 +48,7 @@ struct BaseVehicleListWindow : public Window {
|
|||||||
void SortVehicleList();
|
void SortVehicleList();
|
||||||
void BuildVehicleList();
|
void BuildVehicleList();
|
||||||
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group);
|
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group);
|
||||||
|
bool ShouldShowActionDropdownList() const;
|
||||||
DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group);
|
DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user