LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0)
            {
                return(null);
            }
            LoopListViewItem2 item       = listView.NewListViewItem("ItemPrefab1");
            ListItem6         itemScript = item.GetComponent <ListItem6>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            for (int i = 0; i < mItemCountPerRow; ++i)
            {
                int itemIndex = index * mItemCountPerRow + i;
                if (itemIndex >= mListItemTotalCount)
                {
                    itemScript.mItemList[i].gameObject.SetActive(false);
                    continue;
                }
                ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(itemIndex);
                if (itemData != null)
                {
                    itemScript.mItemList[i].gameObject.SetActive(true);
                    itemScript.mItemList[i].SetItemData(itemData, itemIndex);
                }
                else
                {
                    itemScript.mItemList[i].gameObject.SetActive(false);
                }
            }
            return(item);
        }
        void UpdateItemPrefab()
        {
            ItemPrefabConfData tData      = mLoopListView.GetItemPrefabConfData("ItemPrefab1");
            GameObject         prefabObj  = tData.mItemPrefab;
            RectTransform      rf         = prefabObj.GetComponent <RectTransform>();
            ListItem6          itemScript = prefabObj.GetComponent <ListItem6>();
            float         w     = mLoopListView.ViewPortWidth;
            int           count = itemScript.mItemList.Count;
            GameObject    p0    = itemScript.mItemList[0].gameObject;
            RectTransform rf0   = p0.GetComponent <RectTransform>();
            float         w0    = rf0.rect.width;
            int           c     = Mathf.FloorToInt(w / w0);

            if (c == 0)
            {
                c = 1;
            }
            mItemCountPerRow = c;
            float padding = (w - w0 * c) / (c + 1);

            if (padding < 0)
            {
                padding = 0;
            }
            rf.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, w);
            if (c > count)
            {
                int dif = c - count;
                for (int i = 0; i < dif; ++i)
                {
                    GameObject    go  = Object.Instantiate(p0, Vector3.zero, Quaternion.identity, rf);
                    RectTransform trf = go.GetComponent <RectTransform>();
                    trf.localScale    = Vector3.one;
                    trf.localPosition = Vector3.zero;
                    trf.rotation      = Quaternion.identity;
                    ListItem5 t = go.GetComponent <ListItem5>();
                    itemScript.mItemList.Add(t);
                }
            }
            else if (c < count)
            {
                int dif = count - c;
                for (int i = 0; i < dif; ++i)
                {
                    ListItem5 go = itemScript.mItemList[itemScript.mItemList.Count - 1];
                    itemScript.mItemList.RemoveAt(itemScript.mItemList.Count - 1);
                    Object.DestroyImmediate(go.gameObject);
                }
            }
            float curX = padding;

            for (int k = 0; k < itemScript.mItemList.Count; ++k)
            {
                GameObject obj = itemScript.mItemList[k].gameObject;
                obj.transform.localPosition = new Vector3(curX, 0, 0);
                curX = curX + w0 + padding;
            }
            mLoopListView.OnItemPrefabChanged("ItemPrefab1");
        }
예제 #3
0
        private void UpdateItemPrefab()
        {
            GameObject    mItemPrefab   = this.mLoopListView.GetItemPrefabConfData("ItemPrefab2").mItemPrefab;
            RectTransform component1    = (RectTransform)mItemPrefab.GetComponent <RectTransform>();
            ListItem6     component2    = (ListItem6)mItemPrefab.GetComponent <ListItem6>();
            float         viewPortWidth = this.mLoopListView.ViewPortWidth;
            int           count         = component2.mItemList.Count;
            GameObject    gameObject1   = ((Component)component2.mItemList[0]).get_gameObject();
            Rect          rect          = ((RectTransform)gameObject1.GetComponent <RectTransform>()).get_rect();
            float         width         = ((Rect) ref rect).get_width();
            int           num1          = Mathf.FloorToInt(viewPortWidth / width);

            if (num1 == 0)
            {
                num1 = 1;
            }
            this.mItemCountPerRow = num1;
            float num2 = (viewPortWidth - width * (float)num1) / (float)(num1 + 1);

            if ((double)num2 < 0.0)
            {
                num2 = 0.0f;
            }
            component1.SetSizeWithCurrentAnchors((RectTransform.Axis) 0, viewPortWidth);
            if (num1 > count)
            {
                int num3 = num1 - count;
                for (int index = 0; index < num3; ++index)
                {
                    GameObject    gameObject2 = (GameObject)Object.Instantiate <GameObject>((M0)gameObject1, Vector3.get_zero(), Quaternion.get_identity(), (Transform)component1);
                    RectTransform component3  = (RectTransform)gameObject2.GetComponent <RectTransform>();
                    ((Transform)component3).set_localScale(Vector3.get_one());
                    component3.set_anchoredPosition3D(Vector3.get_zero());
                    ((Transform)component3).set_rotation(Quaternion.get_identity());
                    ListItem5 component4 = (ListItem5)gameObject2.GetComponent <ListItem5>();
                    component2.mItemList.Add(component4);
                }
            }
            else if (num1 < count)
            {
                int num3 = count - num1;
                for (int index = 0; index < num3; ++index)
                {
                    ListItem5 mItem = component2.mItemList[component2.mItemList.Count - 1];
                    component2.mItemList.RemoveAt(component2.mItemList.Count - 1);
                    Object.DestroyImmediate((Object)((Component)mItem).get_gameObject());
                }
            }
            float num4 = num2;

            for (int index = 0; index < component2.mItemList.Count; ++index)
            {
                ((RectTransform)((Component)component2.mItemList[index]).get_gameObject().GetComponent <RectTransform>()).set_anchoredPosition3D(new Vector3(num4, 0.0f, 0.0f));
                num4 = num4 + width + num2;
            }
            this.mLoopListView.OnItemPrefabChanged("ItemPrefab2");
        }
