void CUIInventoryWnd::ProcessPropertiesBoxClicked () { if(UIPropertiesBox.GetClickedItem()) { switch(UIPropertiesBox.GetClickedItem()->GetID()) { case INVENTORY_TO_SLOT_ACTION: ToSlot(CurrentItem(), true); break; case INVENTORY_TO_BELT_ACTION: ToBelt(CurrentItem(),false); break; case INVENTORY_TO_BAG_ACTION: ToBag(CurrentItem(),false); break; case INVENTORY_DROP_ACTION: { void* d = UIPropertiesBox.GetClickedItem()->GetData(); bool b_all = (d==(void*)33); DropCurrentItem(b_all); }break; case INVENTORY_EAT_ACTION: EatItem(CurrentIItem()); break; case INVENTORY_ATTACH_ADDON: AttachAddon((PIItem)(UIPropertiesBox.GetClickedItem()->GetData())); break; case INVENTORY_DETACH_SCOPE_ADDON: DetachAddon(*(smart_cast<CWeapon*>(CurrentIItem()))->GetScopeName()); break; case INVENTORY_DETACH_SILENCER_ADDON: DetachAddon(*(smart_cast<CWeapon*>(CurrentIItem()))->GetSilencerName()); break; case INVENTORY_DETACH_GRENADE_LAUNCHER_ADDON: DetachAddon(*(smart_cast<CWeapon*>(CurrentIItem()))->GetGrenadeLauncherName()); break; case INVENTORY_ACTIVATE_ARTEFACT_ACTION: Activate_Artefact(); break; case INVENTORY_RELOAD_MAGAZINE: (smart_cast<CWeapon*>(CurrentIItem()))->Action(kWPN_RELOAD, CMD_START); break; case INVENTORY_UNLOAD_MAGAZINE: { CUICellItem * itm = CurrentItem(); (smart_cast<CWeaponMagazined*>((CWeapon*)itm->m_pData))->UnloadMagazine(); for(u32 i=0; i<itm->ChildsCount(); ++i) { CUICellItem * child_itm = itm->Child(i); (smart_cast<CWeaponMagazined*>((CWeapon*)child_itm->m_pData))->UnloadMagazine(); } }break; } } }
bool CUIMpTradeWnd::TryToAttachItemAsAddon(SBuyItemInfo* itm, SBuyItemInfo* itm_parent) { bool b_res = false; item_addon_type _addon_type = GetItemType(itm->m_name_sect); if(_addon_type==at_not_addon) return b_res; if(itm_parent) { if(CanAttachAddon(itm_parent,_addon_type)) { return AttachAddon (itm_parent, _addon_type); } }else // auto-attach for(u32 i=0; i<2; ++i) { u32 list_idx = (i==0) ? e_rifle : e_pistol; CUIDragDropListEx* _list = m_list[list_idx]; VERIFY (_list->ItemsCount() <= 1); CUICellItem* ci = (_list->ItemsCount()) ? _list->GetItemIdx(0) : NULL; if(!ci) return false; SBuyItemInfo* attach_to = FindItem(ci); if(CanAttachAddon(attach_to,_addon_type)) { AttachAddon (attach_to,_addon_type); b_res = true; break; } } return b_res; }
bool CUIInventoryWnd::DropItem(PIItem itm, CUIDragDropListEx* lst) { if(lst==m_pUIOutfitList) { EatItem (CurrentIItem()); return true; } CUICellItem* _citem = lst->ItemsCount() ? lst->GetItemIdx(0) : NULL; PIItem _iitem = _citem ? (PIItem)_citem->m_pData : NULL; if(!_iitem) return false; if(!_iitem->CanAttach(itm)) return false; AttachAddon (_iitem); return true; }