Mercurial > hg > openttd
changeset 15516:4f00a142e392 draft
(svn r20170) -Codechange: Add BaseVehicleListWindow::GetActionDropdownSize().
author | frosch <frosch@openttd.org> |
---|---|
date | Sat, 17 Jul 2010 14:47:54 +0000 |
parents | 7ab513db840e |
children | d2a9ffd3a05a |
files | src/group_gui.cpp src/vehicle_gui.cpp src/vehicle_gui_base.h |
diffstat | 3 files changed, 23 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -236,11 +236,7 @@ break; 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 = {0, 0}; - for (const StringID *sid = _dropdown_text; sid != endof(_dropdown_text); sid++) { - d = maxdim(d, GetStringBoundingBox(*sid)); - } + Dimension d = this->GetActionDropdownSize(true); d.height += padding.height; d.width += padding.width; *size = maxdim(*size, d);
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -126,6 +126,27 @@ } /** + * 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. * @param show_group If true include group-related stuff. * @return Itemlist for dropdown
--- a/src/vehicle_gui_base.h +++ b/src/vehicle_gui_base.h @@ -43,6 +43,7 @@ void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const; void SortVehicleList(); void BuildVehicleList(Owner owner, uint16 index, uint16 window_type); + Dimension GetActionDropdownSize(bool show_group); DropDownList *BuildActionDropdownList(bool show_group); };