예제 #1
0
    private void FillContainer(VirtualList.ItemContainer container, int itemID)
    {
        RectTransform rectTransform = (RectTransform)null;

        if (this.OnGetItemObject != null)
        {
            rectTransform = this.OnGetItemObject(itemID, !Object.op_Inequality((Object)container.Body, (Object)null) ? -1 : container.ItemID, container.Body);
        }
        if (Object.op_Equality((Object)rectTransform, (Object)null))
        {
            return;
        }
        if (Object.op_Inequality((Object)container.Body, (Object)null) && Object.op_Inequality((Object)container.Body, (Object)rectTransform) && Object.op_Equality((Object)((Transform)container.Body).get_parent(), (Object)container.RectTr))
        {
            ((Transform)container.Body).SetParent((Transform)null, false);
        }
        container.Body   = rectTransform;
        container.ItemID = itemID;
        ((Transform)rectTransform).SetParent((Transform)container.RectTr, false);
        Vector2 anchoredPosition = rectTransform.get_anchoredPosition();

        // ISSUE: explicit reference operation
        if ((double)((Vector2)@anchoredPosition).get_sqrMagnitude() <= 0.0)
        {
            return;
        }
        rectTransform.set_anchoredPosition(Vector2.get_zero());
    }
예제 #2
0
 public RectTransform FindItem(int itemID)
 {
     VirtualList.ItemContainer itemContainer = this.FindItemContainer(itemID);
     if (Object.op_Inequality((Object)itemContainer, (Object)null))
     {
         return(itemContainer.Body);
     }
     return((RectTransform)null);
 }
예제 #3
0
    private void SwapFast(VirtualList.ItemContainer a, VirtualList.ItemContainer b)
    {
        int itemId = a.ItemID;

        a.ItemID = b.ItemID;
        b.ItemID = itemId;
        RectTransform body = a.Body;

        a.Body = b.Body;
        b.Body = body;
    }
예제 #4
0
    private void ReserveItems(int maxItems)
    {
        Transform transform = ((Component)this).get_transform();

        this.mNumVisibleItems = maxItems;
        for (int count = this.mItemObjects.Count; count < maxItems; ++count)
        {
            VirtualList.ItemContainer component = (VirtualList.ItemContainer) new GameObject(count.ToString(), new System.Type[2]
            {
                typeof(RectTransform),
                typeof(VirtualList.ItemContainer)
            }).GetComponent <VirtualList.ItemContainer>();
            RectTransform rectTr    = component.RectTr;
            Vector2       vector2_1 = new Vector2(0.0f, 1f);
            component.RectTr.set_anchorMax(vector2_1);
            Vector2 vector2_2 = vector2_1;
            rectTr.set_anchorMin(vector2_2);
            component.RectTr.set_sizeDelta(this.ItemSize);
            ((Transform)component.RectTr).SetParent(transform, false);
            this.mItemObjects.Add(component);
        }
    }
