コード例 #1
0
        private void buildList()
        {
            internalGrid.Clear();
            internalGrid.Left.Set(2, 0);
            internalGrid.Top.Set(2, 0);
            internalGrid.Width.Set(0, 1.0f);
            internalGrid.Height.Set(0, 1.0f);

            float startX = 2;
            float startY = 2;

            selected = ((ResearchFrom14)ModLoader.GetMod("ResearchFrom14")).preUI.itemSlot.item;
            if (selected == null || selected.type == 0)
            {
                Recalculate();
                internalGrid.RecalculateChildren();
                hasChanged = false;
                return;
            }
            ResearchPlayer pl = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();

            internalGrid.Add(new PrefixButton(0));
            foreach (byte b in pl.GetResearchedPrefixes(selected))
            {
                internalGrid.Add(new PrefixButton(b));
            }
            Recalculate();
            internalGrid.RecalculateChildren();
            hasChanged = false;
        }
コード例 #2
0
        public override bool CanPickup(Item item, Player player)
        {
            ResearchPlayer rp = player.GetModPlayer <ResearchPlayer>();

            if (ModContent.GetInstance <TrashConfig>().autoTrashResearched&& Main.netMode != NetmodeID.Server && !isItemNotTrasheable(item))
            {
                if (rp.IsResearched(item))
                {
                    item.stack = 0;
                    //item.TurnToAir();
                    return(true);
                }
                else if (ModContent.GetInstance <TrashConfig>().autoTrashResearchPrefix&& rp.IsResearched(item.type))
                {
                    Item curDestroy = rp.destroyingItem;
                    Item clone      = item.DeepClone();
                    rp.destroyingItem = clone;
                    rp.Research();
                    item.stack        = 0;
                    rp.destroyingItem = curDestroy;
                    return(true);
                }
            }
            return(base.CanPickup(item, player));
        }
コード例 #3
0
        public override void RightClick(Player player)
        {
            if (knowledge == null || playerName == null)
            {
                return;
            }
            if (t != null && !t.IsCompleted)
            {
                Main.NewText("Still running...");
                return;
            }
            Main.NewText("Knows " + knowledge.Count + " items.");
            ResearchPlayer rp = player.GetModPlayer <ResearchPlayer>();

            if (player.name.Equals(playerName))
            {
                if (ModContent.GetInstance <Config>().researchRecipes)
                {
                    t = Task.Run(rebuildResearch);
                }
                return;
            }
            else
            {
                t = Task.Run(addKnowledge);
            }


            item.stack--;
        }
コード例 #4
0
        private void rebuildResearch()
        {
            ResearchPlayer rp = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();

            Main.NewText("Rebuilding research from cache. This may take a while...");
            rp.refreshResearch();
            Main.NewText("Done, now knows " + rp.researchedCache.Count + " items.");
            knowledge = rp.researchedCache;
        }
コード例 #5
0
        public override bool ItemSpace(Item item, Player player)
        {
            ResearchPlayer rp = player.GetModPlayer <ResearchPlayer>();

            if (ModContent.GetInstance <TrashConfig>().autoTrashResearched&& Main.netMode != NetmodeID.Server && rp.IsResearched(item))
            {
                return(true);
            }
            return(base.ItemSpace(item, player));
        }
コード例 #6
0
        public override bool ConsumeItem(Item item, Player player)
        {
            ResearchPlayer rp = player.GetModPlayer <ResearchPlayer>();

            if (ModContent.GetInstance <Config>().infiniteItems&& rp.IsResearched(item))
            {
                return(false);
            }
            return(base.ConsumeItem(item, player));
        }
コード例 #7
0
        private void addKnowledge()
        {
            ResearchPlayer rp = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();

            Main.NewText("Adding new research...");
            rp.AddAllResearchedItems(knowledge);
            Main.NewText("Done, now knows " + rp.researchedCache.Count + " items.");
            playerName = Main.player[Main.myPlayer].name;
            knowledge  = rp.researchedCache;
        }
コード例 #8
0
        public override void RightClick(Player player)
        {
            ResearchPlayer rp = player.GetModPlayer <ResearchPlayer>();

            rp.research = new TagCompound();
            rp.researchedCache.Clear();
            rp.researchedTileCache.Clear();
            rp.researchedTileAdj = new bool[TileLoader.TileCount];
            rp.AddAllResearchedItems(new List <int>()
            {
                ModContent.ItemType <ResearchErasingBook>(), ModContent.ItemType <ResearchSharingBook>()
            });

            item.stack--;
        }
