Finished the work for the first stage of the item transfer menu!

This commit is contained in:
JoshuaNavarro 2019-08-05 21:19:56 -07:00
parent b022947542
commit d6fa1672db
11 changed files with 634 additions and 120 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

View File

@ -63,6 +63,16 @@ namespace Revitalize.Framework.Menus
public string hoverTitle;
public Item displayItem;
/// <summary>
/// Checks if the given inventory is full or not.
/// </summary>
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<Item> 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);
}
/// <summary>
/// Populates the menu with all of the items on display.
/// </summary>
@ -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<ItemDisplayButton>(), 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);
}
}
}
}
/// <summary>
@ -176,6 +184,11 @@ namespace Revitalize.Framework.Menus
else return this.items.ElementAt(index);
}
/// <summary>
/// What happens when this menu is hover overed.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
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);
}
/// <summary>
/// Draws the item as a transparent icon if the item is not part of the seach patern.
/// </summary>
/// <param name="I"></param>
/// <returns></returns>
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

View File

@ -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<Item> 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<Item> 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);
}
/// <summary>
/// Handles what happens when the menu is left clicked.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="playSound"></param>
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();
}
}
/// <summary>
/// What happens when the menu is right clicked.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="playSound"></param>
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);
}
}
}
}
/// <summary>
/// Handles what happens when a menu is hover overed.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
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;
}
}
/// <summary>
/// Transfers an item between inventories.
/// </summary>
/// <param name="From"></param>
/// <param name="To"></param>
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();
}
}
/// <summary>
/// Transfers exactly one item across inventories.
/// </summary>
/// <param name="From"></param>
/// <param name="To"></param>
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();
}
}
/// <summary>
/// Puts an item into the trash.
/// </summary>
/// <param name="From"></param>
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();
}
}
/// <summary>
/// Trashes a single item from the given inventory.
/// </summary>
/// <param name="From"></param>
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;
}
}
}
}
/// <summary>
/// Tries to recover the previously trashed item.
/// </summary>
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;
}
}
}
}
/// <summary>
/// Draws
/// </summary>
/// <param name="b"></param>
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);
}
}
}

View File

@ -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<Item> stroageInventory;
public List<Item> receivingInventory;
public List<ItemDisplayButton> storageDisplay;
public StardewValley.Menus.ItemGrabMenu playerInventory;
public int amountToDisplay = 9;
public SimpleItemGrabMenu(int xPos,int yPos,int width, int height,bool showCloseButton,List<Item> StorageInventory,List<Item>ReceivingInventory) : this(xPos, yPos, width, height, showCloseButton,StorageInventory,ReceivingInventory,9)
{
}
public SimpleItemGrabMenu(int xPos, int yPos, int width, int height, bool showCloseButton, List<Item> StorageInventory, List<Item> ReceivingInventory,int AmountToDisplay) : base(xPos, yPos, width, height, showCloseButton)
{
this.stroageInventory = StorageInventory;
this.receivingInventory = ReceivingInventory;
this.storageDisplay = new List<ItemDisplayButton>();
if (this.receivingInventory == null)
{
this.receivingInventory = (List<Item>)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);
}
}
}

View File

@ -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<Item> newItems = new List<Item>()
{
new StardewValley.Object(184,10)
};
Game1.activeClickableMenu = new Revitalize.Framework.Menus.InventoryTransferMenu(100, 100, 500, 500,newItems,36);
}
}

View File

@ -66,7 +66,7 @@
<Compile Include="Framework\Illuminate\FakeLightSource.cs" />
<Compile Include="Framework\Illuminate\LightManager.cs" />
<Compile Include="Framework\Menus\InventoryMenu.cs" />
<Compile Include="Framework\Menus\SimpleItemGrabMenu.cs" />
<Compile Include="Framework\Menus\InventoryTransferMenu.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ICollider.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISpawner.cs" />
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\Interfaces\ISSCLivingEntity.cs" />
@ -172,12 +172,21 @@
<Content Include="Content\Graphics\Menus\InventoryMenu\ItemBackground.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\InventoryMenu\ItemBackgroundNoSpacing.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\InventoryMenu\ItemTransferButton.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\InventoryMenu\NextPageButton.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\InventoryMenu\PreviousPageButton.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\InventoryMenu\TrashButton.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Minigames\SeasideScramble\Graphics\Enemies\Target.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -67,9 +67,9 @@ namespace StardustCore.Animations
/// Draws the sprite to the screen.
/// </summary>
/// <param name="b"></param>
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);
}
/// <summary>
@ -78,9 +78,10 @@ namespace StardustCore.Animations
/// <param name="b"></param>
/// <param name="scale"></param>
/// <param name="depth"></param>
public virtual void draw(SpriteBatch b, float scale, float depth)
/// <param name="alpha"></param>
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);
}
/// <summary>
@ -90,14 +91,24 @@ namespace StardustCore.Animations
/// <param name="position"></param>
/// <param name="scale"></param>
/// <param name="depth"></param>
public virtual void draw(SpriteBatch b,Vector2 position ,float scale, float depth)
/// /// <param name="alpha"></param>
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)
/// <summary>
/// Draws the sprite to the screen.
/// </summary>
/// <param name="b">The spritebatch which to draw the sprite.</param>
/// <param name="position">The position on screen.</param>
/// <param name="scale">The scale of the sprite.</param>
/// <param name="rotation">The rotation of the sprite.</param>
/// <param name="depth">The depth of the sprite.</param>
/// <param name="alpha">The alpha for the sprite.</param>
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);
}
/// <summary>
@ -107,9 +118,10 @@ namespace StardustCore.Animations
/// <param name="position"></param>
/// <param name="scale"></param>
/// <param name="depth"></param>
public virtual void draw(SpriteBatch b, Vector2 position, Vector2 scale, float depth)
/// <param name="alpha"></param>
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);
}