예제 #5
0
    private void Rebuild()
    {
        if (this.IsDiscarding())
        {
            return;
        }
        Rect rect1 = (((Component)this).get_transform() as RectTransform).get_rect();
        int  num1  = this.CalcPitch();

        if (num1 <= 0)
        {
            return;
        }
        Rect rect2        = (((Component)this.ScrollRect).get_transform() as RectTransform).get_rect();
        bool isHorizontal = this.IsHorizontal;
        int  num2;
        int  num3;
        int  num4;
        int  num5;

        if (isHorizontal)
        {
            // ISSUE: explicit reference operation
            this.ReserveItems(Mathf.Max(Mathf.CeilToInt(((Rect)@rect2).get_width() / (float)this.ItemSize.x) + 1, 1) * num1);
            // ISSUE: explicit reference operation
            if ((double)((Rect)@rect1).get_width() <= 0.0)
            {
                this.DisableAllItems();
                return;
            }
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            num2 = Mathf.FloorToInt(-this.HorizontalNormalizedPosition * (((Rect)@rect2).get_width() - ((Rect)@rect1).get_width()) / (float)this.ItemSize.x);
            if ((double)this.mLastScrollPosition <= (double)this.HorizontalNormalizedPosition)
            {
                num3 = 0;
                num4 = this.mItemObjects.Count;
                num5 = 1;
            }
            else
            {
                num3 = this.mItemObjects.Count - 1;
                num4 = -1;
                num5 = -1;
            }
            this.mLastScrollPosition = this.HorizontalNormalizedPosition;
        }
        else
        {
            // ISSUE: explicit reference operation
            this.ReserveItems(num1 * Mathf.Max(Mathf.CeilToInt(((Rect)@rect2).get_width() / (float)this.ItemSize.x), 1));
            // ISSUE: explicit reference operation
            if ((double)((Rect)@rect1).get_height() <= 0.0)
            {
                this.DisableAllItems();
                return;
            }
            // ISSUE: explicit reference operation
            // ISSUE: explicit reference operation
            num2 = Mathf.FloorToInt((float)-(1.0 - (double)this.ScrollRect.get_verticalNormalizedPosition()) * (((Rect)@rect2).get_height() - ((Rect)@rect1).get_height()) / (float)this.ItemSize.y);
            if ((double)this.mLastScrollPosition >= (double)this.ScrollRect.get_verticalNormalizedPosition())
            {
                num3 = 0;
                num4 = this.mItemObjects.Count;
                num5 = 1;
            }
            else
            {
                num3 = this.mItemObjects.Count - 1;
                num4 = -1;
                num5 = -1;
            }
            this.mLastScrollPosition = this.ScrollRect.get_verticalNormalizedPosition();
        }
        bool flag   = false;
        int  index1 = num3;

        while (index1 != num4)
        {
            RectTransform rectTr = this.mItemObjects[index1].RectTr;
            int           num6;
            int           num7;
            int           index2;
            if (isHorizontal)
            {
                num6   = index1 / num1 + num2;
                num7   = index1 % num1;
                index2 = num6 * num1 + num7;
            }
            else
            {
                num6   = index1 % num1;
                num7   = index1 / num1 + num2;
                index2 = num6 + num7 * num1;
            }
            Vector2 sizeDelta = rectTr.get_sizeDelta();
            Vector2 pivot     = rectTr.get_pivot();
            float   x         = (float)((double)num6 * this.ItemSize.x + sizeDelta.x * pivot.x);
            float   y         = (float)((double)-num7 * this.ItemSize.y - sizeDelta.y * pivot.y);
            if (0 <= index2 && index2 < this.mItems.Count)
            {
                if (!this.mForceRebuild)
                {
                    int itemAtPosition = this.FindItemAtPosition(this.mItems[index2], x, y);
                    if (itemAtPosition >= 0 && itemAtPosition != index1)
                    {
                        VirtualList.ItemContainer mItemObject = this.mItemObjects[index1];
                        this.mItemObjects[index1]         = this.mItemObjects[itemAtPosition];
                        this.mItemObjects[itemAtPosition] = mItemObject;
                        goto label_31;
                    }
                }
                VirtualList.ItemContainer itemContainer = this.FindItemContainer(this.mItems[index2]);
                if (Object.op_Inequality((Object)itemContainer, (Object)null))
                {
                    itemContainer.SetBodyActive(true);
                    this.SwapFast(itemContainer, this.mItemObjects[index1]);
                    flag = true;
                }
                else
                {
                    VirtualList.ItemContainer mItemObject = this.mItemObjects[index1];
                    mItemObject.SetBodyActive(true);
                    this.FillContainer(mItemObject, this.mItems[index2]);
                }
            }
            else
            {
                this.mItemObjects[index1].SetBodyActive(false);
            }
            rectTr.set_anchoredPosition(new Vector2(x, y));
label_31:
            index1 += num5;
        }
        if (flag)
        {
            this.ReparentItems();
        }
        this.mForceRebuild = false;
        if (this.OnPostListUpdate == null)
        {
            return;
        }
        this.OnPostListUpdate();
    }