void CUIMpTradeWnd::CleanUserItems() { Msg("--CleanUserItems"); SBuyItemInfo* iinfo = NULL; SBuyItemInfo::EItmState _state=SBuyItemInfo::e_bought; for(int i=0; i<3;++i ) { if(i==0) _state = SBuyItemInfo::e_bought; else if(i==1) _state = SBuyItemInfo::e_sold; else if(i==2) _state = SBuyItemInfo::e_own; do{ iinfo = FindItem(_state); if(iinfo) { while( iinfo->m_cell_item->ChildsCount() ) { CUICellItem* iii = iinfo->m_cell_item->PopChild (); SBuyItemInfo* iinfo_sub = FindItem(iii); R_ASSERT2( iinfo_sub->GetState()==_state || iinfo_sub->GetState()==SBuyItemInfo::e_shop, _state_names[_state]); } if(IsAddonAttached(iinfo, at_scope) ) { SBuyItemInfo* detached_addon = DetachAddon(iinfo, at_scope); detached_addon->SetState (SBuyItemInfo::e_undefined); detached_addon->SetState (SBuyItemInfo::e_shop); detached_addon->m_cell_item->SetOwnerList(NULL); } if(IsAddonAttached(iinfo, at_silencer) ) { SBuyItemInfo* detached_addon = DetachAddon(iinfo, at_silencer); detached_addon->SetState (SBuyItemInfo::e_undefined); detached_addon->SetState (SBuyItemInfo::e_shop); detached_addon->m_cell_item->SetOwnerList(NULL); } if(IsAddonAttached(iinfo, at_glauncher) ) { SBuyItemInfo* detached_addon = DetachAddon(iinfo, at_glauncher); detached_addon->SetState (SBuyItemInfo::e_undefined); detached_addon->SetState (SBuyItemInfo::e_shop); detached_addon->m_cell_item->SetOwnerList(NULL); } iinfo->SetState (SBuyItemInfo::e_undefined); iinfo->SetState (SBuyItemInfo::e_shop); iinfo->m_cell_item->SetOwnerList (NULL); } }while(iinfo); } for(u32 i = e_first; i<e_player_total; ++i) m_list[i]->ClearAll (false); }
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; } } }
void CUIMpTradeWnd::SellItemAddons(SBuyItemInfo* sell_itm, item_addon_type addon_type) { CInventoryItem* item_ = (CInventoryItem*)sell_itm->m_cell_item->m_pData; CWeapon* w = smart_cast<CWeapon*>(item_); if(!w) return; //ammo,medkit etc. if(IsAddonAttached(sell_itm, addon_type)) { SBuyItemInfo* detached_addon = DetachAddon(sell_itm, addon_type); u32 _item_cost = m_item_mngr->GetItemCost(detached_addon->m_name_sect, GetRank() ); SetMoneyAmount (GetMoneyAmount() + _item_cost); DestroyItem (detached_addon); if ( addon_type == at_glauncher ) { CWeaponMagazinedWGrenade* wpn2 = smart_cast<CWeaponMagazinedWGrenade*>(item_); VERIFY(wpn2); for ( u32 ammo_idx = 0; ammo_idx < wpn2->m_ammoTypes2.size(); ++ammo_idx ) { const shared_str& ammo_name = wpn2->m_ammoTypes2[ammo_idx]; SBuyItemInfo* ammo = NULL; while ( (ammo = FindItem(ammo_name, SBuyItemInfo::e_bought)) != NULL ) { SBuyItemInfo* tempo = NULL; TryToSellItem(ammo, true, tempo); } } } } }