Fixed the display/ transfer code for inventory transfer menus to display proper inventory bounds.

This commit is contained in:
JoshuaNavarro 2019-09-18 13:51:42 -07:00
parent ea100b1084
commit 3251d194f7
5 changed files with 68 additions and 58 deletions

View File

@ -241,6 +241,7 @@ namespace Revitalize.Framework.Menus
{
if (button.receiveLeftClick(x, y))
{
if (index > this.capacity) continue;
if (this.activeItem == null)
{
this.activeItem = button.item;
@ -377,16 +378,13 @@ namespace Revitalize.Framework.Menus
{
this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor);
int index = -1;
foreach (ItemDisplayButton button in this.pages[this.pageIndex].storageDisplay)
{
if (string.IsNullOrEmpty(this.searchBox.Text) == false)
{
button.draw(b, 0.25f, this.getItemDrawAlpha(button.item), true);
}
else
{
button.draw(b, 0.25f, 1f, true);
}
index++;
float alpha = this.getItemDrawAlpha(button.item, index + this.pageIndex * this.rows*this.collumns);
button.draw(b, 0.25f, alpha, true);
}
this.searchBox.Draw(b, true);
@ -412,8 +410,9 @@ namespace Revitalize.Framework.Menus
/// </summary>
/// <param name="I"></param>
/// <returns></returns>
private float getItemDrawAlpha(Item I)
private float getItemDrawAlpha(Item I, int index)
{
if (index >= this.capacity) return 0.0f;
if (string.IsNullOrEmpty(this.searchBox.Text) == false)
{
if (I == null) return 0.25f;

View File

@ -36,11 +36,11 @@ namespace Revitalize.Framework.Menus
}
private CurrentMode currentMode;
public InventoryTransferMenu(int x, int y, int width, int height, IList<Item> OtherItems, int OtherCapacity) : base(x, y, width, height, true)
public InventoryTransferMenu(int x, int y, int width, int height, IList<Item> OtherItems, int OtherCapacity,int OtherRows=6,int OtherCollumns=6) : 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.otherInventory = new InventoryMenu(this.playerInventory.xPositionOnScreen + this.playerInventory.width + 128, y, width, height, OtherRows, OtherCollumns, 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);

View File

@ -294,7 +294,7 @@ namespace Revitalize.Framework.Objects.Machines
if (this.InventoryManager.capacity > 0)
{
InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.InventoryManager.items, 36);
InventoryTransferMenu transferMenu = new InventoryTransferMenu(100, 150, 500, 600, this.InventoryManager.items, this.InventoryManager.capacity,this.InventoryManager.displayRows,this.InventoryManager.displayColumns);
machineMenu.addInMenuTab("Inventory", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Inventory Tab", new Vector2(), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTab"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), transferMenu, false);
}

View File

@ -232,8 +232,8 @@ namespace Revitalize.Framework.Objects
///Consumes energy. Produces batteries.
MultiTiledObject batteryBin = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(1), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)));
Machine batteryBin_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(1), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)), new List<InformationFiles.ResourceInformation>()
MultiTiledObject batteryBin = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)));
Machine batteryBin_0_0 = new Machine(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Machines.BatteryBin", TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Battery Bin", "Omegasis.Revitalize.Objects.Machines.BatteryBin", "Consumes energy over time to produce battery packs.", "Machine", Color.SteelBlue, -300, 0, false, 500, true, true, TextureManager.GetTexture(ModCore.Manifest, "Machines", "BatteryBin"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Machines", "BatteryBin"), new Animation(0, 0, 16, 16)), Color.White, false, new InventoryManager(9,3,3), null, new Energy.EnergyManager(500, Enums.EnergyInteractionType.Consumes)), new List<InformationFiles.ResourceInformation>()
{
new InformationFiles.ResourceInformation(new StardewValley.Object((int)Enums.SDVObject.BatteryPack,1),1,1,1,1,1,1,0,0,0,0)

View File

@ -40,6 +40,9 @@ namespace Revitalize.Framework.Utilities
}
}
public int displayRows;
public int displayColumns;
[JsonIgnore]
public bool requiresUpdate;
public InventoryManager()
@ -51,38 +54,46 @@ namespace Revitalize.Framework.Utilities
}
/// <summary>Construct an instance.</summary>
public InventoryManager(List<Item> items)
public InventoryManager(List<Item> items,int DisplayRows=6,int DisplayColumns=6)
{
this.capacity = int.MaxValue;
this.setMaxLimit(int.MaxValue);
this.items = items;
this.bufferItems = new List<Item>();
this.displayRows = DisplayRows;
this.displayColumns = DisplayColumns;
}
public InventoryManager(IList<Item> items)
public InventoryManager(IList<Item> items, int DisplayRows = 6, int DisplayColumns = 6)
{
this.capacity = int.MaxValue;
this.setMaxLimit(int.MaxValue);
this.items = items;
this.bufferItems = new List<Item>();
this.displayRows = DisplayRows;
this.displayColumns = DisplayColumns;
}
/// <summary>Construct an instance.</summary>
public InventoryManager(int capacity)
public InventoryManager(int capacity, int DisplayRows = 6, int DisplayColumns = 6)
{
this.capacity = capacity;
this.MaxCapacity = int.MaxValue;
this.items = new List<Item>();
this.bufferItems = new List<Item>();
this.displayRows = DisplayRows;
this.displayColumns = DisplayColumns;
}
/// <summary>Construct an instance.</summary>
public InventoryManager(int capacity, int MaxCapacity)
public InventoryManager(int capacity, int MaxCapacity, int DisplayRows = 6, int DisplayColumns = 6)
{
this.capacity = capacity;
this.setMaxLimit(MaxCapacity);
this.items = new List<Item>();
this.bufferItems = new List<Item>();
this.displayRows = DisplayRows;
this.displayColumns = DisplayColumns;
}
/// <summary>Add the item to the inventory.</summary>
@ -181,7 +192,7 @@ namespace Revitalize.Framework.Utilities
/// <returns></returns>
public InventoryManager Copy()
{
return new InventoryManager(this.capacity, this.MaxCapacity);
return new InventoryManager(this.capacity, this.MaxCapacity,this.displayRows,this.displayColumns);
}
public void dumpBufferToItems()