static int OnPress(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1)
        {
            LuaFunction arg0 = LuaScriptMgr.GetLuaFunction(L, 1);
            UIEventListener.BoolDelegate o = LuaHelper.OnPress(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 2)
        {
            LuaFunction arg0 = LuaScriptMgr.GetLuaFunction(L, 1);
            int         arg1 = (int)LuaScriptMgr.GetNumber(L, 2);
            UIEventListener.BoolDelegate o = LuaHelper.OnPress(arg0, arg1);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: LuaHelper.OnPress");
        }

        return(0);
    }
        internal static int checkDelegate(IntPtr l, int p, out UIEventListener.BoolDelegate ua)
        {
            int result = LuaObject.extractFunction(l, p);

            if (LuaDLL.pua_isnil(l, p))
            {
                ua = null;
                return(result);
            }
            if (LuaDLL.pua_isuserdata(l, p) == 1)
            {
                ua = (UIEventListener.BoolDelegate)LuaObject.checkObj(l, p);
                return(result);
            }
            LuaDelegate ld;

            LuaObject.checkType(l, -1, out ld);
            LuaDLL.pua_pop(l, 1);
            if (ld.d != null)
            {
                ua = (UIEventListener.BoolDelegate)ld.d;
                return(result);
            }
            l  = LuaState.get(l).L;
            ua = delegate(GameObject a1, bool a2)
            {
                int num = LuaObject.pushTry(l);
                LuaObject.pushValue(l, a1);
                LuaObject.pushValue(l, a2);
                ld.pcall(2, num);
                LuaDLL.pua_settop(l, num - 1);
            };
            ld.d = ua;
            return(result);
        }
