当前位置: 首页>>代码示例>>C++>>正文


C++ CInventory类代码示例

本文整理汇总了C++中CInventory的典型用法代码示例。如果您正苦于以下问题:C++ CInventory类的具体用法?C++ CInventory怎么用?C++ CInventory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CInventory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetInventory

//------------------------------------------------------------------------
int CScriptBind_Inventory::Destroy(IFunctionHandler *pH)
{
	CInventory *pInventory = GetInventory(pH);
	CRY_ASSERT(pInventory);

	pInventory->Destroy();
	return pH->EndFunction();
}
开发者ID:aronarts,项目名称:FireNET,代码行数:9,代码来源:ScriptBind_Inventory.cpp

示例2: assert

//*-------------------------------------------------------------------/
/// 분리/분해후 아이템이 들어갈 자리가 충분히 있는가?
//*-------------------------------------------------------------------/
bool CSeparateDlg::HasEnoughInventoryEmptySlot( CIconItem* pItemIcon, std::vector<CSlot>& OutputItems )
{
#ifdef _NEWBREAK
	//06. 08. 24 - 김주현 : 지금 분해는 재료만 나오게 되어있다. 재료탭만 체크한다.
	short nEmptySlotCount[ MAX_INV_TYPE ];

	CInventory* pInven = g_pAVATAR->GetInventory();
	assert( pInven );

	nEmptySlotCount[INV_ETC] = pInven->GetEmptyInvenSlotCount( (t_InvTYPE)INV_ETC );

	if(nEmptySlotCount[INV_ETC] < 4)
		return false;

	return true;
#else
	assert( pItemIcon );
	if( pItemIcon == NULL ) return false;

	///일단 모든 타입의 빈 슬롯을 구한다.
	short nEmptySlotCount[ MAX_INV_TYPE ];

	CInventory* pInven = g_pAVATAR->GetInventory();
	assert( pInven );

	for( int i = INV_WEAPON; i < MAX_INV_TYPE; ++i )
		nEmptySlotCount[i] = pInven->GetEmptyInvenSlotCount( (t_InvTYPE)i );

	/// 분리/분해할 아이템의 자리를 빈슬롯으로 계산한다( 개수가 없거나 개수가 있지만 1개일경우)
	tagITEM& Item = pItemIcon->GetItem();
	if( (Item.IsEnableDupCNT() && Item.GetQuantity() == 1 ) || !Item.IsEnableDupCNT() )
		nEmptySlotCount[ CInventory::GetInvPageTYPE( Item ) ]++;


	CIcon*		pIcon = NULL;
	CIconItem*	pOutputItemIcon = NULL;
	std::vector<CSlot>::iterator iter;

	for( iter = OutputItems.begin(); iter != OutputItems.end(); ++iter )
	{
		if( pIcon = iter->GetIcon() )
		{
			pOutputItemIcon = ( CIconItem* )pIcon;
			nEmptySlotCount[ CInventory::GetInvPageTYPE( pOutputItemIcon->GetItem() ) ]--;
			if( nEmptySlotCount[ CInventory::GetInvPageTYPE( pOutputItemIcon->GetItem() ) ] < 0 )
				return false;
		}
	}
	return true;
#endif

}
开发者ID:PurpleYouko,项目名称:Wibble_Wibble,代码行数:55,代码来源:CSeparateDlg.cpp

示例3: memcpy

bool CObjUSER::IsInventoryFull( std::list< tagITEM >& appendItems )
{
	CInventory TempInventory;
	memcpy( &TempInventory, &m_Inventory, sizeof( CInventory ) );

	std::list< tagITEM >::iterator iterAppend;
	short nInvenIndex = 0;
	short nWeight	  = 0;

	for( iterAppend = appendItems.begin(); iterAppend != appendItems.end(); ++iterAppend )
	{
		if( TempInventory.AppendITEM(*iterAppend , nWeight ) == -1 )
			return true;
	}
	return false;
}
开发者ID:PurpleYouko,项目名称:Wibble_Wibble,代码行数:16,代码来源:CObjUSER.cpp

