BVB Source Codes

CRYENGINE Show ScriptBind_UIAction.h Source code

Return Download CRYENGINE: download ScriptBind_UIAction.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   ScriptBind_UIAction.h
  5. //  Version:     v1.00
  6. //  Created:     10/9/2010 by Paul Reindell.
  7. //  Description:
  8. // -------------------------------------------------------------------------
  9. //  History:
  10. //
  11. ////////////////////////////////////////////////////////////////////////////
  12. #ifndef __SCRIPTBIND_UIACTION_H__
  13. #define __SCRIPTBIND_UIACTION_H__
  14.  
  15. #pragma once
  16.  
  17. #include <CryScriptSystem/IScriptSystem.h>
  18. #include <CryScriptSystem/ScriptHelpers.h>
  19. #include <CrySystem/Scaleform/IFlashUI.h>
  20. #include <CryCore/Containers/CryListenerSet.h>
  21.  
  22. ////////////////////////////////////////////////////////////////////////////
  23. ////////////////////////////////////////////////////////////////////////////
  24. ////////////////////////////////////////////////////////////////////////////
  25. struct SUIToLuaConversationHelper
  26. {
  27.         static ScriptAnyValue UIValueToLuaValue(const TUIData& value, bool& ok);
  28.         static bool           LuaTableToUIArgs(SmartScriptTable table, SUIArguments& args);
  29.         static bool           LuaArgsToUIArgs(IFunctionHandler* pH, int startIdx, SUIArguments& args);
  30.         static bool           LuaArgToUIArg(IFunctionHandler* pH, int idx, TUIData& value);
  31.         static bool           UIArgsToLuaTable(const SUIArguments& args, SmartScriptTable table);
  32. };
  33.  
  34. ////////////////////////////////////////////////////////////////////////////
  35. ////////////////////////////////////////////////////////////////////////////
  36. ////////////////////////////////////////////////////////////////////////////
  37. template<class T> struct SUILuaCallbackInfo
  38. {
  39.         bool Accept(const SUILuaCallbackInfo<T>& info) const                                                                                { assert(false); return false; }
  40.         void CallScript(SmartScriptTable pScript, const char* functionName, SmartScriptTable args, const SUILuaCallbackInfo<T>& info) const { assert(false); }
  41. };
  42.  
  43. ////////////////////////////////////////////////////////////////////////////
  44. template<class T>
  45. struct SUILuaCallbackData
  46. {
  47.         SUILuaCallbackData(SmartScriptTable pTable, int id, const char* functionName, const SUILuaCallbackInfo<T>& cbinfo)
  48.                 : pScriptTable(pTable)
  49.                 , Id(id)
  50.                 , fctName(functionName)
  51.                 , info(cbinfo)
  52.         {
  53.         }
  54.         int                   Id;
  55.         SmartScriptTable      pScriptTable;
  56.         string                fctName;
  57.         SUILuaCallbackInfo<T> info;
  58. };
  59.  
  60. ////////////////////////////////////////////////////////////////////////////
  61. struct SUISUILuaCallbackDataId
  62. {
  63.         static int GetNextId()
  64.         {
  65.                 static int id = 0;
  66.                 ++id;
  67.                 assert(id > 0);
  68.                 return id;
  69.         }
  70. };
  71.  
  72. template<class T>
  73. struct SUILuaCallbackContainer : public SUISUILuaCallbackDataId
  74. {
  75.         SUILuaCallbackContainer() : m_Callbacks(10) {}
  76.         bool AddCallback(SmartScriptTable pTable, const char* functionName, const SUILuaCallbackInfo<T>& cbinfo)
  77.         {
  78.                 int id = -1;
  79.                 pTable->GetValue("__ui_callback_id", id);
  80.                 if (id > -1)
  81.                 {
  82.                         for (typename TCallbacks::Notifier it(m_Callbacks); it.IsValid(); it.Next())
  83.                         {
  84.                                 SUILuaCallbackData<T>* pListener = *it;
  85.                                 if (pListener->Id == id && pListener->fctName == functionName && pListener->info.Accept(cbinfo))
  86.                                         return false;
  87.                         }
  88.                 }
  89.                 else
  90.                 {
  91.                         id = GetNextId();
  92.                         pTable->SetValue("__ui_callback_id", id);
  93.                 }
  94.                 m_Callbacks.Add(new SUILuaCallbackData<T>(pTable, id, functionName, cbinfo));
  95.                 return true;
  96.         }
  97.  
  98.         bool RemoveCallbacks(SmartScriptTable pTable, const char* functionName = "")
  99.         {
  100.                 bool bErased = false;
  101.                 int id = -1;
  102.                 pTable->GetValue("__ui_callback_id", id);
  103.                 if (id > -1)
  104.                 {
  105.                         for (typename TCallbacks::Notifier it(m_Callbacks); it.IsValid(); it.Next())
  106.                         {
  107.                                 SUILuaCallbackData<T>* pListener = *it;
  108.                                 assert(pListener);
  109.                                 PREFAST_ASSUME(pListener);
  110.                                 if (pListener->Id == id && (strlen(functionName) == 0 || pListener->fctName == functionName))
  111.                                 {
  112.                                         m_Callbacks.Remove(pListener);
  113.                                         delete pListener;
  114.                                 }
  115.                         }
  116.                 }
  117.                 return bErased;
  118.         }
  119.  
  120.         bool IsEnabled(SmartScriptTable pTable)
  121.         {
  122.                 bool bEnabled = true;
  123.                 const char* name;
  124.                 if (pTable->GetValue("__ui_action_name", name) && strlen(name) > 0)
  125.                         bEnabled &= pTable->GetValue("enabled", bEnabled);
  126.                 return bEnabled;
  127.         }
  128.  
  129.         void ClearCallbacks()
  130.         {
  131.                 for (typename TCallbacks::Notifier it(m_Callbacks); it.IsValid(); it.Next())
  132.                         delete *it;
  133.                 m_Callbacks.Clear();
  134.         }
  135.  
  136. protected:
  137.         void NotifyEvent(const SUILuaCallbackInfo<T>& cbinfo, const SUIArguments& args = SUIArguments())
  138.         {
  139.                 SmartScriptTable table = gEnv->pScriptSystem->CreateTable();
  140.                 SUIToLuaConversationHelper::UIArgsToLuaTable(args, table);
  141.  
  142.                 for (typename TCallbacks::Notifier it(m_Callbacks); it.IsValid(); it.Next())
  143.                 {
  144.                         SUILuaCallbackData<T>* pListener = *it;
  145.                         if (pListener->info.Accept(cbinfo) && IsEnabled(pListener->pScriptTable))
  146.                                 pListener->info.CallScript(pListener->pScriptTable, pListener->fctName, table, cbinfo);
  147.                 }
  148.         }
  149.  
  150. private:
  151.         typedef CListenerSet<SUILuaCallbackData<T>*> TCallbacks;
  152.         TCallbacks m_Callbacks;
  153. };
  154.  
  155. ////////////////////////////////////////////////////////////////////////////
  156. /////////////////////////////// IUIElement /////////////////////////////////
  157. ////////////////////////////////////////////////////////////////////////////
  158. template<>
  159. struct SUILuaCallbackInfo<IUIElement>
  160. {
  161.         static SUILuaCallbackInfo<IUIElement> CreateInfo(IUIElement* pElement, const char* eventName, int instanceId = -2)
  162.         {
  163.                 assert(pElement);
  164.                 PREFAST_ASSUME(pElement);
  165.                 SUILuaCallbackInfo<IUIElement> res;
  166.                 res.eventName = eventName;
  167.                 res.elementName = pElement->GetName();
  168.                 res.instanceId = instanceId > -2 ? instanceId : pElement->GetInstanceID();
  169.                 return res;
  170.         }
  171.  
  172.         bool Accept(const SUILuaCallbackInfo<IUIElement>& info) const
  173.         {
  174.                 return (elementName == "" || info.elementName == elementName) && (eventName == "" || info.eventName == eventName) && (instanceId == -1 || instanceId == info.instanceId);
  175.         }
  176.  
  177.         void CallScript(SmartScriptTable pScript, const char* functionName, SmartScriptTable args, const SUILuaCallbackInfo<IUIElement>& info) const
  178.         {
  179.                 Script::CallMethod(pScript, functionName, info.elementName.c_str(), info.instanceId, info.eventName.c_str(), args);
  180.         }
  181.  
  182.         int    instanceId;
  183.         string eventName;
  184.         string elementName;
  185. };
  186.  
  187. ////////////////////////////////////////////////////////////////////////////
  188. struct SUIElementLuaCallback : public SUILuaCallbackContainer<IUIElement>, public IUIElementEventListener
  189. {
  190.         ~SUIElementLuaCallback();
  191.  
  192.         void         Init(IUIElement* pElement);
  193.         void         Clear();
  194.  
  195.         virtual void OnUIEvent(IUIElement* pSender, const SUIEventDesc& event, const SUIArguments& args);
  196.         virtual void OnUIEventEx(IUIElement* pSender, const char* fscommand, const SUIArguments& args, void* pUserData);
  197.  
  198.         virtual void OnInit(IUIElement* pSender, IFlashPlayer* pFlashPlayer);
  199.         virtual void OnUnload(IUIElement* pSender);
  200.         virtual void OnSetVisible(IUIElement* pSender, bool bVisible);
  201.  
  202.         virtual void OnInstanceCreated(IUIElement* pSender, IUIElement* pNewInstance);
  203.         virtual void OnInstanceDestroyed(IUIElement* pSender, IUIElement* pDeletedInstance);
  204. };
  205.  
  206. ////////////////////////////////////////////////////////////////////////////
  207. //////////////////////////////// IUIAction /////////////////////////////////
  208. ////////////////////////////////////////////////////////////////////////////
  209. template<>
  210. struct SUILuaCallbackInfo<IUIAction>
  211. {
  212.         static SUILuaCallbackInfo<IUIAction> CreateInfo(IUIAction* pAction, const char* eventName)
  213.         {
  214.                 SUILuaCallbackInfo<IUIAction> res;
  215.                 res.eventName = eventName;
  216.                 res.actionName = pAction ? pAction->GetName() : "";
  217.                 return res;
  218.         }
  219.  
  220.         bool Accept(const SUILuaCallbackInfo<IUIAction>& info) const
  221.         {
  222.                 return (actionName == "" || info.actionName == actionName) && (eventName == "" || info.eventName == eventName);
  223.         }
  224.  
  225.         void CallScript(SmartScriptTable pScript, const char* functionName, SmartScriptTable args, const SUILuaCallbackInfo<IUIAction>& info) const
  226.         {
  227.                 Script::CallMethod(pScript, functionName, info.actionName.c_str(), info.eventName.c_str(), args);
  228.         }
  229.  
  230.         string eventName;
  231.         string actionName;
  232. };
  233.  
  234. struct SUIActionLuaCallback : public SUILuaCallbackContainer<IUIAction>, public IUIActionListener
  235. {
  236.         SUIActionLuaCallback();
  237.         ~SUIActionLuaCallback();
  238.  
  239.         void         Clear();
  240.  
  241.         virtual void OnStart(IUIAction* pAction, const SUIArguments& args);
  242.         virtual void OnEnd(IUIAction* pAction, const SUIArguments& args);
  243. };
  244.  
  245. ////////////////////////////////////////////////////////////////////////////
  246. ///////////////////////////// IUIEventSystem ///////////////////////////////
  247. ////////////////////////////////////////////////////////////////////////////
  248. template<>
  249. struct SUILuaCallbackInfo<IUIEventSystem>
  250. {
  251.         static SUILuaCallbackInfo<IUIEventSystem> CreateInfo(IUIEventSystem* pEventSystem, const char* eventName)
  252.         {
  253.                 SUILuaCallbackInfo<IUIEventSystem> res;
  254.                 res.eventName = eventName;
  255.                 res.eventSystemName = pEventSystem ? pEventSystem->GetName() : "";
  256.                 return res;
  257.         }
  258.  
  259.         bool Accept(const SUILuaCallbackInfo<IUIEventSystem>& info) const
  260.         {
  261.                 return (eventSystemName == "" || info.eventSystemName == eventSystemName) && (eventName == "" || info.eventName == eventName);
  262.         }
  263.  
  264.         void CallScript(SmartScriptTable pScript, const char* functionName, SmartScriptTable args, const SUILuaCallbackInfo<IUIEventSystem>& info) const
  265.         {
  266.                 Script::CallMethod(pScript, functionName, info.eventSystemName.c_str(), info.eventName.c_str(), args);
  267.         }
  268.  
  269.         string eventName;
  270.         string eventSystemName;
  271. };
  272.  
  273. struct SUIEventSystemLuaCallback : public SUILuaCallbackContainer<IUIEventSystem>
  274. {
  275.         ~SUIEventSystemLuaCallback();
  276.  
  277.         void Init(IUIEventSystem* pEventSystem);
  278.         void Clear();
  279.         void OnEvent(IUIEventSystem* pEventSystem, const SUIEvent& event);
  280.  
  281. private:
  282.         void AddNewListener(IUIEventSystem* pEventSystem);
  283.  
  284.         struct SEventSystemListener : public IUIEventListener
  285.         {
  286.                 SEventSystemListener() : m_pEventSystem(nullptr), m_pOwner(nullptr) {}
  287.                 SEventSystemListener(IUIEventSystem* pEventSystem, SUIEventSystemLuaCallback* pOwner) { Init(pEventSystem, pOwner); }
  288.                 SEventSystemListener(const SEventSystemListener& other) { Init(other.m_pEventSystem, other.m_pOwner); }
  289.                 SEventSystemListener& operator=(const SEventSystemListener& other) { Clear(); Init(other.m_pEventSystem, other.m_pOwner); return *this; }
  290.                 ~SEventSystemListener();
  291.  
  292.                 virtual SUIArgumentsRet OnEvent(const SUIEvent& event);
  293.                 virtual void            OnEventSystemDestroyed(IUIEventSystem* pEventSystem);
  294.  
  295.                 IUIEventSystem*         GetEventSystem() const { return m_pEventSystem; }
  296.  
  297.         private:
  298.                 void Init(IUIEventSystem* pEventSystem, SUIEventSystemLuaCallback* pOwner);
  299.                 void Clear();
  300.                 IUIEventSystem*            m_pEventSystem;
  301.                 SUIEventSystemLuaCallback* m_pOwner;
  302.         };
  303.         typedef std::vector<SEventSystemListener> TListener;
  304.         TListener m_Listener;
  305. };
  306.  
  307. ////////////////////////////////////////////////////////////////////////////
  308. ////////////////////////////////////////////////////////////////////////////
  309. ////////////////////////////////////////////////////////////////////////////
  310.  
  311. class CScriptBind_UIAction
  312.         : public CScriptableBase
  313.           , public IUIModule
  314. {
  315. public:
  316.         CScriptBind_UIAction();
  317.         virtual ~CScriptBind_UIAction();
  318.  
  319.         void         Release() { delete this; };
  320.  
  321.         virtual void GetMemoryUsage(ICrySizer* pSizer) const
  322.         {
  323.                 pSizer->AddObject(this, sizeof(*this));
  324.         }
  325.  
  326.         //! <code>UIAction.ReloadElement( elementName, instanceID )</code>
  327.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  328.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  329.         //! <description>Reloads the UI flash asset.</description>
  330.         int ReloadElement(IFunctionHandler* pH, const char* elementName, int instanceID);
  331.  
  332.         //! <code>UIAction.UnloadElement( elementName, instanceID )</code>
  333.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  334.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  335.         //! <description>Unloads the UI flash asset.</description>
  336.         int UnloadElement(IFunctionHandler* pH, const char* elementName, int instanceID);
  337.  
  338.         //! <code>UIAction.ShowElement( elementName, instanceID )</code>
  339.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  340.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  341.         //! <description>Displays the UI flash asset.</description>
  342.         int ShowElement(IFunctionHandler* pH, const char* elementName, int instanceID);
  343.  
  344.         //! <code>UIAction.HideElement( elementName, instanceID )</code>
  345.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  346.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  347.         //! <description>Hide the UI flash asset.</description>
  348.         int HideElement(IFunctionHandler* pH, const char* elementName, int instanceID);
  349.  
  350.         // <title SoftHideElement>
  351.         //! <code>UIAction.RequestHide( elementName, instanceID )</code>
  352.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  353.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  354.         //! <description>Send the fade out signal to the UI flash asset.</description>
  355.         int RequestHide(IFunctionHandler* pH, const char* elementName, int instanceID);
  356.  
  357.         //! <code>UIAction.CallFunction( elementName, instanceID, functionName, [arg1], [arg2], [...] )</code>
  358.         //!             <param name="elementName">UI Element name as defined in the xml or UIEventSystem name as defined via cpp.</param>
  359.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances. If used on UIEventSystem no instance id is ignored.</param>
  360.         //!             <param name="functionName">Function or event name.</param>
  361.         //!             <param name="args">List of arguments (optional).</param>
  362.         //! <description>Calls a function of the UI flash asset or the UIEventSystem.</description>
  363.         int CallFunction(IFunctionHandler* pH, const char* elementName, int instanceID, const char* functionName);
  364.  
  365.         //! <code>UIAction.SetVariable( elementName, instanceID, varName, value )</code>
  366.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  367.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  368.         //!             <param name="varName">Variable name as defined in the xml.</param>
  369.         //!             <param name="value">Value to set.</param>
  370.         //! <description>Sets a variable of the UI flash asset.</description>
  371.         int SetVariable(IFunctionHandler* pH, const char* elementName, int instanceID, const char* varName);
  372.  
  373.         //! <code>UIAction.GetVariable( elementName, instanceID, varName )</code>
  374.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  375.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  376.         //!             <param name="varName">Variable name as defined in the xml.</param>
  377.         //! <description>Gets a variable of the UI flash asset.</description>
  378.         int GetVariable(IFunctionHandler* pH, const char* elementName, int instanceID, const char* varName);
  379.  
  380.         //! <code>UIAction.SetArray( elementName, instanceID, arrayName, values )</code>
  381.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  382.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  383.         //!             <param name="arrayName">Array name as defined in the xml.</param>
  384.         //!             <param name="values">Table of values for the array.</param>
  385.         //! <description>Sets an array of the UI flash asset.</description>
  386.         int SetArray(IFunctionHandler* pH, const char* elementName, int instanceID, const char* arrayName, SmartScriptTable values);
  387.  
  388.         //! <code>UIAction.GetArray( elementName, instanceID, arrayName )</code>
  389.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  390.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  391.         //!             <param name="arrayName">Array name as defined in the xml.</param>
  392.         //! <description>Returns a table with values of the array.</description>
  393.         int GetArray(IFunctionHandler* pH, const char* elementName, int instanceID, const char* arrayName);
  394.  
  395.         //! <code>UIAction.GotoAndPlay( elementName, instanceID, mcName, frameNum )</code>
  396.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  397.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  398.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  399.         //!             <param name="frameNum">frame number.</param>
  400.         //! <description>Call GotoAndPlay on a MovieClip.</description>
  401.         int GotoAndPlay(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, int frameNum);
  402.  
  403.         //! <code>UIAction.GotoAndStop( elementName, instanceID, mcName, frameNum )</code>
  404.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  405.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  406.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  407.         //!             <param name="frameNum">frame number.</param>
  408.         //! <description>Call GotoAndStop on a MovieClip.</description>
  409.         int GotoAndStop(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, int frameNum);
  410.  
  411.         //! <code>UIAction.GotoAndPlayFrameName( elementName, instanceID, mcName, frameName )</code>
  412.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  413.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  414.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  415.         //!             <param name="frameName">frame name.</param>
  416.         //! <description>Call GotoAndPlay on a MovieClip by frame name.</description>
  417.         int GotoAndPlayFrameName(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, const char* frameName);
  418.  
  419.         //! <code>UIAction.GotoAndStopFrameName( elementName, instanceID, mcName, frameName )</code>
  420.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  421.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  422.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  423.         //!             <param name="frameName">frame name.</param>
  424.         //! <description>Call GotoAndStop on a MovieClip by frame name.</description>
  425.         int GotoAndStopFrameName(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, const char* frameName);
  426.  
  427.         //! <code>UIAction.SetAlpha( elementName, instanceID, mcName, fAlpha )</code>
  428.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  429.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  430.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  431.         //!             <param name="fAlpha">alpha value (0-1).</param>
  432.         //! <description>Set MovieClip alpha value.</description>
  433.         int SetAlpha(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, float fAlpha);
  434.  
  435.         //! <code>UIAction.GetAlpha( elementName, instanceID, mcName )</code>
  436.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  437.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  438.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  439.         //! <description>Get MovieClip alpha value.</description>
  440.         int GetAlpha(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName);
  441.  
  442.         //! <code>UIAction.SetVisible( elementName, instanceID, mcName, bVisible )</code>
  443.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  444.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  445.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  446.         //!             <param name="bVisible">visible.</param>
  447.         //! <description>Set MovieClip visible state.</description>
  448.         int SetVisible(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, bool bVisible);
  449.  
  450.         //! <code>UIAction.IsVisible( elementName, instanceID, mcName )</code>
  451.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  452.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  453.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  454.         //! <description>Get MovieClip visible state.</description>
  455.         int IsVisible(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName);
  456.  
  457.         //! <code>UIAction.SetPos( elementName, instanceID, mcName, vPos )</code>
  458.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  459.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  460.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  461.         //!             <param name="vPos">position.</param>
  462.         //! <description>Set MovieClip position.</description>
  463.         int SetPos(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, Vec3 vPos);
  464.  
  465.         //! <code>UIAction.GetPos( elementName, instanceID, mcName )</code>
  466.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  467.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  468.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  469.         //! <description>Get MovieClip position.</description>
  470.         int GetPos(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName);
  471.  
  472.         //! <code>UIAction.SetRotation( elementName, instanceID, mcName, vRotation )</code>
  473.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  474.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  475.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  476.         //!             <param name="vRotation">rotation.</param>
  477.         //! <description>Set MovieClip rotation.</description>
  478.         int SetRotation(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, Vec3 vRotation);
  479.  
  480.         //! <code>UIAction.GetRotation( elementName, instanceID, mcName )</code>
  481.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  482.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances</param>
  483.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  484.         //! <description>Get MovieClip rotation.</description>
  485.         int GetRotation(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName);
  486.  
  487.         //! <code>UIAction.SetScale( elementName, instanceID, mcName, vScale )</code>
  488.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  489.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  490.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  491.         //!             <param name="vScale">scale.</param>
  492.         //! <description>Set MovieClip scale.</description>
  493.         int SetScale(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName, Vec3 vScale);
  494.  
  495.         //! <code>UIAction.GetScale( elementName, instanceID, mcName  )</code>
  496.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  497.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  498.         //!             <param name="mcName">MovieClip name as defined in the xml.</param>
  499.         //! <description>Get MovieClip scale.</description>
  500.         int GetScale(IFunctionHandler* pH, const char* elementName, int instanceID, const char* mcName);
  501.  
  502.         //! <code>UIAction.StartAction( actionName, arguments )</code>
  503.         //!             <param name="actionName">UI Action name.</param>
  504.         //!             <param name="arguments">arguments to pass to this action.</param>
  505.         //! <description>Starts a UI Action.</description>
  506.         int StartAction(IFunctionHandler* pH, const char* actionName, SmartScriptTable arguments);
  507.  
  508.         //! <code>UIAction.EndAction( table, disable, arguments )</code>
  509.         //!             <param name="table">must be "self".</param>
  510.         //!             <param name="disable">if true this action gets disabled on end.</param>
  511.         //!             <param name="arguments">arguments to return from this action.</param>
  512.         //! <description>Ends a UI Action. This can be only used withing a UIAction Lua script!</description>
  513.         int EndAction(IFunctionHandler* pH, SmartScriptTable pTable, bool disable, SmartScriptTable arguments);
  514.  
  515.         //! <code>UIAction.EnableAction( actionName )</code>
  516.         //!             <param name="actionName">UI Action name.</param>
  517.         //! <description>Enables the UI Action.</description>
  518.         int EnableAction(IFunctionHandler* pH, const char* actionName);
  519.  
  520.         //! <code>UIAction.DisableAction( actionName )</code>
  521.         //!             <param name="actionName">UI Action name.</param>
  522.         //! <description>Disables the UI Action.</description>
  523.         int DisableAction(IFunctionHandler* pH, const char* actionName);
  524.  
  525.         //! <code>UIAction.RegisterElementListener( table, elementName, instanceID, eventName, callbackFunctionName )</code>
  526.         //!             <param name="table">the script that receives the callback (can be "self" to refer the current script).</param>
  527.         //!             <param name="elementName">UI Element name as defined in the xml.</param>
  528.         //!             <param name="instanceID">ID of the instance (if instance with id does not exist, it will be created). '-1' for all instances.</param>
  529.         //!             <param name="eventName">Name of the event that is fired from the UI Element - if empty string it will receive all events!</param>
  530.         //!             <param name="callbackFunctionName">name of the script function that will receive the callback.</param>
  531.         //! <description>
  532.         //!             Register a callback function for a UIElement event.
  533.         //!             Callback Function must have form: CallbackName(elementName, instanceId, eventName, argTable)
  534.         //! </description>
  535.         int RegisterElementListener(IFunctionHandler* pH, SmartScriptTable pTable, const char* elementName, int instanceID, const char* eventName, const char* callback);
  536.  
  537.         //! <code>UIAction.RegisterActionListener( table, actionName, eventName, callbackFunctionName )</code>
  538.         //!             <param name="table">the script that receives the callback (can be "self" to refer the current script).</param>
  539.         //!             <param name="actionName">UI Action name.</param>
  540.         //!             <param name="eventName">Name of the event that is fired from the UI Action (can be "OnStart" or "OnEnd") - if empty string it will receive all events!</param>
  541.         //!             <param name="callbackFunctionName">name of the script function that will receive the callback.</param>
  542.         //! <description>
  543.         //!             Register a callback function for a UIAction event.
  544.         //!             Callback Function must have form: CallbackName(actionName, eventName, argTable)
  545.         //! </description>
  546.         int RegisterActionListener(IFunctionHandler* pH, SmartScriptTable pTable, const char* actionName, const char* eventName, const char* callback);
  547.  
  548.         //! <code>UIAction.RegisterEventSystemListener( table, eventSystem, eventName, callbackFunctionName )</code>
  549.         //!             <param name="table">the script that receives the callback (can be "self" to refer the current script).</param>
  550.         //!             <param name="eventSystem">UI Event System name</param>
  551.         //!             <param name="eventName">Name of the event that is fired from the UI EventSystem - if empty string it will receive all events!</param>
  552.         //!             <param name="callbackFunctionName">name of the script function that will receive the callback.</param>
  553.         //! <description>
  554.         //!             Register a callback function for a UIEventSystem event.
  555.         //!             Callback Function must have form: CallbackName(actionName, eventName, argTable)
  556.         //! </description>
  557.         int RegisterEventSystemListener(IFunctionHandler* pH, SmartScriptTable pTable, const char* eventSystem, const char* eventName, const char* callback);
  558.  
  559.         //! <code>UIAction.UnregisterElementListener( table, callbackFunctionName )</code>
  560.         //!             <param name="table">the script that receives the callback (can be "self" to refer the current script).</param>
  561.         //!             <param name="callbackFunctionName">name of the script function that receives the callback. if "" all callbacks for this script will be removed.</param>
  562.         //! <description>Unregister callback functions for a UIElement event.</description>
  563.         int UnregisterElementListener(IFunctionHandler* pH, SmartScriptTable pTable, const char* callback);
  564.  
  565.         //! <code>UIAction.UnregisterActionListener( table, callbackFunctionName )</code>
  566.         //!             <param name="table">the script that receives the callback (can be "self" to refer the current script).</param>
  567.         //!             <param name="callbackFunctionName">name of the script function that receives the callback. if "" all callbacks for this script will be removed.</param>
  568.         //! <description>Unregister callback functions for a UIAction event.</description>
  569.         int UnregisterActionListener(IFunctionHandler* pH, SmartScriptTable pTable, const char* callback);
  570.  
  571.         //! <code>UIAction.UnregisterEventSystemListener( table, callbackFunctionName )</code>
  572.         //!             <param name="table">the script that receives the callback (can be "self" to refer the current script).</param>
  573.         //!             <param name="callbackFunctionName">name of the script function that receives the callback. if "" all callbacks for this script will be removed.</param>
  574.         //! <description>Unregister callback functions for a UIEventSystem event.</description>
  575.         int UnregisterEventSystemListener(IFunctionHandler* pH, SmartScriptTable pTable, const char* callback);
  576.  
  577.         // IUIModule
  578.         virtual void Reload();
  579.         virtual void Reset();
  580.         // ~IUIModule
  581.  
  582. private:
  583.         void            RegisterMethods();
  584.  
  585.         IUIElement*     GetElement(const char* sName, int instanceID, bool bSupressWarning = false);
  586.         IUIAction*      GetAction(const char* sName);
  587.         IUIEventSystem* GetEventSystem(const char* sName, IUIEventSystem::EEventSystemType type);
  588.  
  589.         SUIElementLuaCallback     m_ElementCallbacks;
  590.         SUIActionLuaCallback      m_ActionCallbacks;
  591.         SUIEventSystemLuaCallback m_EventSystemCallbacks;
  592. };
  593.  
  594. #endif // #ifndef __SCRIPTBIND_UIACTION_H__
  595.  
downloadScriptBind_UIAction.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top