The crafting menu works but needs some polish.

This commit is contained in:
JoshuaNavarro 2019-09-02 20:48:29 -07:00
parent 5f48f54079
commit 85592f1b53
5 changed files with 41 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

View File

@ -15,7 +15,7 @@ using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
namespace Revitalize.Framework.Menus
{
/// <summary>
/// Need to display description, required items, and a craft button. Also need to make the menu longer.
/// Need to display a craft button.
/// Also need to make the crafting menu scroll better.
/// </summary>
public class CraftingInformationPage:IClickableMenuExtended
@ -30,6 +30,8 @@ namespace Revitalize.Framework.Menus
private Dictionary<ItemDisplayButton,int> requiredItems;
public AnimatedButton craftingButton;
public Item actualItem
{
get
@ -56,6 +58,19 @@ namespace Revitalize.Framework.Menus
ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).Key, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White);
this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).Value);
}
this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f);
}
public override void receiveLeftClick(int x, int y, bool playSound = true)
{
if (this.craftingButton.containsPoint(x, y))
{
if (this.canCraftRecipe())
{
Game1.soundBank.PlayCue("coin");
this.infoButton.craftItem();
}
}
}
public override void draw(SpriteBatch b)
@ -73,6 +88,8 @@ namespace Revitalize.Framework.Menus
b.DrawString(Game1.smallFont, button.Key.item.DisplayName+ " x "+button.Value.ToString(), button.Key.Position + new Vector2(64, 16), this.getNameColor(button.Key.item, button.Value));
}
this.craftingButton.draw(b, this.getCraftableColor().A);
this.drawMouse(b);
}
@ -87,6 +104,16 @@ namespace Revitalize.Framework.Menus
return this.infoButton.recipe.CanCraft(this.inventory);
}
/// <summary>
/// Gets the color for the crafting button.
/// </summary>
/// <returns></returns>
private Color getCraftableColor()
{
if (this.canCraftRecipe()) return Color.White;
else return new Color(1f, 1f, 1f, 0.25f);
}
public Color getNameColor()
{
if (this.canCraftRecipe()) return Color.Black;
@ -144,5 +171,10 @@ namespace Revitalize.Framework.Menus
return this.getItemDescriptionOffset()+offset+ new Vector2(0,64*(this.requiredItems.Count));
}
private float getCraftingButtonHeight()
{
return this.yPositionOnScreen + this.height - 64*2;
}
}
}

View File

@ -188,6 +188,7 @@ namespace Revitalize.Framework.Menus
if (this.craftingInfo != null)
{
this.craftingInfo.receiveLeftClick(x, y);
if (this.craftingInfo.doesMenuContainPoint(x, y)) return;
}
this.craftingInfo = null;

View File

@ -298,6 +298,8 @@ namespace Revitalize
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"));
TextureManager.AddTextureManager(Manifest, "CraftingMenu");
TextureManager.GetTextureManager(Manifest, "CraftingMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "CraftingMenu"));
}
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e)
@ -331,8 +333,7 @@ namespace Revitalize
{
//Inputs here
{new StardewValley.Object((int)Enums.SDVObject.Coal,1),1 },
{new StardewValley.Object((int)Enums.SDVObject.PrismaticShard,1),3 },
}, 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");
}, new KeyValuePair<Item, int>(new StardewValley.Object((int)Enums.SDVObject.PrismaticShard, 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;
@ -468,7 +469,7 @@ namespace Revitalize
axe =(StardewValley.Tools.Axe)Serializer.Deserialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"),typeof(StardewValley.Tools.Axe));
//Game1.player.addItemToInventory(axe);
*/
Game1.player.addItemToInventory(new StardewValley.Object((int)Enums.SDVObject.Coal, 1));
}
/*

View File

@ -230,6 +230,9 @@
<Content Include="Content\Graphics\Items\Resources\Ore\TitaniumOre.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\CraftingMenu\CraftButton.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\InventoryMenu\ItemBackground.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
@ -394,7 +397,6 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Content\Graphics\Menus\CraftingMenu\" />
<Folder Include="Framework\Objects\InformationFiles\Extras\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />