Exemple #1
0
 public override void SelectElement(int index, bool isDispatchSelectedChangeEvent = true)
 {
     if (this.m_selectingState != enExpandListSelectingState.None)
     {
         return;
     }
     this.m_lastSelectedElementIndex = this.m_selectedElementIndex;
     this.m_selectedElementIndex     = index;
     if (this.m_lastSelectedElementIndex == this.m_selectedElementIndex)
     {
         this.m_selectedElementIndex = -1;
     }
     if (this.m_lastSelectedElementIndex >= 0)
     {
         CUIListElementScript elemenet = base.GetElemenet(this.m_lastSelectedElementIndex);
         if (elemenet != null)
         {
             elemenet.ChangeDisplay(false);
         }
     }
     if (this.m_selectedElementIndex >= 0)
     {
         CUIListElementScript elemenet2 = base.GetElemenet(this.m_selectedElementIndex);
         if (elemenet2 != null)
         {
             elemenet2.ChangeDisplay(true);
             if (elemenet2.onSelected != null)
             {
                 elemenet2.onSelected();
             }
         }
     }
     base.DispatchElementSelectChangedEvent();
     this.m_contentAnchoredPosition = this.m_contentRectTransform.anchoredPosition;
     this.m_timeSlice = 0f;
     if (this.m_lastSelectedElementIndex >= 0)
     {
         this.m_selectingState = enExpandListSelectingState.Retract;
     }
     else if (this.m_selectedElementIndex >= 0)
     {
         this.m_targetContentAnchoredPosition = this.GetTargetContentAnchoredPosition(this.m_selectedElementIndex);
         this.m_selectingState = enExpandListSelectingState.Move;
         this.m_timeSlice      = 0f;
     }
 }
Exemple #2
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;
        }
Exemple #3
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;
        }