コード例 #9
0
 public override void ModifyTooltips(Item item, List <TooltipLine> tooltips)
 {
     if (ModContent.GetInstance <Config>().showResearch)
     {
         ResearchPlayer rp = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();
         if (rp.IsResearched(item))
         {
             if (ModContent.GetInstance <Config>().showResearched)
             {
                 tooltips.Add(new TooltipLine(this.mod, "Research", "Researched!")
                 {
                     overrideColor = Color.Lerp(Color.HotPink, Color.White, 0.1f)
                 });
             }
         }
         else
         {
             if (ResearchTable.GetTotalResearch(item) <= 0)
             {
                 tooltips.Add(new TooltipLine(this.mod, "Research", "Unresearchable!")
                 {
                     overrideColor = Color.Lerp(Color.HotPink, Color.White, 0.1f)
                 });
             }
             else
             {
                 if (!rp.IsResearched(item.type))
                 {
                     tooltips.Add(new TooltipLine(this.mod, "Research", "Research " + (ResearchTable.GetTotalResearch(item) - rp.GetResearchedAmount(item)) + " more to unlock.")
                     {
                         overrideColor = Color.Lerp(Color.HotPink, Color.White, 0.1f)
                     });
                 }
                 else
                 {
                     tooltips.Add(new TooltipLine(this.mod, "Research", "Base item Researched, but not this Prefix for this item.")
                     {
                         overrideColor = Color.Lerp(Color.HotPink, Color.White, 0.1f)
                     });
                 }
             }
         }
     }
     if (ModContent.GetInstance <Config>().showTag)
     {
         tooltips.Add(new TooltipLine(this.mod, "tagID", "<" + ResearchFrom14.ItemToTag(item) + ">"));
     }
 }
