mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
(svn r20172) -Codechange: Use BaseVehicleListWindow::BuildActionDropdownList() also for the normal vehicle list.
This commit is contained in:
parent
240e8df052
commit
f06560ad45
@ -236,7 +236,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN: {
|
case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN: {
|
||||||
Dimension d = this->GetActionDropdownSize(true);
|
Dimension d = this->GetActionDropdownSize(true, true);
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
d.width += padding.width;
|
d.width += padding.width;
|
||||||
*size = maxdim(*size, d);
|
*size = maxdim(*size, d);
|
||||||
@ -473,7 +473,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN: {
|
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);
|
ShowDropDownList(this, list, 0, GRP_WIDGET_MANAGE_VEHICLES_DROPDOWN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -134,14 +134,15 @@ void BaseVehicleListWindow::BuildVehicleList(Owner owner, uint16 index, uint16 w
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the size for the Action dropdown.
|
* 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.
|
* @param show_group If true include group-related stuff.
|
||||||
* @return Required size.
|
* @return Required size.
|
||||||
*/
|
*/
|
||||||
Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_group)
|
Dimension BaseVehicleListWindow::GetActionDropdownSize(bool show_autoreplace, bool show_group)
|
||||||
{
|
{
|
||||||
Dimension d = {0, 0};
|
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(STR_VEHICLE_LIST_SEND_FOR_SERVICING));
|
||||||
d = maxdim(d, GetStringBoundingBox(this->vehicle_depot_name[this->vehicle_type]));
|
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.
|
* Display the Action dropdown window.
|
||||||
|
* @param show_autoreplace If true include the autoreplace item.
|
||||||
* @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_group)
|
DropDownList *BaseVehicleListWindow::BuildActionDropdownList(bool show_autoreplace, bool show_group)
|
||||||
{
|
{
|
||||||
DropDownList *list = new DropDownList();
|
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(STR_VEHICLE_LIST_SEND_FOR_SERVICING, ADI_SERVICE, false));
|
||||||
list->push_back(new DropDownListStringItem(this->vehicle_depot_name[this->vehicle_type], ADI_DEPOT, false));
|
list->push_back(new DropDownListStringItem(this->vehicle_depot_name[this->vehicle_type], ADI_DEPOT, false));
|
||||||
|
|
||||||
@ -1223,23 +1225,8 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN: {
|
case VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN: {
|
||||||
static StringID action_str[] = {
|
DropDownList *list = this->BuildActionDropdownList((this->window_number & VLW_MASK) == VLW_STANDARD, false);
|
||||||
STR_VEHICLE_LIST_REPLACE_VEHICLES,
|
ShowDropDownList(this, list, 0, VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN);
|
||||||
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);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1261,14 +1248,14 @@ public:
|
|||||||
assert(this->vehicles.Length() != 0);
|
assert(this->vehicles.Length() != 0);
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: // Replace window
|
case ADI_REPLACE: // Replace window
|
||||||
ShowReplaceGroupVehicleWindow(DEFAULT_GROUP, this->vehicle_type);
|
ShowReplaceGroupVehicleWindow(DEFAULT_GROUP, this->vehicle_type);
|
||||||
break;
|
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) */,
|
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));
|
(this->window_number & VLW_MASK) | DEPOT_MASS_SEND | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type));
|
||||||
break;
|
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) */,
|
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));
|
(this->window_number & VLW_MASK) | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type));
|
||||||
break;
|
break;
|
||||||
|
@ -44,8 +44,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(Owner owner, uint16 index, uint16 window_type);
|
void BuildVehicleList(Owner owner, uint16 index, uint16 window_type);
|
||||||
Dimension GetActionDropdownSize(bool show_group);
|
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group);
|
||||||
DropDownList *BuildActionDropdownList(bool show_group);
|
DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group);
|
||||||
};
|
};
|
||||||
|
|
||||||
uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
|
uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user