mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
(svn r20170) -Codechange: Add BaseVehicleListWindow::GetActionDropdownSize().
This commit is contained in:
parent
c79d4f46a3
commit
ce480fb4b5
@ -236,11 +236,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN: {
|
case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN: {
|
||||||
static const StringID _dropdown_text[] = {STR_VEHICLE_LIST_REPLACE_VEHICLES, STR_VEHICLE_LIST_SEND_FOR_SERVICING, STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT, STR_GROUP_ADD_SHARED_VEHICLE, STR_GROUP_REMOVE_ALL_VEHICLES};
|
Dimension d = this->GetActionDropdownSize(true);
|
||||||
Dimension d = {0, 0};
|
|
||||||
for (const StringID *sid = _dropdown_text; sid != endof(_dropdown_text); sid++) {
|
|
||||||
d = maxdim(d, GetStringBoundingBox(*sid));
|
|
||||||
}
|
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
d.width += padding.width;
|
d.width += padding.width;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
|
@ -125,6 +125,27 @@ void BaseVehicleListWindow::BuildVehicleList(Owner owner, uint16 index, uint16 w
|
|||||||
this->vscroll.SetCount(this->vehicles.Length());
|
this->vscroll.SetCount(this->vehicles.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute the size for the Action dropdown.
|
||||||
|
* @param show_group If true include group-related stuff.
|
||||||
|
* @return Required size.
|
||||||
|
*/
|
||||||
|
Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_group)
|
||||||
|
{
|
||||||
|
Dimension d = {0, 0};
|
||||||
|
|
||||||
|
d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_REPLACE_VEHICLES));
|
||||||
|
d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_SEND_FOR_SERVICING));
|
||||||
|
d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT));
|
||||||
|
|
||||||
|
if (show_group) {
|
||||||
|
d = maxdim(d, GetStringBoundingBox(STR_GROUP_ADD_SHARED_VEHICLE));
|
||||||
|
d = maxdim(d, GetStringBoundingBox(STR_GROUP_REMOVE_ALL_VEHICLES));
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the Action dropdown window.
|
* Display the Action dropdown window.
|
||||||
* @param show_group If true include group-related stuff.
|
* @param show_group If true include group-related stuff.
|
||||||
|
@ -43,6 +43,7 @@ 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(Owner owner, uint16 index, uint16 window_type);
|
void BuildVehicleList(Owner owner, uint16 index, uint16 window_type);
|
||||||
|
Dimension GetActionDropdownSize(bool show_group);
|
||||||
DropDownList *BuildActionDropdownList(bool show_group);
|
DropDownList *BuildActionDropdownList(bool show_group);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user