diff --git a/ItemBoxTracker/src/Plugin/GUI/InventoryItemDataTemplate.xaml b/ItemBoxTracker/src/Plugin/GUI/InventoryItemDataTemplate.xaml
index 567bcb9..9bd8719 100644
--- a/ItemBoxTracker/src/Plugin/GUI/InventoryItemDataTemplate.xaml
+++ b/ItemBoxTracker/src/Plugin/GUI/InventoryItemDataTemplate.xaml
@@ -23,7 +23,7 @@
Padding="0,0,10,0" />
-
+
diff --git a/ItemBoxTracker/src/Plugin/Service/InventoryService.cs b/ItemBoxTracker/src/Plugin/Service/InventoryService.cs
index fcd970c..190900c 100644
--- a/ItemBoxTracker/src/Plugin/Service/InventoryService.cs
+++ b/ItemBoxTracker/src/Plugin/Service/InventoryService.cs
@@ -4,6 +4,8 @@
using System.Threading;
using System.Threading.Tasks;
using HunterPie.Core;
+using HunterPie.Core.Craft;
+using HunterPie.Core.Definitions;
using MHWItemBoxTracker.Model;
using MHWItemBoxTracker.Utils;
@@ -69,12 +71,34 @@ public void Refresh() {
}
var ids = Data.Items.Select(i => i.Item.ItemId).ToHashSet();
var box = Context.Player.ItemBox?.FindItemsInBox(ids) ?? new();
- var pouch = Context.Player.Inventory?.FindItemsAndAmmos(ids).ToDictionary(i => i.ItemId, i => i.Amount);
+ var pouch = Context.Player.Inventory?.FindItemsAndAmmos(ids)?.ToDictionary(i => i.ItemId, i => i.Amount) ?? new();
foreach (var item in Data.Items) {
box.TryGetValue(item.Item.ItemId, out int AmountInBox);
pouch.TryGetValue(item.Item.ItemId, out int AmountInPouch);
- // TODO: Get this
- int AmountCraftable = 0;
+
+ var recipes = Recipes.FindRecipes(item.Item.ItemId) ?? new();
+ var materials = recipes
+ .SelectMany(r => r.MaterialsNeeded)
+ .Select(m => m.ItemId)
+ .ToHashSet();
+
+ var pouchCraft = item.TrackPouch
+ ? Context.Player.Inventory?.FindItemsAndAmmos(materials) ?? new sItem[0]
+ : new sItem[0];
+
+ var boxCraft = (item.TrackBox
+ ? Context.Player.ItemBox?.FindItemsInBox(materials) ?? new()
+ : new())
+ .Select(
+ i => new sItem() {
+ ItemId = i.Key,
+ Amount = i.Value,
+ })
+ .ToArray();
+
+ int AmountCraftable = (item.TrackPouch ? recipes.Select(r => r.Calculate(pouchCraft)).Sum() : 0)
+ + (item.TrackBox ? recipes.Select(r => r.Calculate(boxCraft)).Sum() : 0);
+
item.AmountInBox = item.TrackBox ? AmountInBox : 0;
item.AmountInPouch = item.TrackPouch ? AmountInPouch : 0;
item.AmountCraftable = item.TrackCraftable ? AmountCraftable : 0;
diff --git a/README.md b/README.md
index eb0e3c5..953a4b6 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,12 @@ A plugin for hunter pie that lets players track the items they are farming.
Reducing cognitive overhead by allowing the player to stop looking at the box after every quest to find out that they still need 5 more tickets, 1 less than the last time they checked, and stop asking "how many did I need again?"
-![Overlay](https://user-images.githubusercontent.com/5027713/118384904-3b74b600-b5d8-11eb-90d7-5b6794b67526.png)
+![Overlay](https://user-images.githubusercontent.com/5027713/118386273-4df4ec80-b5e4-11eb-9a6b-7c1e4c2f9fa2.png)
+
> The numbers displayed are `pouch | box (+craftable) / wanted`
+>
+> Craftable items are counted from box items if **Track items in box** is enabled and from pouch if **Track items in pouch** is enabled. The number shown is their sum.
## Changelog