| 208 | } |
| 209 | |
| 210 | void CUIInventoryWnd::ProcessPropertiesBoxClicked() |
| 211 | { |
| 212 | if (UIPropertiesBox.GetClickedItem()) |
| 213 | { |
| 214 | switch (UIPropertiesBox.GetClickedItem()->GetTAG()) |
| 215 | { |
| 216 | case INVENTORY_TO_SLOT_ACTION: { |
| 217 | auto item = CurrentIItem(); |
| 218 | // Явно указали слот в меню |
| 219 | void* d = UIPropertiesBox.GetClickedItem()->GetData(); |
| 220 | if (d) |
| 221 | { |
| 222 | auto slot = (u8)(__int64)d; |
| 223 | item->SetSlot(slot); |
| 224 | if (ToSlot(CurrentItem(), true)) |
| 225 | return; |
| 226 | } |
| 227 | // Пытаемся найти свободный слот из списка разрешенных. |
| 228 | // Если его нету, то принудительно займет первый слот, |
| 229 | // указанный в списке. |
| 230 | auto slots = item->GetSlots(); |
| 231 | for (u8 i = 0; i < (u8)slots.size(); ++i) |
| 232 | { |
| 233 | item->SetSlot(slots[i]); |
| 234 | if (ToSlot(CurrentItem(), false)) |
| 235 | return; |
| 236 | } |
| 237 | item->SetSlot(slots.size() ? slots[0] : NO_ACTIVE_SLOT); |
| 238 | ToSlot(CurrentItem(), true); |
| 239 | break; |
| 240 | } |
| 241 | |
| 242 | case INVENTORY_TO_BELT_ACTION: ToBelt(CurrentItem(), false); break; |
| 243 | case INVENTORY_TO_BAG_ACTION: ToBag(CurrentItem(), false); break; |
| 244 | case INVENTORY_DROP_ACTION: { |
| 245 | void* d = UIPropertiesBox.GetClickedItem()->GetData(); |
| 246 | bool b_all = (d == (void*)33); |
| 247 | |
| 248 | DropCurrentItem(b_all); |
| 249 | } |
| 250 | break; |
| 251 | case INVENTORY_EAT_ACTION: EatItem(CurrentIItem()); break; |
| 252 | case INVENTORY_ATTACH_ADDON: AttachAddon((PIItem)(UIPropertiesBox.GetClickedItem()->GetData())); break; |
| 253 | case INVENTORY_DETACH_SCOPE_ADDON: DetachAddon(*(smart_cast<CWeapon*>(CurrentIItem()))->GetScopeName()); break; |
| 254 | case INVENTORY_DETACH_SILENCER_ADDON: DetachAddon(*(smart_cast<CWeapon*>(CurrentIItem()))->GetSilencerName()); break; |
| 255 | case INVENTORY_DETACH_GRENADE_LAUNCHER_ADDON: DetachAddon(*(smart_cast<CWeapon*>(CurrentIItem()))->GetGrenadeLauncherName()); break; |
| 256 | case INVENTORY_RELOAD_MAGAZINE: (smart_cast<CWeapon*>(CurrentIItem()))->Action(kWPN_RELOAD, CMD_START); break; |
| 257 | case INVENTORY_UNLOAD_MAGAZINE: { |
| 258 | auto ProcessUnload = [](void* pWpn) { |
| 259 | auto WpnMagaz = static_cast<CWeaponMagazined*>(pWpn); |
| 260 | WpnMagaz->UnloadMagazine(); |
| 261 | if (auto WpnMagazWgl = smart_cast<CWeaponMagazinedWGrenade*>(WpnMagaz)) |
| 262 | { |
| 263 | if (WpnMagazWgl->IsGrenadeLauncherAttached()) |
| 264 | { |
| 265 | WpnMagazWgl->PerformSwitchGL(); |
| 266 | WpnMagazWgl->UnloadMagazine(); |
| 267 | WpnMagazWgl->PerformSwitchGL(); |
nothing calls this directly
no test coverage detected