Ejemplo n.º 1
0
        public void SelectElementImmediately(int index)
        {
            base.SelectElement(index, true);
            this.m_contentSize = Vector2.zero;
            Vector2 zero = Vector2.zero;

            if (this.m_listType == enUIListType.Horizontal)
            {
                zero.x += this.m_elementLayoutOffset;
            }
            else if (this.m_listType == enUIListType.Vertical)
            {
                zero.y += this.m_elementLayoutOffset;
            }
            for (int i = 0; i < this.m_elementAmount; i++)
            {
                stRect stRect = this.LayoutExpandElement(i, (float)((i != index) ? 0 : 1), ref this.m_contentSize, ref zero);
                if (i < this.m_elementsRect.get_Count())
                {
                    this.m_elementsRect.set_Item(i, stRect);
                }
                else
                {
                    this.m_elementsRect.Add(stRect);
                }
            }
            this.ResizeContent(ref this.m_contentSize, false);
            if (index < 0 || index >= this.m_elementAmount)
            {
                this.m_contentRectTransform.anchoredPosition = Vector2.zero;
            }
            else
            {
                this.m_contentRectTransform.anchoredPosition = this.GetTargetContentAnchoredPosition(index);
            }
            for (int j = 0; j < this.m_elementAmount; j++)
            {
                stRect stRect2 = this.m_elementsRect.get_Item(j);
                CUIListElementScript elemenet = base.GetElemenet(j);
                if (elemenet != null)
                {
                    elemenet.SetRect(ref stRect2);
                }
                else if (!this.m_useOptimized || base.IsRectInScrollArea(ref stRect2))
                {
                    base.CreateElement(j, ref stRect2);
                }
            }
        }
Ejemplo n.º 2
0
        public void SelectElementImmediately(int index)
        {
            base.SelectElement(index, true);
            base.m_contentSize = Vector2.zero;
            Vector2 zero = Vector2.zero;

            if (base.m_listType == enUIListType.Horizontal)
            {
                zero.x += base.m_elementLayoutOffset;
            }
            else if (base.m_listType == enUIListType.Vertical)
            {
                zero.y += base.m_elementLayoutOffset;
            }
            for (int i = 0; i < base.m_elementAmount; i++)
            {
                stRect item = this.LayoutExpandElement(i, (i != index) ? ((float)0) : ((float)1), ref this.m_contentSize, ref zero);
                if (i < base.m_elementsRect.Count)
                {
                    base.m_elementsRect[i] = item;
                }
                else
                {
                    base.m_elementsRect.Add(item);
                }
            }
            this.ResizeContent(ref this.m_contentSize, false);
            if ((index < 0) || (index >= base.m_elementAmount))
            {
                base.m_contentRectTransform.anchoredPosition = Vector2.zero;
            }
            else
            {
                base.m_contentRectTransform.anchoredPosition = this.GetTargetContentAnchoredPosition(index);
            }
            for (int j = 0; j < base.m_elementAmount; j++)
            {
                stRect rect = base.m_elementsRect[j];
                CUIListElementScript elemenet = base.GetElemenet(j);
                if (elemenet != null)
                {
                    elemenet.SetRect(ref rect);
                }
                else if (!base.m_useOptimized || base.IsRectInScrollArea(ref rect))
                {
                    base.CreateElement(j, ref rect);
                }
            }
        }
