diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs index 25f94d80..518ab9e4 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingInformationPage.cs @@ -10,9 +10,14 @@ using Revitalize.Framework.Objects; using Revitalize.Framework.Utilities; using StardewValley; using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; namespace Revitalize.Framework.Menus { + /// + /// Need to display description, required items, and a craft button. Also need to make the menu longer. + /// Also need to make the crafting menu scroll better. + /// public class CraftingInformationPage:IClickableMenuExtended { @@ -23,6 +28,8 @@ namespace Revitalize.Framework.Menus public IList inventory; + private Dictionary requiredItems; + public Item actualItem { get @@ -42,6 +49,13 @@ namespace Revitalize.Framework.Menus this.infoButton = ItemToDisplay; this.itemDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width / 2) - 32, this.yPositionOnScreen + (128)); this.inventory = Inventory; + + this.requiredItems = new Dictionary(); + for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++) + { + 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); + } } public override void draw(SpriteBatch b) @@ -51,6 +65,14 @@ namespace Revitalize.Framework.Menus b.DrawString(Game1.dialogueFont, this.actualItem.DisplayName, this.itemDisplayLocation + this.getHeightOffsetFromItem()-this.getItemNameOffset(), this.getNameColor()); + b.DrawString(Game1.smallFont, Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width),new Vector2(this.xPositionOnScreen+64,this.getItemDescriptionOffset().Y), Color.Black); + + foreach(KeyValuePair button in this.requiredItems) + { + button.Key.draw(b); + 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.drawMouse(b); } @@ -71,6 +93,20 @@ namespace Revitalize.Framework.Menus else return Color.Red; } + public Color getNameColor(Item I, int amount) + { + KeyValuePair Pair = new KeyValuePair(I, amount); + if (this.infoButton.recipe.InventoryContainsIngredient(this.inventory, Pair)) + { + return Color.Black; + } + else + { + return Color.Red; + } + + } + private Vector2 getHeightOffsetFromItem() { if (ObjectUtilities.IsSameType(typeof(StardewValley.Object), this.actualItem.GetType())){ @@ -92,5 +128,21 @@ namespace Revitalize.Framework.Menus return length; } + private Vector2 getItemDescriptionOffset() + { + return this.getHeightOffsetFromItem()+new Vector2(0,64)+new Vector2(0,this.itemDisplayLocation.Y); + } + + /// + /// Gets the height position for where to draw a required ingredient. + /// + /// + private Vector2 getIngredientHeightOffset() + { + string parsedDescription = Game1.parseText(this.actualItem.getDescription(), Game1.smallFont, this.width); + Vector2 offset=Game1.smallFont.MeasureString(parsedDescription); + return this.getItemDescriptionOffset()+offset+ new Vector2(0,64*(this.requiredItems.Count)); + } + } } diff --git a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs index 6ee24e09..0ce44829 100644 --- a/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs +++ b/GeneralMods/Revitalize/Framework/Menus/CraftingMenuV1.cs @@ -174,7 +174,7 @@ namespace Revitalize.Framework.Menus 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); + this.craftingInfo = new CraftingInformationPage(this.xPositionOnScreen + this.width+this.xOffset, this.yPositionOnScreen, 400, this.height, this.backgroundColor, button,ref this.fromInventory); Game1.soundBank.PlayCue("coin"); if (this.playerInventory) { @@ -197,7 +197,7 @@ namespace Revitalize.Framework.Menus public override void draw(SpriteBatch b) { this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor); - + //this.drawDialogueBoxBackground(); foreach (KeyValuePair pair in this.CraftingTabs) { pair.Value.draw(b); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 137c38f0..6934253b 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -324,13 +324,14 @@ namespace Revitalize if (e.Button == SButton.U) { - CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 600, Color.White, Game1.player.Items); + CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 0, 400, 800, 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 StardewValley.Object((int)Enums.SDVObject.Coal,1),1 }, + {new StardewValley.Object((int)Enums.SDVObject.PrismaticShard,1),3 }, }, 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";