Exemple #3
0
 public static UIEventListener.BoolDelegate AddPress(GameObject go, Action <object, bool> handler, object arg = null)
 {
     if (pressDic.ContainsKey(go))
     {
         Dictionary <Action <object, bool>, UIEventListener.BoolDelegate> dic = pressDic[go];
         if (dic.ContainsKey(handler))
         {
             return(null);
         }
     }
     else
     {
         pressDic.Add(go, new Dictionary <Action <object, bool>, UIEventListener.BoolDelegate>());
     }
     if (arg == null)
     {
         arg = go;
     }
     UIEventListener.BoolDelegate de = delegate(GameObject go1, bool pressed) {
         handler.DynamicInvoke(arg, pressed);
     };
     UIEventListener.Get(go).onPress += de;
     pressDic[go].Add(handler, de);
     return(de);
 }
    static int BoolDelegate(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(LuaInterface.LuaFunction)))
            {
                LuaFunction arg0 = ToLua.ToLuaFunction(L, 1);
                UIEventListener.BoolDelegate o = LuaHelper.BoolDelegate(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(LuaInterface.LuaFunction), typeof(LuaInterface.LuaTable)))
            {
                LuaFunction arg0 = ToLua.ToLuaFunction(L, 1);
                LuaTable    arg1 = ToLua.ToLuaTable(L, 2);
                UIEventListener.BoolDelegate o = LuaHelper.BoolDelegate(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaHelper.BoolDelegate"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 // 用于接收NGUI处理的输入事件,不经过GlobalTouchSystem
 public void registeBoxColliderNGUI(txUIObject button, UIEventListener.VoidDelegate clickCallback,
                                    UIEventListener.BoolDelegate pressCallback = null, UIEventListener.BoolDelegate hoverCallback = null)
 {
     button.setClickCallback(clickCallback);
     button.setPressCallback(pressCallback);
     button.setHoverCallback(hoverCallback);
 }
Exemple #6
0
 public void OnConfirm(GameObject objClick)
 {
     if (onConfirm != null)
     {
         try
         {
             LocalPos.x   = System.Convert.ToSingle(xPos.text);
             LocalPos.y   = System.Convert.ToSingle(yPos.text);
             LocalPos.z   = System.Convert.ToSingle(zPos.text);
             LocalScale.x = System.Convert.ToSingle(xScale.text);
             LocalScale.y = System.Convert.ToSingle(yScale.text);
             LocalScale.z = System.Convert.ToSingle(zScale.text);
             LocalEuler.x = System.Convert.ToSingle(xRotation.text);
             LocalEuler.y = System.Convert.ToSingle(yRotation.text);
             LocalEuler.z = System.Convert.ToSingle(zRotation.text);
         }
         catch (System.Exception exp)
         {
             Debug.LogError(exp.Message + "|" + exp.StackTrace);
             return;
         }
         onConfirm(objParam, false);
         onConfirm = null;
         objParam  = null;
         Close();
     }
 }
    static int set_onTooltip(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIEventListener obj = (UIEventListener)o;
            UIEventListener.BoolDelegate arg0 = null;
            LuaTypes funcType2 = LuaDLL.lua_type(L, 2);

            if (funcType2 != LuaTypes.LUA_TFUNCTION)
            {
                arg0 = (UIEventListener.BoolDelegate)ToLua.CheckObject(L, 2, typeof(UIEventListener.BoolDelegate));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                arg0 = DelegateFactory.CreateDelegate(typeof(UIEventListener.BoolDelegate), func) as UIEventListener.BoolDelegate;
            }

            obj.onTooltip = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index onTooltip on a nil value" : e.Message));
        }
    }
 public static void AddGenericPress(UIEventListener.BoolDelegate fun)
 {
     if (UICamera.genericEventHandler != null)
     {
         UIEventListener.Get(UICamera.genericEventHandler).onPress += fun;
     }
 }
Exemple #9
0
 public static UIEventListener.BoolDelegate AddHover(GameObject go, Action <object, bool> handler, object arg = null)
 {
     if (hoverDic.ContainsKey(go))
     {
         Dictionary <Action <object, bool>, UIEventListener.BoolDelegate> dic = hoverDic[go];
         if (dic.ContainsKey(handler))
         {
             return(null);
         }
     }
     else
     {
         hoverDic.Add(go, new Dictionary <Action <object, bool>, UIEventListener.BoolDelegate>());
     }
     if (arg == null)
     {
         arg = go;
     }
     UIEventListener.BoolDelegate de = delegate(GameObject go1, bool isHover) {
         handler.DynamicInvoke(arg, isHover);
     };
     UIEventListener.Get(go).onHover += de;
     hoverDic[go].Add(handler, de);
     return(de);
 }
Exemple #10
0
    public override void UIInit()
    {
        onConfirm = null;
        objParam  = null;
        xPos      = Global.ldaControlX("XPos", Panel).GetComponent <UIInput>();
        yPos      = Global.ldaControlX("YPos", Panel).GetComponent <UIInput>();
        zPos      = Global.ldaControlX("ZPos", Panel).GetComponent <UIInput>();

        xScale = Global.ldaControlX("XScale", Panel).GetComponent <UIInput>();
        yScale = Global.ldaControlX("YScale", Panel).GetComponent <UIInput>();
        zScale = Global.ldaControlX("ZScale", Panel).GetComponent <UIInput>();

        xRotation = Global.ldaControlX("XRotation", Panel).GetComponent <UIInput>();
        yRotation = Global.ldaControlX("YRotation", Panel).GetComponent <UIInput>();
        zRotation = Global.ldaControlX("ZRotation", Panel).GetComponent <UIInput>();

        Global.ldaControlX("Confirm", Panel).GetComponent <UIEventListener>().onClick = OnConfirm;
        Global.ldaControlX("Cancel", Panel).GetComponent <UIEventListener>().onClick  = OnCancel;

        xPos.text = "0.0";
        yPos.text = "0.0";
        zPos.text = "0.0";

        xScale.text = "1.0";
        yScale.text = "1.0";
        zScale.text = "1.0";

        xRotation.text = "0";
        yRotation.text = "0";
        zRotation.text = "0";
    }
Exemple #11
0
 public static UIEventListener.BoolDelegate BoolDelegate(LuaFunction func)
 {
     UIEventListener.BoolDelegate action = (go, isPressed) =>
     {
         func.Call(new object[] { go, isPressed });
     };
     return(action);
 }
Exemple #12
0
 public static UIEventListener.BoolDelegate BoolDelegate(LuaFunction func, LuaTable tab)
 {
     UIEventListener.BoolDelegate action = (go, state) =>
     {
         func.Call(tab, go, state);
     };
     return(action);
 }
Exemple #13
0
    public static void RemovePressEventListener(GameObject gameObject, UIEventListener.BoolDelegate listener)
    {
        if (gameObject == null)
        {
            return;
        }

        UIEventListener.Get(gameObject).onPress -= listener;
    }
Exemple #14
0
    static int BoolDelegate(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        LuaFunction arg0 = LuaScriptMgr.GetLuaFunction(L, 1);

        UIEventListener.BoolDelegate o = LuaHelper.BoolDelegate(arg0);
        LuaScriptMgr.Push(L, o);
        return(1);
    }
    static int OnHover(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        LuaFunction arg0 = LuaScriptMgr.GetLuaFunction(L, 1);
        int         arg1 = (int)LuaScriptMgr.GetNumber(L, 2);

        UIEventListener.BoolDelegate o = LuaHelper.OnHover(arg0, arg1);
        LuaScriptMgr.Push(L, o);
        return(1);
    }
Exemple #16
0
    public static Delegate UIEventListener_BoolDelegate(LuaFunction func)
    {
        if (func == null)
        {
            UIEventListener.BoolDelegate fn = delegate { };
            return(fn);
        }

        UIEventListener.BoolDelegate d = (new UIEventListener_BoolDelegate_Event(func)).Call;
        return(d);
    }
 public static void RemoveGenericPress(UIEventListener.BoolDelegate fun)
 {
     if (UICamera.genericEventHandler != null)
     {
         UIEventListener e = UIEventListener.Get(UICamera.genericEventHandler);
         if (e != null)
         {
             e.onPress -= fun;
         }
     }
 }
Exemple #18
0
 public void AddChangeFun(UIEventListener.BoolDelegate fun)
 {
     if (_changeFun == null)
     {
         _changeFun = fun;
     }
     else
     {
         Debug.LogError("CButton only support one function");
     }
 }
Exemple #19
0
    // 用于接收NGUI处理的输入事件
#if USE_NGUI
    public void registeBoxColliderNGUI(txNGUIObject obj, UIEventListener.VoidDelegate clickCallback,
                                       UIEventListener.BoolDelegate pressCallback = null, UIEventListener.BoolDelegate hoverCallback = null)
    {
        if (obj.getCollider() == null)
        {
            logInfo("window must has box collider that can registeBoxColliderNGUI!");
            return;
        }
        obj.setClickCallback(clickCallback);
        obj.setPressCallback(pressCallback);
        obj.setHoverCallback(hoverCallback);
    }
Exemple #20
0
 /// <summary>
 /// OnPress事件
 /// </summary>
 /// <param name="func"></param>
 /// <returns></returns>
 public static UIEventListener.BoolDelegate OnPress(LuaFunction func, int excelID)
 {
     if (func == null)
     {
         return(null);
     }
     UIEventListener.BoolDelegate action = (go, state) =>
     {
         func.Call(go, state, excelID);
     };
     return(action);
 }
 public static Delegate UIEventListener_BoolDelegate(LuaFunction func)
 {
     UIEventListener.BoolDelegate d = (param0, param1) =>
     {
         int    top = func.BeginPCall();
         IntPtr L   = func.GetLuaState();
         LuaScriptMgr.Push(L, param0);
         LuaScriptMgr.Push(L, param1);
         func.PCall(top, 2);
         func.EndPCall(top);
     };
     return(d);
 }
Exemple #22
0
 public static void TryRegistOnPress(this GameObject go, UIEventListener.BoolDelegate action, bool isAddUp = false)
 {
     if (go == null)
     {
         return;
     }
     if (isAddUp)
     {
         UIEventListener.Get(go).onPress += action;
     }
     else
     {
         UIEventListener.Get(go).onPress = action;
     }
 }
    static int set_onTooltip(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIEventListener obj = (UIEventListener)o;
            UIEventListener.BoolDelegate arg0 = (UIEventListener.BoolDelegate)ToLua.CheckDelegate <UIEventListener.BoolDelegate>(L, 2);
            obj.onTooltip = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onTooltip on a nil value"));
        }
    }
    static int get_onTooltip(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIEventListener obj = (UIEventListener)o;
            UIEventListener.BoolDelegate ret = obj.onTooltip;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onTooltip on a nil value"));
        }
    }
