Only show template replacement menu item where sensible.
Fix drop-down not being sized for template replacement item to fit.
This commit is contained in:
@@ -398,7 +398,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
|
case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
|
||||||
Dimension d = this->GetActionDropdownSize(true, true);
|
Dimension d = this->GetActionDropdownSize(true, true, this->vli.vtype == VEH_TRAIN);
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
d.width += padding.width;
|
d.width += padding.width;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
@@ -657,7 +657,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
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), this->vli.vtype == VEH_TRAIN);
|
||||||
ShowDropDownList(this, list, 0, WID_GL_MANAGE_VEHICLES_DROPDOWN);
|
ShowDropDownList(this, list, 0, WID_GL_MANAGE_VEHICLES_DROPDOWN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -143,11 +143,14 @@ void BaseVehicleListWindow::BuildVehicleList()
|
|||||||
* @param show_group If true include group-related stuff.
|
* @param show_group If true include group-related stuff.
|
||||||
* @return Required size.
|
* @return Required size.
|
||||||
*/
|
*/
|
||||||
Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bool show_group)
|
Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bool show_group, bool show_template_replace)
|
||||||
{
|
{
|
||||||
Dimension d = {0, 0};
|
Dimension d = {0, 0};
|
||||||
|
|
||||||
if (show_autoreplace) d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_REPLACE_VEHICLES));
|
if (show_autoreplace) d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_REPLACE_VEHICLES));
|
||||||
|
if (show_autoreplace && show_template_replace) {
|
||||||
|
d = maxdim(d, GetStringBoundingBox(STR_TMPL_TEMPLATE_REPLACEMENT));
|
||||||
|
}
|
||||||
d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_SEND_FOR_SERVICING));
|
d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_SEND_FOR_SERVICING));
|
||||||
d = maxdim(d, GetStringBoundingBox(this->vehicle_depot_name[this->vli.vtype]));
|
d = maxdim(d, GetStringBoundingBox(this->vehicle_depot_name[this->vli.vtype]));
|
||||||
|
|
||||||
@@ -165,12 +168,14 @@ Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bo
|
|||||||
* @param show_group If true include group-related stuff.
|
* @param show_group If true include group-related stuff.
|
||||||
* @return Itemlist for dropdown
|
* @return Itemlist for dropdown
|
||||||
*/
|
*/
|
||||||
DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group)
|
DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_template_replace)
|
||||||
{
|
{
|
||||||
DropDownList *list = new DropDownList();
|
DropDownList *list = new DropDownList();
|
||||||
|
|
||||||
*list->Append() = new DropDownListStringItem(STR_TMPL_TEMPLATE_REPLACEMENT, ADI_TEMPLATE_REPLACE, false);
|
|
||||||
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, false);
|
||||||
|
if (show_autoreplace && show_template_replace) {
|
||||||
|
*list->Append() = new DropDownListStringItem(STR_TMPL_TEMPLATE_REPLACEMENT, ADI_TEMPLATE_REPLACE, false);
|
||||||
|
}
|
||||||
*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, false);
|
||||||
*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, false);
|
||||||
|
|
||||||
@@ -1520,7 +1525,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
|
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
|
||||||
Dimension d = this->GetActionDropdownSize(this->vli.type == VL_STANDARD, false);
|
Dimension d = this->GetActionDropdownSize(this->vli.type == VL_STANDARD, false, this->vli.vtype == VEH_TRAIN);
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
d.width += padding.width;
|
d.width += padding.width;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
@@ -1645,7 +1650,8 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
|
case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
|
||||||
DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier(this->window_number).type == VL_STANDARD, false);
|
DropDownList *list = this->BuildActionDropdownList(VehicleListIdentifier(this->window_number).type == VL_STANDARD,
|
||||||
|
false, this->vli.vtype == VEH_TRAIN);
|
||||||
ShowDropDownList(this, list, 0, WID_VL_MANAGE_VEHICLES_DROPDOWN);
|
ShowDropDownList(this, list, 0, WID_VL_MANAGE_VEHICLES_DROPDOWN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1671,7 +1677,9 @@ public:
|
|||||||
ShowReplaceGroupVehicleWindow(ALL_GROUP, this->vli.vtype);
|
ShowReplaceGroupVehicleWindow(ALL_GROUP, this->vli.vtype);
|
||||||
break;
|
break;
|
||||||
case ADI_TEMPLATE_REPLACE:
|
case ADI_TEMPLATE_REPLACE:
|
||||||
ShowTemplateReplaceWindow(this->unitnumber_digits, this->resize.step_height);
|
if (vli.vtype == VEH_TRAIN) {
|
||||||
|
ShowTemplateReplaceWindow(this->unitnumber_digits, this->resize.step_height);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ADI_SERVICE: // Send for servicing
|
case ADI_SERVICE: // Send for servicing
|
||||||
case ADI_DEPOT: // Send to Depots
|
case ADI_DEPOT: // Send to Depots
|
||||||
|
@@ -47,8 +47,8 @@ struct BaseVehicleListWindow : public Window {
|
|||||||
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
|
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
|
||||||
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 show_template_replace);
|
||||||
DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group);
|
DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_template_replace);
|
||||||
};
|
};
|
||||||
|
|
||||||
uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
|
uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
|
||||||
|
Reference in New Issue
Block a user