コード例 #10
0
        public override object Call(params object[] args)
        {
            if (args.Length == 0 || !(args[0] is string) || (((args[0]) as string) == null))
            {
                Logger.Info("Mod call was Empty. This will display, in log, what functions are currently available. All function calls are case-insensitive, but arguments are not.");
                Logger.Info("Player arguments accept the Player object or the Player.whoAmI (position in the Main.player array)");
                Logger.Info("Item arguments take Item objects, ModItem object, the int Type of that item or the Item Tag of the item)");
                Logger.Info("Int values accept int or its string representation");

                Logger.Info("Functions available");
                Logger.Info(" - IsResearched (Player, Item) ");
                Logger.Info("Returns -1 if the item is irresearchable, 0 if it is totally researched or the number of items remaining before becoming fully researched.");
                Logger.Info(" - AddResearch (Player, Item, Int) ");
                Logger.Info("Adds Int to the researched amount of Item for the given Player. Send Int32.Max for fully research the item regardless of current amount. This will not research items considered unresearchable. Returns the research amount remaining after adding.");
                Logger.Info(" - SetDefaultMaxResearch (Item, Int) ");
                Logger.Info("Sets the default, starting value for the specified item's research needed. If this value is -1, makes it impossible to research, 0 makes this mod's algorithm decide, positive values are set as the amount needed.\n" +
                            "Note: This function does not alter the values outright. After finishing calling all the SetDefault* you need, call ResetTable.");
                Logger.Info(" - SetDefaultCategories (Item, List<string>) or SetDefaultCategories (Item, string ...) ");
                Logger.Info("Sets the default category to a custom value. This does not stop it from showing up in other categories, it's just a way to make custom categories for mods possible.\n" +
                            "Note: This function does not alter the values outright. After finishing calling all the SetDefault* you need, call ResetTable.");
                Logger.Info(" - ResetTable() ");
                Logger.Info("Resets the table, applying the new defaults that have been set. This function is required to apply the changes made by the two SetDefault functions. Use it at the end of all your Item Changes.");
                return(null);
            }

            string function = args[0] as string;

            /* IsResearched
             * - Params
             * - Player
             * - item
             * - Returns -1 if unresearchable, 0 if researched, the remaining items to reseach otherwise.*/
            if (function.ToLower().Equals("isresearched"))
            {
                if (args.Length != 3)
                {
                    Logger.Error("Error in ModCall IsResearched: Invalid parameter number (Player, Item)");
                    return(null);
                }
                Player p = getPlayerFromObject(args[1]);
                if (p == null)
                {
                    Logger.Error("Error in ModCall IsResearched: Player is null (means not really a Player or a player.whoAmI)");
                    return(null);
                }

                int?itemID = getItemTypeFromObject(args[2]);
                if (itemID == null)
                {
                    Logger.Error("Error in ModCall IsResearched: Item is null (means not really an Item, ModItem, int or valid ItemTag string)");
                    return(null);
                }
                if (itemID.Value == 0)
                {
                    Logger.Error("Error in ModCall IsResearched: Item type is 0. This value is not valid (probably invalid ItemTag string)");
                    return(null);
                }

                ResearchPlayer player     = p.GetModPlayer <ResearchPlayer>();
                int            researched = player.GetResearchedAmount(itemID.Value);
                int            total      = ResearchTable.GetTotalResearch(itemID.Value);
                if (total < 1)
                {
                    return(-1);
                }
                if (researched <= total)
                {
                    return(total - researched);
                }
                return(0);
            }

            /* AddResearch
             * - Params
             *  - Player
             *  - item
             *  - amount
             * - Adds research amount to item for Player*/
            if (function.ToLower().Equals("addresearch"))
            {
                if (args.Length != 4)
                {
                    Logger.Error("Error in ModCall AddResearch: Invalid parameter number (Player, Item, int amount)");
                    return(null);
                }
                Player p = getPlayerFromObject(args[1]);
                if (p == null)
                {
                    Logger.Error("Error in ModCall AddResearch: Player is null (means not really a Player or a player.whoAmI)");
                    return(null);
                }

                int?itemID = getItemTypeFromObject(args[2]);
                if (itemID == null)
                {
                    Logger.Error("Error in ModCall AddResearch: Item is null (means not really an Item, ModItem, int or valid ItemTag string)");
                    return(null);
                }
                if (itemID.Value == 0)
                {
                    Logger.Error("Error in ModCall AddResearch: Item type is 0. This value is not valid (probably invalid ItemTag string)");
                    return(null);
                }

                int?amount = getIntFromObject(args[3]);
                if (amount == null)
                {
                    Logger.Error("Error in ModCall AddResearch: amount is null (means not really an int or an int-parsable string)");
                    return(null);
                }

                ResearchPlayer player = p.GetModPlayer <ResearchPlayer>();
                if (ResearchTable.GetTotalResearch(itemID.Value) <= 0)
                {
                    return(-1);
                }
                try
                {
                    Item itm = new Item();
                    itm.SetDefaults(itemID.Value);
                    itm.stack = amount.Value == Int32.MaxValue ? (amount.Value - 1000): amount.Value;
                    int total = player.AddResearchedAmount(itm);
                    return(total);
                }catch (Exception ex)
                {
                    Logger.Error("Error in ModCall AddResearch: Item cannot be SetDefault");
                }
                return(null);
            }

            /* SetDefaultMaxResearch
             * - Params
             * - item
             * - int amount
             * Sets the default value for the required research for the given item to become infinite
             * - Returns nothing*/
            if (function.ToLower().Equals("setdefaultmaxresearch"))
            {
                if (args.Length != 3)
                {
                    Logger.Error("Error in ModCall SetDefaultMaxResearch: Invalid parameter number (Item, int)");
                    return(null);
                }

                int?itemID = getItemTypeFromObject(args[1]);
                if (itemID == null)
                {
                    Logger.Error("Error in ModCall SetDefaultMaxResearch: Item is null (means not really an Item, ModItem, int or valid ItemTag string)");
                    return(null);
                }
                if (itemID.Value == 0)
                {
                    Logger.Error("Error in ModCall SetDefaultMaxResearch: Item type is 0. This value is not valid (probably invalid ItemTag string)");
                    return(null);
                }

                int?amount = getIntFromObject(args[2]);
                if (amount == null)
                {
                    Logger.Error("Error in ModCall SetDefaultMaxResearch: amount is null (means not really an int or an int-parsable string)");
                    return(null);
                }

                ResearchTable.defaultValues[itemID.Value] = amount.Value;
                return(ResearchTable.defaultValues[itemID.Value]);
            }

            /* SetDefaultCategories
             * - Params
             * - item
             * - List<string> or string...
             * Sets the default categories for the given item
             * - Returns true if successfully added category*/
            if (function.ToLower().Equals("setdefaultcategories"))
            {
                if (args.Length < 3)
                {
                    Logger.Error("Error in ModCall SetDefaultCategories: Invalid parameter number (Item, List<string> or string...)");
                    return(null);
                }
                int?itemID = getItemTypeFromObject(args[1]);
                if (itemID == null)
                {
                    Logger.Error("Error in ModCall SetDefaultCategories: Item is null (means not really an Item, ModItem, int or valid ItemTag string)");
                    return(null);
                }
                if (itemID.Value == 0)
                {
                    Logger.Error("Error in ModCall SetDefaultCategories: Item type is 0. This value is not valid (probably invalid ItemTag string)");
                    return(null);
                }

                List <string> cats = getListOfStringFromObjects(args, 2);
                if (cats.Count == 0)
                {
                    Logger.Error("Error in ModCall SetDefaultCategories: no strings found");
                    return(null);
                }
                if (ResearchTable.defaultCategories.ContainsKey(itemID.Value))
                {
                    ResearchTable.defaultCategories[itemID.Value].AddRange(cats);
                }
                else
                {
                    ResearchTable.defaultCategories[itemID.Value] = cats;
                }
                return(true);
            }
            if (function.ToLower().Equals("resettable"))
            {
                ResearchTable.InitResearchTable();
            }

            Logger.Error("Error in ModCall: function \"" + function + "\" does not exist.");
            return(null);
        }