Exemple #25
0
 public void Clear()
 {
     this.onSubmit      = null;
     this.onClick       = null;
     this.onDoubleClick = null;
     this.onHover       = null;
     this.onPress       = null;
     this.onSelect      = null;
     this.onScroll      = null;
     this.onDragStart   = null;
     this.onDrag        = null;
     this.onDragOver    = null;
     this.onDragOut     = null;
     this.onDragEnd     = null;
     this.onDrop        = null;
     this.onKey         = null;
     this.onTooltip     = null;
 }
Exemple #26
0
    private static int get_onTooltip(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            UIEventListener uIEventListener        = (UIEventListener)obj;
            UIEventListener.BoolDelegate onTooltip = uIEventListener.onTooltip;
            ToLua.Push(L, onTooltip);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index onTooltip on a nil value");
        }
        return(result);
    }
    /* btnIndex 0:button of guide tip, 1-5:button of controller */
    void ShowGuide(string guide, int btnIndex = 0, bool ignoreCD = false)
    {
        if (curTipCD > 0f && !ignoreCD)
        {
            return;
        }
        if (!completedGuide.Contains(guide))
        {
            matchReviseTip.HideTip();

            if (btnIndex == 0)
            {
                guideTip.firstButtonVisible = true;
            }
            else
            {
                guideTip.firstButtonVisible = false;
                UIButton btn = m_uiController.m_btns[btnIndex - 1].btn;
                UIEventListener.BoolDelegate onBtnPress = null;
                onBtnPress = (GameObject go, bool pressed) =>
                {
                    if (pressed)
                    {
                        UIEventListener.Get(btn.gameObject).onPress -= onBtnPress;
                        OnTipClick(btn.gameObject);
                        HighlightButton((uint)(btnIndex - 1), false);
                    }
                };
                UIEventListener.Get(btn.gameObject).onPress += onBtnPress;
                HighlightButton((uint)(btnIndex - 1), true);
            }

            guideTip.tip = CommonFunction.GetConstString("MATCH_GUIDE_" + guide);
            guideTip.Show();
            completedGuide.Add(guide);
            curGuide = guide;
            curTipCD = TIP_CD;

            Pause();
        }
    }