View File

@ -10,9 +10,17 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
{
public class AnimatedButton
{
/// <summary>
/// The sprite that handles all of the visuals for the button.
/// </summary>
public Animations.AnimatedSprite sprite;
/// <summary>
/// The default bounds for the button.
/// </summary>
private Rectangle defaultBounds;
/// <summary>
/// The actual bounds for the button which takes scale into acount.
/// </summary>
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));
}
}
/// <summary>
/// The scale for the button.
/// </summary>
public float scale;
/// <summary>
/// The label for the button.
/// </summary>
public string label;
/// <summary>
/// The name of the button.
/// </summary>
public string name;
/// <summary>
/// The hovertext for the button.
/// </summary>
public string hoverText;
/// <summary>
@ -43,6 +63,12 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
}
}
/// <summary>
/// Constructor.
/// </summary>
/// <param name="Sprite">The sprite for the button.</param>
/// <param name="DefaultBounds">The default hitbox for the button.</param>
/// <param name="Scale">The scale for the button's sprite and it's hitbox</param>
public AnimatedButton(Animations.AnimatedSprite Sprite, Rectangle DefaultBounds, float Scale)
{
@ -54,34 +80,71 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
this.hoverText = "";
}
/// <summary>
/// Update the button's logic.
/// </summary>
/// <param name="time"></param>
public void update(GameTime time)
{
}
public void draw(SpriteBatch b)
/// <summary>
/// Draw the button to the screen.
/// </summary>
/// <param name="b"></param>
public void draw(SpriteBatch b,float Alpha=1f)
{
this.sprite.draw(b);
this.sprite.draw(b,Alpha);
}
public void draw(SpriteBatch b, float Depth)
/// <summary>
/// Draw the button to the screen.
/// </summary>
/// <param name="b"></param>
/// <param name="Depth"></param>
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);
}
/// <summary>
/// Checks to see if the bounding box for this button contains the given x,y cordinates.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool containsPoint(int x, int y)
{
return this.bounds.Contains(x, y);
}
/// <summary>
/// Checks to see if this button has been left clicked.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool receiveLeftClick(int x, int y)
{
return this.containsPoint(x, y);
}
/// <summary>
/// Checks to see if this button has been right clicked.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool receiveRightClick(int x, int y)
{
return this.containsPoint(x, y);
}
/// <summary>
/// Checks to see if this button has been hover overed.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool receiveHover(int x, int y)
{
return this.containsPoint(x, y);

View File

@ -15,12 +15,42 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
public class ItemDisplayButton
{
/// <summary>
/// The position for the button.
/// </summary>
private Vector2 position;
/// <summary>
/// The item owned by the button.
/// </summary>
public StardewValley.Item item;
public Rectangle boundingBox;
private Rectangle defaultBounds;
/// <summary>
/// The hit box for detecting interaction.
/// </summary>
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));
}
}
/// <summary>
/// The scale of the button.
/// </summary>
public float scale;
/// <summary>
/// Should the stack number be drawn?
/// </summary>
public bool drawStackNumber;
/// <summary>
/// The color for the item.
/// </summary>
public Color drawColor;
/// <summary>
/// The background sprite for the item.
/// </summary>
public StardustCore.Animations.AnimatedSprite background;
/// <summary>
@ -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.
/// </summary>
/// <param name="b"></param>
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);
}
/// <summary>
@ -89,7 +120,7 @@ namespace StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons
/// <param name="DrawShadow"></param>
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);
}