示例#1
0
        public BetterCraftingPage(ModEntry betterCrafting, CategoryData categoryData, Nullable <ItemCategory> defaultCategory)
            : base(Game1.activeClickableMenu.xPositionOnScreen, Game1.activeClickableMenu.yPositionOnScreen, Game1.activeClickableMenu.width, Game1.activeClickableMenu.height)
        {
            this.betterCrafting = betterCrafting;

            this.categoryManager = new CategoryManager(betterCrafting.Monitor, categoryData);

            this.inventory = new InventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth,
                                               this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4,
                                               false);
            this.inventory.showGrayedOutSlots = true;

            this.pageX = this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth - Game1.tileSize / 4;
            this.pageY = this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth - Game1.tileSize / 4;

            if (defaultCategory.HasValue)
            {
                this.selectedCategory = defaultCategory.Value;
            }
            else
            {
                this.selectedCategory = this.categoryManager.GetDefaultItemCategory();
            }
            this.recipePage = 0;

            this.recipes    = new Dictionary <ItemCategory, List <Dictionary <ClickableTextureComponent, CraftingRecipe> > >();
            this.categories = new Dictionary <ClickableComponent, ItemCategory>();

            int catIndex = 0;

            var categorySpacing = Game1.tileSize / 6;
            var tabPad          = Game1.tileSize + Game1.tileSize / 4;

            int id = 0;

            foreach (ItemCategory category in this.categoryManager.GetItemCategories())
            {
                this.recipes.Add(category, new List <Dictionary <ClickableTextureComponent, CraftingRecipe> >());

                var catName = this.categoryManager.GetItemCategoryName(category);

                var nameSize = Game1.smallFont.MeasureString(catName);

                var width  = nameSize.X + Game1.tileSize / 2;
                var height = nameSize.Y + Game1.tileSize / 4;

                var x = this.xPositionOnScreen - width;
                var y = this.yPositionOnScreen + tabPad + catIndex * (height + categorySpacing);

                var c = new ClickableComponent(
                    new Rectangle((int)x, (int)y, (int)width, (int)height),
                    category.Equals(this.selectedCategory) ? UNAVAILABLE : AVAILABLE, catName);
                c.myID           = id;
                c.upNeighborID   = id - 1;
                c.downNeighborID = id + 1;

                this.categories.Add(c, category);

                catIndex += 1;
                id       += 1;
            }

            this.trashCan = new ClickableTextureComponent(
                new Rectangle(
                    this.xPositionOnScreen + width + 4,
                    this.yPositionOnScreen + height - Game1.tileSize * 3 - Game1.tileSize / 2 - IClickableMenu.borderWidth - 104,
                    Game1.tileSize, 104),
                Game1.mouseCursors,
                new Rectangle(669, 261, 16, 26),
                (float)Game1.pixelZoom, false);

            this.throwComp = new ClickableComponent(
                new Rectangle(
                    this.xPositionOnScreen + width + 4,
                    this.yPositionOnScreen + height - Game1.tileSize * 3 - IClickableMenu.borderWidth,
                    Game1.tileSize, Game1.tileSize),
                "");

            this.oldButton = new ClickableTextureComponent("",
                                                           new Rectangle(
                                                               this.xPositionOnScreen + width,
                                                               this.yPositionOnScreen + height / 3 - Game1.tileSize + Game1.pixelZoom * 2,
                                                               Game1.tileSize,
                                                               Game1.tileSize),
                                                           "",
                                                           "Old Crafting Menu",
                                                           Game1.mouseCursors,
                                                           new Rectangle(162, 440, 16, 16),
                                                           (float)Game1.pixelZoom, false);

            this.UpdateInventory();
        }