Started work on crafting menu. Still need to display all required items, a description, and a craft button.

This commit is contained in:
JoshuaNavarro 2019-09-02 19:02:58 -07:00
parent 70edc9acf0
commit bd03736e65
18 changed files with 556 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

View File

@ -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
{
}
}

View File

@ -174,7 +174,7 @@ namespace Revitalize.Framework.Crafting
/// <param name="to">The inventory to put outputs into.</param> /// <param name="to">The inventory to put outputs into.</param>
/// <param name="dropToGround">Should this item be dropped to the ground when crafted?</param> /// <param name="dropToGround">Should this item be dropped to the ground when crafted?</param>
/// <param name="isPlayerInventory">Checks to see if the invventory is the player's</param> /// <param name="isPlayerInventory">Checks to see if the invventory is the player's</param>
private void craft(ref IList<Item> from, ref IList<Item> to, bool dropToGround = false, bool isPlayerInventory = false) public void craft(ref IList<Item> from, ref IList<Item> to, bool dropToGround = false, bool isPlayerInventory = false)
{ {
InventoryManager manager = new InventoryManager(to); InventoryManager manager = new InventoryManager(to);
if (manager.ItemCount + this.outputs.Count >= manager.capacity) if (manager.ItemCount + this.outputs.Count >= manager.capacity)
@ -207,7 +207,7 @@ namespace Revitalize.Framework.Crafting
return this.PlayerContainsAllIngredients() && this.statCost.canSafelyAffordCost(); return this.PlayerContainsAllIngredients() && this.statCost.canSafelyAffordCost();
} }
public bool CanCraft(List<Item> items) public bool CanCraft(IList<Item> items)
{ {
return this.InventoryContainsAllIngredient(items); return this.InventoryContainsAllIngredient(items);
} }

View File

@ -9,7 +9,7 @@ using StardewValley;
namespace Revitalize.Framework.Crafting namespace Revitalize.Framework.Crafting
{ {
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
public class VanillaRecipe public class VanillaRecipe
{ {

View File

@ -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<Item> 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<Item> 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;
}
}
}

View File

@ -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
{
/// <summary>
/// All the different pages for crafting.
/// </summary>
public Dictionary<string, AnimatedButton> CraftingTabs;
public Dictionary<string, List<CraftingRecipeButton>> craftingItemsToDisplay;
public IList<Item> fromInventory;
public IList<Item> toInventory;
public int currentPageIndex;
public string currentTab;
public int currentScrollIndex;
public Color backgroundColor;
public int xOffset = 72;
public string hoverText;
/// <summary>
/// How many crafting recipes to display at a time.
/// </summary>
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<Item> Inventory) : base(X, Y, Width, Height, false)
{
this.backgroundColor = BackgroundColor;
this.CraftingTabs = new Dictionary<string, AnimatedButton>();
this.craftingItemsToDisplay = new Dictionary<string, List<CraftingRecipeButton>>();
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<Item> Inventory) : base(X, Y, Width, Height, false)
{
this.backgroundColor = BackgroundColor;
this.CraftingTabs = new Dictionary<string, AnimatedButton>();
this.craftingItemsToDisplay = new Dictionary<string, List<CraftingRecipeButton>>();
this.currentPageIndex = 0;
this.fromInventory = Inventory;
this.toInventory = Inventory;
}
public CraftingMenuV1(int X, int Y, int Width, int Height, Color BackgroundColor, ref IList<Item> FromInventory, ref IList<Item> ToInventory) : base(X, Y, Width, Height, false)
{
this.backgroundColor = BackgroundColor;
this.CraftingTabs = new Dictionary<string, AnimatedButton>();
this.craftingItemsToDisplay = new Dictionary<string, List<CraftingRecipeButton>>();
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<CraftingRecipeButton>());
}
}
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<string, AnimatedButton> 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<CraftingRecipeButton> 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<string, AnimatedButton> 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<CraftingRecipeButton> 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<string, AnimatedButton> 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<CraftingRecipeButton> 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<CraftingRecipeButton> getRecipeButtonsToDisplay()
{
List<CraftingRecipeButton> buttonsToDraw = this.craftingItemsToDisplay[this.currentTab].GetRange(this.currentScrollIndex, Math.Min(this.craftingItemsToDisplay[this.currentTab].Count, this.amountOfRecipesToShow));
return buttonsToDraw;
}
}
}

