| 305 | } |
| 306 | |
| 307 | void TransactionScreen::populateControlsVehicleEquipment() |
| 308 | { |
| 309 | bool flying = type == Type::FlyingEquipment; |
| 310 | static const std::list<EquipmentSlotType> vehTypes = {EquipmentSlotType::VehicleWeapon, |
| 311 | EquipmentSlotType::VehicleGeneral, |
| 312 | EquipmentSlotType::VehicleEngine}; |
| 313 | int leftIndex = getLeftIndex(); |
| 314 | int rightIndex = getRightIndex(); |
| 315 | for (auto &t : vehTypes) |
| 316 | { |
| 317 | for (auto ve_it = state->vehicle_equipment.begin(); ve_it != state->vehicle_equipment.end(); |
| 318 | ++ve_it) |
| 319 | { |
| 320 | auto &ve = *ve_it; |
| 321 | if (ve.second->type != t) |
| 322 | { |
| 323 | continue; |
| 324 | } |
| 325 | if (flying && |
| 326 | ve.second->users.find(VEquipmentType::User::Air) == ve.second->users.end()) |
| 327 | { |
| 328 | continue; |
| 329 | } |
| 330 | if (!flying && |
| 331 | ve.second->users.find(VEquipmentType::User::Ground) == ve.second->users.end()) |
| 332 | { |
| 333 | continue; |
| 334 | } |
| 335 | if (state->economy.find(ve.first) == state->economy.end()) |
| 336 | { |
| 337 | continue; |
| 338 | } |
| 339 | auto itemControl = TransactionControl::createControl( |
| 340 | *state, StateRef<VEquipmentType>{state.get(), ve.first}, leftIndex, rightIndex); |
| 341 | if (itemControl) |
| 342 | { |
| 343 | itemControl->addCallback(FormEventType::ScrollBarChange, onScrollChange); |
| 344 | itemControl->addCallback(FormEventType::MouseMove, onHover); |
| 345 | if (auto otherControl = findControlById(ve.first)) |
| 346 | { |
| 347 | TransactionControl::link(otherControl, itemControl); |
| 348 | } |
| 349 | transactionControls[type].push_back(itemControl); |
| 350 | } |
| 351 | // don't add ammo control if not in economy |
| 352 | if (state->economy.find(ve.second->ammo_type.id) == state->economy.end()) |
| 353 | { |
| 354 | continue; |
| 355 | } |
| 356 | auto veNextIterator = std::next(ve_it, 1); |
| 357 | // skip this iteration if we're adding a control for the same ammo type in the |
| 358 | // next iteration |
| 359 | if (veNextIterator != state->vehicle_equipment.end() && |
| 360 | veNextIterator->second->ammo_type.id == ve.second->ammo_type.id) |
| 361 | { |
| 362 | continue; |
| 363 | } |
| 364 |
nothing calls this directly
no test coverage detected