本文整理汇总了C++中IUIElement类的典型用法代码示例。如果您正苦于以下问题:C++ IUIElement类的具体用法?C++ IUIElement怎么用?C++ IUIElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IUIElement类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetElement
//------------------------------------------------------------------------
int CScriptBind_UIAction::GetVariable( IFunctionHandler *pH, const char * elementName, int instanceID, const char* varName )
{
IUIElement* pElement = GetElement( elementName, instanceID );
if ( pElement )
{
const SUIParameterDesc* pVarDesc = pElement->GetVariableDesc( varName );
if ( pVarDesc )
{
TUIData value;
if ( pElement->GetVariable( pVarDesc, value ) )
{
bool ok;
ScriptAnyValue res = SUIToLuaConversationHelper::UIValueToLuaValue(value, ok);
if (!ok)
{
UIACTION_WARNING( "LUA: Error reading variable %s from UI Element %s", varName, elementName );
}
return pH->EndFunctionAny( res );
}
}
UIACTION_WARNING( "LUA: Element %s has no variable %s", elementName, varName );
}
else
{
UIACTION_WARNING( "LUA: UIElement %s does not exist", elementName );
}
return pH->EndFunction( false );
}
示例2: CRY_ASSERT_MESSAGE
//------------------------------------------------------------------------
IUIElement* CScriptBind_UIAction::GetElement( const char* sName, int instanceID, bool bSupressWarning )
{
if (gEnv->IsDedicated())
return NULL;
CRY_ASSERT_MESSAGE( gEnv->pFlashUI, "FlashUI extension does not exist!" );
if ( !gEnv->pFlashUI )
{
UIACTION_WARNING( "LUA: FlashUI extension does not exist!" );
return NULL;
}
IUIElement* pElement = gEnv->pFlashUI->GetUIElement( sName );
if ( pElement && instanceID > 0)
pElement = pElement->GetInstance( instanceID );
if (pElement && pElement->IsValid())
return pElement;
if (!bSupressWarning)
{
UIACTION_WARNING( "LUA: Try to access UIElement %s that is not valid!", sName );
}
return NULL;
}
示例3: UIACTION_WARNING
//------------------------------------------------------------------------
int CScriptBind_UIAction::CallFunction( IFunctionHandler *pH, const char * elementName, int instanceID, const char* functionName )
{
SUIArguments args;
if (!SUIToLuaConversationHelper::LuaArgsToUIArgs(pH, 4, args))
{
UIACTION_WARNING( "LUA: Failed to call function %s on element %s: Invalid arguments", functionName, elementName );
return pH->EndFunction(false);
}
IUIElement* pElement = GetElement( elementName, instanceID, true );
if ( pElement )
{
const SUIEventDesc* pFctDesc = pElement->GetFunctionDesc( functionName );
if ( pFctDesc )
{
TUIData res;
bool bFctOk = true;
if ( instanceID < 0 )
{
IUIElementIteratorPtr elements = pElement->GetInstances();
while ( IUIElement* pInstance = elements->Next() )
bFctOk &= pInstance->CallFunction( pFctDesc, args, &res);
}
else
{
bFctOk = pElement->CallFunction( pFctDesc, args, &res);
}
if ( bFctOk )
{
string sRes;
res.GetValueWithConversion( sRes );
return pH->EndFunction( sRes.c_str() );
}
}
UIACTION_WARNING( "LUA: UIElement %s does not have function %s", elementName, functionName );
}
else if (IUIEventSystem* pEventSystem = GetEventSystem( elementName, IUIEventSystem::eEST_UI_TO_SYSTEM ))
{
uint eventid = pEventSystem->GetEventId( functionName );
if ( eventid != ~0 )
{
SUIArguments res = pEventSystem->SendEvent( SUIEvent( eventid, args ) );
SmartScriptTable table = gEnv->pScriptSystem->CreateTable();
SUIToLuaConversationHelper::UIArgsToLuaTable(res, table);
return pH->EndFunction( table );
}
UIACTION_WARNING( "LUA: UIEventSystem %s does not have event %s", elementName, functionName );
}
else
{
UIACTION_WARNING( "LUA: UIElement or UIEventSystem %s does not exist", elementName );
}
return pH->EndFunction(false);
}
示例4: UIACTION_ERROR
//------------------------------------------------------------------------
int CScriptBind_UIAction::SetVariable( IFunctionHandler *pH, const char * elementName, int instanceID, const char* varName )
{
if (pH->GetParamCount() != 4)
{
UIACTION_ERROR( "LUA: UIAction.SetVariable - wrong number of arguments!");
return pH->EndFunction(false);
}
IUIElement* pElement = GetElement( elementName, instanceID );
if ( pElement )
{
const SUIParameterDesc* pVarDesc = pElement->GetVariableDesc( varName );
if ( pVarDesc )
{
bool bRet = true;
TUIData value;
if (SUIToLuaConversationHelper::LuaArgToUIArg(pH, 4, value))
{
bool bVarOk = true;
if ( instanceID < 0 )
{
IUIElementIteratorPtr elements = pElement->GetInstances();
while ( IUIElement* pInstance = elements->Next() )
bVarOk &= pInstance->SetVariable( pVarDesc, value );
}
else
{
bVarOk = pElement->SetVariable( pVarDesc, value );
}
if ( bVarOk )
return pH->EndFunction(true);
else
{
UIACTION_WARNING( "LUA: Element %s has no variable %s", elementName, varName );
}
}
else
{
UIACTION_WARNING( "LUA: Element %s: wrong datatype for variable %s", elementName, varName );
}
}
else
{
UIACTION_WARNING( "LUA: Element %s has no variable %s", elementName, varName );
}
}
else
{
UIACTION_WARNING( "LUA: UIElement %s does not exist", elementName );
}
return pH->EndFunction(false);
}
示例5: OnRemoveTaggedEntity
void CUIEntityDynTexTag::OnAddTaggedEntity(EntityId entityId, const char *uiElementName, const char *entityClass, const char *materialTemplate, const Vec3 &offset, const char *idx)
{
OnRemoveTaggedEntity(entityId, idx);
IEntityClass *pEntClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass(entityClass);
if(pEntClass)
{
SEntitySpawnParams params;
params.nFlags = ENTITY_FLAG_CLIENT_ONLY;
params.pClass = pEntClass;
IEntity *pTagEntity = gEnv->pEntitySystem->SpawnEntity(params);
IUIElement *pElement = gEnv->pFlashUI->GetUIElement(uiElementName);
if(pTagEntity && pElement)
{
IMaterial *pMatTemplate = gEnv->p3DEngine->GetMaterialManager()->LoadMaterial(materialTemplate, false);
if(pMatTemplate && pMatTemplate->GetShaderItem().m_pShaderResources->GetTexture(0))
{
pMatTemplate->GetShaderItem().m_pShaderResources->GetTexture(0)->m_Name.Format("%[email protected]%d.ui", uiElementName, entityId);
IMaterial *pMat = gEnv->p3DEngine->GetMaterialManager()->CloneMaterial(pMatTemplate);
pTagEntity->SetMaterial(pMat);
}
IEntityRenderProxy *pRenderProxy = (IEntityRenderProxy *) pTagEntity->GetProxy(ENTITY_PROXY_RENDER);
if(pRenderProxy)
{
IRenderNode *pRenderNode = pRenderProxy->GetRenderNode();
if(pRenderNode)
{
pRenderNode->SetViewDistRatio(256);
}
}
pElement->RemoveEventListener(this); // first remove to avoid assert if already registered!
pElement->AddEventListener(this, "CUIEntityDynTexTag");
gEnv->pEntitySystem->AddEntityEventListener(entityId, ENTITY_EVENT_DONE, this);
m_Tags.push_back(STagInfo(entityId, pTagEntity->GetId(), idx, offset, pElement->GetInstance((uint)entityId)));
}
}
}
示例6: switch
void CFlowSetupModelPostRender::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
switch (event)
{
case eFE_Initialize:
break;
case eFE_Activate:
if (IsPortActive(pActInfo, IN_SHUTDOWN))
{
CMenuRender3DModelMgr::Release(true);
ITexture *tex = NULL;
//unbind tex from MC
if(gEnv->pConsole->GetCVar("r_UsePersistentRTForModelHUD")->GetIVal() > 0)
tex = gEnv->pRenderer->EF_LoadTexture("$ModelHUD");
else
tex = gEnv->pRenderer->EF_LoadTexture("$BackBuffer");
IUIElement* pElement = pFlashUI->GetUIElement(sUIElement.c_str());
IUIElement* pUIElement = pElement ? pElement->GetInstance(0) : NULL;
if(pUIElement)
pUIElement->UnloadTexFromMc(sMovieClipName.c_str(), tex);
return;
}
if (IsPortActive(pActInfo, IN_START))
{
INDENT_LOG_DURING_SCOPE();
// Setup scene settings
CMenuRender3DModelMgr::SSceneSettings sceneSettings;
sceneSettings.fovScale = 0.85f;
sceneSettings.fadeInSpeed = 0.01f;
sceneSettings.flashEdgeFadeScale = 0.0f;
sceneSettings.ambientLight = Vec4(GetPortVec3(pActInfo, IN_AMBIENTLIGHTCOLOR), GetPortFloat(pActInfo, IN_AMBIENTLIGHTSTRENGTH));
sceneSettings.lights.resize(3);
sceneSettings.lights[0].pos.Set(-25.f, -10.f, 30.f);
sceneSettings.lights[0].color = GetPortVec3(pActInfo, IN_LIGHTCOLOR1);
sceneSettings.lights[0].specular = 4.f;
sceneSettings.lights[0].radius = 400.f;
sceneSettings.lights[1].pos.Set(25.f, -4.f, 30.f);
sceneSettings.lights[1].color = GetPortVec3(pActInfo, IN_LIGHTCOLOR2);
sceneSettings.lights[1].specular = 10.f;
sceneSettings.lights[1].radius = 400.f;
sceneSettings.lights[2].pos.Set(60.f, 40.f, 10.f);
sceneSettings.lights[2].color = GetPortVec3(pActInfo, IN_LIGHTCOLOR3);
sceneSettings.lights[2].specular = 10.f;
sceneSettings.lights[2].radius = 400.f;
//Create scene
CMenuRender3DModelMgr *renderModels = new CMenuRender3DModelMgr();
renderModels->SetSceneSettings(sceneSettings);
ITexture *tex = NULL;
//Fetch texture and send to movieclip
if(gEnv->pConsole->GetCVar("r_UsePersistentRTForModelHUD")->GetIVal() > 0)
tex = gEnv->pRenderer->EF_LoadTexture("$ModelHUD");
else
tex = gEnv->pRenderer->EF_LoadTexture("$BackBuffer");
string sStr = GetPortString(pActInfo, IN_MC);
string::size_type sPos = sStr.find( ':' );
sUIElement = sStr.substr( 0, sPos );
sMovieClipName = sStr.substr( sPos + 1 );
IUIElement* pElement = pFlashUI->GetUIElement(sUIElement.c_str());
IUIElement* pUIElement = pElement ? pElement->GetInstance(0) : NULL;
if(pUIElement)
pUIElement->LoadTexIntoMc(sMovieClipName.c_str(), tex);
else
CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "CFlowAdd3DModelToHUD: Movieclip not found");
//check debug info
float debugscale = GetPortFloat(pActInfo, IN_DEBUGSCALE);
ICVar* cv_debugRender = gEnv->pConsole->GetCVar("g_post3DRendererDebug");
if(debugscale > 0.0f)
{
if(cv_debugRender)
{
cv_debugRender->Set(2);
CMenuRender3DModelMgr::GetInstance()->SetDebugScale(debugscale);
}
}
else
{
cv_debugRender->Set(0);
}
}
break;
}
}
示例7: HandleFSCommand
void CHUDInventory::HandleFSCommand(const char *strCommand,const char *strArgs, void* pUserData)
{
if(!strcmp(strCommand,"itemPressed"))
{
EntityId id = static_cast<EntityId>(atoi(strArgs));
if(id>=1)
{
CActor *pActor=static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
if(IItem *pItem = gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(id))
{
if (pItem->CanSelect())
{
CItem *pItemii = static_cast<CItem*>(gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(id));
if(!pItemii->IsSelected())
{
pActor->SelectItem(id,true,true);
}
}
}
}
}
if(!strcmp(strCommand,"slotChanged"))
{
SUIArguments args;
args.SetDelimiter(",");
args.SetArguments(strArgs);
int oldSlotID;
int slotID;
int itemID;
args.GetArg(0, oldSlotID);
args.GetArg(1, slotID);
args.GetArg(2, itemID);
for(int i = 0; i<inventoryItems.size(); i++)
{
if(inventoryItems[i].itemID == itemID)
{
//CryLog("ID find in items, changing slotID....");
inventoryItems[i].slotID = slotID;
}
}
}
if(!strcmp(strCommand,"dropItem"))
{
EntityId itemID = static_cast<EntityId>(atoi(strArgs));
CItem *curItem = static_cast<CItem*>(gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(itemID));
curItem->Drop(1.f,false,false);
//CryLog("Drop item = %d", itemID);
for(int i = 0; i<inventoryItems.size(); i++)
{
if(inventoryItems[i].itemID == itemID)
{
SFlashVarValue args[1] = {inventoryItems[i].slotID};
IUIElement* pElement = gEnv->pFlashUI->GetUIElement("Inventory");
pElement->GetFlashPlayer()->Invoke("removeInventoryItem", args, 1);
}
}
}
}
示例8: ShowInventory
void CHUDInventory::ShowInventory()
{
IUIElement* pElement = gEnv->pFlashUI->GetUIElement("Inventory");
if(pElement)
{
if(!Inv_loaded)
{
pElement->Reload();
pElement->GetFlashPlayer()->SetVisible(true);
pElement->SetVisible(true);
CActor *pActor = static_cast<CActor *>(gEnv->pGame->GetIGameFramework()->GetClientActor());
IInventory *pInventory = pActor->GetInventory();
g_pGame->Actions().FilterNoMouse()->Enable(true);
for (int i = 0; i < pInventory->GetCount(); i++)
{
EntityId ide = pInventory->GetItem(i);
EntityId slotID = pActor->GetInventory()->FindItem(ide);
CItem *curItem = static_cast<CItem*>(gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(ide));
IItem *pItem = static_cast<IItem*>(gEnv->pGame->GetIGameFramework()->GetIItemSystem()->GetItem(ide));
CItem::SInventotyInfo info = curItem->GetInventoryInfo();
//int slotID;
EntityId itemID = pItem->GetEntityId();
itemsSaved = false;
for(int i = 0; i<inventoryItems.size(); i++)
{
if(inventoryItems[i].itemID == itemID)
{
//CryLog("Items finded in saved items");
slotID = inventoryItems[i].slotID;
itemsSaved = true;
break;
}
}
if(!itemsSaved)
slotID--;
SFlashVarValue args[8] = {slotID, info.iconName.c_str(), itemID, info.itemName.c_str(), info.itemDescription.c_str(), 0, info.canStack, info.canQuick};
if(info.itemClass)
{
pElement->GetFlashPlayer()->Invoke("addInventoryItem", args, 8);
if(!itemsSaved)
{
SInventoryItem inventoryItem;
inventoryItem.itemName = info.itemName.c_str();
inventoryItem.itemID = itemID;
inventoryItem.slotID = slotID++;
inventoryItem.itemAmmount = 0;
inventoryItem.canStack = info.canStack;
inventoryItems.push_back(inventoryItem);
}
}
}
pElement->GetFlashPlayer()->SetFSCommandHandler(this);
Inv_loaded = true;
}
else
{
g_pGame->Actions().FilterNoMouse()->Enable(false);
pElement->SetVisible(false);
pElement->GetFlashPlayer()->SetVisible(false);
pElement->GetFlashPlayer()->SetFSCommandHandler(NULL);
Inv_loaded = false;
}
}
else
CryLog("CHUDInventory::Error open inventory!");
}
示例9: ProcessEvent
virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
switch (event)
{
case eFE_Initialize:
break;
case eFE_Activate:
IGameFramework* pGameFramework = gEnv->pGame->GetIGameFramework();
if(IsPortActive(pActInfo, EIP_Cast))
{
// setup ray + optionally skip 1 entity
ray_hit rayHit;
static const float maxRayDist = 100.f;
const unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any;
IPhysicalEntity *skipList[1];
int skipCount = 0;
IEntity* skipEntity = gEnv->pEntitySystem->GetEntity(GetPortEntityId(pActInfo, EIP_SkipEntity));
if(skipEntity)
{
skipList[0] = skipEntity->GetPhysics();
skipCount = 1;
}
Vec3 rayPos = GetPortVec3(pActInfo, EIP_RayPos);
Vec3 rayDir = GetPortVec3(pActInfo, EIP_RayDir);
// Check if the ray hits an entity
if(gEnv->pSystem->GetIPhysicalWorld()->RayWorldIntersection(rayPos, rayDir * 100, ent_all, flags, &rayHit, 1, skipList, skipCount))
{
int type = rayHit.pCollider->GetiForeignData();
if (type == PHYS_FOREIGN_ID_ENTITY)
{
IEntity* pEntity = (IEntity*)rayHit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY);
IEntityRenderProxy* pRenderProxy = pEntity ? (IEntityRenderProxy*)pEntity->GetProxy(ENTITY_PROXY_RENDER) : 0;
// Get the renderproxy, and use it to check if the material is a DynTex, and get the UIElement if so
if(pRenderProxy)
{
IRenderNode *pRenderNode = pRenderProxy->GetRenderNode();
IMaterial* pMaterial = pRenderProxy->GetRenderMaterial();
SEfResTexture* texture = 0;
if(pMaterial && pMaterial->GetShaderItem().m_pShaderResources)
texture= pMaterial->GetShaderItem().m_pShaderResources->GetTexture(EFTT_DIFFUSE);
IUIElement* pElement = texture ? gEnv->pFlashUI->GetUIElementByInstanceStr(texture->m_Name) : 0;
if(pElement && pRenderNode)
{
int m_dynTexGeomSlot = 0;
IStatObj* pObj = pRenderNode->GetEntityStatObj(m_dynTexGeomSlot);
// result
bool hasHit = false;
Vec2 uv0, uv1, uv2;
Vec3 p0, p1, p2;
Vec3 hitpos;
// calculate ray dir
CCamera cam = gEnv->pRenderer->GetCamera();
if (pEntity->GetSlotFlags(m_dynTexGeomSlot) & ENTITY_SLOT_RENDER_NEAREST)
{
ICVar *r_drawnearfov = gEnv->pConsole->GetCVar("r_DrawNearFoV");
assert(r_drawnearfov);
cam.SetFrustum(cam.GetViewSurfaceX(),cam.GetViewSurfaceZ(),DEG2RAD(r_drawnearfov->GetFVal()),cam.GetNearPlane(),cam.GetFarPlane(), cam.GetPixelAspectRatio());
}
Vec3 vPos0 = rayPos;
Vec3 vPos1 = rayPos + rayDir;
// translate into object space
const Matrix34 m = pEntity->GetWorldTM().GetInverted();
vPos0 = m * vPos0;
vPos1 = m * vPos1;
// walk through all sub objects
const int objCount = pObj->GetSubObjectCount();
for (int obj = 0; obj <= objCount && !hasHit; ++obj)
{
Vec3 vP0, vP1;
IStatObj* pSubObj = NULL;
if (obj == objCount)
{
vP0 = vPos0;
vP1 = vPos1;
pSubObj = pObj;
}
else
{
IStatObj::SSubObject* pSub = pObj->GetSubObject(obj);
const Matrix34 mm = pSub->tm.GetInverted();
vP0 = mm * vPos0;
vP1 = mm * vPos1;
pSubObj = pSub->pStatObj;
}
IRenderMesh* pMesh = pSubObj ? pSubObj->GetRenderMesh() : NULL;
if (pMesh)
//.........这里部分代码省略.........