diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/ItemBackgroundNoSpacing.png b/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/ItemBackgroundNoSpacing.png new file mode 100644 index 00000000..e4ab4358 Binary files /dev/null and b/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/ItemBackgroundNoSpacing.png differ diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/ItemTransferButton.png b/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/ItemTransferButton.png new file mode 100644 index 00000000..03d1a534 Binary files /dev/null and b/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/ItemTransferButton.png differ diff --git a/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/TrashButton.png b/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/TrashButton.png new file mode 100644 index 00000000..871af725 Binary files /dev/null and b/GeneralMods/Revitalize/Content/Graphics/Menus/InventoryMenu/TrashButton.png differ diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs index cb82c390..405fef98 100644 --- a/GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryMenu.cs @@ -63,6 +63,16 @@ namespace Revitalize.Framework.Menus public string hoverTitle; public Item displayItem; + /// + /// Checks if the given inventory is full or not. + /// + public bool isFull + { + get + { + return this.items.Count >= this.capacity && this.items.Where(i=>i==null).Count()==0; + } + } public InventoryMenu(int xPos, int yPos, int width, int height, int Rows, int Collumns, bool showCloseButton, IList Inventory, int maxCapacity,Color BackgroundColor) : base(xPos, yPos, width, height, showCloseButton) { @@ -106,6 +116,11 @@ namespace Revitalize.Framework.Menus this.previousPage.Position= new Vector2(64 + (this.searchBox.X + this.searchBox.Width),this.searchBox.Y); } + public void populateClickableItems() + { + this.populateClickableItems(this.rows, this.collumns, this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen + this.yOffset); + } + /// /// Populates the menu with all of the items on display. /// @@ -116,17 +131,15 @@ namespace Revitalize.Framework.Menus public void populateClickableItems(int rows, int collums, int xPosition, int yPosition) { this.pages.Clear(); - - int size = this.capacity; - ModCore.log("Hello World! SIZE IS: " + size); + //ModCore.log("Hello World! SIZE IS: " + size); int maxPages = ((size) / (this.rows * this.collumns)) + 1; for (int i = 0; i < maxPages; i++) { int amount = Math.Min(rows * collums, size); this.pages.Add(i, new InventoryMenuPage(i, new List(), amount)); - ModCore.log("Added in a new page with size: " + size); + //ModCore.log("Added in a new page with size: " + size); size -= amount; for (int y = 0; y < collums; y++) { @@ -135,33 +148,28 @@ namespace Revitalize.Framework.Menus int index = ((y * rows) + x) + (rows * collums * i); if (index >= this.pages[i].amountToDisplay + (rows * collums * i)) { - ModCore.log("Break page creation."); - ModCore.log("Index is: " + index); - ModCore.log("Max display is: " + this.pages[i].amountToDisplay); + //ModCore.log("Break page creation."); + //ModCore.log("Index is: " + index); + //ModCore.log("Max display is: " + this.pages[i].amountToDisplay); break; } if (index > this.items.Count) { - ModCore.log("Index greater than items!"); Vector2 pos2 = new Vector2(x * 64 + xPosition, y * 64 + yPosition); - ItemDisplayButton b2 = new ItemDisplayButton(null, new StardustCore.Animations.AnimatedSprite("ItemBackground", pos2, new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "ItemBackground"), new Animation(0, 0, 32, 32)), Color.White), pos2, new Rectangle(0, 0, 32 * 2, 32 * 2), 2f, true, Color.White); + ItemDisplayButton b2 = new ItemDisplayButton(null, new StardustCore.Animations.AnimatedSprite("ItemBackground", pos2, new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "ItemBackground"), new Animation(0, 0, 32, 32)), Color.White), pos2, new Rectangle(0, 0, 32, 32), 2f, true, Color.White); this.pages[i].storageDisplay.Add(b2); continue; } - ModCore.log("Add in a new display item"); Item item = this.getItemFromList(index); Vector2 pos = new Vector2(x * 64 + xPosition, y * 64 + yPosition); - ItemDisplayButton b = new ItemDisplayButton(item, new StardustCore.Animations.AnimatedSprite("ItemBackground", pos, new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "ItemBackground"), new Animation(0, 0, 32, 32)), Color.White), pos, new Rectangle(0, 0, 32 * 2, 32 * 2), 2f, true, Color.White); + ItemDisplayButton b = new ItemDisplayButton(item, new StardustCore.Animations.AnimatedSprite("ItemBackground", pos, new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "ItemBackground"), new Animation(0, 0, 32, 32)), Color.White), pos, new Rectangle(0, 0, 32, 32), 2f, true, Color.White); this.pages[i].storageDisplay.Add(b); } } } - - - } /// @@ -176,6 +184,11 @@ namespace Revitalize.Framework.Menus else return this.items.ElementAt(index); } + /// + /// What happens when this menu is hover overed. + /// + /// + /// public override void performHoverAction(int x, int y) { bool hovered = false; @@ -231,7 +244,7 @@ namespace Revitalize.Framework.Menus this.activeItem = button.item; if (this.activeItem != null) { - ModCore.log("Got item: " + this.activeItem.DisplayName); + //ModCore.log("Got item: " + this.activeItem.DisplayName); } return; } @@ -239,7 +252,7 @@ namespace Revitalize.Framework.Menus { if (button.item == null) { - ModCore.log("Placed item: " + this.activeItem.DisplayName); + //ModCore.log("Placed item: " + this.activeItem.DisplayName); swap = this.activeItem; this.activeItem = null; break; @@ -247,7 +260,7 @@ namespace Revitalize.Framework.Menus else { swap = button.item; - ModCore.log("Swap item: " + swap.DisplayName); + //ModCore.log("Swap item: " + swap.DisplayName); break; } } @@ -279,7 +292,7 @@ namespace Revitalize.Framework.Menus if (this.nextPage.containsPoint(x, y)) { - ModCore.log("Left click next page"); + //ModCore.log("Left click next page"); if (this.pageIndex + 1 < this.pages.Count) { this.pageIndex++; @@ -288,7 +301,7 @@ namespace Revitalize.Framework.Menus } if (this.previousPage.containsPoint(x, y)) { - ModCore.log("Left click previous page"); + //ModCore.log("Left click previous page"); if (this.pageIndex > 0) { this.pageIndex--; @@ -306,7 +319,7 @@ namespace Revitalize.Framework.Menus { if (I == null) { - ModCore.log("Odd item is null"); + //ModCore.log("Odd item is null"); return; } if (insertIndex + 1 > this.items.Count) @@ -376,27 +389,32 @@ namespace Revitalize.Framework.Menus this.searchBox.Draw(b, true); - this.nextPage.draw(b,0.25f); - this.previousPage.draw(b,0.25f); + this.nextPage.draw(b,0.25f,1f); + this.previousPage.draw(b,0.25f,1f); b.DrawString(Game1.dialogueFont, ("Page: " + (this.pageIndex + 1) + " / " + this.pages.Count).ToString(), new Vector2(this.xPositionOnScreen, this.yPositionOnScreen + this.height), Color.White); this.drawMouse(b); - if (this.displayItem != null) IClickableMenu.drawToolTip(b, this.hoverText, this.hoverTitle, this.displayItem, false, -1, 0, -1, -1, (CraftingRecipe)null, -1); + this.drawToolTip(b); //base.draw(b); } + public void drawToolTip(SpriteBatch b) + { + if (this.displayItem != null) IClickableMenu.drawToolTip(b, this.hoverText, this.hoverTitle, this.displayItem, false, -1, 0, -1, -1, (CraftingRecipe)null, -1); + } + /// /// Draws the item as a transparent icon if the item is not part of the seach patern. /// /// /// private float getItemDrawAlpha(Item I) - { - if (I == null) return 1f; + { if (string.IsNullOrEmpty(this.searchBox.Text) == false) { + if (I == null) return 0.25f; return I.DisplayName.ToLowerInvariant().Contains(this.searchBox.Text.ToLowerInvariant()) ? 1f : 0.25f; } else diff --git a/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs new file mode 100644 index 00000000..8367489f --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Menus/InventoryTransferMenu.cs @@ -0,0 +1,443 @@ +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 StardewValley; +using StardewValley.Menus; +using StardustCore.Animations; +using StardustCore.UIUtilities; +using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; + +namespace Revitalize.Framework.Menus +{ + public class InventoryTransferMenu : IClickableMenuExtended + { + public InventoryMenu playerInventory; + public InventoryMenu otherInventory; + private IList otherItems; + private bool isPlayerInventory; + public AnimatedButton transferButton; + public AnimatedButton trashButton; + public string hoverText; + + public ItemDisplayButton trashedItem; + private bool displayTrashedItem; + + private enum CurrentMode + { + TransferItems, + TrashItem + } + private CurrentMode currentMode; + + public InventoryTransferMenu(int x, int y, int width, int height, IList OtherItems, int OtherCapacity) : base(x, y, width, height, true) + { + this.playerInventory = new InventoryMenu(x, y, width, height, 6, 6, true, Game1.player.Items, Game1.player.MaxItems, Color.SandyBrown); + this.otherItems = OtherItems; + this.otherInventory = new InventoryMenu(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 128, y, width, height, 6, 6, true, this.otherItems, OtherCapacity, Color.SandyBrown); + this.isPlayerInventory = true; + this.currentMode = CurrentMode.TransferItems; + this.transferButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Transfer Button", new Vector2(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 64, this.playerInventory.yPositionOnScreen + (this.playerInventory.height * .3f)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "ItemTransferButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); + this.trashButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Trash Button", new Vector2(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 64, this.playerInventory.yPositionOnScreen + (this.playerInventory.height * .3f) + 96), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "TrashButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); + this.trashedItem = new ItemDisplayButton(null, new StardustCore.Animations.AnimatedSprite("ItemBackground", new Vector2(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 64, this.playerInventory.yPositionOnScreen + (this.playerInventory.height * .3f) + 180), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "ItemBackground"), new Animation(0, 0, 32, 32)), Color.White), new Vector2(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 64, this.playerInventory.yPositionOnScreen + (this.playerInventory.height * .3f) + 180), new Rectangle(0, 0, 32, 32), 2f, true, Color.White); + } + + + /// + /// Handles what happens when the menu is left clicked. + /// + /// + /// + /// + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + if (this.currentMode == CurrentMode.TransferItems) + { + if (this.otherInventory.isFull == false) + { + this.playerInventory.receiveLeftClick(x, y); + if (this.playerInventory.activeItem != null) + { + this.transferItem(ref this.playerInventory, ref this.otherInventory); + } + } + if (this.playerInventory.isFull == false) + { + this.otherInventory.receiveLeftClick(x, y); + if (this.otherInventory.activeItem != null) + { + this.transferItem(ref this.otherInventory, ref this.playerInventory); + } + } + } + + if (this.currentMode == CurrentMode.TrashItem) + { + this.playerInventory.receiveLeftClick(x, y); + this.otherInventory.receiveLeftClick(x, y); + if (this.playerInventory.activeItem != null) + { + this.trashItem(ref this.playerInventory); + } + if (this.otherInventory.activeItem != null) + { + this.trashItem(ref this.otherInventory); + } + } + + if (this.transferButton.receiveLeftClick(x, y)) + { + this.currentMode = CurrentMode.TransferItems; + Game1.playSound("shwip"); + } + if (this.trashButton.receiveLeftClick(x, y)) + { + this.currentMode = CurrentMode.TrashItem; + Game1.playSound("shwip"); + } + if (this.trashedItem.receiveLeftClick(x, y)) + { + this.recoverTrashedItem(); + this.playerInventory.populateClickableItems(); + this.otherInventory.populateClickableItems(); + } + } + + /// + /// What happens when the menu is right clicked. + /// + /// + /// + /// + public override void receiveRightClick(int x, int y, bool playSound = true) + { + if (this.currentMode == CurrentMode.TransferItems) + { + if (this.otherInventory.isFull == false) + { + this.playerInventory.receiveLeftClick(x, y); + if (this.playerInventory.activeItem != null) + { + this.transferOneItem(ref this.playerInventory, ref this.otherInventory); + } + } + if (this.playerInventory.isFull == false) + { + this.otherInventory.receiveLeftClick(x, y); + if (this.otherInventory.activeItem != null) + { + this.transferOneItem(ref this.otherInventory, ref this.playerInventory); + } + } + } + } + + /// + /// Handles what happens when a menu is hover overed. + /// + /// + /// + public override void performHoverAction(int x, int y) + { + this.playerInventory.performHoverAction(x, y); + this.otherInventory.performHoverAction(x, y); + + if (this.transferButton.containsPoint(x, y)) + { + this.hoverText = "Transfer Items"; + } + else if (this.trashButton.containsPoint(x, y)) + { + this.hoverText = "Trash Items"; + } + else + { + this.hoverText = ""; + } + + if (this.trashedItem.Contains(x, y)) + { + if (this.trashedItem.item != null) + { + this.displayTrashedItem = true; + } + else + { + this.displayTrashedItem = false; + } + } + else + { + this.displayTrashedItem = false; + } + } + + /// + /// Transfers an item between inventories. + /// + /// + /// + private void transferItem(ref InventoryMenu From, ref InventoryMenu To) + { + //Stack size control logic. + foreach (Item I in To.items) + { + if (I == null) continue; + if (From.activeItem.canStackWith(I)) + { + I.addToStack(From.activeItem.Stack); + From.items.Remove(From.activeItem); + From.activeItem = null; + From.populateClickableItems(); + To.populateClickableItems(); + return; + } + else if (I.maximumStackSize() > I.Stack + From.activeItem.Stack && From.activeItem.canStackWith(I)) + { + int sizeLeft = I.getRemainingStackSpace(); + I.Stack = I.maximumStackSize(); + From.activeItem.Stack -= sizeLeft; + + break; + } + } + if (To.isFull == false) + { + To.items.Add(From.activeItem); + From.items.Remove(From.activeItem); + From.activeItem = null; + From.populateClickableItems(); + To.populateClickableItems(); + } + } + + /// + /// Transfers exactly one item across inventories. + /// + /// + /// + private void transferOneItem(ref InventoryMenu From, ref InventoryMenu To) + { + //Stack size control logic. + foreach (Item I in To.items) + { + if (I == null) continue; + if (From.activeItem.canStackWith(I)) + { + I.addToStack(1); + From.activeItem.Stack--; + if (From.activeItem.Stack <= 0) + { + From.items.Remove(From.activeItem); + } + From.activeItem = null; + From.populateClickableItems(); + To.populateClickableItems(); + return; + } + } + if (To.isFull == false) + { + To.items.Add(From.activeItem.getOne()); + From.activeItem.Stack--; + if (From.activeItem.Stack <= 0) + { + From.items.Remove(From.activeItem); + } + From.activeItem = null; + From.populateClickableItems(); + To.populateClickableItems(); + } + } + + + /// + /// Puts an item into the trash. + /// + /// + private void trashItem(ref InventoryMenu From) + { + if (From.activeItem != null) + { + this.trashedItem.item = From.activeItem; + From.items.Remove(From.activeItem); + From.activeItem = null; + From.populateClickableItems(); + } + } + + /// + /// Trashes a single item from the given inventory. + /// + /// + private void transhOneItem(ref InventoryMenu From) + { + if (From.activeItem != null) + { + if (this.trashedItem.item == null) + { + this.trashedItem.item = From.activeItem.getOne(); + From.activeItem.Stack--; + if (From.activeItem.Stack == 0) + { + From.items.Remove(From.activeItem); + } + From.activeItem = null; + From.populateClickableItems(); + } + else if (this.trashedItem.item != null) + { + if (From.activeItem.canStackWith(this.trashedItem.item)) + { + this.trashedItem.item.Stack += 1; + From.activeItem.Stack--; + if (From.activeItem.Stack == 0) + { + From.items.Remove(From.activeItem); + } + From.activeItem = null; + From.populateClickableItems(); + return; + } + else + { + this.trashedItem.item = From.activeItem.getOne(); + From.activeItem.Stack--; + if (From.activeItem.Stack == 0) + { + From.items.Remove(From.activeItem); + } + From.activeItem = null; + From.populateClickableItems(); + return; + } + } + } + } + + /// + /// Tries to recover the previously trashed item. + /// + private void recoverTrashedItem() + { + if (this.trashedItem.item != null) + { + if (this.playerInventory.isFull == false) + { + foreach (Item I in this.playerInventory.items) + { + if (I == null) continue; + if (this.trashedItem.item.canStackWith(I)) + { + I.addToStack(this.trashedItem.item.Stack); + this.trashedItem.item = null; + return; + } + else if (I.maximumStackSize() > I.Stack + this.trashedItem.item.Stack && this.trashedItem.item.canStackWith(I)) + { + int sizeLeft = I.getRemainingStackSpace(); + I.Stack = I.maximumStackSize(); + this.trashedItem.item.Stack -= sizeLeft; + break; + } + } + if (this.playerInventory.isFull == false) + { + this.playerInventory.items.Add(this.trashedItem.item); + this.trashedItem.item = null; + return; + } + else if (this.otherInventory.isFull == false) + { + foreach (Item I in this.otherInventory.items) + { + if (I == null) continue; + if (this.trashedItem.item.canStackWith(I)) + { + I.addToStack(this.trashedItem.item.Stack); + this.trashedItem.item = null; + return; + } + else if (I.maximumStackSize() > I.Stack + this.trashedItem.item.Stack && this.trashedItem.item.canStackWith(I)) + { + int sizeLeft = I.getRemainingStackSpace(); + I.Stack = I.maximumStackSize(); + this.trashedItem.item.Stack -= sizeLeft; + + break; + } + } + if (this.otherInventory.isFull == false) + { + this.otherInventory.items.Add(this.trashedItem.item); + this.trashedItem.item = null; + return; + } + } + } + else if (this.otherInventory.isFull == false) + { + foreach (Item I in this.otherInventory.items) + { + if (I == null) continue; + if (this.trashedItem.item.canStackWith(I)) + { + I.addToStack(this.trashedItem.item.Stack); + this.trashedItem.item = null; + return; + } + else if (I.maximumStackSize() > I.Stack + this.trashedItem.item.Stack && this.trashedItem.item.canStackWith(I)) + { + int sizeLeft = I.getRemainingStackSpace(); + I.Stack = I.maximumStackSize(); + this.trashedItem.item.Stack -= sizeLeft; + + break; + } + } + if (this.otherInventory.isFull == false) + { + this.otherInventory.items.Add(this.trashedItem.item); + this.trashedItem.item = null; + return; + } + + } + } + } + + /// + /// Draws + /// + /// + public override void draw(SpriteBatch b) + { + this.playerInventory.draw(b); + this.otherInventory.draw(b); + + this.transferButton.draw(b, 1f, this.currentMode== CurrentMode.TransferItems? 1f:.4f); + this.trashButton.draw(b, 1f, this.currentMode == CurrentMode.TrashItem ? 1f : .4f); + this.trashedItem.draw(b,0.25f, (this.currentMode == CurrentMode.TrashItem || this.trashedItem.item!=null) ? 1f:.4f, false); + if (this.hoverText != null) + { + IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont); + } + //To prevent awkward overlap from the other menu. + if (this.playerInventory.hoverText != null) + { + this.playerInventory.drawToolTip(b); + } + + this.drawToolTip(b); + this.drawMouse(b); + } + + public void drawToolTip(SpriteBatch b) + { + 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); + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Menus/SimpleItemGrabMenu.cs b/GeneralMods/Revitalize/Framework/Menus/SimpleItemGrabMenu.cs deleted file mode 100644 index 79a468f8..00000000 --- a/GeneralMods/Revitalize/Framework/Menus/SimpleItemGrabMenu.cs +++ /dev/null @@ -1,69 +0,0 @@ -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 StardewValley; -using StardewValley.Menus; -using StardustCore.UIUtilities; -using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons; - -namespace Revitalize.Framework.Menus -{ - public class SimpleItemGrabMenu: StardustCore.UIUtilities.IClickableMenuExtended - { - public List stroageInventory; - public List receivingInventory; - public List storageDisplay; - public StardewValley.Menus.ItemGrabMenu playerInventory; - - public int amountToDisplay = 9; - public SimpleItemGrabMenu(int xPos,int yPos,int width, int height,bool showCloseButton,List StorageInventory,ListReceivingInventory) : this(xPos, yPos, width, height, showCloseButton,StorageInventory,ReceivingInventory,9) - { - - } - - public SimpleItemGrabMenu(int xPos, int yPos, int width, int height, bool showCloseButton, List StorageInventory, List ReceivingInventory,int AmountToDisplay) : base(xPos, yPos, width, height, showCloseButton) - { - this.stroageInventory = StorageInventory; - this.receivingInventory = ReceivingInventory; - this.storageDisplay = new List(); - if (this.receivingInventory == null) - { - this.receivingInventory = (List)Game1.player.Items; - } - this.amountToDisplay = AmountToDisplay; - - this.playerInventory = new ItemGrabMenu(this.receivingInventory); - } - - public override void performHoverAction(int x, int y) - { - - } - - public override void receiveLeftClick(int x, int y, bool playSound = true) - { - this.playerInventory.receiveLeftClick(x, y, playSound); - } - - public override void receiveRightClick(int x, int y, bool playSound = true) - { - - } - - public override void update(GameTime time) - { - - } - - public override void draw(SpriteBatch b) - { - this.drawDialogueBoxBackground(); - this.drawMouse(b); - //base.draw(b); - } - } -} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index ead6be26..27cdb10c 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -189,14 +189,21 @@ namespace Revitalize private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { + /* if(e.Button== SButton.U) { Game1.currentMinigame = new Revitalize.Framework.Minigame.SeasideScrambleMinigame.SeasideScramble(); } - else if(e.Button== SButton.Y) + */ + if(e.Button== SButton.Y) { //Game1.activeClickableMenu = new ItemGrabMenu(Game1.player.Items,false,true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems),); - Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryMenu(100, 100, 500, 500,3,4,false, Game1.player.Items,15,Color.SandyBrown); + List newItems = new List() + { + new StardewValley.Object(184,10) + }; + + Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500,newItems,36); } } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 94376b17..85395509 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -66,7 +66,7 @@ - + @@ -172,12 +172,21 @@ Always + + PreserveNewest + + + PreserveNewest + Always Always + + PreserveNewest + Always diff --git a/GeneralMods/StardustCore/Animations/AnimatedSprite.cs b/GeneralMods/StardustCore/Animations/AnimatedSprite.cs index 952e9009..b8406802 100644 --- a/GeneralMods/StardustCore/Animations/AnimatedSprite.cs +++ b/GeneralMods/StardustCore/Animations/AnimatedSprite.cs @@ -67,9 +67,9 @@ namespace StardustCore.Animations /// Draws the sprite to the screen. /// /// - public virtual void draw(SpriteBatch b) + public virtual void draw(SpriteBatch b,float Alpha=1f) { - this.draw(b, 1f, 0f); + this.draw(b, 1f, 0f,Alpha); } /// @@ -78,9 +78,10 @@ namespace StardustCore.Animations /// /// /// - public virtual void draw(SpriteBatch b, float scale, float depth) + /// + public virtual void draw(SpriteBatch b, float scale, float depth,float alpha=1f) { - this.animation.draw(b, this.position, this.color, scale, SpriteEffects.None, depth); + this.animation.draw(b, this.position, new Color(this.color.R, this.color.G, this.color.B, alpha), scale, SpriteEffects.None, depth); } /// @@ -90,14 +91,24 @@ namespace StardustCore.Animations /// /// /// - public virtual void draw(SpriteBatch b,Vector2 position ,float scale, float depth) + /// /// + public virtual void draw(SpriteBatch b,Vector2 position ,float scale, float depth,float alpha=1f) { - this.animation.draw(b, position, this.color, scale, SpriteEffects.None, depth); + this.animation.draw(b, position, new Color(this.color.R, this.color.G, this.color.B, alpha), scale, SpriteEffects.None, depth); } - public virtual void draw(SpriteBatch b, Vector2 position, float scale,float rotation ,float depth) + /// + /// Draws the sprite to the screen. + /// + /// The spritebatch which to draw the sprite. + /// The position on screen. + /// The scale of the sprite. + /// The rotation of the sprite. + /// The depth of the sprite. + /// The alpha for the sprite. + public virtual void draw(SpriteBatch b, Vector2 position, float scale,float rotation ,float depth,float alpha=1f) { - this.animation.draw(b, position, this.color, scale, rotation,SpriteEffects.None, depth); + this.animation.draw(b, position, new Color(this.color.R,this.color.G,this.color.B,alpha), scale, rotation,SpriteEffects.None, depth); } /// @@ -107,9 +118,10 @@ namespace StardustCore.Animations /// /// /// - public virtual void draw(SpriteBatch b, Vector2 position, Vector2 scale, float depth) + /// + public virtual void draw(SpriteBatch b, Vector2 position, Vector2 scale, float depth,float alpha=1f) { - this.animation.draw(b, position, this.color, scale, SpriteEffects.None, depth); + this.animation.draw(b, position, new Color(this.color.R, this.color.G, this.color.B, alpha), scale, SpriteEffects.None, depth); } diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs index 92549f8a..70fe129a 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/AnimatedButton.cs @@ -10,9 +10,17 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons { public class AnimatedButton { + /// + /// The sprite that handles all of the visuals for the button. + /// public Animations.AnimatedSprite sprite; - + /// + /// The default bounds for the button. + /// private Rectangle defaultBounds; + /// + /// The actual bounds for the button which takes scale into acount. + /// public Rectangle bounds { get @@ -20,10 +28,22 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons return new Rectangle((int)this.Position.X, (int)this.Position.Y, (int)(this.defaultBounds.Width * this.scale), (int)(this.defaultBounds.Height * this.scale)); } } + /// + /// The scale for the button. + /// public float scale; + /// + /// The label for the button. + /// public string label; + /// + /// The name of the button. + /// public string name; + /// + /// The hovertext for the button. + /// public string hoverText; /// @@ -43,6 +63,12 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons } } + /// + /// Constructor. + /// + /// The sprite for the button. + /// The default hitbox for the button. + /// The scale for the button's sprite and it's hitbox public AnimatedButton(Animations.AnimatedSprite Sprite, Rectangle DefaultBounds, float Scale) { @@ -54,34 +80,71 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons this.hoverText = ""; } + /// + /// Update the button's logic. + /// + /// public void update(GameTime time) { } - public void draw(SpriteBatch b) + /// + /// Draw the button to the screen. + /// + /// + public void draw(SpriteBatch b,float Alpha=1f) { - this.sprite.draw(b); + this.sprite.draw(b,Alpha); } - public void draw(SpriteBatch b, float Depth) + /// + /// Draw the button to the screen. + /// + /// + /// + public void draw(SpriteBatch b, float Depth,float Alpha=1f) { - this.sprite.draw(b, this.scale, Depth); + this.sprite.draw(b, this.scale, Depth,Alpha); } + /// + /// Checks to see if the bounding box for this button contains the given x,y cordinates. + /// + /// + /// + /// public bool containsPoint(int x, int y) { return this.bounds.Contains(x, y); } + /// + /// Checks to see if this button has been left clicked. + /// + /// + /// + /// public bool receiveLeftClick(int x, int y) { return this.containsPoint(x, y); } + /// + /// Checks to see if this button has been right clicked. + /// + /// + /// + /// public bool receiveRightClick(int x, int y) { return this.containsPoint(x, y); } + /// + /// Checks to see if this button has been hover overed. + /// + /// + /// + /// public bool receiveHover(int x, int y) { return this.containsPoint(x, y); diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs index 5fb3fb3e..87d38efd 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/ComponentsV2/Buttons/ItemDisplayButton.cs @@ -15,12 +15,42 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons public class ItemDisplayButton { + /// + /// The position for the button. + /// private Vector2 position; + /// + /// The item owned by the button. + /// public StardewValley.Item item; - public Rectangle boundingBox; + + private Rectangle defaultBounds; + + /// + /// The hit box for detecting interaction. + /// + public Rectangle boundingBox + { + get + { + return new Rectangle((int)this.Position.X, (int)this.Position.Y, (int)(this.defaultBounds.Width * this.scale), (int)(this.defaultBounds.Height * this.scale)); + } + } + /// + /// The scale of the button. + /// public float scale; + /// + /// Should the stack number be drawn? + /// public bool drawStackNumber; + /// + /// The color for the item. + /// public Color drawColor; + /// + /// The background sprite for the item. + /// public StardustCore.Animations.AnimatedSprite background; /// @@ -35,8 +65,8 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons set { this.position = value; - this.boundingBox.X =(int)this.position.X; - this.boundingBox.Y =(int)this.position.Y; + this.defaultBounds.X =(int)this.position.X; + this.defaultBounds.Y =(int)this.position.Y; } } @@ -57,7 +87,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons public ItemDisplayButton(Item I,StardustCore.Animations.AnimatedSprite Background,Vector2 Position, Rectangle BoundingBox, float Scale, bool DrawStackNumber, Color DrawColor) { this.item = I; - this.boundingBox = BoundingBox; + this.defaultBounds = BoundingBox; this.Position = Position; this.scale = Scale; this.drawStackNumber = DrawStackNumber; @@ -74,10 +104,11 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// A simple draw function. /// /// - public void draw(SpriteBatch b) + public void draw(SpriteBatch b,float Alpha=1f) { - this.background.draw(b); - if(this.item!=null)this.item.drawInMenu(b, this.position, this.scale); + //this.background.draw(b); + //if(this.item!=null)this.item.drawInMenu(b, this.position, this.scale); + this.draw(b, 1f, Alpha, false); } /// @@ -89,7 +120,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons /// public void draw(SpriteBatch b,float Depth, float Alpha,bool DrawShadow) { - this.background.draw(b, this.scale, Depth); + 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); }