MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / CallFunction

Method CallFunction

Code/CryEngine/CryAction/FlashUI/ScriptBind_UIAction.cpp:262–315  ·  view source on GitHub ↗

------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

260
261//------------------------------------------------------------------------
262int CScriptBind_UIAction::CallFunction(IFunctionHandler* pH, const char* elementName, int instanceID, const char* functionName)
263{
264 SUIArguments args;
265 if (!SUIToLuaConversationHelper::LuaArgsToUIArgs(pH, 4, args))
266 {
267 UIACTION_WARNING("LUA: Failed to call function %s on element %s: Invalid arguments", functionName, elementName);
268 return pH->EndFunction(false);
269 }
270
271 IUIElement* pElement = GetElement(elementName, instanceID, true);
272 if (pElement)
273 {
274 const SUIEventDesc* pFctDesc = pElement->GetFunctionDesc(functionName);
275 if (pFctDesc)
276 {
277 TUIData res;
278 bool bFctOk = true;
279 if (instanceID < 0)
280 {
281 IUIElementIteratorPtr elements = pElement->GetInstances();
282 while (IUIElement* pInstance = elements->Next())
283 bFctOk &= pInstance->CallFunction(pFctDesc, args, &res);
284 }
285 else
286 {
287 bFctOk = pElement->CallFunction(pFctDesc, args, &res);
288 }
289 if (bFctOk)
290 {
291 string sRes;
292 res.GetValueWithConversion(sRes);
293 return pH->EndFunction(sRes.c_str());
294 }
295 }
296 UIACTION_WARNING("LUA: UIElement %s does not have function %s", elementName, functionName);
297 }
298 else if (IUIEventSystem* pEventSystem = GetEventSystem(elementName, IUIEventSystem::eEST_UI_TO_SYSTEM))
299 {
300 uint eventid = pEventSystem->GetEventId(functionName);
301 if (eventid != ~0)
302 {
303 SUIArguments res = pEventSystem->SendEvent(SUIEvent(eventid, args));
304 SmartScriptTable table = gEnv->pScriptSystem->CreateTable();
305 SUIToLuaConversationHelper::UIArgsToLuaTable(res, table);
306 return pH->EndFunction(table);
307 }
308 UIACTION_WARNING("LUA: UIEventSystem %s does not have event %s", elementName, functionName);
309 }
310 else
311 {
312 UIACTION_WARNING("LUA: UIElement or UIEventSystem %s does not exist", elementName);
313 }
314 return pH->EndFunction(false);
315}
316
317//------------------------------------------------------------------------
318int CScriptBind_UIAction::SetVariable(IFunctionHandler* pH, const char* elementName, int instanceID, const char* varName)

Callers

nothing calls this directly

Calls 10

SUIEventClass · 0.85
GetInstancesMethod · 0.80
CreateTableMethod · 0.80
EndFunctionMethod · 0.45
GetFunctionDescMethod · 0.45
NextMethod · 0.45
c_strMethod · 0.45
GetEventIdMethod · 0.45
SendEventMethod · 0.45

Tested by

no test coverage detected