예제 #4
0
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int row)
        {
            if (row < 0)
            {
                return(null);
            }

            LoopListViewItem2 item = null;

            if (row == 0)
            {
                item = listView.NewListViewItem("ItemPrefab0");
                UpdateLoadingTip1(item);
                return(item);
            }
            if (row == GetMaxRowCount() + 1)
            {
                item = listView.NewListViewItem("ItemPrefab1");
                UpdateLoadingTip2(item);
                return(item);
            }
            int itemRow = row - 1;

            item = listView.NewListViewItem("ItemPrefab2");
            ListItem6 itemScript = item.GetComponent <ListItem6>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            for (int i = 0; i < mItemCountPerRow; ++i)
            {
                int itemIndex = itemRow * mItemCountPerRow + i;
                if (itemIndex >= DataSourceMgr.Get.TotalItemCount)
                {
                    itemScript.mItemList[i].gameObject.SetActive(false);
                    continue;
                }
                ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(itemIndex);
                if (itemData != null)
                {
                    itemScript.mItemList[i].gameObject.SetActive(true);
                    itemScript.mItemList[i].SetItemData(itemData, itemIndex);
                }
                else
                {
                    itemScript.mItemList[i].gameObject.SetActive(false);
                }
            }
            return(item);
        }
예제 #5
0
        private LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int row)
        {
            if (row < 0)
            {
                return((LoopListViewItem2)null);
            }
            if (row == 0)
            {
                LoopListViewItem2 loopListViewItem2 = listView.NewListViewItem("ItemPrefab0");
                this.UpdateLoadingTip1(loopListViewItem2);
                return(loopListViewItem2);
            }
            if (row == this.GetMaxRowCount() + 1)
            {
                LoopListViewItem2 loopListViewItem2 = listView.NewListViewItem("ItemPrefab1");
                this.UpdateLoadingTip2(loopListViewItem2);
                return(loopListViewItem2);
            }
            int num1 = row - 1;
            LoopListViewItem2 loopListViewItem2_1 = listView.NewListViewItem("ItemPrefab2");
            ListItem6         component           = (ListItem6)((Component)loopListViewItem2_1).GetComponent <ListItem6>();

            if (!loopListViewItem2_1.IsInitHandlerCalled)
            {
                loopListViewItem2_1.IsInitHandlerCalled = true;
                component.Init();
            }
            for (int index = 0; index < this.mItemCountPerRow; ++index)
            {
                int num2 = num1 * this.mItemCountPerRow + index;
                if (num2 >= DataSourceMgr.Get.TotalItemCount)
                {
                    ((Component)component.mItemList[index]).get_gameObject().SetActive(false);
                }
                else
                {
                    ItemData itemDataByIndex = DataSourceMgr.Get.GetItemDataByIndex(num2);
                    if (itemDataByIndex != null)
                    {
                        ((Component)component.mItemList[index]).get_gameObject().SetActive(true);
                        component.mItemList[index].SetItemData(itemDataByIndex, num2);
                    }
                    else
                    {
                        ((Component)component.mItemList[index]).get_gameObject().SetActive(false);
                    }
                }
            }
            return(loopListViewItem2_1);
        }
        private LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0)
            {
                return((LoopListViewItem2)null);
            }
            LoopListViewItem2 loopListViewItem2 = listView.NewListViewItem("ItemPrefab1");
            ListItem6         component         = (ListItem6)((Component)loopListViewItem2).GetComponent <ListItem6>();

            if (!loopListViewItem2.IsInitHandlerCalled)
            {
                loopListViewItem2.IsInitHandlerCalled = true;
                component.Init();
            }
            for (int index1 = 0; index1 < this.mItemCountPerRow; ++index1)
            {
                int num = index * this.mItemCountPerRow + index1;
                if (num >= this.mListItemTotalCount)
                {
                    ((Component)component.mItemList[index1]).get_gameObject().SetActive(false);
                }
                else
                {
                    ItemData itemDataByIndex = DataSourceMgr.Get.GetItemDataByIndex(num);
                    if (itemDataByIndex != null)
                    {
                        ((Component)component.mItemList[index1]).get_gameObject().SetActive(true);
                        component.mItemList[index1].SetItemData(itemDataByIndex, num);
                    }
                    else
                    {
                        ((Component)component.mItemList[index1]).get_gameObject().SetActive(false);
                    }
                }
            }
            return(loopListViewItem2);
        }