本文整理汇总了C++中IUIElement::GetInstances方法的典型用法代码示例。如果您正苦于以下问题:C++ IUIElement::GetInstances方法的具体用法?C++ IUIElement::GetInstances怎么用?C++ IUIElement::GetInstances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUIElement
的用法示例。
在下文中一共展示了IUIElement::GetInstances方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CallFunction
//------------------------------------------------------------------------
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);
}
示例2: SetVariable
//------------------------------------------------------------------------
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);
}
示例3: RequestHide
//------------------------------------------------------------------------
int CScriptBind_UIAction::RequestHide( IFunctionHandler *pH, const char * elementName, int instanceID )
{
IUIElement* pElement = GetElement( elementName, instanceID );
if ( pElement )
{
if ( instanceID < 0 )
{
IUIElementIteratorPtr elements = pElement->GetInstances();
while ( IUIElement* pInstance = elements->Next() )
pInstance->RequestHide();
}
else
{
pElement->RequestHide();
}
return pH->EndFunction( true );
}
UIACTION_WARNING( "LUA: UIElement %s does not exist", elementName );
return pH->EndFunction( false );
}
示例4: SetArray
//------------------------------------------------------------------------
int CScriptBind_UIAction::SetArray( IFunctionHandler *pH, const char * elementName, int instanceID, const char* arrayName, SmartScriptTable values )
{
IUIElement* pElement = GetElement( elementName, instanceID );
if ( pElement )
{
const SUIParameterDesc* pArrayDesc = pElement->GetArrayDesc( arrayName );
if ( pArrayDesc )
{
SUIArguments vals;
if (SUIToLuaConversationHelper::LuaTableToUIArgs(values, vals))
{
bool bVarOk = true;
if ( instanceID < 0 )
{
IUIElementIteratorPtr elements = pElement->GetInstances();
while ( IUIElement* pInstance = elements->Next() )
bVarOk &= pInstance->SetArray( pArrayDesc, vals );
}
else
{
bVarOk = pElement->SetArray( pArrayDesc, vals );
}
if ( bVarOk )
return pH->EndFunction(true);
}
UIACTION_ERROR( "LUA: Failed to set array %s on Element %s: Invalid arguments", arrayName, elementName);
}
UIACTION_WARNING( "LUA: Element %s has no array %s", elementName, arrayName);
}
else
{
UIACTION_WARNING( "LUA: UIElement %s does not exist", elementName);
}
return pH->EndFunction(false);
}