Example #1
0
        public override void RefreshItems(TEStorageCenter center = null)
        {
            if (Main.player[Main.myPlayer].GetModPlayer <StoragePlayer>().tileType == typeof(TCraftingStorageAccess))
            {
                MagicStorageTwo.Instance.guiM?.CraftingGUI.RefreshItems();
            }
            if (StoragePlayer.IsOnlyStorageCrafting())
            {
                return;
            }
            items.Clear();
            TEStorageHeart heart = center as TEStorageHeart ?? GetHeart();

            if (heart == null)
            {
                return;
            }
            InitLangStuff();
            InitSortButtons();
            InitFilterButtons();
            SortMode   sortMode   = (SortMode)sortButtons.Choice;
            FilterMode filterMode = (FilterMode)filterButtons.Choice;

            items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, modSearchBar.Text, nameSearchBar.Text));
        }
Example #2
0
        public static void RefreshItems()
        {
            if (StoragePlayer.IsStorageCrafting())
            {
                CraftingGUI.RefreshItems();
                return;
            }
            items.Clear();
            didMatCheck.Clear();
            TEStorageHeart heart = GetHeart();

            if (heart == null)
            {
                return;
            }
            InitLangStuff();
            InitSortButtons();
            InitFilterButtons();
            SortMode   sortMode   = (SortMode)sortButtons.Choice;
            FilterMode filterMode = (FilterMode)filterButtons.Choice;

            items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, searchBar2.Text, searchBar.Text));
            for (int k = 0; k < items.Count; k++)
            {
                didMatCheck.Add(false);
            }
        }
Example #3
0
        // In this example we used Initialize and Unload_Inner in conjunction with Load and Unload to avoid TypeInitializationException, but we could also just check Enabled before calling MagicStorageIntegration.Unload(); and assign MagicStorage and check Enabled before calling MagicStorageIntegration.Load();
        // I opted to keep the MagicStorage integration logic in the MagicStorageIntegration class to keep MagicStorage related code as sparse and unobtrusive as possible within the remaining codebase for this mod.
        // That said, in ItemChecklistPlayer, we see this:
        //	if (ItemChecklistUI.collectChestItems && MagicStorageIntegration.Enabled)
        //		MagicStorageIntegration.FindItemsInStorage();
        // I could have changed this to always call FindItemsInStorage and have FindItemsInStorage check Enabled, but that would require a FindItemsInStorage_Inner type class once again to prevent errors.
        // Whatever approach you do, be aware of what you are doing and be careful.

        // StoragePlayer and TEStorageHeart are classes in MagicStorage.
        // Make sure to extract the .dll from the .tmod and then add them to your .csproj as references.
        // As a convention, I rename the .dll file ModName_v1.2.3.4.dll and place them in Mod Sources/Mods/lib.
        // I do this for organization and so the .csproj loads properly for others using the GitHub repository.
        // Remind contributors to download the referenced mod itself if they wish to build the mod.
        internal static void FindItemsInStorage()
        {
            var     storagePlayer = Main.LocalPlayer.GetModPlayer <StoragePlayer>();
            Point16 storageAccess = storagePlayer.ViewingStorage();

            if (storageAccess == previousStorageAccess)
            {
                return;
            }
            previousStorageAccess = storageAccess;
            if (!Main.playerInventory || storageAccess.X < 0 || storageAccess.Y < 0)
            {
                return;
            }
            ModTile modTile = TileLoader.GetTile(Main.tile[storageAccess.X, storageAccess.Y].type);

            if (modTile == null || !(modTile is StorageAccess))
            {
                return;
            }
            TEStorageHeart heart = ((StorageAccess)modTile).GetHeart(storageAccess.X, storageAccess.Y);

            if (heart == null)
            {
                return;
            }
            var items = heart.GetStoredItems();

            // Will 1000 items crash the chat?
            foreach (var item in items)
            {
                ItemChecklist.instance.GetGlobalItem <ItemChecklistGlobalItem>().ItemReceived(item);
            }
        }
Example #4
0
        public void RefreshItems()
        {
            items = ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, searchBar2.Text, searchBar.Text);

            UpdateCounter();

            slotZone.UpdateScrollBar((items.Count + columns - 1) / columns);
        }
        public IEnumerable <Tuple <Item, object> > EnumerateItems(int x, int y)
        {
            TEStorageHeart targetHeart = FindHeart(x, y);

            if (targetHeart == null)
            {
                yield break;
            }

            foreach (var item in targetHeart.GetStoredItems())
            {
                yield return(new Tuple <Item, object>(item, item));
            }
        }
Example #6
0
        public static int ItemCount(int itemType)
        {
            int            count     = 0;
            List <Item>    countList = new List <Item>();
            TEStorageHeart heart     = GetHeart();

            if (heart == null)
            {
                return(-1);
            }
            countList.Clear();
            countList.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), SortMode.Default, FilterMode.All, SubFilterMode.All, "", ""));
            foreach (Item sItem in countList)
            {
                if (sItem.type == itemType)
                {
                    count += sItem.stack;
                }
            }
            return(count);
        }
