Esempio n. 1
0
 /// <summary>
 /// Try to find a Node designated by name in the subnode of the actual one.
 /// If the Node is found, the NodeIterator is updated.
 /// Else it keeps its reference to the current Node.
 /// </summary>
 /// <param name="name">Name of the node looked for.</param>
 /// <returns>true if succeeds, else returns false.</returns>
 public bool find(String name, bool registerStack = false)
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         if (m_nodeCpp != IntPtr.Zero)
         {
             IntPtr ptr = node_search(m_nodeCpp, __MarshallingUtils.NativeUtf8FromString(name));
             if (ptr != IntPtr.Zero)
             {
                 if (registerStack)
                 {
                     m_navigation.Add(m_nodeCpp);
                 }
                 m_nodeCpp = ptr;
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             throw new CKLBExceptionNullCppObject();
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }
Esempio n. 2
0
 public bool gotoParent(bool registerStack = false)
 {
     if (m_counter == NativeManagement.getContextCounter())
     {
         IntPtr nNode = node_getParent(m_nodeCpp);
         if (nNode != IntPtr.Zero)
         {
             // Push on navigation stack if needed.
             if (registerStack)
             {
                 m_navigation.Add(m_nodeCpp);
             }
             m_nodeCpp = nNode;
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         throw new CKLBExceptionTooOld();
     }
 }
        /// <summary>
        /// Links a C++ object to its C# wrapper.
        /// </summary>
        /// <param name='cppObj'>
        /// Pointer to the CppObject to register.
        /// </param>
        /// <param name='handle'>
        /// Handle of the C# object.
        /// </param>
        public static void  registerWrapper(IntPtr cppObj, uint handle)
        {
            Console.WriteLine("[C#] NativeManagement.registerWrapper BEGIN");
            GameObject gameObject = WrapperReg.getInstance().getObjectFromHandle(handle);

            if (cppObj != IntPtr.Zero)
            {
                // C# and C++ classes must have the same typeID to be bound
                //Console.WriteLine("[C#] NativeManagement.registerWrapper - native typeID : 0x" + NativeManagement.getTypeID(cppObj).ToString("X") + " - C# typeID : 0x" + gameObject.TypeID.ToString("X"));
                if (NativeManagement.getTypeID(cppObj) == gameObject.TypeID)
                {
                    //Console.WriteLine("[C#] Register Wrapper : handle = " + handle);
                    CKLBObjectScriptable_setScriptContext(cppObj, handle);
                }
                else
                {
                    throw new CKLBException("C# object and C++ object don't have the same typeID, impossible to bind them.");
                }

                // Debug
                //uint handleResult = GameObject_getHandle(cppObj);
                //Console.WriteLine("Result : " + handleResult);
            }
            else
            {
                throw new CKLBExceptionNullCppObject();
            }
            Console.WriteLine("[C#] NativeManagement.registerWrapper END");
        }
Esempio n. 4
0
 /// <summary>
 /// Associates the C++ to the C# GameObject.
 /// </summary>
 /// <param name='cppObj'>
 /// Cpp object.
 /// </param>
 internal void bind(IntPtr cppObj)
 {
     if (cppObj != IntPtr.Zero)
     {
         if (m_cppObject == IntPtr.Zero)
         {
             uint nativeHandle = CKLBObjectScriptable_getScriptContext(cppObj);
             // Is this object already bound ? if yes it must already have a Handle.
             if (nativeHandle == NULLHANDLER)
             {
                 NativeManagement.registerWrapper(cppObj, m_handle);
                 m_cppObject = cppObj;
                 doSetupCallbacks();
             }
             else
             {
                 throw new CKLBException("This C++ object is already wrapped.");
             }
         }
         else
         {
             throw new CKLBException("This GameObject is already binded.");
         }
     }
     else
     {
         throw new CKLBException("Impossible to bind a null pointer (It can be a failure on Engine side while creating C++ instance).");
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Bind a GameObject to a C++ ObjectScriptable through its node name.
        /// </summary>
        /// <param name="nodeName">Name of the Node to bind.</param>
        public void bind(String nodeName)
        {
            if (nodeName == null)
            {
                throw new CKLBException("Impossible to bind with a null name.");
            }
            if (m_cppObject != IntPtr.Zero)
            {
                throw new CKLBException("This GameObject is already binded.");
            }

            NodeIterator nodeIterator = new NodeIterator(NativeManagement.getContextCounter(), NodeIterator.getRoot());

            if (nodeIterator.find(nodeName))
            {
                IntPtr cppObj       = nodeIterator.getAsUITask().CppObject;
                uint   nativeHandle = CKLBObjectScriptable_getScriptContext(cppObj);

                if (nativeHandle == NULLHANDLER)
                {
                    NativeManagement.registerWrapper(cppObj, m_handle);
                    m_cppObject = cppObj;
                    doSetupCallbacks();
                }
                else
                {
                    throw new CKLBException("This C++ object is already wrapped.");
                }
            }
            else
            {
                throw new CKLBException("There is not any Node with this name.");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Get a node iterator, allowing to navigate through the scenegraph and manipulate nodes inside a task.
        /// Return the node passed as parameter.
        /// </summary>
        /// <param name="nodeIterator">Return a </param>
        /// <returns></returns>
        public NodeIterator getIterator(out NodeIterator nodeIterator)
        {
            uint   counter = NativeManagement.getContextCounter();
            IntPtr node    = NodeIterator.getNodeFromTask(this);

            nodeIterator = new NodeIterator(counter, node);
            return(nodeIterator);
        }
Esempio n. 7
0
        public CKLBUIFreeVertItem(CKLBUITask parent, uint order, float x, float y, String asset, float[] verticesArray) : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBUIFreeVertItem_create(parent != null ? parent.CppObject : IntPtr.Zero, order, x, y, __MarshallingUtils.NativeUtf8FromString(asset), verticesArray);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 8
0
        public CKLBUIPolyline(CKLBUITask parent, uint order, uint maxPoint) : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBUIPolyline_create(parent != null ? parent.CppObject : IntPtr.Zero, order, maxPoint);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 9
0
        public CKLBUILabel(CKLBUITask parent, uint order, float x, float y, uint argb, String font_name, uint font_size, String text, EALIGN align)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBUILabel_create(parent != null ? parent.CppObject : IntPtr.Zero, order, x, y, argb, __MarshallingUtils.NativeUtf8FromString(font_name), font_size, __MarshallingUtils.NativeUtf8FromString(text), (uint)align);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 10
0
        public CSData(uint ID)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBLuaLibDATA_cmdCreateData(ID);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 11
0
        public CSSound(String sound_asset, bool bgmMode = false)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBLuaLibSOUND_cmdSoundOpen(__MarshallingUtils.NativeUtf8FromString(sound_asset), bgmMode);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 12
0
        public CKLBUIScale9(CKLBUITask parent, uint order, float x, float y, int width, int height, String asset)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBUIScale9_create(parent != null ? parent.CppObject : IntPtr.Zero, order, x, y, width, height, __MarshallingUtils.NativeUtf8FromString(asset));

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 13
0
        public CKLBUIClip(CKLBUITask parent, uint baseOrder, uint maxOrder, float x, float y, float clipWidth, float clipHeight)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBUIClip_create(parent != null ? parent.CppObject : IntPtr.Zero,
                                           baseOrder, maxOrder, x, y, clipWidth, clipHeight);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 14
0
        public CKLBUIPieChart(CKLBUITask parent, uint order, float x, float y, float width, float height, String image_asset, float start_angle, float end_angle, int anim_time = 0, float initial_value = 0.0f)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBUIPieChart_create(parent != null ? parent.CppObject : IntPtr.Zero, order, x, y, width, height, __MarshallingUtils.NativeUtf8FromString(image_asset), start_angle, end_angle, anim_time, initial_value);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 15
0
        //a string is given to the constructor which creates a font object
        public CKLBUIDebugItem(CKLBUITask parent, uint order, float x, float y, uint argb, String font_name, uint font_size, String text, uint cmdID, CallBack callback)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBUIDebugItem_create(parent != null ? parent.CppObject : IntPtr.Zero, order, x, y, argb, __MarshallingUtils.NativeUtf8FromString(font_name), font_size, __MarshallingUtils.NativeUtf8FromString(text), cmdID);

            NativeManagement.intercepCppError();
            bind(ptr);
            m_callback = callback;
        }
Esempio n. 16
0
        public static void getBoundSize(String assetPath, out FSize size)
        {
            float width = 0, height = 0;

            NativeManagement.resetCppError();
            CKLBLuaLibASSET_getBoundSize(__MarshallingUtils.NativeUtf8FromString(assetPath), ref width, ref height);
            NativeManagement.intercepCppError();
            size.width  = width;
            size.height = height;
        }
Esempio n. 17
0
        public CKLBStoreService(CallBack callback)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBStoreService_create();

            NativeManagement.intercepCppError();
            m_callback = callback;
            bind(ptr);
        }
Esempio n. 18
0
        public CSBin(String bin_asset)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBLuaLibBIN_open(__MarshallingUtils.NativeUtf8FromString(bin_asset));

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 19
0
        public CKLBUIForm(CKLBUITask parent, uint order, int x, int y, bool assetFile, String asset_name, bool bExclusive = false, bool modal = false, bool urgent = false)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBUIForm_create(parent != null ? parent.CppObject : IntPtr.Zero, order, x, y, assetFile, __MarshallingUtils.NativeUtf8FromString(asset_name), bExclusive, modal, urgent);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 20
0
        public CKLBUIMoviePlayer(CKLBUITask parent, bool background_mode, float x, float y, float width, float height, CallBack callback, String url = null)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBUIMoviePlayer_create(parent != null ? parent.CppObject : IntPtr.Zero, background_mode, x, y, width, height, __MarshallingUtils.NativeUtf8FromString(url));

            NativeManagement.intercepCppError();
            bind(ptr);
            m_callback = callback;
        }
Esempio n. 21
0
        public CKLBUIGroup(CKLBUITask parent, float x, float y)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBUIGroup_create(parent != null ? parent.CppObject : IntPtr.Zero, x, y);

            NativeManagement.intercepCppError();
            bind(ptr);
        }
Esempio n. 22
0
        public CSDB(String db_asset, bool b_write = true, bool b_create = true)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBLuaLibDB_dbopen(__MarshallingUtils.NativeUtf8FromString(db_asset), b_write, b_create);

            NativeManagement.intercepCppError();
            bind(ptr);
            m_isWritable  = b_write;
            m_isCreatable = b_create;
        }
Esempio n. 23
0
        public CSFont(uint size, String name)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBLuaLibFONT_createFont((int)size, __MarshallingUtils.NativeUtf8FromString(name));

            NativeManagement.intercepCppError();
            bind(ptr);
            m_size = size;
            m_name = name;
        }