示例4: ai

void CScriptGameObject::ForEachInventoryItems(const luabind::functor<void> &functor)
{
	CInventoryOwner* owner = smart_cast<CInventoryOwner*>(&object());
	if(!owner){
		ai().script_engine().script_log		(ScriptStorage::eLuaMessageTypeError,"CScriptGameObject::ForEachInventoryItems non-CInventoryOwner object !!!");
		return;
	}
	
	CInventory* pInv = &owner->inventory();
	TIItemContainer item_list;
	pInv->AddAvailableItems(item_list, true);

	TIItemContainer::iterator it;
	for(it =  item_list.begin(); item_list.end() != it; ++it) 
	{
		CGameObject* inv_go = smart_cast<CGameObject*>(*it);
		if( inv_go ){
			functor(inv_go->lua_game_object(),this);
		}
	}
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:21,代码来源:script_game_object_inventory_owner.cpp

示例5: GetCategory

void CInventory::CopyTo(CInventory& targetInventory)
{
	// Iterate over all categories to copy stuff
	for (int c = 0; c < GetNumCategories(); ++c)
	{
		const CInventoryCategoryPtr& category = GetCategory(c);

		for (int itemIdx = 0; itemIdx < category->GetNumItems(); ++itemIdx)
		{
			const CInventoryItemPtr& item = category->GetItem(itemIdx);

			DM_LOG(LC_INVENTORY, LT_DEBUG)LOGSTRING("Copying item %s to inventory.\r", common->Translate(item->GetName().c_str()));

			// Add this item to the target inventory
			targetInventory.PutItem(item, item->Category()->GetName());
		}
	}
}
开发者ID:jaredmitch,项目名称:executable,代码行数:18,代码来源:Inventory.cpp

示例6: GameWarning


//.........这里部分代码省略.........
					if(pActor && pActor->GetInventory())
					{
						IItem* pItem = pActor->GetInventory()->GetItemByName(sel);
						CWeapon* pWeapon;
						if(pItem && (pWeapon = (CWeapon*)(pItem->GetIWeapon())))
						{

						int fireModeIdx = pWeapon->GetCurrentFireMode();
						if(m_bLogWarning)
							{
									CheckDifference(recFireModeIdx,fireModeIdx,"TimeDemo:GameState: Frame %d - Actor %s - FIRE MODE mismatch for weapon %s (rec:%d, cur:%d)",pEntity,pItem->GetEntity() ? pItem->GetEntity()->GetName() : "(null)");
							}

							if(demo_forceGameState==2 && fireModeIdx!= recFireModeIdx)
								pWeapon->SetCurrentFireMode(recFireModeIdx);
						}
					}
				}
			}
			break;

		case eGE_WeaponReload:
			{
				const char* ammoType = event.description;
				TAmmoContainer& ammoMags = gstate.AmmoMags;
				TAmmoContainer::iterator it = ammoMags.find(ammoType);
				if(it!=ammoMags.end())
				{
					it->second -= (uint16)event.value;
				
					CActor *pActor = (CActor*)(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
					if(pActor)
					{
						CInventory* pInventory = (CInventory*)(pActor->GetInventory());
						if(pInventory)
						{
							{
								IEntityClass* pAmmoClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammoType);
								if(pAmmoClass)
								{
									if(m_bLogWarning)
										CheckDifference(it->second,pInventory->GetAmmoCount(pAmmoClass),"TimeDemo:GameState: Frame %d - Actor %s - WEAPON RELOAD, ammo count mismatch for ammo class %s (rec:%d, cur:%d)",pEntity,ammoType);
		
									if(demo_forceGameState == 2)
										pInventory->SetAmmoCount(pAmmoClass,it->second);
								}
							}
						}
					}
				}
			}
			break;

		case eGE_ItemSelected:
			{
				TItemName itemName = event.description;
				gstate.itemSelected = itemName;
				if(itemName)
				{
					if( !bRecording && (event.value > 0 || demo_forceGameState==2)) // EVENT.VALUE > 0 means initialization
					{
						CActor *pActor = (CActor*)(gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(id));
						if(pActor && pActor->GetInventory())
						{
							IItem* pItem = pActor->GetInventory()->GetItemByName(itemName);
							if(pItem)
开发者ID:kitnet,项目名称:project-o,代码行数:67,代码来源:GameStateRecorder.cpp

示例7: SendGamePlayEvent

void CGameStateRecorder::DumpWholeGameState(const CActor* pActor)
{
	GameplayEvent event;
	IEntity* pEntity = pActor->GetEntity();
	
	// health
	float health = (float)pActor->GetHealth();
	event.event = eGE_HealthChanged;
	event.value = health;
	SendGamePlayEvent(pEntity,event);
	
	// Inventory
	CInventory *pInventory = (CInventory*)(pActor->GetInventory());
	if(!pInventory)
		return;

	int count = pInventory->GetCount();
	for(int i=0; i<count; ++i)
	{
		EntityId itemId = pInventory->GetItem(i);
		
		CItem* pItem=NULL;
		TItemName itemName = GetItemName(itemId,&pItem);
		if(pItem && itemName)	
		{
			event.event = eGE_ItemPickedUp;
			event.description = itemName;
			SendGamePlayEvent(pEntity,event);

			if(pActor->GetCurrentItem() == pItem)
			{
				event.event = eGE_ItemSelected;
				event.description = itemName;
				event.value = 1; // for initialization
				SendGamePlayEvent(pEntity,event);
			}
			
			CWeapon* pWeapon = (CWeapon*)(pItem->GetIWeapon());
			if(pWeapon)
			{
				IEntityClass* pItemClass = pWeapon->GetEntity()->GetClass();
				if(pItemClass && !strcmpi(pItemClass->GetName(),"binoculars"))
					continue; // no fire mode or ammo recorded for binocular (which is a weapon)

				// fire mode
				int fireModeIdx = pWeapon->GetCurrentFireMode();

				event.event = eGE_WeaponFireModeChanged;
				event.value = (float)fireModeIdx;
				event.description = itemName;
				SendGamePlayEvent(pEntity,event);
				// count ammo
				for(SWeaponAmmo weaponAmmo = pWeapon->GetFirstAmmo(); weaponAmmo.pAmmoClass ; weaponAmmo = pWeapon->GetNextAmmo())
				{
					const char* ammoClass;
					if(weaponAmmo.pAmmoClass && (ammoClass = weaponAmmo.pAmmoClass->GetName()))
					{
						event.event = eGE_AmmoCount;
						event.value = (float)weaponAmmo.count;
						event.extra = (void*)ammoClass;
						event.description = (const char*)itemName;
						SendGamePlayEvent(pEntity,event);
					}
				}
			}
		}
	}

	count = pInventory->GetAccessoryCount();

	for(int i=0; i< count; i++)
	{
		const char* accessory = pInventory->GetAccessory(i);
		if(accessory && strlen(accessory))	
		{
			IEntityClass* pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(accessory);
			if(pClass)
			{
				TItemName classItem = pClass->GetName();
				event.event = eGE_AccessoryPickedUp;
				//event.value = classIdx;
				event.description = classItem;
				SendGamePlayEvent(pEntity,event);
			}
		}
	}

	int nInvAmmo = pInventory->GetAmmoPackCount();
	pInventory->AmmoIteratorFirst();
	for(int j=0 ; !pInventory->AmmoIteratorEnd(); j++, pInventory->AmmoIteratorNext())
	{
		const IEntityClass* pAmmoClass = pInventory->AmmoIteratorGetClass();
		if(pAmmoClass)
		{
			const char* ammoClassName = pAmmoClass->GetName();
			int ammoCount = pInventory->AmmoIteratorGetCount();
			GameplayEvent event;
			event.event = eGE_AmmoPickedUp;
			event.description = ammoClassName;
			event.value = (float)ammoCount;
//.........这里部分代码省略.........
开发者ID:kitnet,项目名称:project-o,代码行数:101,代码来源:GameStateRecorder.cpp

示例8: if

/*template <class EventHandlerFunc> */void CGameStateRecorder::CheckInventory(CActor* pActor, IItem *pItem)//, EventHandlerFunc eventHandler)
{

	if(pActor)
	{
		TGameStates::iterator itGS;
		if(pActor->IsPlayer())
			itGS = m_itSingleActorGameState;
		else if(pActor->GetEntity())
			itGS = m_GameStates.find(pActor->GetEntity()->GetId());
		else
			return;

		if(itGS != m_GameStates.end())
		{
			SActorGameState& gstate = itGS->second;

			// items

			CInventory *pInventory = (CInventory*)(pActor->GetInventory());
			if(pInventory)
			{
				bool bSingleItem = (pItem!=0);
				int nInvItems = (bSingleItem ? 1 : pInventory->GetCount());
				TItemContainer& Items = gstate.Items;
				
				for(int i=0; i< nInvItems; i++)
				{
					if(!bSingleItem) 
						pItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pInventory->GetItem(i));

					if(pItem)
					{
						TItemName szItemName = GetItemName(pItem->GetEntityId());

						TItemContainer::iterator it = Items.find(szItemName);
						if(it==Items.end())
						{
							it = (Items.insert(std::make_pair(szItemName,SItemProperties()))).first;

							GameplayEvent event;
							event.event = eGE_ItemPickedUp;
							event.description = szItemName;
							//eventHandler(pActor,event);
							SendGamePlayEvent(pActor->GetEntity(),event);

							SItemProperties& recItem = it->second;
							CWeapon *pWeapon = (CWeapon*)(pItem->GetIWeapon());
							if(pWeapon)
							{
								// ammo
								for(SWeaponAmmo weaponAmmo = pWeapon->GetFirstAmmo(); weaponAmmo.pAmmoClass ; weaponAmmo = pWeapon->GetNextAmmo())
								{
									int ammoCount = weaponAmmo.count;
									string ammoClass;
									if(weaponAmmo.pAmmoClass && (ammoClass = weaponAmmo.pAmmoClass->GetName()))
									{
										TAmmoContainer& recAmmo = recItem.Ammo;

										if(recAmmo.find(ammoClass) == recAmmo.end())
											recAmmo.insert(std::make_pair(ammoClass,0));
										int recAmmoCount = recAmmo[ammoClass];
										if(ammoCount!=recAmmoCount)
										{
											GameplayEvent event;
											event.event = eGE_AmmoCount;
											event.value = (float)ammoCount;
											event.extra = (void*)(ammoClass.c_str());
											event.description = (const char*)szItemName;
											//eventHandler(pActor,event);
											SendGamePlayEvent(pActor->GetEntity(),event);

										}
									}
								}
								// current fire mode
								int curFireModeIdx = pWeapon->GetCurrentFireMode();
								int recFireModeIdx = recItem.fireMode;
								if(curFireModeIdx!= recFireModeIdx)
								{
									GameplayEvent event;
									event.event = eGE_WeaponFireModeChanged;
									event.value = (float)curFireModeIdx;
									event.description = (const char*)szItemName;
									//eventHandler(pActor,event);
									SendGamePlayEvent(pActor->GetEntity(),event);
								}
							}
						}
					}
				}

				/// Accessories

				int nInvAccessories = pInventory->GetAccessoryCount();

				TAccessoryContainer& Accessories = gstate.Accessories;
				int nRecAccessories = Accessories.size();

				for(int j=0 ; j< nInvAccessories; j++)
//.........这里部分代码省略.........
开发者ID:kitnet,项目名称:project-o,代码行数:101,代码来源:GameStateRecorder.cpp

示例9: GetActorOfName

float CGameStateRecorder::RenderInfo(float y, bool bRecording)
{
	float retY = 0;

	IRenderer *pRenderer = gEnv->pRenderer;

	if (bRecording)
	{
		float fColor[4] = {1,0,0,1};
		pRenderer->Draw2dLabel( 1,y+retY, 1.3f, fColor,false," Recording game state");
		retY +=15;
	}
	else 
	{
		const float xp = 300;
		const float xr = 400;
		const float xri = 600;

		float fColor[4] = {0,1,0,1};
		float fColorWarning[4] = {1,1,0,1};

		const char* actorName = m_demo_actorInfo->GetString();
		CActor *pActor = GetActorOfName(actorName);
		if(pActor)
		{
			pRenderer->Draw2dLabel( 1,y+retY, 1.3f, fColor,false," Game state - Actor: %s --------------------------------------------------",pActor->GetEntity()? pActor->GetEntity()->GetName(): "(no entity)");
			retY +=15;

			if(m_itSingleActorGameState != m_GameStates.end() && pActor->GetEntity() && m_itSingleActorGameState->first == pActor->GetEntity()->GetId())
			{
				ICVar *pVar = gEnv->pConsole->GetCVar( "demo_force_game_state" );
				if(pVar)
				{
					int demo_forceGameState = pVar->GetIVal();
					if(demo_forceGameState)
					{
						pRenderer->Draw2dLabel( 1,y+retY, 1.3f, fColor,false,demo_forceGameState==1 ? 
							" Override mode = (health, suit energy)" : " Override mode = (all)");
						retY +=15;
					}
				}

				pRenderer->Draw2dLabel( xp,y+retY, 1.3f, fColor,false,"Current");
				pRenderer->Draw2dLabel( xr,y+retY, 1.3f, fColor,false,"Recorded");
				retY +=15;

				SActorGameState& gstate = m_itSingleActorGameState->second;
				float recordedHealth = (float)gstate.health;
				float health = (float)pActor->GetHealth();
				bool bError = CHECK_MISMATCH(health, recordedHealth,10);

				pRenderer->Draw2dLabel( 1,y+retY, 1.3f, fColor,false," Health:");
				pRenderer->Draw2dLabel( xp,y+retY, 1.3f, bError? fColorWarning : fColor, false,"%d",(int)health);
				pRenderer->Draw2dLabel( xr,y+retY, 1.3f, bError? fColorWarning : fColor, false,"%d",(int)recordedHealth);
				retY +=15;
				
				// items
				pRenderer->Draw2dLabel( 1,y+retY, 1.3f, fColor,false," Inventory ---------------------------------------------------------------------------------------");
				retY +=15;
				pRenderer->Draw2dLabel( xp,y+retY, 1.3f, fColor,false,"Current");
				pRenderer->Draw2dLabel( xri,y+retY, 1.3f, fColor,false,"Recorded");
				retY +=15;

				CInventory *pInventory = (CInventory*)(pActor->GetInventory());
				if(pInventory)
				{
					int nInvItems = pInventory->GetCount();
						
					TItemContainer& Items = gstate.Items;
					int nRecItems = Items.size();
					int maxItems = max(nRecItems,nInvItems);

					int i=0;
					EntityId curSelectedId = pActor->GetCurrentItemId();
					TItemName curSelClass = GetItemName(curSelectedId);
					bool bSelectedError = !equal_strings(gstate.itemSelected,curSelClass);

					for(; i< nInvItems; i++)
					{
						IItem *pItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem(pInventory->GetItem(i));
						if(pItem)	
						{
							TItemName szItemName = GetItemName(pItem->GetEntityId());

							TItemContainer::iterator it = Items.find(szItemName);
							bError = it==Items.end();
							pRenderer->Draw2dLabel( 1,y+retY, 1.3f, fColor,false," %2d)",i+1);

							EntityId curId = pItem->GetEntityId();
							TItemName curClass = GetItemName(curId);
							if(equal_strings(curClass,curSelClass) )
								pRenderer->Draw2dLabel( xp-16,y+retY, 1.3f,bSelectedError ? fColorWarning:fColor, false, "[]");

							if(equal_strings(szItemName, gstate.itemSelected))
								pRenderer->Draw2dLabel( xri-16,y+retY, 1.3f,bSelectedError ? fColorWarning:fColor, false, "[]");

							char itemName[32];
							const char* originalItemName = pItem->GetEntity() ? pItem->GetEntity()->GetName():"(null)";
							int length = strlen(originalItemName);
							length = min(length,31);
//.........这里部分代码省略.........
开发者ID:kitnet,项目名称:project-o,代码行数:101,代码来源:GameStateRecorder.cpp

示例10: initInventoryScene

void initInventoryScene()
{
	map<uint32, NL3D::UInstance*>::iterator	itu;
	for(itu = InventoryItems.begin(); itu!=InventoryItems.end(); itu++)
	{
		InventoryScene->deleteInstance( (*itu).second);
	}
	InventoryItems.clear();
//	invSelectPS->setPos (0.0f, 0.0f, 0.0f);
//	invSelectPS->setScale( 1.0f, 1.0f, 1.0f );
	if (ShowDebugInChat) nlinfo("InvScene cleared");
	placeInList=0;
	map<uint32,uint8>::iterator	it;
	for(it = CharacterInventory._Inventory.begin(); it!=CharacterInventory._Inventory.end(); it++)
	{
	if (ShowDebugInChat) nlinfo(". %d",placeInList);
		placeInList++;
		if ((*it).second==1)
		{
//			DIT dynamicObject = DynamicObjects.find ((*it).first);
//			CClientDynamicObject	&dynamicObjecta = dynamicObject->second; // hack
//			if (dynamicObjecta.MeshName=="") dynamicObjecta.MeshName = "MagicWand01.shape";
//			UInstance* dynamicInventoryItem = InventoryScene->createInstance( dynamicObjecta.MeshName );
//			dynamicInventoryItem->setPos (-1.0f, 3.5f, placeInList*-0.5f);
//			dynamicInventoryItem->setScale( CVector(0.2f, 0.2f, 0.2f	 ));
//			InventoryItems.insert(make_pair (dynamicObjecta.Id, dynamicInventoryItem));
//			PlaceInInventoryList.insert(make_pair (dynamicObjecta.Id, placeInList));
		}
		else if ((*it).second==2)
		{
			FIT dynamicFirearmObject = Firearms.find ((*it).first);
			CClientFirearm &dynamicFirearmObjecta = dynamicFirearmObject->second; // hack
			if (dynamicFirearmObjecta.MeshName=="") dynamicFirearmObjecta.MeshName = "handgun.shape";
			NL3D::UInstance* dynamicInventoryItem = InventoryScene->createInstance( dynamicFirearmObjecta.MeshName );
			dynamicInventoryItem->setPos (-2.0f, 4.5f, placeInList*-0.4f);
			InventoryItems.insert(make_pair (dynamicFirearmObjecta.Id, dynamicInventoryItem));
			PlaceInInventoryList.insert(make_pair (dynamicFirearmObjecta.Id, placeInList));
		}
		if ((*it).first==CharacterInventory.getSelected())
		{
//			nlinfo("setting select particle system");
//			invSelectPS->show();
//			invSelectPS->setPos (-2.0f, 4.5f, (placeInList*-1.0f)+0.7f);
//			invSelectPS->setScale( 0.3f, 0.3f, 0.3f );
		}

	}
	sendSelectedInInventory( CharacterInventory.getSelected() );
	
}
开发者ID:rbjarnason,项目名称:Mayans,代码行数:50,代码来源:inventory_display.cpp

示例11: updateSelected

void updateSelected()
{
	
	std::map<uint32, NL3D::UInstance*>::iterator	itInvItems;
	std::map<uint32, uint8>::iterator				itInvSelItems;
	itInvItems = InventoryItems.find(CharacterInventory.getSelected());
	if(itInvItems!=InventoryItems.end())
	{
		itInvSelItems = PlaceInInventoryList.find(CharacterInventory.getSelected());
		if(itInvSelItems!=PlaceInInventoryList.end())
		{	
//			invSelectPS->setPos (-2.0f, 4.5f, ((*itInvSelItems).second*-1.0f)+0.7f);
//			nlinfo("Have set inv ps pos %d", (*itInvSelItems).second);
		}
	}
	
}
开发者ID:rbjarnason,项目名称:Mayans,代码行数:17,代码来源:inventory_display.cpp

示例12: displayInventory

void displayInventory()
{

	float	x= 8/800.0f;
	float	y= 8/600.0f;
	float	w=128/800.0f;
	float	h=128/600.0f;	
	_Clicked=0;

	h=(128-42)/600.0f;	

	y=y+.03f;

	uint8 whereInOrder = 0;

	map<uint32,uint8>::iterator	it;
	for(it = CharacterInventory._Inventory.begin(); it!=CharacterInventory._Inventory.end(); it++)
	{
		whereInOrder++;
		string itemname;
		char Buf[20];
		sprintf(Buf, "%d", (*it).first);
		itemname = Buf;

		uint8 itemquantity = (*it).second;

		//nlinfo("displayinv: %s %d",itemname, itemquantity);
		w = 64/800.0f;
		h = 64/600.0f;
		string filename = itemname+"Icon.tga";
//		nlinfo("loading texture: %s",filename);
		

		NL3D::UTexture *iconTexture = Driver->createTextureFile (filename);
//		nlinfo("placing at %f",(1-(h+y)));
		if (iconTexture!=NULL)
		{
	        Driver->setMatrixMode2D ( CFrustum (0.0f, ScreenWidth, 0.0f, ScreenHeight, 0.0f, 1.0f, false));
//			Driver->drawBitmap (10, ScreenHeight-128-10, 128, 128, *iconTexture);
//			Driver->drawBitmap (ScreenWidth-128-10, ScreenHeight-16-10, 128, 16, *iconTexture);
			if ((*it).first == CharacterInventory.getSelected())
			{
//				nlinfo("drawing quad");
//				Driver->setMatrixMode2D11 ();
//				Driver->drawQuad( 0.0149f, 0.96f-(whereInOrder*0.08f), 0.077f, 1.04f-(whereInOrder*0.08f) ,CRGBA(100,0,0,100));
				Driver->drawBitmap (15, ScreenHeight-24-(whereInOrder*72), 64, 64, *SelectedTexture);				
			//	nlinfo("xLeft %f yBottom %f xRight %f yTop %f", xLeft,yBottom,xRight,yTop);
//				0.1 0.8, 0.2, 0.9
			}
			Driver->drawBitmap (15, ScreenHeight-24-(whereInOrder*72), 64, 64, *iconTexture);
//			nlinfo("drawBitmap at x %f y %f", x, y);
		//_ClickMap[(1-(h+y))]=(*it).first;
		}
//		if ((*it).first == CharacterInventory.getSelected()) TextContext->setColor(CRGBA(255,0,255,255));
//		else TextContext->setColor(CRGBA(255,255,255,255));
//		TextContext->printfAt(x+.03f+w/2.0f,1.0f-h-y+.01f,"%d %s", itemquantity, itemname);
		y=y+.07f;		
//		nlinfo("outof loop");
	}

	if(_Clicked)
	{
		float	x= 8/800.0f;
		float	y= 8/600.0f;
		float	w=128/800.0f;
		float	h=128/600.0f;
		
		y=y+.03f;
		w = 32/800.0f;
		h = 32/600.0f;

		string itemname = "";
		string filename = itemname+"Icon.tga";
//		uint32 itemquantity = CharacterInventory.getInventory()[_Clicked];
//		NL3D::UTexture *iconTexture = Driver->createTextureFile (filename);
//		Driver->drawBitmap (x, 1-(h+y), w, h, *iconTexture);
//		TextContext->printfAt(x+.02f+w/2.0f,(1.0f-h-y+.01f)+0.03f,"%d %s", itemquantity, itemname);
	}

}
开发者ID:rbjarnason,项目名称:Mayans,代码行数:80,代码来源:inventory_display.cpp


注:本文中的CInventory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。