From 5e5c15f69233c8718287f2ea4e30b99b5e459071 Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Wed, 11 Sep 2019 22:59:39 -0700 Subject: [PATCH] Updated machine inventory menu to update when an item is crafted. --- .../Framework/Menus/CraftingInformationPage.cs | 3 +++ .../Framework/Menus/InventoryTransferMenu.cs | 7 +++++++ .../Framework/Menus/Machines/MachineMenu.cs | 11 +++++++++++ .../Revitalize/Framework/Objects/Machines/Machine.cs | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 5bb7c30d..7fad536c 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Revitalize.Framework.Crafting; +using Revitalize.Framework.Menus.Machines; using Revitalize.Framework.Menus.MenuComponents; using Revitalize.Framework.Objects; using Revitalize.Framework.Objects.Machines; @@ -121,6 +122,8 @@ namespace Revitalize.Framework.Menus { this.inventory = Game1.player.Items; } + + if (Game1.activeClickableMenu is MachineMenu) (Game1.activeClickableMenu as MachineMenu).updateInventoryMenuIfPossible(); } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs index 9870c167..1a3b21c7 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs @@ -457,5 +457,12 @@ namespace Revitalize.Framework.Menus { if (this.displayTrashedItem && this.trashedItem.item!=null) IClickableMenu.drawToolTip(b, this.trashedItem.item.getDescription(), this.trashedItem.item.DisplayName, this.trashedItem.item, false, -1, 0, -1, -1, (CraftingRecipe)null, -1); } + + + public void updateInventory() + { + this.playerInventory.populateClickableItems(); + this.otherInventory.populateClickableItems(); + } } } diff --git a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs index 98f13775..e6494c82 100644 --- a/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/Machines/MachineMenu.cs @@ -12,6 +12,9 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus.Machines { + /// + /// Need to + /// public class MachineMenu : IClickableMenuExtended { @@ -148,5 +151,13 @@ namespace Revitalize.Framework.Menus.Machines this.drawMouse(b); } + + public void updateInventoryMenuIfPossible() + { + if (this.menuPages.ContainsKey("Inventory")) + { + (this.menuPages["Inventory"].Value as InventoryTransferMenu).updateInventory(); + } + } } } diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs index 95626ec5..3087e042 100644 --- a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -281,7 +281,7 @@ namespace Revitalize.Framework.Objects.Machines if (string.IsNullOrEmpty(this.craftingRecipeBook)==false) { - CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.InventoryManager.items,ref this.InventoryManager.bufferItems,this); + CraftingMenuV1 craftingMenu = CraftingRecipeBook.CraftingRecipesByGroup[this.craftingRecipeBook].getCraftingMenuForMachine(100, 100, 400, 700, ref this.InventoryManager.items,ref this.InventoryManager.items,this); machineMenu.addInMenuTab("Crafting", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Crafting Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), craftingMenu, false); }