diff --git a/RebornToolbox/Common/MainWindow.cs b/RebornToolbox/Common/MainWindow.cs index b2c8dbb..c2c0067 100644 --- a/RebornToolbox/Common/MainWindow.cs +++ b/RebornToolbox/Common/MainWindow.cs @@ -52,8 +52,15 @@ public override void Draw() Plugin.Configuration.ShoppingListConfig.RemoveQuantityAutomatically = inventoryCheck; Plugin.Configuration.SaveConfig(); } - ImGuiEx.Tooltip("Automatically subtract from needed quantity when items are added to your inventory."); + + var allChars = Plugin.Configuration.ShoppingListConfig.AllCharactersInventory; + if (ImGui.Checkbox("Consider Inventory Counts from All Characters", ref allChars)) + { + Plugin.Configuration.ShoppingListConfig.AllCharactersInventory = allChars; + Plugin.Configuration.SaveConfig(); + } + ImGuiEx.Tooltip("Whether or not to pull items from every character's inventory using Allagan Tools"); } ImGui.Unindent(); diff --git a/RebornToolbox/Features/MBShoppingList/MBShoppingList.Config.cs b/RebornToolbox/Features/MBShoppingList/MBShoppingList.Config.cs index 898112e..89ebc68 100644 --- a/RebornToolbox/Features/MBShoppingList/MBShoppingList.Config.cs +++ b/RebornToolbox/Features/MBShoppingList/MBShoppingList.Config.cs @@ -10,4 +10,5 @@ public class MBShoppingList_Config public int LifeStreamTimeout { get; set; } = 300; public bool UseVnavPathing { get; set; } = false; public bool RemoveQuantityAutomatically { get; set; } = false; + public bool AllCharactersInventory { get; set; } = false; } \ No newline at end of file diff --git a/RebornToolbox/Features/MBShoppingList/Models/ShoppingListItem.cs b/RebornToolbox/Features/MBShoppingList/Models/ShoppingListItem.cs index 82928c9..ef9db54 100644 --- a/RebornToolbox/Features/MBShoppingList/Models/ShoppingListItem.cs +++ b/RebornToolbox/Features/MBShoppingList/Models/ShoppingListItem.cs @@ -49,7 +49,26 @@ internal void OnDeserializedMethod(StreamingContext context) public bool IsMarketable { get; private set; } public long Quantity { get; set; } - public long InventoryCount => AllaganTools_IPCSubscriber.IsInitialized() ? AllaganTools_IPCSubscriber.ItemCountOwned(ItemId, false, ValidInventoryTypes.Select(i => (uint)i).ToArray()) : 0; + [Newtonsoft.Json.JsonIgnore] + private DateTime _inventoryLastUpdated = DateTime.MinValue; + + [Newtonsoft.Json.JsonIgnore] + private long _inventoryCount = 0; + + [Newtonsoft.Json.JsonIgnore] + public long InventoryCount + { + get + { + if (DateTime.Now.Subtract(_inventoryLastUpdated).TotalSeconds > 1) + { + _inventoryLastUpdated = DateTime.Now; + _inventoryCount = AllaganTools_IPCSubscriber.IsInitialized() ? AllaganTools_IPCSubscriber.ItemCountOwned(ItemId, !Plugin.Configuration.ShoppingListConfig.AllCharactersInventory, ValidInventoryTypes.Select(i => (uint)i).ToArray()) : 0; + } + + return _inventoryCount; + } + } [Newtonsoft.Json.JsonIgnore] private List ValidInventoryTypes = new List()