コード例 #11
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            int messageID = reader.ReadByte();

            Logger.Info("Received Message id " + messageID);

            /*message 0: Share research with server (not used)
             * int Player
             * TAGCompound Research*/
            if (messageID == 0)
            {
                int player = reader.ReadByte();
                if (Main.netMode == NetmodeID.Server || player != Main.myPlayer)
                {
                    TagCompound tempResearch = TagIO.Read(reader);
                    foreach (KeyValuePair <string, object> read in tempResearch)
                    {
                        Main.player[player].GetModPlayer <ResearchPlayer>().research[read.Key] = tempResearch.GetAsInt(read.Key);
                    }
                    Main.player[player].GetModPlayer <ResearchPlayer>().dirtyCache = true;
                    Main.player[player].GetModPlayer <ResearchPlayer>().RebuildCache();
                    return;
                }
            }

            /*message 1: dirty cache
             * int player
             * refreshes the cache*/
            if (messageID == 1)
            {
                int player = reader.ReadByte();
                Main.player[player].GetModPlayer <ResearchPlayer>().dirtyCache = true;
                Main.player[player].GetModPlayer <ResearchPlayer>().RebuildCache();
                return;
            }

            /*message 10 : P2P item cache sharing
             * byte player
             * int count
             * int[count] itemIDs
             * Share the cache with another player. Meant to share multiple, fully researched items at once.
             * Will send another such message to the sender (with this whoAmI) with the researched items,
             * and will keep sending them to one another until the cache is equal*/
            if (messageID == 10) //Shared item Cache
            {
                ResearchPlayer rp     = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();
                int            sendTo = reader.ReadByte();
                //Logger.Info("Received shared cache Message to "+i);
                List <int> oldCache = new List <int>();
                oldCache.AddRange(rp.researchedCache);

                int count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    int id = reader.ReadInt32();
                    if (!rp.IsResearched(id))
                    {
                        rp.AddResearchedAmount(id, ResearchTable.GetTotalResearch(id));
                        rp.CheckRecipesForItem(id);
                    }
                }
                if (Main.netMode == NetmodeID.Server || sendTo != Main.myPlayer)
                {
                    rp.shareCacheTo(sendTo);
                }
                return;
            }

            /*message 11: Share single item with intermediate result
             * byte player to send to
             * byte player that sent the message
             * int item
             * int research count
             *
             * Adds the research count to the player's research, and replies with the same message with its previous research count
             */
            if (messageID == 11)
            {
                ResearchPlayer rp           = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();
                int            sendTo       = reader.ReadByte();
                int            orgSender    = reader.ReadByte();
                int            itm          = reader.ReadInt32();
                int            amount       = reader.ReadInt32();
                int            prevResearch = rp.GetResearchedAmount(itm);
                int            res          = rp.AddResearchedAmount(itm, amount);
                if (Main.netMode == NetmodeID.Server)
                {
                    ModPacket pk = GetPacket();
                    pk.Write((byte)11);
                    pk.Write((byte)(sendTo));
                    pk.Write((byte)(orgSender));
                    pk.Write(itm);
                    pk.Write(amount);
                    pk.Send(sendTo);
                    return;
                }
                //Logger.Info("Received share single item Message from " + sender + ". Item " + itm + " with amount "+ amount);

                if (rp.IsResearched(itm) && res != amount)
                {
                    rp.CheckRecipesForItem(itm);

                    //Logger.Info("Item "+ itm + " was fully researched with " + amount);
                    rp.RebuildCache();
                    if (orgSender == Main.myPlayer)
                    {
                        return;
                    }
                    ModPacket pk = GetPacket();
                    pk.Write((byte)11);
                    pk.Write((byte)(orgSender));
                    pk.Write((byte)(orgSender));
                    pk.Write(itm);
                    pk.Write(prevResearch + amount);
                    pk.Send();
                }
                else
                {
                    //Logger.Info("Item " + itm + " was not fully researched with " + amount);
                }
                return;
            }

            /*message 12: Share prefixes
             * byte player to send to
             * int itm
             * int count
             * byte[count] prefixes
             *
             * Sends all prefixes for item itm, with no replies. Only adds prefixes.*/
            if (messageID == 12)
            {
                ResearchPlayer rp       = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();
                int            sendTo   = reader.ReadByte();
                int            itm      = reader.ReadInt32();
                int            count    = reader.ReadInt32();
                List <byte>    prefixes = new List <byte>();
                for (int i = 0; i < count; i++)
                {
                    byte p = reader.ReadByte();
                    prefixes.Add(p);
                    rp.AddResearchPrefix(itm, p);
                }
                if (Main.netMode == NetmodeID.Server)
                {
                    ModPacket pk = GetPacket();
                    pk.Write((byte)12);
                    pk.Write((byte)(sendTo));

                    pk.Write(prefixes.Count);
                    for (int k = 0; k < prefixes.Count; k++)
                    {
                        pk.Write((byte)(prefixes[k]));
                    }
                    pk.Send(sendTo);
                }
                return;
            }

            if (messageID == 99)
            {
                int player = reader.ReadByte();
                ResearchTable.InitResearchTable();
                if (Main.netMode == NetmodeID.Server)
                {
                    ModPacket pk = this.GetPacket();
                    pk.Write((byte)99);
                    pk.Write((byte)player);
                    pk.Send(-1, player);
                    ModContent.GetInstance <ExceptionListConfig>().forceReload = false;
                    SaveListConfig();
                }
                else
                {
                    Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>().RebuildCache();
                }
                ModContent.GetInstance <ExceptionListConfig>().forceReload = false;
                return;
            }
        }
