| 2091 | } |
| 2092 | |
| 2093 | void scrollDragEnd(const Ui::Point& pos) |
| 2094 | { |
| 2095 | if (DragVehiclePart::getDragCarComponent() == nullptr) |
| 2096 | { |
| 2097 | return; |
| 2098 | } |
| 2099 | |
| 2100 | auto vehicleWindow = getVehicleDetailsWindow(pos); |
| 2101 | if (vehicleWindow == nullptr) |
| 2102 | { |
| 2103 | return; |
| 2104 | } |
| 2105 | |
| 2106 | auto targetWidget = vehicleWindow->findWidgetAt(pos.x, pos.y); |
| 2107 | switch (targetWidget) |
| 2108 | { |
| 2109 | case widx::remove: |
| 2110 | { |
| 2111 | GameCommands::VehicleSellArgs gcArgs{}; |
| 2112 | gcArgs.car = DragVehiclePart::getDragCarComponent()->id; |
| 2113 | |
| 2114 | if (Common::confirmComponentChange(gcArgs.car, StringIds::confirm_vehicle_component_sell_cargo_warning_title, StringIds::confirm_vehicle_component_sell_cargo_warning_message, StringIds::confirm_vehicle_component_sell_cargo_warning_confirm)) |
| 2115 | { |
| 2116 | GameCommands::setErrorTitle(StringIds::cant_sell_vehicle); |
| 2117 | GameCommands::doCommand(gcArgs, GameCommands::Flags::apply); |
| 2118 | } |
| 2119 | |
| 2120 | break; |
| 2121 | } |
| 2122 | case widx::carList: |
| 2123 | { |
| 2124 | auto car = getCarFromScrollViewPos(*vehicleWindow, pos); |
| 2125 | if (car != nullptr) |
| 2126 | { |
| 2127 | GameCommands::VehicleRearrangeArgs args{}; |
| 2128 | args.source = DragVehiclePart::getDragCarComponent()->id; |
| 2129 | args.dest = car->id; |
| 2130 | |
| 2131 | auto* srcVehicle = EntityManager::get<Vehicles::VehicleBase>(args.source); |
| 2132 | auto* destVehicle = EntityManager::get<Vehicles::VehicleBase>(args.dest); |
| 2133 | |
| 2134 | bool sameHead = srcVehicle == nullptr || destVehicle == nullptr || srcVehicle->head == destVehicle->head; |
| 2135 | |
| 2136 | const StringId warningMessage = sameHead ? StringIds::confirm_vehicle_component_move_cargo_warning_message : StringIds::confirm_vehicle_component_move_cargo_multiple_vehicles_warning_message; |
| 2137 | |
| 2138 | if (Common::confirmComponentChange(args.source, args.dest, StringIds::confirm_vehicle_component_move_cargo_warning_title, warningMessage, StringIds::confirm_vehicle_component_move_cargo_warning_confirm)) |
| 2139 | { |
| 2140 | GameCommands::setErrorTitle(StringIds::cant_move_vehicle); |
| 2141 | GameCommands::doCommand(args, GameCommands::Flags::apply); |
| 2142 | } |
| 2143 | } |
| 2144 | break; |
| 2145 | } |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | // copied and modified from VehicleDraw::getDrawItemsForVehicle |
| 2150 | static BodyItems getBodyItemsForVehicle(const VehicleObject& vehObject, const uint8_t yaw, const Vehicles::Car& car) |
no test coverage detected