View File

@ -15,6 +15,9 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
namespace Revitalize.Framework.Menus namespace Revitalize.Framework.Menus
{ {
/// <summary>
/// Deals with displaying the internal contents of an inventory. Used mainly as a component for another menu that extends this functionality.
/// </summary>
public class InventoryMenuPage public class InventoryMenuPage
{ {

View File

@ -13,6 +13,9 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
namespace Revitalize.Framework.Menus namespace Revitalize.Framework.Menus
{ {
/// <summary>
/// Used with transfering items between two inventories.
/// </summary>
public class InventoryTransferMenu : IClickableMenuExtended public class InventoryTransferMenu : IClickableMenuExtended
{ {
public InventoryMenu playerInventory; public InventoryMenu playerInventory;

View File

@ -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);
}
/// <summary>
/// Draws the component to the screen.
/// </summary>
/// <param name="B"></param>
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);
}
/// <summary>
/// Draw the display item with the given alpha
/// </summary>
/// <param name="B"></param>
/// <param name="Alpha"></param>
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<Item> fromInventory, IList<Item> toInventory)
{
this.recipe.craft(ref fromInventory, ref toInventory, false, false);
}
}
}

View File

@ -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
{
}
}

View File

@ -28,5 +28,21 @@ namespace Revitalize.Framework.Utilities
else return false; 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);
}
} }
} }

View File

@ -26,6 +26,8 @@ using Revitalize.Framework.Hacks;
using Revitalize.Framework.Configs; using Revitalize.Framework.Configs;
using StardewValley.Locations; using StardewValley.Locations;
using System.Linq; using System.Linq;
using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
using Revitalize.Framework.Menus;
namespace Revitalize 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.GetTextureManager(Manifest, "Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Resources", "Ore"));
TextureManager.AddTextureManager(Manifest, "Items.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.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) 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); 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<Item, int>()
{
//Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }
}, new KeyValuePair<Item, int>(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) private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e)

View File