コード例 #12
0
 public override void whileMouseHovering()
 {
     base.whileMouseHovering();
     if (Main.mouseLeftRelease && Main.mouseLeft)
     {
         if (ItemSlot.ShiftInUse && item.type != ModContent.ItemType <ResearchSharingBook>())
         {
             Item itm = item.DeepClone();
             itm.stack = item.maxStack;
             itm       = Main.player[Main.myPlayer].GetItem(Main.myPlayer, itm, false, false);
             if (itm.stack > 0)
             {
                 Main.player[Main.myPlayer].QuickSpawnItem(itm, itm.stack);
             }
             return;
         }
         if (Main.mouseItem == null || Main.mouseItem.type == 0)
         {
             Main.mouseItem = new Item();
             Main.mouseItem.SetDefaults(item.type);
             if (item.type == ModContent.ItemType <ResearchSharingBook>())
             {
                 ResearchSharingBook rs = Main.mouseItem.modItem as ResearchSharingBook;
                 ResearchPlayer      rp = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();
                 ((ResearchSharingBook)Main.mouseItem.modItem).knowledge  = rp.researchedCache;
                 ((ResearchSharingBook)Main.mouseItem.modItem).playerName = rp.player.name;
                 Main.NewText(rp.player.name + " : " + ((ResearchSharingBook)Main.mouseItem.modItem).knowledge.Count);
                 //Main.mouseItem.HoverName = rp.player.name + "'s " + Main.mouseItem.modItem.Name;
             }
             Main.mouseItem.stack = Main.mouseItem.maxStack;
             return;
         }
         else
         {
             if (Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>().IsResearched(Main.mouseItem))
             {
                 Main.mouseItem = new Item();
             }
         }
     }
     else if (Main.stackSplit <= 1 && Main.mouseRight)
     {
         if (item.maxStack >= 1 && (Main.mouseItem.IsTheSameAs(item) || Main.mouseItem.type == 0) && (Main.mouseItem.stack < Main.mouseItem.maxStack || Main.mouseItem.type == 0))
         {
             if (Main.mouseItem.type == 0)
             {
                 Main.mouseItem = new Item();
                 Main.mouseItem.SetDefaults(item.type);
                 if (item.type == ModContent.ItemType <ResearchSharingBook>())
                 {
                     ResearchSharingBook rs = Main.mouseItem.modItem as ResearchSharingBook;
                     ResearchPlayer      rp = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();
                     ((ResearchSharingBook)Main.mouseItem.modItem).knowledge  = rp.researchedCache;
                     ((ResearchSharingBook)Main.mouseItem.modItem).playerName = rp.player.name;
                     Main.NewText(rp.player.name + " : " + ((ResearchSharingBook)Main.mouseItem.modItem).knowledge.Count);
                     //Main.mouseItem.HoverName = rp.player.name + "'s " + Main.mouseItem.modItem.Name;
                 }
                 Main.mouseItem.stack = 1;
             }
             else
             {
                 if (Main.mouseItem.stack <= Main.mouseItem.maxStack)
                 {
                     Main.mouseItem.stack += 1;
                 }
             }
             Recipe.FindRecipes();
             Main.soundInstanceMenuTick.Stop();
             Main.soundInstanceMenuTick = Main.soundMenuTick.CreateInstance();
             Main.PlaySound(12, -1, -1, 1, 1f, 0f);
             if (Main.stackSplit == 0)
             {
                 Main.stackSplit = 15;
             }
             else
             {
                 Main.stackSplit = Main.stackDelay;
             }
         }
     }
 }
