//------------------------------------------------------------------------ void CInventory::HolsterItem(bool holster) { //CryLogAlways("%s::HolsterItem(%s)", GetEntity()->GetName(), holster?"true":"false"); if (!holster) { if (m_stats.holsteredItemId) { IItem* pItem = m_pGameFrameWork->GetIItemSystem()->GetItem(m_stats.holsteredItemId); if(pItem && pItem->CanSelect()) { m_pGameFrameWork->GetIItemSystem()->SetActorItem(GetActor(), m_stats.holsteredItemId, false); } else { m_pGameFrameWork->GetIItemSystem()->SetActorItem(GetActor(), GetLastItem(), false); } } m_stats.holsteredItemId = 0; } else if (m_stats.currentItemId && (!m_stats.holsteredItemId || m_stats.holsteredItemId == m_stats.currentItemId)) { m_stats.holsteredItemId = m_stats.currentItemId; m_pGameFrameWork->GetIItemSystem()->SetActorItem(GetActor(), (EntityId)0, false); } }
//-------------------------------------------------------------------------------------- // Class: CILDBuffer // Method: GetModifiedMedia() // Description: Calculates the mean in the buffer's elements trying to maintain variations // over 3 //-------------------------------------------------------------------------------------- LEVEL_DATA CILDBuffer::GetModifiedMedia() { int i; LEVEL_DATA tmp_data; LEVEL_DATA last; tmp_data.ild=0; tmp_data.left_level=0; tmp_data.right_level=0; if (!global_valid) return tmp_data; last = GetLastItem(); for (i=0;i<m_size;i++ ) { tmp_data.ild=(tmp_data.ild+pointer[i].ild); tmp_data.left_level=(tmp_data.left_level+pointer[i].left_level); tmp_data.right_level=(tmp_data.right_level+pointer[i].right_level); } tmp_data.ild=tmp_data.ild/m_size; tmp_data.left_level=tmp_data.left_level/m_size; tmp_data.right_level=tmp_data.right_level/m_size; tmp_data.valid = 1; if (fabs(last.ild - tmp_data.ild) > 3) return last; else return tmp_data; }
HTREEITEM CTreeCtrl::GetPrevItem(HTREEITEM hItem) const { if (hItem==NULL) return GetLastItem(); // First check sibling on above HTREEITEM hSibling=GetNextItem(hItem,TVGN_PREVIOUS); if (hSibling!=NULL) { // Item has siblings above for (;;) { // Now check wheter this sibling has childs HTREEITEM hChild=GetNextItem(hSibling,TVGN_CHILD); if (hChild==NULL) { // No childs, return this sibling return hSibling; } // Get last child to hSibling do { hSibling=hChild; } while ((hChild=GetNextItem(hChild,TVGN_NEXT))!=NULL); } } // Return parent item return GetParentItem(hItem); }
/*---------------------------------------------------------------*/ TCHAR CPidlMgr::GetData ( LPCITEMIDLIST pidl ) { LPITEMIDLIST pLast; PIDLDATA* pData; if ( NULL == pidl ) return '\0'; // Get the last item of the PIDL to make sure we get the right TCHAR // in case of multiple nesting levels pLast = GetLastItem ( pidl ); pData = (PIDLDATA*)( pLast->mkid.abID ); return pData->chDriveLtr; }
//------------------------------------------------------------------------ void CInventory::SerializeInventoryForLevelChange( TSerialize ser ) { IActor *pActor = GetActor(); if(!pActor) return; if(ser.IsReading()) { m_stats.ammoInfo.clear(); } m_bSerializeLTL = true; //Items by class (accessories) ser.BeginGroup("accessorySlots"); int exSize = m_stats.accessorySlots.size(); ser.Value("Size", exSize); if(ser.IsReading()) { m_stats.accessorySlots.resize(0); if(exSize>0) m_stats.accessorySlots.reserve(exSize); } for(int i = 0; i<exSize; ++i) { string accessoryName; if(ser.IsWriting()) accessoryName = m_stats.accessorySlots[i]->GetName(); ser.BeginGroup("Class"); ser.Value("AccessoryName", accessoryName); ser.EndGroup(); if(ser.IsReading()) { IEntityClass* pAccessoryClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(accessoryName); CRY_ASSERT(pAccessoryClass); if (pAccessoryClass) { m_stats.accessorySlots.push_back(pAccessoryClass); } } } ser.EndGroup();//"accessorySlots" if(ser.IsReading()) { for(int r = 0; r < m_stats.slots.size(); ++r) { IItem *pItem = m_pGameFrameWork->GetIItemSystem()->GetItem(m_stats.slots[r]); if(pItem) { pItem->Drop(); pItem->GetEntity()->SetFlags(pItem->GetEntity()->GetFlags()|ENTITY_FLAG_UPDATE_HIDDEN); pItem->GetEntity()->Hide(true); gEnv->pEntitySystem->RemoveEntity(m_stats.slots[r]); } } } int numItems = 0; string currentItemNameOnReading; if(ser.IsReading()) { m_stats.slots.clear(); m_stats.currentItemId = 0; m_stats.holsteredItemId = 0; m_stats.lastItemId = 0; string itemName; ser.Value("numOfItems", numItems); for(int i = 0; i < numItems; ++i) { ser.BeginGroup("Items"); bool nextItemExists = false; ser.Value("nextItemExists", nextItemExists); if(nextItemExists) { ser.Value("ItemName", itemName); EntityId id = m_pGameFrameWork->GetIItemSystem()->GiveItem(pActor, itemName.c_str(), false, false, false); IItem *pItem = m_pGameFrameWork->GetIItemSystem()->GetItem(id); if(pItem) { //actual serialization pItem->SerializeLTL(ser); } else CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Couldn't spawn inventory item %s, got id %i.", itemName.c_str(), id); } ser.EndGroup(); } ser.Value("CurrentItemName", itemName); if(stricmp(itemName.c_str(), "none")) { currentItemNameOnReading = itemName; IEntityClass *pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(itemName.c_str()); if(pClass) { if(IItem* pItem = m_pGameFrameWork->GetIItemSystem()->GetItem(GetItemByClass(pClass))) { if (pActor->GetCurrentItem() && pActor->GetCurrentItem() != pItem) pActor->GetCurrentItem()->Select(false); pItem->Select(true); m_stats.currentItemId = pItem->GetEntityId(); } else m_stats.currentItemId = m_pGameFrameWork->GetIItemSystem()->GiveItem(pActor, itemName.c_str(), false, true, false); } } } else { numItems = m_stats.slots.size(); ser.Value("numOfItems", numItems); for(int i = 0; i < numItems; ++i) { ser.BeginGroup("Items"); IItem *pItem = m_pGameFrameWork->GetIItemSystem()->GetItem(m_stats.slots[i]); bool nextItem = true; if(pItem) { ser.Value("nextItemExists", nextItem); ser.Value("ItemName", pItem->GetEntity()->GetClass()->GetName()); pItem->SerializeLTL(ser); } else { nextItem = false; ser.Value("nextItemExists", nextItem); } ser.EndGroup(); } bool currentItemIsInInventory = stl::find(m_stats.slots, m_stats.currentItemId); IItem* pCurrentItem = NULL; if (currentItemIsInInventory) { pCurrentItem = m_pGameFrameWork->GetIItemSystem()->GetItem(m_stats.currentItemId); } else { pCurrentItem = m_pGameFrameWork->GetIItemSystem()->GetItem(GetHolsteredItem()); //Fallback to last selected one... if (!pCurrentItem) { pCurrentItem = m_pGameFrameWork->GetIItemSystem()->GetItem(GetLastItem()); // desperate fallback to any weapon... // this fallback should never be needed. However, right now it happens if the player loads a savegame where a heavyweapon is being used, right before the end of the mission. // that is a bug, but at this point is safer to just do this bruteforce fallback instead of fixing it // TODO: to fix that and remove this fallback... if (!pCurrentItem) { for(int i = 0; i < numItems; ++i) { IItem *pItem = m_pGameFrameWork->GetIItemSystem()->GetItem( m_stats.slots[i] ); if (pItem) { const char* pCategoryName = m_pGameFrameWork->GetIItemSystem()->GetItemCategory( pItem->GetEntity()->GetClass()->GetName() ); if (pCategoryName) { EInventorySlots slotType = GetSlotForItemCategory( pCategoryName ); if (slotType==eInventorySlot_Weapon) { pCurrentItem = pItem; break; } } } } } } } if (pCurrentItem) { ser.Value("CurrentItemName", pCurrentItem->GetEntity()->GetClass()->GetName()); } else { string name("none"); ser.Value("CurrentItemName", name); } } //**************************************AMMO ser.BeginGroup("Ammo"); TAmmoInfoMap::iterator ammoInfoIt = m_stats.ammoInfo.begin(); int ammoAmount = m_stats.ammoInfo.size(); ser.Value("AmmoAmount", ammoAmount); for(int i = 0; i < ammoAmount; ++i) { string name; int amount = 0; int users = 0; int capacity = 0; if(ser.IsWriting()) { IEntityClass* pAmmoClass = ammoInfoIt->first; CRY_ASSERT(pAmmoClass); name = (pAmmoClass) ? pAmmoClass->GetName() : ""; const SAmmoInfo& ammoInfo = ammoInfoIt->second;; amount = ammoInfo.GetCount(); capacity = ammoInfo.GetCapacity(); ++ammoInfoIt; } ser.BeginGroup("Ammo"); ser.Value("AmmoName", name); ser.Value("Bullets", amount); ser.Value("Capacity", capacity); ser.EndGroup(); if(ser.IsReading()) { IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(name); CRY_ASSERT(pClass); TAmmoInfoMap::iterator it = m_stats.ammoInfo.find(pClass); if (it == m_stats.ammoInfo.end()) { m_stats.ammoInfo[pClass] = SAmmoInfo(amount, capacity); } else { it->second.SetCount(amount); it->second.SetCapacity(capacity); } } } ser.EndGroup(); m_bSerializeLTL = false; }
BOOL ViewContextMenu::BuildOverView(Spread* pSpread, DocCoord ClickPos, ClickModifiers ClickMods) { ERROR2IF(pSpread==NULL,FALSE,"BuildOverView passed NULL spread pointer"); BOOL ok = TRUE; //---------------------------------------------// // First ask selected nodes if they want to supply items and if so show the blob menu... if (AskBlobsForItems(pSpread, ClickPos, ClickMods)) { // If they supply items then we won't add the normal items about the selection return TRUE; } //---------------------------------------------// // Find what the click was on and show the object menu... // NodeRenderableInk* pHitNode = NodeRenderableInk::FindSimpleAtPoint(pSpread, ClickPos); NodeRenderableInk* pHitNode = FindNodeAtPoint(pSpread,ClickPos); if (pHitNode) { BOOL HitNodeIsGuideline = IS_A(pHitNode,NodeGuideline); if (!HitNodeIsGuideline) // BODGE so that guidelines (which can't be selected) can have a pop-up menu { // Now find out if there's just one node selected and if so ask it for some items... SelRange* pSel = GetApplication()->FindSelection(); if (pSel!=NULL) { Node* pNode = pSel->FindFirst(); if (pNode && pSel->FindNext(pNode) == NULL) { // There's only one object selected so let's ask it about itself... ((NodeRenderableInk*) pNode)->OnNodePopUp(pSpread, ClickPos, this); } } } else pHitNode->OnNodePopUp(pSpread, ClickPos, this); if (!HitNodeIsGuideline) // BODGE to stop guideline pop-up menus having irrelevant menu items { // Build the rest of the standard object menu... // Effect commands ok = ok && BuildEffectCommands(); // Edit commands ok = ok && BuildTransferCommands(TRUE); // Arrange commands // WEBSTER-ranbirr-13/11/96 // #ifndef WEBSTER ok = ok && BuildCommand(OPTOKEN_MAKE_SHAPES); // #endif //webster ok = ok && BuildCommand(OPTOKEN_CONVERTTOBITMAP); // WEBSTER-ranbirr-13/11/96 // Now Taken out by vector stroking code Neville 2/10/97 #ifdef VECTOR_STROKING // ok = ok && BuildCommand(OPTOKEN_MAKE_STROKE); #endif // VECTOR_STROKING ok = ok && BuildCommand(OPTOKEN_COMBINESHAPES,TRUE); MenuItem* pCombineRoot = GetLastItem(); // WEBSTER-ranbirr-13/11/96 // #ifndef WEBSTER ok = ok && BuildCommand(OPTOKEN_ADDSHAPES, FALSE, pCombineRoot); ok = ok && BuildCommand(OPTOKEN_SUBTRACTSHAPES, FALSE, pCombineRoot); ok = ok && BuildCommand(OPTOKEN_INTERSECTSHAPES, FALSE, pCombineRoot); ok = ok && BuildCommand(OPTOKEN_SLICESHAPES, FALSE, pCombineRoot); // #endif //webster #ifndef WEBSTER // Imagesetting submenu ok = ok && BuildCommand(OPTOKEN_IMAGESETTING, TRUE); pCombineRoot = GetLastItem(); ok = ok && BuildCommand(OPTOKEN_OVERPRINTFILL, FALSE, pCombineRoot); ok = ok && BuildCommand(OPTOKEN_OVERPRINTLINE, TRUE, pCombineRoot); ok = ok && BuildCommand(OPTOKEN_PRINTONALLPLATES, FALSE, pCombineRoot); #endif //webster // Utils commands ok = ok && BuildCommand(OPTOKEN_WEBADDRESSDLG); ok = ok && BuildCommand(OPTOKEN_COLOUREDITDLG, TRUE); PORTNOTE("other", "Removed brush edit dialog from popup menu") #ifndef EXCLUDE_FROM_XARALX ok = ok && BuildCommand(OPTOKEN_BRUSHEDIT_DLG); #endif ok = ok && BuildCommand(OPTOKEN_SELECTBRUSH); } return ok; } //---------------------------------------------// // If on white space then show the white space menu... // Window commands // MENUITEM OPTOKEN_TOOLBARDLG // MENUITEM OPTOKEN_VIEWCOLOURBAR // MENUITEM OPTOKEN_VIEWSTATUSBAR // MENUITEM OPTOKEN_VIEWSCROLLBARS // WEBSTER-ranbirr-13/11/96 #ifndef WEBSTER ok = ok && BuildCommand(OPTOKEN_WINDOWNEWVIEW); ok = ok && BuildCommand(OPTOKEN_VIEWFULLSCREEN,TRUE); #else ok = ok && BuildCommand(OPTOKEN_WINDOWNEWVIEW,TRUE); #endif //webster // Paste option - we don't need to do the // BuildTransferCommands as the Cut and Copy operations // are never applicable here... matt-23/08/2000 ok = ok && BuildCommand(OPTOKEN_PASTE, TRUE); // View quality ok = ok && BuildCommand(OPTOKEN_WINDOWQUALITY,FALSE); MenuItem* pQualityRoot = GetLastItem(); ok = ok && BuildCommand(OPTOKEN_QUALITYANTIALIASED, FALSE, pQualityRoot); ok = ok && BuildCommand(OPTOKEN_QUALITYNORMAL, FALSE, pQualityRoot); ok = ok && BuildCommand(OPTOKEN_QUALITYSIMPLE, FALSE, pQualityRoot); ok = ok && BuildCommand(OPTOKEN_QUALITYOUTLINE, FALSE, pQualityRoot); // View commands // WEBSTER-ranbirr-13/11/96 #ifndef WEBSTER ok = ok && BuildCommand(OPTOKEN_SHOWGRID); ok = ok && BuildCommand(OPTOKEN_SHOWGUIDES,TRUE); #else ok = ok && BuildCommand(OPTOKEN_SHOWGRID,TRUE); #endif //webster // WEBSTER-ranbirr-13/11/96 #ifndef WEBSTER ok = ok && BuildCommand(OPTOKEN_SNAPTOGRID); ok = ok && BuildCommand(OPTOKEN_SNAPTOGUIDES); ok = ok && BuildCommand(OPTOKEN_SNAPTOOBJECTS,TRUE); #else ok = ok && BuildCommand(OPTOKEN_SNAPTOGRID,TRUE); #endif //webster ok = ok && BuildCommand(OPTOKEN_DELETEPAGEBACKGROUND); // Page commands (almost "Properties...") ok = ok && BuildCommand(OPTOKEN_PAGESIZEDLG); return ok; }