Esempio n. 24
0
        public CKLBAsyncLoader(CKLBTask pParent, String[] assets, uint datasetID, CallBack callback)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBAsyncLoader_create((pParent != null) ? pParent.CppObject : IntPtr.Zero,
                                                __MarshallingUtils.NativeUtf8ArrayFromStringArray(assets, assets.Length), (uint)assets.Length, datasetID);

            NativeManagement.intercepCppError();
            m_callback = callback;
            bind(ptr);
        }
Esempio n. 25
0
        public CKLBUICanvas(CKLBUITask parent, uint order, float x, float y, uint vertexMax, uint indexMax, CallBack onDrawCallBack)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBUICanvas_create(parent != null ? parent.CppObject : IntPtr.Zero, order, x, y, vertexMax, indexMax);

            NativeManagement.intercepCppError();
            bind(ptr);
            m_callback = onDrawCallBack;
        }
Esempio n. 26
0
        public CKLBUITextInput(CKLBUITask parent, bool passwordMode, int x, int y, uint width, uint height, String defaultText, CallBack callback,
                               int widgetId = 0, int maxLen = 0, uint charType = (uint)(ECHAR_TYPE.TXCH_7BIT_ASCII | ECHAR_TYPE.TXCH_UTF8))
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBUITextInput_create(parent != null ? parent.CppObject : IntPtr.Zero, passwordMode, x, y, width, height, __MarshallingUtils.NativeUtf8FromString(defaultText), widgetId, maxLen, charType);

            NativeManagement.intercepCppError();
            bind(ptr);
            m_callback = callback;
        }
