void CUIGameCTA::BuyMenuItemInserter(PIItem const & item) { VERIFY(m_pCurBuyMenu); if (!item) return; if (item->IsInvalid() || smart_cast<CWeaponKnife*>(&item->object()) ) return; CArtefact* pArtefact = smart_cast<CArtefact*>(item); if (pArtefact) return; if (!pSettings->line_exist(m_costSection, item->object().cNameSect())) return; if (!item->CanTrade()) return; u8 addons = 0; CWeapon* pWeapon = smart_cast<CWeapon*>(item); if (pWeapon) addons = pWeapon->GetAddonsState(); CWeaponAmmo* pAmmo = smart_cast<CWeaponAmmo*>(item); if (pAmmo && (pAmmo->m_boxCurr != pAmmo->m_boxSize)) return; m_pCurBuyMenu->ItemToSlot(item->object().cNameSect(), addons); }
u8 GetItemAddonsState_ext(SBuyItemInfo* item) { CInventoryItem* item_ = (CInventoryItem*)item->m_cell_item->m_pData; CWeapon* w = smart_cast<CWeapon*>(item_); if(!w) return 0; return w->GetAddonsState(); }
bool CUIMpTradeWnd::AttachAddon(SBuyItemInfo* itm, item_addon_type at) { VERIFY (!IsAddonAttached(itm,at)); CInventoryItem* item_ = (CInventoryItem*)itm->m_cell_item->m_pData; CWeapon* w = smart_cast<CWeapon*>(item_); R_ASSERT (w); u8 curr_addon_state = w->GetAddonsState(); curr_addon_state |= at; w->SetAddonsState (curr_addon_state); return true; }
u8 CUIBagWnd::GetItemIndex(CUICellItem* pItem, u8 §ionNum){ sectionNum = 0; u8 ret = static_cast<u8>(-1); if (!pItem) return ret; ret = static_cast<u8>(m_info[pItem->m_index].pos_in_section); sectionNum = static_cast<u8>(m_info[pItem->m_index].section); CInventoryItem* iitem = (CInventoryItem*)pItem->m_pData; if (iitem->GetSlot() == PISTOL_SLOT || iitem->GetSlot() == RIFLE_SLOT) { CWeapon* pWeapon = (CWeapon*)pItem->m_pData; u8 addon = pWeapon->GetAddonsState(); if (addon & CSE_ALifeItemWeapon::eWeaponAddonScope) ret |= 1<<5; if (addon & CSE_ALifeItemWeapon::eWeaponAddonGrenadeLauncher) ret |= 1<<6; if (addon & CSE_ALifeItemWeapon::eWeaponAddonSilencer) ret |= 1<<7; } //returnID = static_cast<u8>(pDDItem->GetPosInSectionsGroup()); //sectionNum = static_cast<u8>(pDDItem->GetSectionGroupID()); //// Проверяем на наличие приаттаченых аддонов к оружию //if (pDDItem->bAddonsAvailable) //{ // u8 flags = 0; // for (int i = 0; i < 3; ++i) // { // if (1 == pDDItem->m_AddonInfo[i].iAttachStatus) // flags |= 1; // flags = flags << 1; // } // flags = flags << 4; // // В результате старшие 3 бита являются флагами признаков аддонов: // // FF - Scope, FE - Silencer, FD - Grenade Launcher // returnID |= flags; //} return ret; }
SBuyItemInfo* CUIMpTradeWnd::DetachAddon(SBuyItemInfo* itm, item_addon_type at) { VERIFY (IsAddonAttached(itm,at)); CInventoryItem* item_ = (CInventoryItem*)itm->m_cell_item->m_pData; CWeapon* w = smart_cast<CWeapon*>(item_); R_ASSERT (w); u8 curr_addon_state = w->GetAddonsState(); curr_addon_state &= ~at; shared_str addon_name_sect = GetAddonNameSect(itm, at); w->SetAddonsState (curr_addon_state); SBuyItemInfo* detached_addon = CreateItem(addon_name_sect, SBuyItemInfo::e_own, false); return detached_addon; }