Example #7
0
        private void RefreshItems()
        {
            itemCounts.Clear();

            foreach (int key in RecipeGroup.recipeGroups.Keys)
            {
                recipeGroupCounts[key] = 0;
            }

            items = ItemSorter.SortAndFilter(heart.GetStoredItems(), SortMode.Id, FilterMode.All, "", "");

            foreach (Item item in items)
            {
                if (!item.material)
                {
                    continue;
                }

                if (itemCounts.ContainsKey(item.netID))
                {
                    itemCounts[item.netID] += item.stack;
                }
                else
                {
                    itemCounts[item.netID] = item.stack;
                }

                foreach (KeyValuePair <int, RecipeGroup> pair in RecipeGroup.recipeGroups)
                {
                    if (pair.Value.ContainsItem(item.type))
                    {
                        recipeGroupCounts[pair.Key] += item.stack;
                    }
                }
            }
        }
Example #8
0
        public void RefreshItems()
        {
            items.Clear();

            TEStorageHeart heart = StoragePlayer.GetStorageHeart();

            if (heart == null)
            {
                return;
            }

            // @Volatile :SearchBars
            var searchByName = sideBar[0] as UISearchBar;
            var searchByMod  = sideBar[1] as UISearchBar;

            string nameFilter = "";

            if (searchByName.Text != searchByName.HintText)
            {
                nameFilter = searchByName.Text;
            }
            string modFilter = "";

            if (searchByMod.Text != searchByMod.HintText)
            {
                modFilter = searchByMod.Text;
            }

            var sort   = sideBar[2] as UIDropDown; // @Volatile :SortAndFilter
            var filter = sideBar[3] as UIDropDown; // @Volatile :SortAndFilter

            items.AddRange(Sorting.Items.FilterAndSort(heart.GetStoredItems(), (SortMode)sort.CurrentOption, (FilterMode)filter.CurrentOption, modFilter, nameFilter));
            items.ForEach(x => x.checkMat());

            Recipe.FindRecipes();
        }
Example #9
0
        public static void RefreshItems()
        {
            if (StoragePlayer.IsStorageCrafting())
            {
                CraftingGUI.RefreshItems();
                return;
            }
            items.Clear();
            didMatCheck.Clear();
            TEStorageHeart heart = GetHeart();

            if (heart == null)
            {
                return;
            }
            InitLangStuff();
            InitSortButtons();
            InitFilterButtons();
            InitSubFilterButtons();
            SortMode sortMode;

            switch (sortButtons.Choice)
            {
            case 0:
                sortMode = SortMode.Default;
                break;

            case 1:
                sortMode = SortMode.Id;
                break;

            case 2:
                sortMode = SortMode.Name;
                break;

            case 3:
                sortMode = SortMode.Quantity;
                break;

            default:
                sortMode = SortMode.Default;
                break;
            }
            switch (filterButtons.Choice)
            {
            case 0:
                filterMode = FilterMode.All;
                break;

            case 1:
                filterMode = FilterMode.Weapons;
                break;

            case 2:
                filterMode = FilterMode.Tools;
                break;

            case 3:
                filterMode = FilterMode.Equipment;
                break;

            case 4:
                filterMode = FilterMode.Potions;
                break;

            case 5:
                filterMode = FilterMode.Placeables;
                break;

            case 6:
                filterMode = FilterMode.Misc;
                break;

            default:
                filterMode = FilterMode.All;
                break;
            }
            if (filterMode != oldFilterMode)
            {
                UpdateSubFilterButtons();
                oldFilterMode = filterMode;
            }
            SubFilterMode subFilterMode;

            subFilterMode = (SubFilterMode)subFilterButtons.Choice;
            items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, subFilterMode, searchBar2.Text, searchBar.Text));
            numItemsShown = items.Count;
            for (int k = 0; k < items.Count; k++)
            {
                didMatCheck.Add(false);
            }
        }
Example #10
0
        public static void RefreshItems()
        {
            items.Clear();
            TEStorageHeart heart = GetHeart();

            if (heart == null)
            {
                return;
            }
            InitSortButtons();
            InitFilterButtons();
            SortMode sortMode;

            switch (sortButtons.Choice)
            {
            case 0:
                sortMode = SortMode.Default;
                break;

            case 1:
                sortMode = SortMode.Id;
                break;

            case 2:
                sortMode = SortMode.Name;
                break;

            case 3:
                sortMode = SortMode.Quantity;
                break;

            default:
                sortMode = SortMode.Default;
                break;
            }
            FilterMode filterMode;

            switch (filterButtons.Choice)
            {
            case 0:
                filterMode = FilterMode.All;
                break;

            case 1:
                filterMode = FilterMode.Weapons;
                break;

            case 2:
                filterMode = FilterMode.Tools;
                break;

            case 3:
                filterMode = FilterMode.Equipment;
                break;

            case 4:
                filterMode = FilterMode.Potions;
                break;

            case 5:
                filterMode = FilterMode.Placeables;
                break;

            case 6:
                filterMode = FilterMode.Misc;
                break;

            default:
                filterMode = FilterMode.All;
                break;
            }
            items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, searchBar2.Text, searchBar.Text));
        }