public CategoryManager(IMonitor monitor, CategoryData data) { this.monitor = monitor; this.data = data; this.itemCategories = this.data.categories.Keys.Select(str => new ItemCategory(str)).ToList(); if (!this.itemCategories.Contains(new ItemCategory("misc"))) { if (!this.data.categoryNames.ContainsKey("misc")) { this.data.categoryNames.Add("misc", "Misc"); } this.itemCategories.Add(new ItemCategory("misc")); } }
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(); }
public BetterCraftingPage(ModEntry betterCrafting, CategoryData categoryData, Nullable <ItemCategory> defaultCategory, List <Chest> material_containers = null) : base(Game1.activeClickableMenu.xPositionOnScreen, Game1.activeClickableMenu.yPositionOnScreen, Game1.activeClickableMenu.width, Game1.activeClickableMenu.height) { _materialContainers = material_containers; _ = _materialContainers; 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; } if (ShouldShowJunimoNoteIcon()) { junimoNoteIcon = new ClickableTextureComponent("", new Rectangle(xPositionOnScreen + width, yPositionOnScreen + 96, 64, 64), "", Game1.content.LoadString("Strings\\UI:GameMenu_JunimoNote_Hover"), Game1.mouseCursors, new Rectangle(331, 374, 15, 14), 4f) { myID = 898, leftNeighborID = 11, downNeighborID = 106 }; } this.trashCan = new ClickableTextureComponent( new Rectangle( this.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, 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), Game1.pixelZoom, false); }