diff --git a/EndlessClient/HUD/Inventory/InventorySlotRepository.cs b/EndlessClient/HUD/Inventory/InventorySlotRepository.cs index 1da3bc145..1f1b6811a 100644 --- a/EndlessClient/HUD/Inventory/InventorySlotRepository.cs +++ b/EndlessClient/HUD/Inventory/InventorySlotRepository.cs @@ -1,5 +1,6 @@ using AutomaticTypeMapper; using EndlessClient.HUD.Panels; +using EOLib; using EOLib.IO.Map; namespace EndlessClient.HUD.Inventory @@ -15,13 +16,18 @@ public interface IInventorySlotProvider } [AutoMappedType(IsSingleton = true)] - public class InventorySlotRepository : IInventorySlotProvider, IInventorySlotRepository + public class InventorySlotRepository : IInventorySlotProvider, IInventorySlotRepository, IResettable { public Matrix FilledSlots { get; set; } IReadOnlyMatrix IInventorySlotProvider.FilledSlots => FilledSlots; public InventorySlotRepository() + { + ResetState(); + } + + public void ResetState() { FilledSlots = new Matrix(InventoryPanel.InventoryRows, InventoryPanel.InventoryRowSlots, false); } diff --git a/EndlessClient/HUD/Panels/InventoryPanel.cs b/EndlessClient/HUD/Panels/InventoryPanel.cs index 4cc7f4a6e..f3ff79aba 100644 --- a/EndlessClient/HUD/Panels/InventoryPanel.cs +++ b/EndlessClient/HUD/Panels/InventoryPanel.cs @@ -11,6 +11,7 @@ using EOLib.Graphics; using EOLib.IO; using EOLib.IO.Extensions; +using EOLib.IO.Map; using EOLib.IO.Pub; using EOLib.IO.Repositories; using EOLib.Localization; @@ -230,6 +231,9 @@ protected override void Dispose(bool disposing) _junk.OnMouseEnter -= MouseOverButton; Game.Exiting -= SaveInventoryFile; + // todo: IResettable should work but it doesn't + _inventorySlotRepository.FilledSlots = new Matrix(InventoryRows, InventoryRowSlots, false); + SaveInventoryFile(null, EventArgs.Empty); }