Ejemplo n.º 1
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);

restart:
            changedToList = false;
            internalGrid.Clear();

            if (parent.destroySlot.item != null && parent.destroySlot.item.type != 0 && !ARareItemSwapJPANs.tokenList.Contains(ARareItemSwapJPANs.ItemToTag(parent.destroySlot.item)) && PartRecipes.recipesByResult.ContainsKey(ARareItemSwapJPANs.ItemToTag(parent.destroySlot.item)))
            {
                foreach (PartRecipe pr in PartRecipes.recipesByResult[ARareItemSwapJPANs.ItemToTag(parent.destroySlot.item)])
                {
                    if (pr.isAvailable())
                    {
                        PurchaseItemSlot pt = new PurchaseItemSlot(pr);
                        if (parent.selectedRecipe == null)
                        {
                            parent.selectedRecipe = pr;
                        }
                        if (pr.Equals(parent.selectedRecipe))
                        {
                            pt.select(true);
                        }
                        internalGrid.Add(pt);
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
            else if (selected.Equals(changer.availableTree))
            {
                List <PartRecipe> prtList = new List <PartRecipe>();

                prtList.AddRange(PartRecipes.allRecipes);
                prtList.Sort(PartRecipe.orderByResultName);
                for (int i = 0; i < prtList.Count; i++)
                {
                    if (!prtList[i].isAvailable())
                    {
                        prtList.RemoveAt(i);
                        i--;
                    }
                    else
                    {
                        if (!Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>().CanCraftRecipe(prtList[i]))
                        {
                            prtList.RemoveAt(i);
                            i--;
                        }
                    }
                    if (changedToList)
                    {
                        goto restart;
                    }
                }

                foreach (PartRecipe pr in prtList)
                {
                    if (search == null || search.Trim().Length == 0 || pr.result.Name.ToLower().Contains(search.ToLower()) || (tooltipSearch && condensedTooltip(pr.result).ToLower().Contains(search.ToLower())))
                    {
                        PurchaseItemSlot pt = new PurchaseItemSlot(pr);
                        internalGrid.Add(pt);
                    }
                    if (changedToList)
                    {
                        goto restart;
                    }
                }
            }
            else if (selected.Equals(changer.allTree))
            {
                List <PartRecipe> prtList = new List <PartRecipe>();

                prtList.AddRange(PartRecipes.allRecipes);
                prtList.Sort(PartRecipe.orderByResultName);

                foreach (PartRecipe pr in prtList)
                {
                    if (pr.isAvailable())
                    {
                        if (search == null || search.Trim().Length == 0 || pr.result.Name.ToLower().Contains(search.ToLower()) || (tooltipSearch && condensedTooltip(pr.result).ToLower().Contains(search.ToLower())))
                        {
                            PurchaseItemSlot pt = new PurchaseItemSlot(pr);
                            internalGrid.Add(pt);
                        }
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
            else if (selected.Equals(changer.partsTree))
            {
                PartsPlayer prt = Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>();
                foreach (string s in ARareItemSwapJPANs.tokenList)
                {
                    if (prt.parts.ContainsKey(s))
                    {
                        Item part = ARareItemSwapJPANs.getItemFromTag(s);
                        if (search == null || search.Trim().Length == 0 || part.Name.ToLower().Contains(search.ToLower()) || (tooltipSearch && condensedTooltip(part).ToLower().Contains(search.ToLower())))
                        {
                            PartItemSlot pt = new PartItemSlot(s, -1);
                            internalGrid.Add(pt);
                        }
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
            else
            {
                if (selected != null && PartRecipes.recipesByCategory.ContainsKey(selected.getFullPath()))
                {
                    List <PartRecipe> prtList = new List <PartRecipe>();
                    prtList.AddRange(PartRecipes.recipesByCategory[selected.getFullPath()]);
                    prtList.Sort(PartRecipe.orderByResultName);
                    foreach (PartRecipe pr in prtList)
                    {
                        if (pr.isAvailable())
                        {
                            if (search == null || search.Length == 0 || pr.result.Name.ToLower().Contains(search.ToLower()) || (tooltipSearch && condensedTooltip(pr.result).ToLower().Contains(search.ToLower())))
                            {
                                PurchaseItemSlot pt = new PurchaseItemSlot(pr);

                                internalGrid.Add(pt);
                            }
                        }
                        if (changedToList)
                        {
                            goto restart;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
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;
                        }
                    }
                }
            }
        }