Skip to content

Commit

Permalink
Merge pull request #1 from FFXIV-CombatReborn/day-1-fixes
Browse files Browse the repository at this point in the history
Allagan Tools IPC Improvements
  • Loading branch information
NostraThomas99 authored Oct 7, 2024
2 parents 6054e96 + 3982eef commit cf33081
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
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

0 comments on commit cf33081

Please sign in to comment.