RestrictWithinBounds() public method

Restrict the scroll view's contents to be within the scroll view's bounds.
public RestrictWithinBounds ( bool instant ) : bool
instant bool
return bool
Ejemplo n.º 1
0
    public void MoveNext(int delta)
    {
        Debug.Log("delta:" + delta);
        m_scrollView.DisableSpring();
        m_scrollView.MoveRelative(new Vector3(delta * cellWidth, 0));
        m_scrollView.InvalidateBounds();
        m_scrollView.RestrictWithinBounds(true);

        gameObject.SetActive(false);
        gameObject.SetActive(true);
    }
Ejemplo n.º 2
0
    private static int RestrictWithinBounds(IntPtr L)
    {
        int num = LuaDLL.lua_gettop(L);

        if (num == 2)
        {
            UIScrollView uIScrollView = (UIScrollView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIScrollView");
            bool         boolean      = LuaScriptMgr.GetBoolean(L, 2);
            bool         b            = uIScrollView.RestrictWithinBounds(boolean);
            LuaScriptMgr.Push(L, b);
            return(1);
        }
        if (num == 4)
        {
            UIScrollView uIScrollView2 = (UIScrollView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIScrollView");
            bool         boolean2      = LuaScriptMgr.GetBoolean(L, 2);
            bool         boolean3      = LuaScriptMgr.GetBoolean(L, 3);
            bool         boolean4      = LuaScriptMgr.GetBoolean(L, 4);
            bool         b2            = uIScrollView2.RestrictWithinBounds(boolean2, boolean3, boolean4);
            LuaScriptMgr.Push(L, b2);
            return(1);
        }
        LuaDLL.luaL_error(L, "invalid arguments to method: UIScrollView.RestrictWithinBounds");
        return(0);
    }
Ejemplo n.º 3
0
    protected void SetBounds(float totalLength)
    {
        Vector3 topLeft   = CalcTopLeft();
        float   width     = scrollView.panel.baseClipRegion.z;
        float   visHeight = scrollView.panel.baseClipRegion.w;

        totalLength = Mathf.Max(totalLength, visHeight);
        scrollView.panel.GetViewSize();

        Vector3 center = new Vector3(topLeft.x + width / 2f, topLeft.y - totalLength / 2f, 0);
        Vector3 size   = new Vector3(width, totalLength, 0);

        scrollView.bounds = new Bounds(center, size);

        BoxCollider bc = Content.gameObject.GetOrAddComponent <BoxCollider>();

        bc.center = center;
        bc.size   = size;
        var widget = Content.gameObject.GetOrAddComponent <UIWidget>();

        widget.rawPivot = UIWidget.Pivot.TopLeft;
        widget.width    = (int)size.x;
        widget.height   = (int)size.y;

        if (scrollView.restrictWithinPanel)
        {
            scrollView.RestrictWithinBounds(true);
        }
    }
Ejemplo n.º 4
0
    static int RestrictWithinBounds(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                UIScrollView obj  = (UIScrollView)ToLua.CheckObject <UIScrollView>(L, 1);
                bool         arg0 = LuaDLL.luaL_checkboolean(L, 2);
                bool         o    = obj.RestrictWithinBounds(arg0);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 4)
            {
                UIScrollView obj  = (UIScrollView)ToLua.CheckObject <UIScrollView>(L, 1);
                bool         arg0 = LuaDLL.luaL_checkboolean(L, 2);
                bool         arg1 = LuaDLL.luaL_checkboolean(L, 3);
                bool         arg2 = LuaDLL.luaL_checkboolean(L, 4);
                bool         o    = obj.RestrictWithinBounds(arg0, arg1, arg2);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UIScrollView.RestrictWithinBounds"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 5
0
    static int RestrictWithinBounds(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UIScrollView), typeof(bool)))
            {
                UIScrollView obj  = (UIScrollView)ToLua.ToObject(L, 1);
                bool         arg0 = LuaDLL.lua_toboolean(L, 2);
                bool         o    = obj.RestrictWithinBounds(arg0);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 4 && ToLua.CheckTypes(L, 1, typeof(UIScrollView), typeof(bool), typeof(bool), typeof(bool)))
            {
                UIScrollView obj  = (UIScrollView)ToLua.ToObject(L, 1);
                bool         arg0 = LuaDLL.lua_toboolean(L, 2);
                bool         arg1 = LuaDLL.lua_toboolean(L, 3);
                bool         arg2 = LuaDLL.lua_toboolean(L, 4);
                bool         o    = obj.RestrictWithinBounds(arg0, arg1, arg2);
                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.tolua_error(L, "invalid arguments to method: UIScrollView.RestrictWithinBounds"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 6
0
        void ResetScrollView(GameObject scvObj, bool isVertical)
        {
            UIPanel      panel      = scvObj.GetComponent <UIPanel>();
            UIScrollView scrollview = scvObj.GetComponent <UIScrollView>();
            Transform    trs        = scvObj.transform;

            if (panel == null || scrollview == null)
            {
                return;
            }

            scrollview.ResetPosition();
            scrollview.RestrictWithinBounds(false, !isVertical, isVertical);

            panel.clipOffset = Vector3.zero;

            if (isVertical)
            {
                trs.localPosition = new Vector3(trs.localPosition.x, 0.0f, trs.localPosition.z);
            }
            else
            {
                trs.localPosition = new Vector3(0.0f, trs.localPosition.y, trs.localPosition.z);
                // 计算标签索引,以及是否显示标签小箭头
                SetTabArrowStatus();
            }
        }
Ejemplo n.º 7
0
    static int RestrictWithinBounds(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2)
        {
            UIScrollView obj  = (UIScrollView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIScrollView");
            bool         arg0 = LuaScriptMgr.GetBoolean(L, 2);
            bool         o    = obj.RestrictWithinBounds(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 4)
        {
            UIScrollView obj  = (UIScrollView)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UIScrollView");
            bool         arg0 = LuaScriptMgr.GetBoolean(L, 2);
            bool         arg1 = LuaScriptMgr.GetBoolean(L, 3);
            bool         arg2 = LuaScriptMgr.GetBoolean(L, 4);
            bool         o    = obj.RestrictWithinBounds(arg0, arg1, arg2);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: UIScrollView.RestrictWithinBounds");
        }

        return(0);
    }
 void Update()
 {
     if (_isPress)
     {
         scrollView.MoveRelative(direction * Speed);
         scrollView.RestrictWithinBounds(false, !verticle, verticle);
     }
 }
Ejemplo n.º 9
0
    public void ItemViewPostion(int nItemNumber)
    {
        float width = mGridObject.cellWidth;
        //float height = mGridObject.cellHeight;

        Vector3 postionVec3 = VPostion(width, 0f, nItemNumber, 0);

        mScrollView.MoveRelative(postionVec3);
        mScrollView.RestrictWithinBounds(true);
    }
Ejemplo n.º 10
0
        public void SetData(LegionData data)
        {
            if (!data.legionIconSptName.Equals(""))
            {
                legionIconSpt.spriteName = data.legionIconSptName;
            }
            iconBGSp.spriteName = data.legionIconBGSptName;

            LTUIUtil.SetText(legionNameLabel, data.legionName);
            LTUIUtil.SetText(legionLevelLabel, data.legionLevel.ToString());
            LTUIUtil.SetText(expLabel, string.Format("{0}/{1}", data.currentExp, data.growupExp));
            LTUIUtil.SetText(peopleNumLabel, string.Format("{0}/{1}", data.currentPeopleNum, data.maxPeopleNum));
            LTUIUtil.SetText(bossNameLabel, data.ownerName);
            if (data.notice != null)
            {
                LTUIUtil.SetText(logLabel, data.notice.Equals("") ? logLabel.text : data.notice);
            }
            if (isShow)
            {
                memberItemScroll.SetItemDatas(data.listMember.ToArray());
            }
            //权限
            if (data.userMemberData != null)
            {
                editNameBtn.gameObject.CustomSetActive(data.userMemberData.dutyType == eAllianceMemberRole.Owner);
                switch (data.userMemberData.dutyType)
                {
                case eAllianceMemberRole.Member:
                    PageMemberState = State.Member;
                    ChangeOpen(false, false, false);
                    break;

                case eAllianceMemberRole.Admin:
                    PageMemberState = State.Admin;
                    ChangeOpen(true, false, false);
                    break;

                case eAllianceMemberRole.ExtraOwner:
                    PageMemberState = State.Admin;
                    ChangeOpen(true, true, false);
                    break;

                case eAllianceMemberRole.Owner:
                    PageMemberState = State.Admin;
                    ChangeOpen(true, true, true);
                    break;
                }
            }

            if (scrollView != null)
            {
                scrollView.RestrictWithinBounds(true);
            }
        }
Ejemplo n.º 11
0
        static int _m_RestrictWithinBounds(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UIScrollView gen_to_be_invoked = (UIScrollView)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2))
                {
                    bool _instant = LuaAPI.lua_toboolean(L, 2);

                    bool gen_ret = gen_to_be_invoked.RestrictWithinBounds(_instant);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 4 && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4))
                {
                    bool _instant    = LuaAPI.lua_toboolean(L, 2);
                    bool _horizontal = LuaAPI.lua_toboolean(L, 3);
                    bool _vertical   = LuaAPI.lua_toboolean(L, 4);

                    bool gen_ret = gen_to_be_invoked.RestrictWithinBounds(_instant, _horizontal, _vertical);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UIScrollView.RestrictWithinBounds!"));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// ScrollView 位移表现
        /// </summary>
        /// <param name="mScroll"></param>
        /// <param name="dis"></param>
        /// 正数为从右到左、负数为从左到右
        public static void ScrollViewTweenPosition(UIScrollView mScroll, float dis)
        {
            Vector3 ls = mScroll.gameObject.transform.localPosition;
            float   px = ls.x + dis;

            mScroll.gameObject.transform.localPosition = new Vector3(px, ls.y, ls.z);
            Vector2 v2 = mScroll.GetComponent <UIPanel>().clipOffset;

            v2.x = -px + ls.x + v2.x;
            mScroll.GetComponent <UIPanel>().clipOffset = v2;
            mScroll.RestrictWithinBounds(false);
        }
Ejemplo n.º 13
0
        public static void ScrollHorizontalTo(this UIScrollView scroll, Transform t, bool centered = true)
        {
            scroll.ResetPosition();
            Vector3 delta      = t.TransformSpace(Vector3.zero, scroll.transform);
            Bounds  cellBounds = NGUIMath.CalculateRelativeWidgetBounds(t);
            float   x          = -delta.x + cellBounds.extents.x;

            if (centered)
            {
                x -= scroll.panel.GetViewSize().x / 2;
            }
            scroll.MoveRelative(new Vector3(x, 0, 0));
            scroll.RestrictWithinBounds(true);
        }
Ejemplo n.º 14
0
    public void MoveRelative(int delta)
    {
        m_scrollView.DisableSpring();
        if (m_scrollView.canMoveVertically)
        {
            m_scrollView.MoveRelative(new Vector3(0, (delta - m_lastDataIndex) * cellHeight));
        }
        else
        {
            m_scrollView.MoveRelative(new Vector3((m_lastDataIndex - delta) * cellWidth, 0));
        }
        m_scrollView.InvalidateBounds();
        m_scrollView.RestrictWithinBounds(true);

        gameObject.SetActive(false);
        gameObject.SetActive(true);
    }
Ejemplo n.º 15
0
        void OnEnable()
        {
            if (previousSearches.Count == 0)                 // if there are no recent searches
            {
                model.recentSearchLabel.color = Color.clear; // don't show label
            }
            else
            {
                model.recentSearchLabel.color = Color.white;                // else if there are, show label

                previousLocationView.RestrictWithinBounds(true);
            }

#if UNITY_ANDROID
            model.clearButton.SetActive(false);
#endif
        }
    /// <summary>
    /// 定位
    /// </summary>
    /// <param name="index"></param>
    public void GoToPosition(int index, int ofx = 0, int ofy = 0)
    {
        if (index < 0 || index >= mDataSource.Count)
        {
            return;
        }

        int actualIndex = index / maxPerLine;

        if (arrangement == Arrangement.Vertical)
        {
            float   h     = cellHeight * actualIndex;
            Vector3 vTemp = Vector3.zero;
            vTemp.x = mPanelInitPos.x;
            vTemp.y = mPanelInitPos.y + h;
            vTemp.z = mPanelInitPos.z;
            mPanel.transform.localPosition = vTemp;
            vTemp.x           = mPanelInitOffest.x;
            vTemp.y           = mPanelInitOffest.y - h;
            vTemp.z           = 0;
            mPanel.clipOffset = vTemp;
        }
        else if (arrangement == Arrangement.Horizontal)
        {
            float   w     = cellWidth * actualIndex;
            Vector3 vTemp = Vector3.zero;
            vTemp.x = mPanelInitPos.x - w + ofx;
            vTemp.y = mPanelInitPos.y + ofy;
            vTemp.z = mPanelInitPos.z;
            mPanel.transform.localPosition = vTemp;

            vTemp.x           = mPanelInitOffest.x + w + ofx;
            vTemp.y           = mPanelInitOffest.y + ofy;
            vTemp.z           = 0;
            mPanel.clipOffset = vTemp;
        }

        OnCustomDrag();
        UIScrollView view = NGUITools.FindInParents <UIScrollView>(gameObject);

        view.DisableSpring();
        view.UpdateScrollbars(true);
        view.RestrictWithinBounds(false, view.canMoveHorizontally, view.canMoveVertically);
    }
Ejemplo n.º 17
0
    public static int RestrictWithinBounds(IntPtr l)
    {
        int result;

        try
        {
            int num = LuaDLL.pua_gettop(l);
            if (num == 2)
            {
                UIScrollView uIScrollView = (UIScrollView)LuaObject.checkSelf(l);
                bool         instant;
                LuaObject.checkType(l, 2, out instant);
                bool b = uIScrollView.RestrictWithinBounds(instant);
                LuaObject.pushValue(l, true);
                LuaObject.pushValue(l, b);
                result = 2;
            }
            else if (num == 4)
            {
                UIScrollView uIScrollView2 = (UIScrollView)LuaObject.checkSelf(l);
                bool         instant2;
                LuaObject.checkType(l, 2, out instant2);
                bool horizontal;
                LuaObject.checkType(l, 3, out horizontal);
                bool vertical;
                LuaObject.checkType(l, 4, out vertical);
                bool b2 = uIScrollView2.RestrictWithinBounds(instant2, horizontal, vertical);
                LuaObject.pushValue(l, true);
                LuaObject.pushValue(l, b2);
                result = 2;
            }
            else
            {
                LuaObject.pushValue(l, false);
                LuaDLL.pua_pushstring(l, "No matched override function to call");
                result = 2;
            }
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Ejemplo n.º 18
0
    public void GoToPosition(int index)
    {
        if (index < 0 || index >= this.mDataSource.Count)
        {
            return;
        }
        int num = index / this.maxPerLine;

        if (this.arrangement == UIGrid.Arrangement.Vertical)
        {
            float   num2 = this.cellHeight * (float)num;
            Vector3 zero = Vector3.zero;
            zero.x = this.mPanelInitPos.x;
            zero.y = this.mPanelInitPos.y + num2;
            zero.z = this.mPanelInitPos.z;
            this.mPanel.transform.localPosition = zero;
            zero.x = this.mPanelInitOffest.x;
            zero.y = this.mPanelInitOffest.y - num2;
            zero.z = 0f;
            this.mPanel.clipOffset = zero;
        }
        else if (this.arrangement == UIGrid.Arrangement.Horizontal)
        {
            float   num3  = this.cellWidth * (float)num;
            Vector3 zero2 = Vector3.zero;
            zero2.x = this.mPanelInitPos.x - num3;
            zero2.y = this.mPanelInitPos.y;
            zero2.z = this.mPanelInitPos.z;
            this.mPanel.transform.localPosition = zero2;
            zero2.x = this.mPanelInitOffest.x + num3;
            zero2.y = this.mPanelInitOffest.y;
            zero2.z = 0f;
            this.mPanel.clipOffset = zero2;
        }
        this.OnCustomDrag();
        UIScrollView uIScrollView = NGUITools.FindInParents <UIScrollView>(base.gameObject);

        uIScrollView.DisableSpring();
        uIScrollView.UpdateScrollbars(true);
        uIScrollView.RestrictWithinBounds(false, uIScrollView.canMoveHorizontally, uIScrollView.canMoveVertically);
    }
Ejemplo n.º 19
0
    public void Reposition()
    {
        if (Application.isPlaying && !mInitDone)
        {
            mReposition = true;
            return;
        }

        if (!mInitDone)
        {
            Init();
        }

        mReposition = false;
        Transform myTrans = transform;

        mChildren.Clear();
        List <Transform> ch = children;

        if (ch.Count > 0)
        {
            RepositionVariableSize(ch);
        }

        if (mDrag != null)
        {
            mDrag.UpdateScrollbars(true);
            mDrag.RestrictWithinBounds(true);
        }
        else if (mPanel != null)
        {
            mPanel.ConstrainTargetToBounds(myTrans, true);
        }

        if (onReposition != null)
        {
            onReposition();
        }
    }
Ejemplo n.º 20
0
    protected void EventResetPosition()
    {
        for (int i = 0; i < _iCountScrollItem; i++)
        {
            _listScrollViewItem[i].SetActive(i < _iCountRealItem);
        }

        int iMaxItem = Mathf.Max(1, _iCountRealItem - 1);

        _pUIWrapContent.minIndex = -iMaxItem;
        _pUIWrapContent.maxIndex = 0;

        _pUIWrapContent.SortAlphabetically();
        _pUIWrapContent.WrapContent();

        if (_iCountRealItem < _iCountScrollItem)
        {
            _pUIScrollView.ResetPosition();
            _pUIScrollView.RestrictWithinBounds(true);
        }

        ProcCheckDisableDrag();
    }
Ejemplo n.º 21
0
        void OnDragFinished()
        {
            Vector3 constraint = mScrollView.panel.CalculateConstrainOffset(mScrollView.bounds.min, mScrollView.bounds.max);

            if (mScrollView.RestrictWithinBounds(false, false, true))
            {
                if (constraint.y > 0f)//上到头
                {
                    mArrowUpDown[0].gameObject.SetActive(false);
                    mArrowUpDown[1].gameObject.SetActive(true);
                }
                else//左到头
                {
                    mArrowUpDown[0].gameObject.SetActive(true);
                    mArrowUpDown[1].gameObject.SetActive(false);
                }
            }
            else
            {
                mArrowUpDown[0].gameObject.SetActive(true);
                mArrowUpDown[1].gameObject.SetActive(true);
            }
        }
Ejemplo n.º 22
0
    private static int RestrictWithinBounds(IntPtr L)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(L);
            if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(UIScrollView), typeof(bool)))
            {
                UIScrollView uIScrollView = (UIScrollView)ToLua.ToObject(L, 1);
                bool         instant      = LuaDLL.lua_toboolean(L, 2);
                bool         value        = uIScrollView.RestrictWithinBounds(instant);
                LuaDLL.lua_pushboolean(L, value);
                result = 1;
            }
            else if (num == 4 && TypeChecker.CheckTypes(L, 1, typeof(UIScrollView), typeof(bool), typeof(bool), typeof(bool)))
            {
                UIScrollView uIScrollView2 = (UIScrollView)ToLua.ToObject(L, 1);
                bool         instant2      = LuaDLL.lua_toboolean(L, 2);
                bool         horizontal    = LuaDLL.lua_toboolean(L, 3);
                bool         vertical      = LuaDLL.lua_toboolean(L, 4);
                bool         value2        = uIScrollView2.RestrictWithinBounds(instant2, horizontal, vertical);
                LuaDLL.lua_pushboolean(L, value2);
                result = 1;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "invalid arguments to method: UIScrollView.RestrictWithinBounds");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Ejemplo n.º 23
0
 static public int RestrictWithinBounds(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UIScrollView   self = (UIScrollView)checkSelf(l);
             System.Boolean a1;
             checkType(l, 2, out a1);
             var ret = self.RestrictWithinBounds(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 4)
         {
             UIScrollView   self = (UIScrollView)checkSelf(l);
             System.Boolean a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             System.Boolean a3;
             checkType(l, 4, out a3);
             var ret = self.RestrictWithinBounds(a1, a2, a3);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 24
0
        public void SetData(LegionData data)
        {
            limitLevelLabel.text = data.conditionLevel.ToString();
            requestNumLabel.text = data.listRequestJoin.Count.ToString();

            IsOpenApprove = data.isNeedApprove;

            //int num = data.listRequestJoin.Count;
            //LTUIUtil.SetNumTemplate(approveItemTemplate, listApproveItem, num, itemBehind);

            if (data.listRequestJoin.Count > listApproveItem.Count)
            {
                int length = data.listRequestJoin.Count;
                int index  = listApproveItem.Count;

                for (int i = index; i < length; i++)
                {
                    GameObject go = Object.Instantiate(approveItemTemplate.mDMono.gameObject);
                    go.transform.parent     = grid.transform;
                    go.transform.localScale = approveItemTemplate.mDMono.transform.localScale;
                    LegionApproveItem item = go.GetMonoILRComponent <LegionApproveItem>();
                    listApproveItem.Add(item);
                }
                grid.Reposition();
            }

            for (int i = 0; i < listApproveItem.Count; i++)
            {
                if (i < data.listRequestJoin.Count)
                {
                    RequestJoinData   joinData = data.listRequestJoin[i];
                    LegionApproveItem item     = listApproveItem[i];
                    item.SetData(joinData);
                    item.SetAction(OnClickConsentApprove, OnClickRefuseApprove);
                }
                else
                {
                    listApproveItem[i].ShowUI(false);
                }
            }

            //权限
            if (data.userMemberData != null)
            {
                switch (data.userMemberData.dutyType)
                {
                case eAllianceMemberRole.Member:
                case eAllianceMemberRole.Admin:
                    ChangeOpen(false);
                    break;

                case eAllianceMemberRole.ExtraOwner:
                case eAllianceMemberRole.Owner:
                    ChangeOpen(true);
                    break;
                }
            }

            if (scrollView != null)
            {
                scrollView.RestrictWithinBounds(true);
            }
        }
Ejemplo n.º 25
0
    private void OnMoved(UIPanel panel)
    {
        if (enabled)
        {
            Vector3 momentum  = mScrollView.currentMomentum * mScrollView.momentumAmount;
            Vector3 moveDelta = NGUIMath.SpringDampen(ref momentum, 9f, 2f);
            float   offset    = 0;
            float   delta     = 0;
            int     sign      = space < 0 ? -1 : 1;
            if (mAxis == Vector3.right)
            {
                offset = mPanel.clipOffset.x;
                delta  = (moveDelta * momentumOffset).x;
            }
            else if (mAxis == Vector3.down)
            {
                offset = -mPanel.clipOffset.y;
                delta  = (moveDelta * momentumOffset).y;
            }

            int minIndex = mCenterIndex - itemRadius;
            int maxIndex = mCenterIndex + itemRadius;
            if (offset * sign + mSize + delta > (maxIndex + 1 - prevRefresh) * space * sign && mCenterIndex < mTotalCount - 1 - itemRadius)
            {
                while (offset * sign + mSize + delta > (maxIndex + 1 - prevRefresh) * space * sign && mCenterIndex < mTotalCount - 1 - itemRadius)
                {
                    int shortIndex = (minIndex) % mShortCount;
                    mItems[shortIndex].localPosition = (maxIndex + 1) * space * mAxis;
                    if (onUpdateItem != null)
                    {
                        onUpdateItem(mItems[shortIndex], maxIndex + 1);
                    }
                    ++mCenterIndex;
                    ++minIndex;
                    ++maxIndex;
                }
                SortItems();
                mScrollView.InvalidateBounds();
                mScrollView.RestrictWithinBounds(true);
            }
            else if (offset * sign + delta < (minIndex + prevRefresh) * space * sign && mCenterIndex > itemRadius)
            {
                while (offset * sign + delta < (minIndex + prevRefresh) * space * sign && mCenterIndex > itemRadius)
                {
                    int shortIndex = (maxIndex) % mShortCount;
                    mItems[shortIndex].localPosition = (minIndex - 1) * space * mAxis;
                    if (onUpdateItem != null)
                    {
                        onUpdateItem(mItems[shortIndex], minIndex - 1);
                    }
                    --mCenterIndex;
                    --minIndex;
                    --maxIndex;
                }
                SortItems();
                mScrollView.InvalidateBounds();
                mScrollView.RestrictWithinBounds(true);
            }

            UpdatePagination(offset, mTotalCount);
        }
    }
Ejemplo n.º 26
0
    public void Reposition()
    {
        if (Application.isPlaying && !mStarted)
        {
            mReposition = true;
            return;
        }

        if (!mInitDone)
        {
            Init();
        }

        mReposition = false;
        Transform myTrans = transform;

        int x      = 0;
        int y      = 0;
        int height = 0;

        for (int i = 0; i < myTrans.childCount; ++i)
        {
            Transform t = myTrans.GetChild(i);

            // UISprite cell = t.FindChild("back").gameObject.GetComponent<UISprite>();
            UISprite cell = t.GetComponent <UISprite>();
            if (!NGUITools.GetActive(t.gameObject) && hideInactive)
            {
                continue;
            }

            float depth = t.localPosition.z;

            Vector3 pos = new Vector3(0, -height, depth);

            height += cell.height;

            if (animateSmoothly && Application.isPlaying)
            {
                SpringPosition.Begin(t.gameObject, pos, 15f);
            }
            else
            {
                t.localPosition = pos;
            }

            if (++x >= maxPerLine && maxPerLine > 0)
            {
                x = 0;
                ++y;
            }
        }

        if (mDrag != null)
        {
            mDrag.UpdateScrollbars(true);
            mDrag.RestrictWithinBounds(true);
        }
        else if (mPanel != null)
        {
            mPanel.ConstrainTargetToBounds(myTrans, true);
        }

        if (onReposition != null)
        {
            onReposition();
        }
    }
Ejemplo n.º 27
0
    public void Reposition()
    {
        if (Application.isPlaying && !mStarted)
        {
            mReposition = true;
            return;
        }

        //if (!mInitDone) Init();

        mReposition = false;
        Transform myTrans = transform;

        /*
         * int x = 0;
         * int y = 0;
         * //if (sorted)
         * if( false )
         * {
         *      List<Transform> list = new List<Transform>();
         *
         *      for (int i = 0; i < myTrans.childCount; ++i)
         *      {
         *              Transform t = myTrans.GetChild(i);
         *              if (t && (!hideInactive || NGUITools.GetActive(t.gameObject))) list.Add(t);
         *      }
         *      list.Sort(SortByName);
         *
         *      for (int i = 0, imax = list.Count; i < imax; ++i)
         *      {
         *              Transform t = list[i];
         *
         *              if (!NGUITools.GetActive(t.gameObject) && hideInactive) continue;
         *
         *              float depth = t.localPosition.z;
         *              Vector3 pos = (arrangement == Arrangement.Horizontal) ?
         *                      new Vector3(cellWidth * x, -cellHeight * y, depth) :
         *                      new Vector3(cellWidth * y, -cellHeight * x, depth);
         *
         *              if (animateSmoothly && Application.isPlaying)
         *              {
         *                      SpringPosition.Begin(t.gameObject, pos, 15f);
         *              }
         *              else t.localPosition = pos;
         *
         *              if (++x >= maxPerLine && maxPerLine > 0)
         *              {
         *                      x = 0;
         ++y;
         *              }
         *      }
         * /*		}
         * else
         * {
         *      /*for (int i = 0; i < myTrans.childCount; ++i)
         *      {
         *              Transform t = myTrans.GetChild(i);
         *
         *              if (!NGUITools.GetActive(t.gameObject) && hideInactive) continue;
         *
         *              float depth = t.localPosition.z;
         *              Vector3 pos = (arrangement == Arrangement.Horizontal) ?
         *                      new Vector3(cellWidth * x, -cellHeight * y, depth) :
         *                      new Vector3(cellWidth * y, -cellHeight * x, depth);
         *
         *              if (animateSmoothly && Application.isPlaying)
         *              {
         *                      SpringPosition.Begin(t.gameObject, pos, 15f);
         *              }
         *              else t.localPosition = pos;
         *
         *              if (++x >= maxPerLine && maxPerLine > 0)
         *              {
         *                      x = 0;
         ++y;
         *              }
         *      }
         * }
         */

        if (mDrag != null)
        {
            mDrag.UpdateScrollbars(true);
            mDrag.RestrictWithinBounds(true);
        }
        else if (mPanel != null)
        {
            mPanel.ConstrainTargetToBounds(myTrans, true);
        }

        if (onReposition != null)
        {
            onReposition();
        }
    }
Ejemplo n.º 28
0
    public void Reposition()
    {
        if (Application.isPlaying && !mStarted)
        {
            mReposition = true;
            return;
        }

        if (!mInitDone)
        {
            Init();
        }

        mReposition = false;
        Transform myTrans = transform;

        int x      = 0;
        int y      = 0;
        int height = 0;

        List <ChatItemBase> list = OnSortTime();

        for (int i = 0; i < list.Count; ++i)
        {
            ChatItemBase item = list[i];

            if (item == null)
            {
                continue;
            }

            Transform t = item.transform;

            if (!NGUITools.GetActive(t.gameObject) && hideInactive)
            {
                continue;
            }

            float   depth = t.localPosition.z;
            Vector3 vTemp = Vector3.zero;
            vTemp.x = 0;
            vTemp.y = height;
            vTemp.z = depth;
            Vector3 pos = vTemp;
            height += cellHeight;
            if (animateSmoothly && Application.isPlaying)
            {
                SpringPosition.Begin(t.gameObject, pos, 15f);
            }
            else
            {
                t.localPosition = pos;
            }
            if (++x >= maxPerLine && maxPerLine > 0)
            {
                x = 0;
                ++y;
            }
        }

        if (mDrag != null)
        {
            mDrag.UpdateScrollbars(true);

            if (isMainHeight)
            {
                mDrag.RestrictWithinBounds(true);
            }
            else
            {
                mDrag.RestrictWithinBounds(true, false, true);
            }
        }
        else if (mPanel != null)
        {
            //if (isMainHeight)
            mPanel.ConstrainTargetToBounds(myTrans, true);
        }

        if (onReposition != null)
        {
            onReposition();
        }
    }