예제 #1
0
        internal void UpdateGrid()
        {
            if (!updateNeeded)
            {
                return;
            }
            updateNeeded = false;

            chestGrid.Clear();
            mainPanel.DragTargetClear();
            mainPanel.AddDragTarget(inlaidPanel);
            mainPanel.AddDragTarget(chestGrid);

            Clear();

            var rect = ChestBrowserUtils.GetSearchRangeRectangle();

            foreach (var chest in Main.chest.Where(x => x != null && (ModContent.GetInstance <ChestBrowserConfig>().isInfinityRange ? true : rect.Contains(x.x, x.y))))
            {
                int  itemType  = -1;
                bool isDresser = chest.isDresser();
                int  iconIndex = chest.getIconIndex();
                if (isDresser && !FilterItemTypeUI.dresserTypeExist[iconIndex])
                {
                    FilterItemTypeUI.dresserTypeExist[iconIndex] = true;
                    itemType = Chest.dresserTypeToIcon[iconIndex];
                }
                else if (!isDresser && !FilterItemTypeUI.chestTypeExist[iconIndex])
                {
                    FilterItemTypeUI.chestTypeExist[iconIndex] = true;
                    itemType = Chest.chestTypeToIcon[iconIndex];
                }
                if (0 <= itemType)
                {
                    var box = new UIFilterChestSlot(isDresser, iconIndex, chest.ToItem());
                    chestGrid._items.Add(box);
                    chestGrid._innerList.Append(box);
                    mainPanel.AddDragTarget(box);
                }
            }
            chestGrid.UpdateOrder();
            chestGrid._innerList.Recalculate();

            mainPanel.caption = caption.Replace("??", $"{chestGrid.Count}");
        }
예제 #2
0
        internal void UpdateGrid()
        {
            if (!updateNeeded)
            {
                return;
            }
            updateNeeded = false;

            Clear();

            foreach (var netID in filterItemList)
            {
                var item = new Item();
                item.SetDefaults(netID);

                var box = new UIFilterItemSlot(item);
                gridFilterItem._items.Add(box);
                gridFilterItem._innerList.Append(box);
            }
            gridFilterItem.UpdateOrder();
            gridFilterItem._innerList.Recalculate();

            var rect = ChestBrowserUtils.GetSearchRangeRectangle();

            foreach (var chest in Main.chest.Where(x => x != null && (ModContent.GetInstance <ChestBrowserConfig>().isInfinityRange ? true : rect.Contains(x.x, x.y))))
            {
                if (panelSplitter.Panel1Visible && btnFilterChestType.GetValue <bool>())
                {
                    int  itemType  = -1;
                    bool isDresser = chest.isDresser();
                    int  iconIndex = chest.getIconIndex();
                    if (isDresser && !dresserTypeExist[iconIndex])
                    {
                        dresserTypeExist[iconIndex] = true;
                        itemType = Chest.dresserTypeToIcon[iconIndex];
                    }
                    else if (!isDresser && !chestTypeExist[iconIndex])
                    {
                        chestTypeExist[iconIndex] = true;
                        itemType = Chest.chestTypeToIcon[iconIndex];
                    }
                    if (0 <= itemType)
                    {
                        var box = new UIFilterChestSlot(isDresser, iconIndex, chest.ToItem());
                        gridFilterChestType._items.Add(box);
                        gridFilterChestType._innerList.Append(box);
                        panelMain.AddDragTarget(box);
                    }
                }

                if (isView(chest))
                {
                    var box = new UIChestSlot(chest);
                    gridChest._items.Add(box);
                    gridChest._innerList.Append(box);
                    panelMain.AddDragTarget(box);
                }
            }
            gridFilterChestType.UpdateOrder();
            gridFilterChestType._innerList.Recalculate();
            gridChest.UpdateOrder();
            gridChest._innerList.Recalculate();

            panelMain.caption = caption.Replace("??", $"{gridChest.Count}");
        }