public CustomCraftingMenu(int x, int y, int width, int height,
                                  List <Chest> material_containers,
                                  List <string> craftingRecipes, List <string> cookingRecipes)
            : base(x, y, width, height)
        {
            inventory = new InventoryMenu(xPositionOnScreen + spaceToClearSideBorder + borderWidth, yPositionOnScreen + spaceToClearTopBorder + borderWidth + 320 - 16, playerInventory: false);
            inventory.showGrayedOutSlots   = true;
            currentPageClickableComponents = new List <ClickableComponent>();
            foreach (ClickableComponent item in inventory.GetBorder(InventoryMenu.BorderSide.Top))
            {
                item.upNeighborID = -99998;
            }
            _materialContainers = material_containers;
            _ = _materialContainers;
            initializeUpperRightCloseButton();
            trashCan = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 192 - 32 - borderWidth - 104, 64, 104), Game1.mouseCursors, new Rectangle(564 + Game1.player.trashCanLevel * 18, 102, 18, 26), 4f)
            {
                myID = 106
            };
            dropItemInvisibleButton = new ClickableComponent(new Rectangle(xPositionOnScreen - borderWidth - spaceToClearSideBorder - 64, trashCan.bounds.Y, 64, 64), "")
            {
                myID            = 107,
                rightNeighborID = 0
            };
            List <string> playerRecipes = new List <string>();

            Game1.playSound("bigSelect");
            layoutRecipes(craftingRecipes, cookingRecipes);
            if (pagesOfCraftingRecipes.Count > 1)
            {
                upButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + 768 + 32, craftingPageY(), 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 12), 0.8f)
                {
                    myID            = 88,
                    downNeighborID  = 89,
                    rightNeighborID = 106,
                    leftNeighborID  = -99998
                };
                downButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + 768 + 32, craftingPageY() + 192 + 32, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 11), 0.8f)
                {
                    myID            = 89,
                    upNeighborID    = 88,
                    rightNeighborID = 106,
                    leftNeighborID  = -99998
                };
            }
            _UpdateCurrentPageButtons();
            if (Game1.options.SnappyMenus)
            {
                snapToDefaultClickableComponent();
            }
        }
示例#2
0
        public CraftingPage(int x, int y, int width, int height, bool cooking = false, bool standalone_menu = false, List <Chest> material_containers = null)
            : base(x, y, width, height)
        {
            _standaloneMenu = standalone_menu;
            this.cooking    = cooking;
            inventory       = new InventoryMenu(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth, yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + 320 - 16, playerInventory: false);
            inventory.showGrayedOutSlots   = true;
            currentPageClickableComponents = new List <ClickableComponent>();
            foreach (ClickableComponent item in inventory.GetBorder(InventoryMenu.BorderSide.Top))
            {
                item.upNeighborID = -99998;
            }
            _materialContainers = material_containers;
            _ = _materialContainers;
            if (_standaloneMenu)
            {
                initializeUpperRightCloseButton();
            }
            trashCan = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + width + 4, yPositionOnScreen + height - 192 - 32 - IClickableMenu.borderWidth - 104, 64, 104), Game1.mouseCursors, new Rectangle(564 + Game1.player.trashCanLevel * 18, 102, 18, 26), 4f)
            {
                myID = 106
            };
            dropItemInvisibleButton = new ClickableComponent(new Rectangle(xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - 64, trashCan.bounds.Y, 64, 64), "")
            {
                myID            = 107,
                rightNeighborID = 0
            };
            List <string> playerRecipes = new List <string>();

            if (_standaloneMenu)
            {
                Game1.playSound("bigSelect");
            }
            if (!cooking)
            {
                foreach (string s2 in CraftingRecipe.craftingRecipes.Keys)
                {
                    if (Game1.player.craftingRecipes.ContainsKey(s2))
                    {
                        playerRecipes.Add(s2);
                    }
                }
            }
            else
            {
                foreach (string s in CraftingRecipe.cookingRecipes.Keys)
                {
                    playerRecipes.Add(s);
                }
                playerRecipes.Sort(delegate(string a, string b)
                {
                    int num   = -1;
                    int value = -1;
                    if (a != null && CraftingRecipe.cookingRecipes.ContainsKey(a))
                    {
                        string[] array = CraftingRecipe.cookingRecipes[a].Split('/');
                        if (array.Length > 2 && int.TryParse(array[2], out int result))
                        {
                            num = result;
                        }
                    }
                    if (b != null && CraftingRecipe.cookingRecipes.ContainsKey(b))
                    {
                        string[] array2 = CraftingRecipe.cookingRecipes[b].Split('/');
                        if (array2.Length > 2 && int.TryParse(array2[2], out int result2))
                        {
                            value = result2;
                        }
                    }
                    return(num.CompareTo(value));
                });
            }
            layoutRecipes(playerRecipes);
            if (pagesOfCraftingRecipes.Count > 1)
            {
                upButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + 768 + 32, craftingPageY(), 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 12), 0.8f)
                {
                    myID            = 88,
                    downNeighborID  = 89,
                    rightNeighborID = 106,
                    leftNeighborID  = -99998
                };
                downButton = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + 768 + 32, craftingPageY() + 192 + 32, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 11), 0.8f)
                {
                    myID            = 89,
                    upNeighborID    = 88,
                    rightNeighborID = 106,
                    leftNeighborID  = -99998
                };
            }
            _UpdateCurrentPageButtons();
            if (Game1.options.SnappyMenus)
            {
                snapToDefaultClickableComponent();
            }
        }