diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTab.png b/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTab.png new file mode 100644 index 00000000..9d68580b Binary files /dev/null and b/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTab.png differ diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTabHorizontal.png b/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTabHorizontal.png new file mode 100644 index 00000000..6c67d130 Binary files /dev/null and b/GeneralMods/Revitalize/Content/Graphics/Menus/Misc/MenuTabHorizontal.png differ diff --git a/GeneralMods/Revitalize/Framework/Crafting/MachineCraftingRecipe.cs b/GeneralMods/Revitalize/Framework/Crafting/MachineCraftingRecipe.cs new file mode 100644 index 00000000..a584ecbe --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Crafting/MachineCraftingRecipe.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Crafting +{ + public class MachineCraftingRecipe + { + } +} diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index d5c87ef6..6a04e150 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -174,7 +174,7 @@ namespace Revitalize.Framework.Crafting /// The inventory to put outputs into. /// Should this item be dropped to the ground when crafted? /// Checks to see if the invventory is the player's - private void craft(ref IList from, ref IList to, bool dropToGround = false, bool isPlayerInventory = false) + public void craft(ref IList from, ref IList to, bool dropToGround = false, bool isPlayerInventory = false) { InventoryManager manager = new InventoryManager(to); if (manager.ItemCount + this.outputs.Count >= manager.capacity) @@ -207,7 +207,7 @@ namespace Revitalize.Framework.Crafting return this.PlayerContainsAllIngredients() && this.statCost.canSafelyAffordCost(); } - public bool CanCraft(List items) + public bool CanCraft(IList items) { return this.InventoryContainsAllIngredient(items); } diff --git a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipe.cs b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipe.cs index 85b893db..033a017a 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/VanillaRecipe.cs @@ -9,7 +9,7 @@ using StardewValley; namespace Revitalize.Framework.Crafting { /// - /// A vanilla recipe to be used with staandard stardew valley machines such as the furnace. + /// A vanilla recipe to be used with standard stardew valley machines such as the furnace. /// public class VanillaRecipe { diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs new file mode 100644 index 00000000..25f94d80 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Revitalize.Framework.Menus.MenuComponents; +using Revitalize.Framework.Objects; +using Revitalize.Framework.Utilities; +using StardewValley; +using StardustCore.UIUtilities; + +namespace Revitalize.Framework.Menus +{ + public class CraftingInformationPage:IClickableMenuExtended + { + + public CraftingRecipeButton infoButton; + public Color backgroundColor; + + public Vector2 itemDisplayLocation; + + public IList inventory; + + public Item actualItem + { + get + { + return this.infoButton.displayItem.item; + } + } + + public CraftingInformationPage():base() + { + + } + + public CraftingInformationPage(int x, int y, int width, int height,Color BackgroundColor,CraftingRecipeButton ItemToDisplay,ref IList Inventory) : base(x, y, width, height, false) + { + this.backgroundColor = BackgroundColor; + this.infoButton = ItemToDisplay; + this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128)); + this.inventory = Inventory; + } + + public override void draw(SpriteBatch b) + { + this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + this.infoButton.draw(b,this.itemDisplayLocation); + + b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName, this.itemDisplayLocation + this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor()); + + this.drawMouse(b); + } + + public bool doesMenuContainPoint(int x, int y) + { + Rectangle r = new Rectangle(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height); + return r.Contains(x, y); + } + + public bool canCraftRecipe() + { + return this.infoButton.recipe.CanCraft(this.inventory); + } + + public Color getNameColor() + { + if (this.canCraftRecipe()) return Color.Black; + else return Color.Red; + } + + private Vector2 getHeightOffsetFromItem() + { + if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), this.actualItem.GetType())){ + return new Vector2(0, 64f); + } + if (ObjectUtilities.IsSameType(typeof(Revitalize.Framework.Objects.MultiTiledObject), this.actualItem.GetType())) + { + return new Vector2(0, 64f*(this.actualItem as MultiTiledObject).Height); + } + + return new Vector2(0, 64f); + } + + private Vector2 getItemNameOffset() + { + Vector2 length = Game1.dialogueFont.MeasureString(this.actualItem.DisplayName); + length.X = length.X / 4; + length.Y = 0; + return length; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs new file mode 100644 index 00000000..6ee24e09 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -0,0 +1,257 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Revitalize.Framework.Menus.MenuComponents; +using StardewValley; +using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; + +namespace Revitalize.Framework.Menus +{ + public class CraftingMenuV1 : IClickableMenuExtended + { + + /// + /// All the different pages for crafting. + /// + public Dictionary CraftingTabs; + + public Dictionary> craftingItemsToDisplay; + public IList fromInventory; + public IList toInventory; + + public int currentPageIndex; + public string currentTab; + public int currentScrollIndex; + + public Color backgroundColor; + + public int xOffset = 72; + + public string hoverText; + + /// + /// How many crafting recipes to display at a time. + /// + public int amountOfRecipesToShow = 4; + + public bool playerInventory; + + public CraftingInformationPage craftingInfo; + + public CraftingMenuV1() : base() + { + + } + + public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, IList Inventory) : base(X, Y, Width, Height, false) + { + this.backgroundColor = BackgroundColor; + this.CraftingTabs = new Dictionary(); + this.craftingItemsToDisplay = new Dictionary>(); + this.currentPageIndex = 0; + this.fromInventory = Inventory; + this.toInventory = Inventory; + this.playerInventory = true; + } + + public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList Inventory) : base(X, Y, Width, Height, false) + { + this.backgroundColor = BackgroundColor; + this.CraftingTabs = new Dictionary(); + this.craftingItemsToDisplay = new Dictionary>(); + this.currentPageIndex = 0; + this.fromInventory = Inventory; + this.toInventory = Inventory; + } + + public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList FromInventory, ref IList ToInventory) : base(X, Y, Width, Height, false) + { + this.backgroundColor = BackgroundColor; + this.CraftingTabs = new Dictionary(); + this.craftingItemsToDisplay = new Dictionary>(); + this.currentPageIndex = 0; + this.fromInventory = FromInventory; + this.toInventory = ToInventory; + } + + public void addInCraftingPageTab(string name, AnimatedButton Button) + { + int count = this.CraftingTabs.Count; + + if (this.CraftingTabs.ContainsKey(name)) + { + return; + } + else + { + Vector2 newPos = new Vector2(100 + (48) * (count + 1), 100 + (24 * 4) * (count + 1)); + Button.Position = newPos; + this.CraftingTabs.Add(name, Button); + this.craftingItemsToDisplay.Add(name, new List()); + } + + } + + public void addInCraftingRecipe(CraftingRecipeButton Button, string WhichTab) + { + if (this.craftingItemsToDisplay.ContainsKey(WhichTab)) + { + int count = this.craftingItemsToDisplay.Count; + Vector2 newPos = new Vector2(100 + (64) * (count + 1), 100 + (16 * 4) * (count + 1)); + Button.displayItem.Position = newPos; + this.craftingItemsToDisplay[WhichTab].Add(Button); + } + else + { + throw new Exception("Tab: " + WhichTab + " doesn't exist!"); + } + } + + public override void receiveScrollWheelAction(int direction) + { + + } + + public override void performHoverAction(int x, int y) + { + + bool hovered = false; + foreach (KeyValuePair pair in this.CraftingTabs) + { + if (pair.Value.containsPoint(x, y)) + { + this.hoverText = pair.Key; + hovered = true; + } + } + + //get range of buttons to show + + if (string.IsNullOrEmpty(this.currentTab) == false) + { + List buttonsToDraw = this.getRecipeButtonsToDisplay(); + foreach (CraftingRecipeButton button in buttonsToDraw) + { + if (button.containsPoint(x, y)) + { + this.hoverText = button.recipe.outputName; + hovered = true; + } + } + } + + + if (hovered == false) + { + this.hoverText = ""; + } + + } + + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + foreach (KeyValuePair pair in this.CraftingTabs) + { + if (pair.Value.containsPoint(x, y)) + { + this.currentTab = pair.Key; + return; + } + } + + //get range of buttons to show + + if (string.IsNullOrEmpty(this.currentTab) == false) + { + List buttonsToDraw = this.getRecipeButtonsToDisplay(); + foreach (CraftingRecipeButton button in buttonsToDraw) + { + if (button.containsPoint(x, y)) + { + //button.craftItem(this.fromInventory, this.toInventory); + this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, 400, this.backgroundColor, button,ref this.fromInventory); + Game1.soundBank.PlayCue("coin"); + if (this.playerInventory) + { + Game1.player.Items = this.toInventory; + return; + } + + } + } + } + + if (this.craftingInfo != null) + { + if (this.craftingInfo.doesMenuContainPoint(x, y)) return; + } + this.craftingInfo = null; + } + + + public override void draw(SpriteBatch b) + { + this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); + + foreach (KeyValuePair pair in this.CraftingTabs) + { + pair.Value.draw(b); + } + + if (string.IsNullOrEmpty(this.currentTab)) + { + if (string.IsNullOrEmpty(this.hoverText) == false) + { + IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont); + } + this.drawMouse(b); + return; + } + + List buttonsToDraw = this.getRecipeButtonsToDisplay(); + + foreach (CraftingRecipeButton button in buttonsToDraw) + { + if (button.recipe.CanCraft(this.fromInventory)) + { + button.draw(b); + } + else + { + button.draw(b, .25f); + } + + b.DrawString(Game1.smallFont, button.displayItem.item.DisplayName, button.displayItem.Position + new Vector2(64, 0), Color.Brown); + } + + if (this.craftingInfo != null) + { + this.craftingInfo.draw(b); + } + + if (string.IsNullOrEmpty(this.hoverText) == false) + { + IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont); + } + + this.drawMouse(b); + } + + public override void update(GameTime time) + { + base.update(time); + } + + public List getRecipeButtonsToDisplay() + { + List buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentScrollIndex, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow)); + return buttonsToDraw; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs similarity index 98% rename from GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs rename to GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs index 405fef98..0214a6d8 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryMenuPage.cs @@ -15,6 +15,9 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { + /// + /// Deals with displaying the internal contents of an inventory. Used mainly as a component for another menu that extends this functionality. + /// public class InventoryMenuPage { diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs index 8367489f..a3edbeda 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs @@ -13,6 +13,9 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { + /// + /// Used with transfering items between two inventories. + /// public class InventoryTransferMenu : IClickableMenuExtended { public InventoryMenu playerInventory; diff --git a/GeneralMods/Revitalize/Framework/Menus/MenuComponents/CraftingRecipeButton.cs b/GeneralMods/Revitalize/Framework/Menus/MenuComponents/CraftingRecipeButton.cs new file mode 100644 index 00000000..c7e8b161 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/MenuComponents/CraftingRecipeButton.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Revitalize.Framework.Crafting; +using StardewValley; +using StardustCore.Animations; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; + +namespace Revitalize.Framework.Menus.MenuComponents +{ + public class CraftingRecipeButton + { + public Recipe recipe; + public ItemDisplayButton displayItem; + + + public CraftingRecipeButton(Recipe RecipeToCraft, StardustCore.Animations.AnimatedSprite Background,Vector2 Position,Rectangle BoundingBox,float Scale, bool DrawStackNumber, Color DrawColor) + { + this.recipe = RecipeToCraft; + this.displayItem = new ItemDisplayButton(this.recipe.DisplayItem, Background, Position, BoundingBox, Scale, DrawStackNumber, DrawColor); + } + + + /// + /// Draws the component to the screen. + /// + /// + public void draw(SpriteBatch B) + { + this.displayItem.draw(B, 0.25f, 1f, false); + } + + public void draw(SpriteBatch B,Vector2 Position) + { + this.displayItem.draw(B,Position,0.25f, 1f, false); + } + + /// + /// Draw the display item with the given alpha + /// + /// + /// + public void draw(SpriteBatch B,float Alpha=1f) + { + this.displayItem.draw(B, 0.25f, Alpha, false); + } + + public bool containsPoint(int x, int y) + { + return this.displayItem.Contains(x, y); + } + + public void craftItem() + { + this.recipe.craft(); + } + + public void craftItem(IList fromInventory, IList toInventory) + { + this.recipe.craft(ref fromInventory, ref toInventory, false, false); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs new file mode 100644 index 00000000..02c5cf55 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/Machines/Machine.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Objects.Machines +{ + public class Machine + { + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs b/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs index 82b2e99d..5ef2f1d7 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/ObjectUtilities.cs @@ -28,5 +28,21 @@ namespace Revitalize.Framework.Utilities else return false; } + public static bool IsSameOrSubclass(Type potentialBase, Type potentialDescendant) + { + return potentialDescendant.IsSubclassOf(potentialBase) + || potentialDescendant == potentialBase; + } + + public static bool IsSameType(Type potentialBase, Type potentialDescendant) + { + return potentialDescendant == potentialBase; + } + + public static bool IsSubclass(Type potentialBase, Type potentialDescendant) + { + return potentialDescendant.IsSubclassOf(potentialBase); + } + } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index f5666cb0..137c38f0 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -26,6 +26,8 @@ using Revitalize.Framework.Hacks; using Revitalize.Framework.Configs; using StardewValley.Locations; using System.Linq; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; +using Revitalize.Framework.Menus; namespace Revitalize { @@ -294,6 +296,8 @@ namespace Revitalize TextureManager.GetTextureManager(Manifest, "Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Resources", "Ore")); TextureManager.AddTextureManager(Manifest, "Items.Resources.Ore"); TextureManager.GetTextureManager(Manifest, "Items.Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Items", "Resources", "Ore")); + TextureManager.AddTextureManager(Manifest, "Menus"); + TextureManager.GetTextureManager(Manifest, "Menus").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "Misc")); } private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) @@ -316,6 +320,22 @@ namespace Revitalize Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500, newItems, 36); } */ + + if (e.Button == SButton.U) + { + + CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 600, Color.White, Game1.player.Items); + menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f)); + + menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(new Recipe(new Dictionary() + { + //Inputs here + {new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 } + }, new KeyValuePair(new StardewValley.Object((int)Enums.SDVObject.Coal, 1), 1)), null, new Vector2(), new Rectangle(0,0,16,16), 4f, true, Color.White),"Default"); + menu.currentTab = "Default"; + + if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu; + } } private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e) diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index f610310d..ca418ef2 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -56,6 +56,7 @@ + @@ -76,8 +77,11 @@ - + + + + @@ -134,6 +138,7 @@ + @@ -243,6 +248,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -383,6 +394,7 @@ + diff --git a/GeneralMods/StardustCore/Animations/AnimatedSprite.cs b/GeneralMods/StardustCore/Animations/AnimatedSprite.cs index b8406802..33920309 100644 --- a/GeneralMods/StardustCore/Animations/AnimatedSprite.cs +++ b/GeneralMods/StardustCore/Animations/AnimatedSprite.cs @@ -72,6 +72,23 @@ namespace StardustCore.Animations this.draw(b, 1f, 0f,Alpha); } + /// + /// Draws the sprite to the screen. + /// + /// + /// + /// + /// + public virtual void draw(SpriteBatch b,Vector2 Position,float Scale ,float Alpha = 1f) + { + this.draw(b, Position, Scale,0f,Alpha); + } + + public virtual void draw(SpriteBatch b,float Scale ,float Alpha = 1f) + { + this.draw(b, Scale, 0f, Alpha); + } + /// /// Draws the sprite to the screen. /// diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs index 70fe129a..a86159c7 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs @@ -95,7 +95,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// public void draw(SpriteBatch b,float Alpha=1f) { - this.sprite.draw(b,Alpha); + this.sprite.draw(b,this.scale,Alpha); } /// diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs index 87d38efd..32fd685c 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs @@ -111,6 +111,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons this.draw(b, 1f, Alpha, false); } + /// /// The full draw function for drawing this component to the screen. /// @@ -120,10 +121,43 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// public void draw(SpriteBatch b,float Depth, float Alpha,bool DrawShadow) { - this.background.draw(b, this.scale, Depth,Alpha); + if(this.background!=null)this.background.draw(b, this.scale, Depth,Alpha); if(this.item!=null)this.item.drawInMenu(b, this.position, 1f,Alpha,Depth,this.drawStackNumber,this.drawColor,DrawShadow); } + /// + /// Draws the component at the given position. + /// + /// + /// + /// + /// + /// + public void draw(SpriteBatch b,Vector2 Position ,float Depth, float Alpha, bool DrawShadow) + { + if (this.background != null) this.background.draw(b,Position,this.scale, Depth, Alpha); + if (this.item != null) this.item.drawInMenu(b, Position, 1f, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); + } + + public void draw(SpriteBatch b,float ItemScale ,float Depth, float Alpha, bool DrawShadow) + { + this.background.draw(b, this.scale, Depth, Alpha); + if (this.item != null) this.item.drawInMenu(b, this.position, ItemScale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); + } + + /// + /// Draws just the item to the screen. + /// + /// + /// The scale for the item. + /// The spritebatch depth to draw the item. + /// The alpha for the item. + /// Should the shadow be drawn for the item? + public void drawJustItem(SpriteBatch b,float Scale,float Depth, float Alpha, bool DrawShadow) + { + if (this.item != null) this.item.drawInMenu(b, this.position, Scale, Alpha, Depth, this.drawStackNumber, this.drawColor, DrawShadow); + } + public bool receiveLeftClick(int x, int y) { return this.boundingBox.Contains(new Point(x, y)); diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.cs b/GeneralMods/Vocalization/Vocalization/Vocalization.cs index ce8d2ec0..581e85b2 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.cs +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.cs @@ -264,7 +264,7 @@ namespace Vocalization { if (e.Button.ToString() == config.menuHotkey) { - Game1.activeClickableMenu = new VocalizationMenu(100, 64, 600, 300, true); + if(Game1.activeClickableMenu==null) Game1.activeClickableMenu = new VocalizationMenu(100, 64, 600, 300, true); } }