Ejemplo n.º 1
0
        public static void LuaCreateWindowAsync(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var manager    = parameters[0] as IUISystem;

            if (null != manager && null != parameters[1] && null != parameters[2])
            {
                var path     = parameters[1].ToString();
                var layer    = Convert.ToInt32(parameters[2]);
                var callback = parameters[3];
                var target   = (parameters.Length > 4 ? parameters[4] : null);
                manager.CreateWindowAsync(path, layer, window =>
                {
                    if (null != callback)
                    {
                        if (null == target)
                        {
                            executer.Call(callback, new object[] { window });
                        }
                        else
                        {
                            executer.Call(callback, new object[] { target, window });
                        }
                    }
                });
            }
        }
Ejemplo n.º 2
0
        public static void RegisterCancelRecordFunction(ILuaExecuter executer)
        {
            var parameters        = executer.PopParameters();
            var recordVoiceButton = parameters[0] as IGiantVoiceRecorder;

            if (null != recordVoiceButton)
            {
                var cancelSuccessfulHandler = parameters.Length > 1 ? parameters[1] : null;
                var cancelFailHandler       = parameters.Length > 2 ? parameters[2] : null;
                recordVoiceButton.RegisterCancel(
                    delegate() {
                    if (null != cancelSuccessfulHandler)
                    {
                        executer.Call(cancelSuccessfulHandler);
                    }
                },
                    delegate(string error)
                {
                    if (null != cancelFailHandler)
                    {
                        executer.Call(cancelFailHandler, error);
                    }
                });
            }
        }
Ejemplo n.º 3
0
        public static void RegisterPlayVoiceFunction(ILuaExecuter executer)
        {
            var parameters         = executer.PopParameters();
            var playVoiceComponent = parameters[0] as IGiantVoicePlayer;
            var voiceId            = parameters[1].ToString();

            if (null != playVoiceComponent && null != voiceId)
            {
                var playSuccessfulHandler = parameters.Length > 2 ? parameters[2] : null;
                var playFailHandler       = parameters.Length > 3 ? parameters[3] : null;
                playVoiceComponent.RegisterPlay(voiceId,
                                                delegate() {
                    if (null != playSuccessfulHandler)
                    {
                        executer.Call(playSuccessfulHandler);
                    }
                },
                                                delegate(string error)
                {
                    if (null != playFailHandler)
                    {
                        executer.Call(playFailHandler, error);
                    }
                });
            }
        }
Ejemplo n.º 4
0
        public static void RegisterStopRecordFunction(ILuaExecuter executer)
        {
            var parameters              = executer.PopParameters();
            var recordVoiceButton       = parameters[0] as IGiantVoiceRecorder;
            var recordSuccessfulHandler = parameters[1];

            if (null != recordVoiceButton && null != recordSuccessfulHandler)
            {
                var recordFailHandler = parameters.Length > 2 ? parameters[2] : null;
                recordVoiceButton.RegisterStop(
                    delegate(string voidId, float recordTime, string words) {
                    executer.Call(recordSuccessfulHandler, voidId, recordTime, words);
                },
                    delegate(string error)
                {
                    if (null != recordFailHandler)
                    {
                        executer.Call(recordFailHandler, error);
                    }
                });
            }
        }
Ejemplo n.º 5
0
        public static void LuaSetHrefClick(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var label      = parameters[0] as ILabel;
            var handler    = parameters[1];

            if (null != label && null != handler && null != label.OnHrefClick)
            {
                label.OnClick(delegate(string hrefInfo)
                {
                    executer.Call(handler, hrefInfo);
                });
            }
        }
Ejemplo n.º 6
0
        public static void LuaOnDragging(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var element    = parameters[0] as IElement;
            var handler    = parameters[1];

            if (null != element)
            {
                element.OnDragging((x, y) =>
                {
                    if (null != handler)
                    {
                        executer.Call(handler, new object[] { x, y });
                    }
                });
            }
        }
Ejemplo n.º 7
0
        public static void LuaOnClick(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var element    = parameters[0] as IElement;
            var handler    = parameters[1];

            if (null != element)
            {
                element.OnClick(() =>
                {
                    if (null != handler)
                    {
                        executer.Call(handler);
                    }
                });
            }
        }
Ejemplo n.º 8
0
        public static void LuaOnChange(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var toggle     = parameters[0] as IToggle;
            var handler    = parameters[1];

            if (null != toggle)
            {
                toggle.OnChange(isOn =>
                {
                    if (null != handler)
                    {
                        executer.Call(handler, new object[] { isOn });
                    }
                });
            }
        }
Ejemplo n.º 9
0
        public static void LuaAddClick(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var button     = parameters[0] as IButton;
            var handler    = parameters[1];

            if (null != button)
            {
                button.OnClick(() =>
                {
                    if (null != handler)
                    {
                        executer.Call(handler);
                    }
                });
            }
        }
Ejemplo n.º 10
0
        public static void LuaAddClick(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var dropdown   = parameters[0] as IDropDown;
            var handler    = parameters[1];

            if (null != dropdown)
            {
                dropdown.OnClick((index) =>
                {
                    if (null != handler)
                    {
                        executer.Call(handler, new object[] { index });
                    }
                });
            }
        }
Ejemplo n.º 11
0
        public static void LuaAddToggleChange(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var toggles    = parameters[0] as IToggles;
            var handler    = parameters[1];

            if (null != toggles)
            {
                toggles.AddToggleChange(() =>
                {
                    if (null != handler)
                    {
                        executer.Call(handler);
                    }
                });
            }
        }
Ejemplo n.º 12
0
        public static void RegisterStopVoiceFunction(ILuaExecuter executer)
        {
            var parameters         = executer.PopParameters();
            var playVoiceComponent = parameters[0] as IGiantVoicePlayer;

            if (null != playVoiceComponent)
            {
                var stopVoiceCompletedHandler = parameters.Length > 1 ? parameters[1] : null;
                playVoiceComponent.RegisterStop(
                    delegate() {
                    if (null != stopVoiceCompletedHandler)
                    {
                        executer.Call(stopVoiceCompletedHandler);
                    }
                });
            }
        }
Ejemplo n.º 13
0
        public static void LuaSetSpriteAtlasAsync(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var img        = parameters[0] as IImage;

            if (null != img && null != parameters[1] && null != parameters[2])
            {
                var defaultPath = parameters.Length > 3 && null != parameters[3] ? parameters[3].ToString() : "";
                img.SetSpriteAtlasAsync(parameters[1].ToString(), parameters[2].ToString(), defaultPath, () =>
                {
                    var callback = parameters.Length > 4 ? parameters[4] : null;
                    if (null != callback)
                    {
                        executer.Call(callback);
                    }
                });
            }
        }
Ejemplo n.º 14
0
        public static void LuaAddAnimation(ILuaExecuter executer)
        {
            var parameters = executer.PopParameters();
            var element    = parameters[0] as IElement;
            var json       = parameters[1].ToString();

            if (null != element)
            {
                var duration = parameters.Length > 2 ? Convert.ToSingle(parameters[2]) : 1.0f;
                var forever  = parameters.Length > 3 ? Convert.ToBoolean(parameters[3]) : false;
                var relative = parameters.Length > 4 ? Convert.ToBoolean(parameters[4]) : false;
                var handler  = parameters.Length > 5 ? parameters[5] : null;
                element.Animate(json, duration, forever, relative, delegate()
                {
                    if (null != handler)
                    {
                        executer.Call(handler);
                    }
                });
            }
        }