Exemple #28
0
        static internal int checkDelegate(IntPtr l, int p, out UIEventListener.BoolDelegate ua)
        {
            int op = extractFunction(l, p);

            if (LuaDLL.lua_isnil(l, p))
            {
                ua = null;
                return(op);
            }
            else if (LuaDLL.lua_isuserdata(l, p) == 1)
            {
                ua = (UIEventListener.BoolDelegate)checkObj(l, p);
                return(op);
            }
            LuaDelegate ld;

            checkType(l, -1, out ld);
            if (ld.d != null)
            {
                ua = (UIEventListener.BoolDelegate)ld.d;
                return(op);
            }
            LuaDLL.lua_pop(l, 1);

            l  = LuaState.get(l).L;
            ua = (UnityEngine.GameObject a1, bool a2) =>
            {
                int error = pushTry(l);

                pushValue(l, a1);
                pushValue(l, a2);
                ld.pcall(2, error);
                LuaDLL.lua_settop(l, error - 1);
            };
            ld.d = ua;
            return(op);
        }
    public void ShowTouchGuide(UIEventListener.BoolDelegate onPress = null, bool up = false, float angle = 0f)
    {
        Transform joystick = m_uiController.transform.FindChild("Joystick/Joystick");

        if (_touch_guide_obj == null)
        {
            _touch_guide_obj = CommonFunction.InstantiateObject(up ? _touch_guide_up_prefab : _touch_guide_prefab, joystick);
            UIManager.Instance.BringWidgetForward(_touch_guide_obj);
            _touch_guide_obj.GetComponentInChildren <TweenAlpha>().AddOnFinished(() =>
            {
                NGUITools.Destroy(_touch_guide_obj);
                _touch_guide_obj = null;
            });
            UIEventListener.Get(joystick.gameObject).onPress += OnJoyStickPress;
            if (onPress != null)
            {
                UIEventListener.Get(joystick.gameObject).onPress += onPress;
            }
        }
        if (up)
        {
            _touch_guide_obj.GetComponent <TouchGuideUp>().angle = angle;
        }
    }
Exemple #30
0
 // 用于接收NGUI处理的输入事件
 public void registeBoxColliderNGUI(txUIObject obj, UIEventListener.VoidDelegate clickCallback,
                                    UIEventListener.BoolDelegate pressCallback = null, UIEventListener.BoolDelegate hoverCallback = null)
 {
     mGlobalTouchSystem.registeBoxColliderNGUI(obj, clickCallback, pressCallback, hoverCallback);
 }