コード例 #13
0
        public void recreateList()
        {
            internalGrid.Left.Set(0, 0);
            internalGrid.Top.Set(0, 0);
            internalGrid.Width.Set(this.Width.Pixels - 4, 0);
            internalGrid.Height.Set(this.Height.Pixels - 4, 0);

            ResearchPlayer player    = Main.player[Main.myPlayer].GetModPlayer <ResearchPlayer>();
            List <Item>    toDisplay = new List <Item>();

            while (player.waitingForResearchCache())
            {
                Task.Yield();
            }
restart:
            changedToList = false;
            toDisplay.Clear();
            internalGrid.Clear();

            foreach (int type in player.researchedCache)
            {
                Item itm = new Item();
                itm.SetDefaults(type);
                itm.stack = 1;
                if (parent.search.GetText() == null || parent.search.GetText().Trim().Length == 0 || itm.Name.ToLower().Contains(parent.search.GetText().ToLower()) ||
                    (tooltipSearch && condensedTooltip(itm).ToLower().Contains(parent.search.GetText().ToLower())))
                {
                    toDisplay.Add(itm);
                }
                if (changedToList)
                {
                    goto restart;
                }
            }
            toDisplay.Sort(new ItemNameComparer());

            if (selected.Equals(changer.allTree))
            {
                foreach (Item itm in toDisplay)
                {
                    internalGrid.Add(new PurchaseItemSlot(itm));
                    if (changedToList)
                    {
                        goto restart;
                    }
                }
            }
            else
            {
                if (ResearchTable.category.ContainsKey(selected.getFullPath()))
                {
                    // ModLoader.GetMod("ResearchFrom14").Logger.Info("Category " + selected.getFullPath() + " has items:");

                    /* foreach (int cat in ResearchTable.category[selected.getFullPath()])
                     * {
                     *   Item test = new Item();
                     *   test.SetDefaults(cat);
                     *   //   ModLoader.GetMod("ResearchFrom14").Logger.Info("  - " + test.Name + " ( id " + test.type + " = "+cat + ")" );
                     * }*/
                    foreach (Item itm in toDisplay)
                    {
                        if (ResearchTable.category[selected.getFullPath()].Contains(itm.type))
                        {
                            internalGrid.Add(new PurchaseItemSlot(itm));
                        }
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
        }