Fixed the display/ transfer code for inventory transfer menus to display proper inventory bounds.
This commit is contained in:
parent
ea100b1084
commit
3251d194f7
|
@ -72,11 +72,11 @@ namespace Revitalize.Framework.Menus
|
|||
{
|
||||
get
|
||||
{
|
||||
return this.items.Count >= this.capacity && this.items.Where(i=>i==null).Count()==0;
|
||||
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)
|
||||
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)
|
||||
{
|
||||
//Amount to display is the lower cap per page.
|
||||
//
|
||||
|
@ -97,8 +97,8 @@ namespace Revitalize.Framework.Menus
|
|||
Game1.keyboardDispatcher.Subscriber = (IKeyboardSubscriber)this.searchBox;
|
||||
this.searchBox.Selected = false;
|
||||
|
||||
this.nextPage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Next Page", new Vector2(128 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y),new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"),new Animation(0,0,32,32)),Color.White),new Rectangle(0, 0, 32, 32), 2f);
|
||||
this.previousPage= new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Previous Page", new Vector2(64 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f);
|
||||
this.nextPage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Next Page", new Vector2(128 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f);
|
||||
this.previousPage = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Previous Page", new Vector2(64 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f);
|
||||
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ namespace Revitalize.Framework.Menus
|
|||
this.searchBox.Y = this.yPositionOnScreen;
|
||||
this.populateClickableItems(this.rows, this.collumns, this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen + this.yOffset);
|
||||
this.nextPage.Position = new Vector2(128 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y);
|
||||
this.previousPage.Position= new Vector2(64 + (this.searchBox.X + this.searchBox.Width),this.searchBox.Y);
|
||||
this.previousPage.Position = new Vector2(64 + (this.searchBox.X + this.searchBox.Width), this.searchBox.Y);
|
||||
}
|
||||
|
||||
public void populateClickableItems()
|
||||
|
@ -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,22 +378,19 @@ 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);
|
||||
|
||||
this.nextPage.draw(b,0.25f,1f);
|
||||
this.previousPage.draw(b,0.25f,1f);
|
||||
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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue