Feature: Create group of vehicles from manage vehicle list button. (#10890)
This commit is contained in:
@@ -428,7 +428,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
|
||||
Dimension d = this->GetActionDropdownSize(true, true);
|
||||
Dimension d = this->GetActionDropdownSize(true, true, true);
|
||||
d.height += padding.height;
|
||||
d.width += padding.width;
|
||||
*size = maxdim(*size, d);
|
||||
@@ -809,7 +809,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
|
||||
ShowDropDownList(this, this->BuildActionDropdownList(true, Group::IsValidID(this->vli.index)), 0, WID_GL_MANAGE_VEHICLES_DROPDOWN);
|
||||
ShowDropDownList(this, this->BuildActionDropdownList(true, Group::IsValidID(this->vli.index), IsDefaultGroupID(this->vli.index)), 0, WID_GL_MANAGE_VEHICLES_DROPDOWN);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -865,7 +865,7 @@ public:
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
|
||||
Command<CMD_ADD_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS);
|
||||
Command<CMD_ADD_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{});
|
||||
|
||||
this->vehicle_sel = INVALID_VEHICLE;
|
||||
this->group_over = INVALID_GROUP;
|
||||
@@ -882,7 +882,7 @@ public:
|
||||
auto it = this->group_sb->GetScrolledItemFromWidget(this->groups, pt.y, this, WID_GL_LIST_GROUP);
|
||||
GroupID new_g = it == this->groups.end() ? NEW_GROUP : (*it)->index;
|
||||
|
||||
Command<CMD_ADD_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, new_g, vindex, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS);
|
||||
Command<CMD_ADD_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, new_g, vindex, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{});
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -975,6 +975,10 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
case ADI_CREATE_GROUP: // Create group
|
||||
Command<CMD_ADD_VEHICLE_GROUP>::Post(CcAddVehicleNewGroup, NEW_GROUP, INVALID_VEHICLE, false, this->vli);
|
||||
break;
|
||||
|
||||
case ADI_ADD_SHARED: // Add shared Vehicles
|
||||
assert(Group::IsValidID(this->vli.index));
|
||||
|
||||
@@ -1190,12 +1194,12 @@ void CcCreateGroup(Commands cmd, const CommandCost &result, GroupID new_group, V
|
||||
* @param new_group ID of the created group.
|
||||
* @param veh_id vehicle to add to a group
|
||||
*/
|
||||
void CcAddVehicleNewGroup(Commands cmd, const CommandCost &result, GroupID new_group, GroupID, VehicleID veh_id, bool)
|
||||
void CcAddVehicleNewGroup(Commands cmd, const CommandCost &result, GroupID new_group, GroupID, VehicleID veh_id, bool, const VehicleListIdentifier &)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
assert(Vehicle::IsValidID(veh_id));
|
||||
CcCreateGroup(new_group, Vehicle::Get(veh_id)->type);
|
||||
const Group *g = Group::Get(new_group);
|
||||
CcCreateGroup(new_group, g->vehicle_type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user