Ejemplo n.º 3
0
        private void UpdateSelectedElement(enExpandListSelectingState selectingState)
        {
            switch (selectingState)
            {
            case enExpandListSelectingState.Retract:
                if (this.m_timeSlice < this.m_expandedTime)
                {
                    this.m_timeSlice  += Time.deltaTime;
                    this.m_contentSize = Vector2.zero;
                    Vector2 zero = Vector2.zero;
                    if (this.m_listType == enUIListType.Horizontal)
                    {
                        zero.x += this.m_elementLayoutOffset;
                    }
                    else if (this.m_listType == enUIListType.Vertical)
                    {
                        zero.y += this.m_elementLayoutOffset;
                    }
                    for (int i = 0; i < this.m_elementAmount; i++)
                    {
                        float num = 0f;
                        if (i == this.m_lastSelectedElementIndex)
                        {
                            num = 1f - this.m_timeSlice / this.m_expandedTime;
                            num = Mathf.Clamp(num, 0f, 1f);
                        }
                        stRect stRect = this.LayoutExpandElement(i, num, ref this.m_contentSize, ref zero);
                        if (i < this.m_elementsRect.get_Count())
                        {
                            this.m_elementsRect.set_Item(i, stRect);
                        }
                        else
                        {
                            this.m_elementsRect.Add(stRect);
                        }
                    }
                    this.ResizeContent(ref this.m_contentSize, false);
                    if (this.m_selectedElementIndex < 0 || this.m_selectedElementIndex >= this.m_elementAmount)
                    {
                        if (this.m_listType == enUIListType.Horizontal)
                        {
                            if (this.m_contentAnchoredPosition.x > 0f)
                            {
                                this.m_contentAnchoredPosition.x = 0f;
                            }
                            else if (this.m_contentAnchoredPosition.x + this.m_contentSize.x < this.m_scrollAreaSize.x)
                            {
                                this.m_contentAnchoredPosition.x = this.m_scrollAreaSize.x - this.m_contentSize.x;
                            }
                        }
                        else if (this.m_listType == enUIListType.Vertical)
                        {
                            if (this.m_contentAnchoredPosition.y < 0f)
                            {
                                this.m_contentAnchoredPosition.y = 0f;
                            }
                            else if (this.m_contentAnchoredPosition.y - this.m_contentSize.y > -this.m_scrollAreaSize.y)
                            {
                                this.m_contentAnchoredPosition.y = -this.m_scrollAreaSize.y + this.m_contentSize.y;
                            }
                        }
                    }
                }
                else if (this.m_selectedElementIndex >= 0 && this.m_selectedElementIndex < this.m_elementAmount)
                {
                    this.m_targetContentAnchoredPosition = this.GetTargetContentAnchoredPosition(this.m_selectedElementIndex);
                    this.m_selectingState = enExpandListSelectingState.Move;
                    this.m_timeSlice      = 0f;
                }
                else
                {
                    this.m_selectingState = enExpandListSelectingState.None;
                }
                break;

            case enExpandListSelectingState.Move:
                if (this.m_contentAnchoredPosition != this.m_targetContentAnchoredPosition)
                {
                    if (this.m_listType == enUIListType.Horizontal)
                    {
                        int num2 = (this.m_targetContentAnchoredPosition.x <= this.m_contentAnchoredPosition.x) ? -1 : 1;
                        this.m_contentAnchoredPosition.x = this.m_contentAnchoredPosition.x + Time.deltaTime * this.m_contentFixingSpeed * (float)num2;
                        if ((num2 > 0 && this.m_contentAnchoredPosition.x >= this.m_targetContentAnchoredPosition.x) || (num2 < 0 && this.m_contentAnchoredPosition.x <= this.m_targetContentAnchoredPosition.x))
                        {
                            this.m_contentAnchoredPosition = this.m_targetContentAnchoredPosition;
                        }
                    }
                    else if (this.m_listType == enUIListType.Vertical)
                    {
                        int num3 = (this.m_targetContentAnchoredPosition.y <= this.m_contentAnchoredPosition.y) ? -1 : 1;
                        this.m_contentAnchoredPosition.y = this.m_contentAnchoredPosition.y + Time.deltaTime * this.m_contentFixingSpeed * (float)num3;
                        if ((num3 > 0 && this.m_contentAnchoredPosition.y >= this.m_targetContentAnchoredPosition.y) || (num3 < 0 && this.m_contentAnchoredPosition.y <= this.m_targetContentAnchoredPosition.y))
                        {
                            this.m_contentAnchoredPosition = this.m_targetContentAnchoredPosition;
                        }
                    }
                }
                else
                {
                    this.m_selectingState = enExpandListSelectingState.Expand;
                    this.m_timeSlice      = 0f;
                }
                break;

            case enExpandListSelectingState.Expand:
                if (this.m_timeSlice < this.m_expandedTime)
                {
                    this.m_timeSlice  += Time.deltaTime;
                    this.m_contentSize = Vector2.zero;
                    Vector2 zero2 = Vector2.zero;
                    if (this.m_listType == enUIListType.Horizontal)
                    {
                        zero2.x += this.m_elementLayoutOffset;
                    }
                    else if (this.m_listType == enUIListType.Vertical)
                    {
                        zero2.y += this.m_elementLayoutOffset;
                    }
                    for (int j = 0; j < this.m_elementAmount; j++)
                    {
                        float num4 = 0f;
                        if (j == this.m_selectedElementIndex)
                        {
                            num4 = this.m_timeSlice / this.m_expandedTime;
                            num4 = Mathf.Clamp(num4, 0f, 1f);
                        }
                        stRect stRect2 = this.LayoutExpandElement(j, num4, ref this.m_contentSize, ref zero2);
                        if (j < this.m_elementsRect.get_Count())
                        {
                            this.m_elementsRect.set_Item(j, stRect2);
                        }
                        else
                        {
                            this.m_elementsRect.Add(stRect2);
                        }
                    }
                    this.ResizeContent(ref this.m_contentSize, false);
                }
                else
                {
                    this.m_selectingState = enExpandListSelectingState.None;
                }
                break;
            }
            for (int k = 0; k < this.m_elementAmount; k++)
            {
                stRect stRect3 = this.m_elementsRect.get_Item(k);
                CUIListElementScript elemenet = base.GetElemenet(k);
                if (elemenet != null)
                {
                    elemenet.SetRect(ref stRect3);
                }
            }
            this.m_contentRectTransform.anchoredPosition = this.m_contentAnchoredPosition;
        }
