diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/group_gui.cpp | 4 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 35 | ||||
-rw-r--r-- | src/vehicle_gui_base.h | 4 |
3 files changed, 15 insertions, 28 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 29728cadb..c3ddc5812 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -236,7 +236,7 @@ public: break; case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN: { - Dimension d = this->GetActionDropdownSize(true); + Dimension d = this->GetActionDropdownSize(true, true); d.height += padding.height; d.width += padding.width; *size = maxdim(*size, d); @@ -473,7 +473,7 @@ public: break; case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN: { - DropDownList *list = this->BuildActionDropdownList(Group::IsValidID(this->group_sel)); + DropDownList *list = this->BuildActionDropdownList(true, Group::IsValidID(this->group_sel)); ShowDropDownList(this, list, 0, GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN); break; } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 1b3b21a56..a01d75dba 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -134,14 +134,15 @@ void BaseVehicleListWindow::BuildVehicleList(Owner owner, uint16 index, uint16 w /** * Compute the size for the Action dropdown. + * @param show_autoreplace If true include the autoreplace item. * @param show_group If true include group-related stuff. * @return Required size. */ -Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_group) +Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bool show_group) { Dimension d = {0, 0}; - d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_REPLACE_VEHICLES)); + if (show_autoreplace) d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_REPLACE_VEHICLES)); d = maxdim(d, GetStringBoundingBox(STR_VEHICLE_LIST_SEND_FOR_SERVICING)); d = maxdim(d, GetStringBoundingBox(this->vehicle_depot_name[this->vehicle_type])); @@ -155,14 +156,15 @@ Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_group) /** * Display the Action dropdown window. + * @param show_autoreplace If true include the autoreplace item. * @param show_group If true include group-related stuff. * @return Itemlist for dropdown */ -DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_group) +DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group) { DropDownList *list = new DropDownList(); - list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, false)); + if (show_autoreplace) list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE, false)); list->push_back(new DropDownListStringItem(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, false)); list->push_back(new DropDownListStringItem(this->vehicle_depot_name[this->vehicle_type], ADI_DEPOT, false)); @@ -1223,23 +1225,8 @@ public: break; case VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN: { - static StringID action_str[] = { - STR_VEHICLE_LIST_REPLACE_VEHICLES, - STR_VEHICLE_LIST_SEND_FOR_SERVICING, - STR_NULL, - INVALID_STRING_ID - }; - - static const StringID depot_name[] = { - STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT, - STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT, - STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT, - STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR - }; - - /* XXX - Substite string since the dropdown cannot handle dynamic strings */ - action_str[2] = depot_name[this->vehicle_type]; - ShowDropDownMenu(this, action_str, 0, VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN, 0, (this->window_number & VLW_MASK) == VLW_STANDARD ? 0 : 1); + DropDownList *list = this->BuildActionDropdownList((this->window_number & VLW_MASK) == VLW_STANDARD, false); + ShowDropDownList(this, list, 0, VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN); break; } @@ -1261,14 +1248,14 @@ public: assert(this->vehicles.Length() != 0); switch (index) { - case 0: // Replace window + case ADI_REPLACE: // Replace window ShowReplaceGroupVehicleWindow(DEFAULT_GROUP, this->vehicle_type); break; - case 1: // Send for servicing + case ADI_SERVICE: // Send for servicing DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */, (this->window_number & VLW_MASK) | DEPOT_MASS_SEND | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type)); break; - case 2: // Send to Depots + case ADI_DEPOT: // Send to Depots DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */, (this->window_number & VLW_MASK) | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type)); break; diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h index 2feda34bc..002dc8b4c 100644 --- a/src/vehicle_gui_base.h +++ b/src/vehicle_gui_base.h @@ -44,8 +44,8 @@ struct BaseVehicleListWindow : public Window { 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); + Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group); + DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group); }; uint GetVehicleListHeight(VehicleType type, uint divisor = 1); |