| 944 | } |
| 945 | |
| 946 | void OnDragDrop_Vehicle(Point pt, WidgetID widget) |
| 947 | { |
| 948 | switch (widget) { |
| 949 | case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles |
| 950 | 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{}); |
| 951 | |
| 952 | this->vehicle_sel = VehicleID::Invalid(); |
| 953 | this->group_over = GroupID::Invalid(); |
| 954 | |
| 955 | this->SetDirty(); |
| 956 | break; |
| 957 | |
| 958 | case WID_GL_LIST_GROUP: { // Matrix group |
| 959 | const VehicleID vindex = this->vehicle_sel; |
| 960 | this->vehicle_sel = VehicleID::Invalid(); |
| 961 | this->group_over = GroupID::Invalid(); |
| 962 | this->SetDirty(); |
| 963 | |
| 964 | auto it = this->group_sb->GetScrolledItemFromWidget(this->groups, pt.y, this, WID_GL_LIST_GROUP); |
| 965 | GroupID new_g = it == this->groups.end() ? NEW_GROUP : it->group->index; |
| 966 | |
| 967 | 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{}); |
| 968 | break; |
| 969 | } |
| 970 | |
| 971 | case WID_GL_LIST_VEHICLE: { // Matrix vehicle |
| 972 | const VehicleID vindex = this->vehicle_sel; |
| 973 | this->vehicle_sel = VehicleID::Invalid(); |
| 974 | this->group_over = GroupID::Invalid(); |
| 975 | this->SetDirty(); |
| 976 | |
| 977 | auto it = this->vscroll->GetScrolledItemFromWidget(this->vehgroups, pt.y, this, WID_GL_LIST_VEHICLE); |
| 978 | if (it == this->vehgroups.end()) return; // click out of list bound |
| 979 | |
| 980 | const GUIVehicleGroup &vehgroup = *it; |
| 981 | switch (this->grouping) { |
| 982 | case GB_NONE: { |
| 983 | const Vehicle *v = vehgroup.GetSingleVehicle(); |
| 984 | if (!VehicleClicked(v) && vindex == v->index) { |
| 985 | ShowVehicleViewWindow(v); |
| 986 | } |
| 987 | break; |
| 988 | } |
| 989 | |
| 990 | case GB_SHARED_ORDERS: { |
| 991 | if (!VehicleClicked(vehgroup)) { |
| 992 | const Vehicle *v = vehgroup.vehicles_begin[0]; |
| 993 | if (vindex == v->index) { |
| 994 | if (vehgroup.NumVehicles() == 1) { |
| 995 | ShowVehicleViewWindow(v); |
| 996 | } else { |
| 997 | ShowVehicleListWindow(v); |
| 998 | } |
| 999 | } |
| 1000 | } |
| 1001 | break; |
| 1002 | } |
| 1003 |
nothing calls this directly
no test coverage detected