Esempio n. 27
0
        public CKLBGenericTask(CKLBTask parent, CKLBTask.ETASK_PHASE phase, ExecuteCallBack executeCallBack, DieCallBack dieCallBack)
            : base(s_classID)
        {
            NativeManagement.resetCppError();
            IntPtr ptr = CKLBGenericTask_create(parent != null ? parent.CppObject : IntPtr.Zero, (uint)phase);

            NativeManagement.intercepCppError();
            bind(ptr);
            m_executeCallBack = executeCallBack;
            m_dieCallBack     = dieCallBack;
        }
Esempio n. 28
0
        public CKLBUITouchPad(CKLBTask parent, CallBack callback, bool modal = false)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBUITouchPad_create(parent != null ? parent.CppObject : IntPtr.Zero, modal);

            NativeManagement.intercepCppError();
            bind(ptr);
            m_callback = callback;
        }
        public CKLBIntervalTimer(CKLBTask parent, uint interval, CallBack callback, bool repeat = false, ETIMERMODE mode = ETIMERMODE.INTERVALTIMER_TIME)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBIntervalTimer_create(parent != null ? parent.CppObject : IntPtr.Zero, interval, repeat, (byte)mode);

            NativeManagement.intercepCppError();
            bind(ptr);

            m_callback = callback;
        }
Esempio n. 30
0
        public CKLBUIControl(CKLBTask parent, OnClickCallBack onClickCallBack, OnDragCallBack onDragCallBack)
            : base(s_classID)
        {
            NativeManagement.resetCppError();

            IntPtr ptr = CKLBUIControl_create(parent != null ? parent.CppObject : IntPtr.Zero);

            NativeManagement.intercepCppError();
            bind(ptr);
            m_onDragCallBack  = onDragCallBack;
            m_onClickCallBack = onClickCallBack;
        }