Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allagan Tools IPC Improvements #1

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion RebornToolbox/Common/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
21 changes: 20 additions & 1 deletion RebornToolbox/Features/MBShoppingList/Models/ShoppingListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<InventoryType> ValidInventoryTypes = new List<InventoryType>()
Expand Down