void CUIInventoryWnd::EatItem(PIItem itm) { SetCurrentItem (NULL); if(!itm->Useful()) return; CActor *pActor = smart_cast<CActor*>(Level().CurrentEntity()); if(!pActor) return; SendEvent_Item_Eat (itm); PlaySnd (eInvItemUse); }
PIItem CInventory::item(CLASS_ID cls_id) const { const TIItemContainer &list = m_all; for(TIItemContainer::const_iterator it = list.begin(); list.end() != it; ++it) { PIItem pIItem = *it; if(pIItem->object().CLS_ID == cls_id && pIItem->Useful()) return pIItem; } return NULL; }
PIItem CInventory::Get(CLASS_ID cls_id, bool bSearchRuck) const { const TIItemContainer &list = bSearchRuck ? m_ruck : m_belt; for(TIItemContainer::const_iterator it = list.begin(); list.end() != it; ++it) { PIItem pIItem = *it; if(pIItem->object().CLS_ID == cls_id && pIItem->Useful()) return pIItem; } return NULL; }
//найти в инвенторе вещь с указанным именем PIItem CInventory::Get(LPCSTR name, bool bSearchRuck) const { const TIItemContainer &list = bSearchRuck ? m_ruck : m_belt; for(TIItemContainer::const_iterator it = list.begin(); list.end() != it; ++it) { PIItem pIItem = *it; if(!xr_strcmp(pIItem->object().cNameSect(), name) && pIItem->Useful()) return pIItem; } return NULL; }
void CUITradeWnd::ColorizeAmmo(CUICellItem* itm) { u32 item_count; CInventoryItem* inventoryitem = (CInventoryItem*) itm->m_pData; if (!inventoryitem) return; CWeaponMagazined* weapon = smart_cast<CWeaponMagazined*>(inventoryitem); if (!weapon) return; xr_vector<shared_str> ammo_types = weapon->m_ammoTypes; u32 color = pSettings->r_color("inventory_color_ammo","color"); for (size_t id = 0; id<ammo_types.size(); ++id) { item_count = m_uidata->UIOurBagList.ItemsCount(); for (u32 i=0; i<item_count; ++i) { CUICellItem* ourBag_item = m_uidata->UIOurBagList.GetItemIdx(i); PIItem invitem = (PIItem) ourBag_item->m_pData; if (invitem && xr_strcmp(invitem->object().cNameSect(), ammo_types[id])==0 && invitem->Useful()) { ourBag_item->SetTextureColor (color); } } } for (size_t id = 0; id<ammo_types.size(); ++id) { item_count = m_uidata->UIOurTradeList.ItemsCount(); for (u32 i=0; i<item_count; ++i) { CUICellItem* ourTradeBag_item = m_uidata->UIOurTradeList.GetItemIdx(i); PIItem invitem = (PIItem) ourTradeBag_item->m_pData; if (invitem && xr_strcmp(invitem->object().cNameSect(), ammo_types[id])==0 && invitem->Useful()) { ourTradeBag_item->SetTextureColor (color); break; } } } for (size_t id = 0; id<ammo_types.size(); ++id) { item_count = m_uidata->UIOthersBagList.ItemsCount(); for (u32 i=0; i<item_count; ++i) { CUICellItem* otherBag_item = m_uidata->UIOthersBagList.GetItemIdx(i); PIItem invitem = (PIItem) otherBag_item->m_pData; if (invitem && xr_strcmp(invitem->object().cNameSect(), ammo_types[id])==0 && invitem->Useful()) { otherBag_item->SetTextureColor (color); break; } } } for (size_t id = 0; id<ammo_types.size(); ++id) { item_count = m_uidata->UIOthersTradeList.ItemsCount(); for (u32 i=0; i<item_count; ++i) { CUICellItem* otherTradeBag_item = m_uidata->UIOthersTradeList.GetItemIdx(i); PIItem invitem = (PIItem) otherTradeBag_item->m_pData; if (invitem && xr_strcmp(invitem->object().cNameSect(), ammo_types[id])==0 && invitem->Useful()) { otherTradeBag_item->SetTextureColor (color); break; } } } }