@ -56,6 +56,7 @@
<Compile Include="Framework\Configs\FurnitureConfig.cs" /> <Compile Include="Framework\Configs\FurnitureConfig.cs" />
<Compile Include="Framework\Configs\Shops_BlacksmithConfig.cs" /> <Compile Include="Framework\Configs\Shops_BlacksmithConfig.cs" />
<Compile Include="Framework\Configs\VanillaMachineRecipeConfig.cs" /> <Compile Include="Framework\Configs\VanillaMachineRecipeConfig.cs" />
<Compile Include="Framework\Crafting\MachineCraftingRecipe.cs" />
<Compile Include="Framework\Crafting\Recipe.cs" /> <Compile Include="Framework\Crafting\Recipe.cs" />
<Compile Include="Framework\Crafting\RecipeBook.cs" /> <Compile Include="Framework\Crafting\RecipeBook.cs" />
<Compile Include="Framework\Crafting\StatCost.cs" /> <Compile Include="Framework\Crafting\StatCost.cs" />
@ -76,8 +77,11 @@
<Compile Include="Framework\Illuminate\ColorExtensions.cs" /> <Compile Include="Framework\Illuminate\ColorExtensions.cs" />
<Compile Include="Framework\Illuminate\FakeLightSource.cs" /> <Compile Include="Framework\Illuminate\FakeLightSource.cs" />
<Compile Include="Framework\Illuminate\LightManager.cs" /> <Compile Include="Framework\Illuminate\LightManager.cs" />
<Compile Include="Framework\Menus\InventoryMenu.cs" /> <Compile Include="Framework\Menus\CraftingInformationPage.cs" />
<Compile Include="Framework\Menus\CraftingMenuV1.cs" />
<Compile Include="Framework\Menus\InventoryMenuPage.cs" />
<Compile Include="Framework\Menus\InventoryTransferMenu.cs" /> <Compile Include="Framework\Menus\InventoryTransferMenu.cs" />
<Compile Include="Framework\Menus\MenuComponents\CraftingRecipeButton.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ICollider.cs" /> <Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ICollider.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISpawner.cs" /> <Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISpawner.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISSCLivingEntity.cs" /> <Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISSCLivingEntity.cs" />
@ -134,6 +138,7 @@
<Compile Include="Framework\Objects\InformationFiles\Furniture\TableInformation.cs" /> <Compile Include="Framework\Objects\InformationFiles\Furniture\TableInformation.cs" />
<Compile Include="Framework\Objects\InformationFiles\ResourceInformaton.cs" /> <Compile Include="Framework\Objects\InformationFiles\ResourceInformaton.cs" />
<Compile Include="Framework\Objects\Items\Resources\Ore.cs" /> <Compile Include="Framework\Objects\Items\Resources\Ore.cs" />
<Compile Include="Framework\Objects\Machines\Machine.cs" />
<Compile Include="Framework\Objects\MultiTiledComponent.cs" /> <Compile Include="Framework\Objects\MultiTiledComponent.cs" />
<Compile Include="Framework\Objects\MultiTiledObject.cs" /> <Compile Include="Framework\Objects\MultiTiledObject.cs" />
<Compile Include="Framework\Objects\ObjectManager.cs" /> <Compile Include="Framework\Objects\ObjectManager.cs" />
@ -243,6 +248,12 @@
<Content Include="Content\Graphics\Menus\InventoryMenu\TrashButton.png"> <Content Include="Content\Graphics\Menus\InventoryMenu\TrashButton.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Graphics\Menus\Misc\MenuTab.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\Misc\MenuTabHorizontal.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Objects\Furniture\Arcade\SeasideScrambleArcade.png"> <Content Include="Content\Graphics\Objects\Furniture\Arcade\SeasideScrambleArcade.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -383,6 +394,7 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Content\Graphics\Menus\CraftingMenu\" />
<Folder Include="Framework\Objects\InformationFiles\Extras\" /> <Folder Include="Framework\Objects\InformationFiles\Extras\" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -72,6 +72,23 @@ namespace StardustCore.Animations
this.draw(b, 1f, 0f,Alpha); this.draw(b, 1f, 0f,Alpha);
} }
/// <summary>
/// Draws the sprite to the screen.
/// </summary>
/// <param name="b"></param>
/// <param name="Position"></param>
/// <param name="Scale"></param>
/// <param name="Alpha"></param>
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);
}
/// <summary> /// <summary>
/// Draws the sprite to the screen. /// Draws the sprite to the screen.
/// </summary> /// </summary>

View File

@ -95,7 +95,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
/// <param name="b"></param> /// <param name="b"></param>
public void draw(SpriteBatch b,float Alpha=1f) public void draw(SpriteBatch b,float Alpha=1f)
{ {
this.sprite.draw(b,Alpha); this.sprite.draw(b,this.scale,Alpha);
} }
/// <summary> /// <summary>

View File

@ -111,6 +111,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
this.draw(b, 1f, Alpha, false); this.draw(b, 1f, Alpha, false);
} }
/// <summary> /// <summary>
/// The full draw function for drawing this component to the screen. /// The full draw function for drawing this component to the screen.
/// </summary> /// </summary>
@ -120,10 +121,43 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
/// <param name="DrawShadow"></param> /// <param name="DrawShadow"></param>
public void draw(SpriteBatch b,float Depth, float Alpha,bool DrawShadow) 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); if(this.item!=null)this.item.drawInMenu(b, this.position, 1f,Alpha,Depth,this.drawStackNumber,this.drawColor,DrawShadow);
} }
/// <summary>
/// Draws the component at the given position.
/// </summary>
/// <param name="b"></param>
/// <param name="Position"></param>
/// <param name="Depth"></param>
/// <param name="Alpha"></param>
/// <param name="DrawShadow"></param>
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);
}
/// <summary>
/// Draws just the item to the screen.
/// </summary>
/// <param name="b"></param>
/// <param name="Scale">The scale for the item.</param>
/// <param name="Depth">The spritebatch depth to draw the item.</param>
/// <param name="Alpha">The alpha for the item.</param>
/// <param name="DrawShadow">Should the shadow be drawn for the item?</param>
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) public bool receiveLeftClick(int x, int y)
{ {
return this.boundingBox.Contains(new Point(x, y)); return this.boundingBox.Contains(new Point(x, y));

View File

@ -264,7 +264,7 @@ namespace Vocalization
{ {
if (e.Button.ToString() == config.menuHotkey) 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);
} }
} }