Added ability to see how much inventory space remains on summary menu. Also made machines unable to produce items if inventory is full.

This commit is contained in:
JoshuaNavarro 2019-09-18 14:30:37 -07:00
parent 505eaf1c2f
commit 620c1b4b70
5 changed files with 14 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

View File

@ -48,6 +48,8 @@ namespace Revitalize.Framework.Menus.Machines
private Vector2 timeDisplayLocation; private Vector2 timeDisplayLocation;
private AnimatedButton energyRequiredButton; private AnimatedButton energyRequiredButton;
private Vector2 energyRequiredDisplayLocation; private Vector2 energyRequiredDisplayLocation;
private AnimatedButton storageButton;
private Vector2 storageRemainingDisplayLocation;
private int requiredEnergyPer10Min; private int requiredEnergyPer10Min;
@ -86,6 +88,7 @@ namespace Revitalize.Framework.Menus.Machines
this.timeDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width * .1f), this.yPositionOnScreen + (this.height * .25f)); this.timeDisplayLocation = new Vector2(this.xPositionOnScreen + (this.width * .1f), this.yPositionOnScreen + (this.height * .25f));
this.energyRequiredDisplayLocation = this.timeDisplayLocation + new Vector2(0, 64); this.energyRequiredDisplayLocation = this.timeDisplayLocation + new Vector2(0, 64);
this.storageRemainingDisplayLocation = this.energyRequiredDisplayLocation + new Vector2(0, 64);
this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72 * 4); this.energyPosition = new Vector2(this.xPositionOnScreen + this.width - 128, this.yPositionOnScreen + this.height - 72 * 4);
this.batteryBackground = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f); this.batteryBackground = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("BatteryFrame", this.energyPosition, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "BatteryFrame"), new StardustCore.Animations.Animation(0, 0, 32, 64)), Color.White), new Rectangle(0, 0, 32, 64), 4f);
@ -94,6 +97,7 @@ namespace Revitalize.Framework.Menus.Machines
this.itemDisplayOffset = ObjectUtilities.GetDimensionOffsetFromItem(this.objectSource); this.itemDisplayOffset = ObjectUtilities.GetDimensionOffsetFromItem(this.objectSource);
this.clockSprite= new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Time Remaining",this.timeDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Clock"), new StardustCore.Animations.Animation(0, 0, 18, 18)), Color.White), new Rectangle(0, 0, 18, 18), 2f); this.clockSprite= new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Time Remaining",this.timeDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Clock"), new StardustCore.Animations.Animation(0, 0, 18, 18)), Color.White), new Rectangle(0, 0, 18, 18), 2f);
this.energyRequiredButton=new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Energy Required", this.energyRequiredDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "LightningBolt"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f); this.energyRequiredButton=new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Energy Required", this.energyRequiredDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus.EnergyMenu", "LightningBolt"), new StardustCore.Animations.Animation(0, 0, 16, 16)), Color.White), new Rectangle(0, 0, 16, 16), 2f);
this.storageButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Storage Remaining", this.storageRemainingDisplayLocation, new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "Chest"), new StardustCore.Animations.Animation(0, 0, 16, 32)), Color.White), new Rectangle(0, 0, 16, 32), 1f);
this.requiredEnergyPer10Min = RequiredEnergyPer10Min; this.requiredEnergyPer10Min = RequiredEnergyPer10Min;
} }
@ -163,6 +167,11 @@ namespace Revitalize.Framework.Menus.Machines
b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min+" E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black); b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min+" E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black);
} }
if (this.objectSource.info.inventory.HasInventory)
{
this.storageButton.draw(b);
b.DrawString(Game1.smallFont, "Storage remaining: "+ (this.objectSource.info.inventory.capacity-this.objectSource.info.inventory.ItemCount)+"/"+this.objectSource.info.inventory.capacity, this.storageRemainingDisplayLocation + new Vector2(0, 32f), Color.Black);
}

View File

@ -234,7 +234,7 @@ namespace Revitalize.Framework.Objects.Machines
remaining -= 10; remaining -= 10;
this.containerObject.MinutesUntilReady -= 10; this.containerObject.MinutesUntilReady -= 10;
if (this.containerObject.MinutesUntilReady <= 0) if (this.containerObject.MinutesUntilReady <= 0 && this.InventoryManager.IsFull==false)
{ {
this.produceItem(); this.produceItem();
this.containerObject.MinutesUntilReady = this.timeToProduce; this.containerObject.MinutesUntilReady = this.timeToProduce;

View File

@ -15,7 +15,7 @@ namespace Revitalize.Framework.Utilities
public int MaxCapacity { get; private set; } public int MaxCapacity { get; private set; }
/// <summary>How many items are currently stored in the inventory.</summary> /// <summary>How many items are currently stored in the inventory.</summary>
public int ItemCount => this.items.Count; public int ItemCount => this.items.Where(i => i != null).Count();
/// <summary>The actual contents of the inventory.</summary> /// <summary>The actual contents of the inventory.</summary>
public IList<Item> items; public IList<Item> items;

View File

@ -379,6 +379,9 @@
<Content Include="Content\Graphics\Menus\InventoryMenu\TrashButton.png"> <Content Include="Content\Graphics\Menus\InventoryMenu\TrashButton.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Graphics\Menus\Misc\Chest.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\Misc\Clock.png"> <Content Include="Content\Graphics\Menus\Misc\Clock.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>