Пример #1
0
        public override void Update(GameTime gameTime)
        {
            if (hasChanges || selected != parent.selectedRecipe || selected == null || !selected.Equals(parent.selectedRecipe))
            {
                selected = parent.selectedRecipe;

                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);
                internalGrid.Clear();

                float startX = 0;
                float startY = 0;
                if (selected != null)
                {
                    PartsPlayer prt = Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>();
                    foreach (Item part in selected.parts)
                    {
                        PartItemSlot pt = new PartItemSlot(ARareItemSwapJPANs.ItemToTag(part), part.stack);
                        //pt.Left.Set(startX, 0);
                        // pt.Top.Set(startY, 0);

                        /*startX += pt.Width.Pixels + 2;
                         * if (startX + pt.Width.Pixels + 2 > this.Height.Pixels - 4)
                         * {
                         *  startX = 0;
                         *  startY += pt.Height.Pixels + 2;
                         * }*/
                        internalGrid.Add(pt);
                    }
                }
                //  internalGrid.Height.Set(Math.Max(this.Height.Pixels, startY + parent.destroySlot.Height.Pixels + 2), 0);
                internalGrid.Recalculate();
                Recalculate();
                hasChanges = false;
            }
            base.Update(gameTime);
        }
Пример #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);

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;
                        }
                    }
                }
            }
        }