Ejemplo n.º 4
0
        private void UpdateSelectedElement(enExpandListSelectingState selectingState)
        {
            Vector2 zero;
            int     num7;

            switch (selectingState)
            {
            case enExpandListSelectingState.Retract:
                if (this.m_timeSlice >= this.m_expandedTime)
                {
                    if ((base.m_selectedElementIndex >= 0) && (base.m_selectedElementIndex < base.m_elementAmount))
                    {
                        this.m_targetContentAnchoredPosition = this.GetTargetContentAnchoredPosition(base.m_selectedElementIndex);
                        this.m_selectingState = enExpandListSelectingState.Move;
                        this.m_timeSlice      = 0f;
                    }
                    else
                    {
                        this.m_selectingState = enExpandListSelectingState.None;
                    }
                    goto Label_055A;
                }
                this.m_timeSlice  += Time.deltaTime;
                base.m_contentSize = Vector2.zero;
                zero = Vector2.zero;
                if (base.m_listType != enUIListType.Horizontal)
                {
                    if (base.m_listType == enUIListType.Vertical)
                    {
                        zero.y += base.m_elementLayoutOffset;
                    }
                    break;
                }
                zero.x += base.m_elementLayoutOffset;
                break;

            case enExpandListSelectingState.Move:
                if (!(this.m_contentAnchoredPosition != this.m_targetContentAnchoredPosition))
                {
                    this.m_selectingState = enExpandListSelectingState.Expand;
                    this.m_timeSlice      = 0f;
                }
                else if (base.m_listType != enUIListType.Horizontal)
                {
                    if (base.m_listType == enUIListType.Vertical)
                    {
                        int num4 = (this.m_targetContentAnchoredPosition.y <= this.m_contentAnchoredPosition.y) ? -1 : 1;
                        this.m_contentAnchoredPosition.y += (Time.deltaTime * this.m_contentFixingSpeed) * num4;
                        if (((num4 > 0) && (this.m_contentAnchoredPosition.y >= this.m_targetContentAnchoredPosition.y)) || ((num4 < 0) && (this.m_contentAnchoredPosition.y <= this.m_targetContentAnchoredPosition.y)))
                        {
                            this.m_contentAnchoredPosition = this.m_targetContentAnchoredPosition;
                        }
                    }
                }
                else
                {
                    int num3 = (this.m_targetContentAnchoredPosition.x <= this.m_contentAnchoredPosition.x) ? -1 : 1;
                    this.m_contentAnchoredPosition.x += (Time.deltaTime * this.m_contentFixingSpeed) * num3;
                    if (((num3 > 0) && (this.m_contentAnchoredPosition.x >= this.m_targetContentAnchoredPosition.x)) || ((num3 < 0) && (this.m_contentAnchoredPosition.x <= this.m_targetContentAnchoredPosition.x)))
                    {
                        this.m_contentAnchoredPosition = this.m_targetContentAnchoredPosition;
                    }
                }
                goto Label_055A;

            case enExpandListSelectingState.Expand:
                if (this.m_timeSlice >= this.m_expandedTime)
                {
                    this.m_selectingState = enExpandListSelectingState.None;
                }
                else
                {
                    this.m_timeSlice  += Time.deltaTime;
                    base.m_contentSize = Vector2.zero;
                    Vector2 offset = Vector2.zero;
                    if (base.m_listType != enUIListType.Horizontal)
                    {
                        if (base.m_listType == enUIListType.Vertical)
                        {
                            offset.y += base.m_elementLayoutOffset;
                        }
                    }
                    else
                    {
                        offset.x += base.m_elementLayoutOffset;
                    }
                    for (int j = 0; j < base.m_elementAmount; j++)
                    {
                        float num6 = 0f;
                        if (j == base.m_selectedElementIndex)
                        {
                            num6 = this.m_timeSlice / this.m_expandedTime;
                            num6 = Mathf.Clamp(num6, 0f, 1f);
                        }
                        stRect item = this.LayoutExpandElement(j, num6, ref this.m_contentSize, ref offset);
                        if (j < base.m_elementsRect.Count)
                        {
                            base.m_elementsRect[j] = item;
                        }
                        else
                        {
                            base.m_elementsRect.Add(item);
                        }
                    }
                    this.ResizeContent(ref this.m_contentSize, false);
                }
                goto Label_055A;

            default:
                goto Label_055A;
            }
            for (int i = 0; i < base.m_elementAmount; i++)
            {
                float num2 = 0f;
                if (i == base.m_lastSelectedElementIndex)
                {
                    num2 = 1f - (this.m_timeSlice / this.m_expandedTime);
                    num2 = Mathf.Clamp(num2, 0f, 1f);
                }
                stRect rect = this.LayoutExpandElement(i, num2, ref this.m_contentSize, ref zero);
                if (i < base.m_elementsRect.Count)
                {
                    base.m_elementsRect[i] = rect;
                }
                else
                {
                    base.m_elementsRect.Add(rect);
                }
            }
            this.ResizeContent(ref this.m_contentSize, false);
            if ((base.m_selectedElementIndex < 0) || (base.m_selectedElementIndex >= base.m_elementAmount))
            {
                if (base.m_listType == enUIListType.Horizontal)
                {
                    if (this.m_contentAnchoredPosition.x > 0f)
                    {
                        this.m_contentAnchoredPosition.x = 0f;
                    }
                    else if ((this.m_contentAnchoredPosition.x + this.m_contentSize.x) < this.m_scrollAreaSize.x)
                    {
                        this.m_contentAnchoredPosition.x = this.m_scrollAreaSize.x - this.m_contentSize.x;
                    }
                }
                else if (base.m_listType == enUIListType.Vertical)
                {
                    if (this.m_contentAnchoredPosition.y < 0f)
                    {
                        this.m_contentAnchoredPosition.y = 0f;
                    }
                    else if ((this.m_contentAnchoredPosition.y - this.m_contentSize.y) > -this.m_scrollAreaSize.y)
                    {
                        this.m_contentAnchoredPosition.y = -this.m_scrollAreaSize.y + this.m_contentSize.y;
                    }
                }
            }
Label_055A:
            num7 = 0;
            while (num7 < base.m_elementAmount)
            {
                stRect rect3 = base.m_elementsRect[num7];
                CUIListElementScript elemenet = base.GetElemenet(num7);
                if (elemenet != null)
                {
                    elemenet.SetRect(ref rect3);
                }
                num7++;
            }
            base.m_contentRectTransform.anchoredPosition = this.m_contentAnchoredPosition;
        }