diff --git a/KitchenSink/Commands/GlamourSetter.cs b/KitchenSink/Commands/GlamourSetter.cs index af0aef2..c93e141 100644 --- a/KitchenSink/Commands/GlamourSetter.cs +++ b/KitchenSink/Commands/GlamourSetter.cs @@ -84,6 +84,8 @@ internal sealed class GlamourSetter : Window, IDisposable private readonly IAddonLifecycle _addonLifecycle; private readonly Configuration _configuration; private readonly ReadOnlyCollection _glamourSets; + + private readonly Dictionary _ownedCurrencies = []; private Configuration.CharacterData? _characterData; public GlamourSetter(IDalamudPluginInterface pluginInterface, IDataManager dataManager, IClientState clientState, @@ -98,6 +100,10 @@ internal sealed class GlamourSetter : Window, IDisposable _addonLifecycle = addonLifecycle; _configuration = configuration; + SizeConstraints = new WindowSizeConstraints + { + MinimumSize = new(300, 400) + }; var armoireItems = dataManager.GetExcelSheet() .Where(x => x.RowId > 0) @@ -227,6 +233,19 @@ internal sealed class GlamourSetter : Window, IDisposable return; } + unsafe + { + InventoryManager* inventoryManager = InventoryManager.Instance(); + if (inventoryManager != null) + { + _ownedCurrencies[ItemMgp] = inventoryManager->GetItemCountInContainer(ItemMgp, InventoryType.Currency); + _ownedCurrencies[ItemWolfMarks] = (int)inventoryManager->GetWolfMarks(); + _ownedCurrencies[ItemTrophyCrystals] = inventoryManager->GetInventoryItemCount(ItemTrophyCrystals); + } + else + _ownedCurrencies.Clear(); + } + var ownedSets = _glamourSets.Where(x => _characterData.GlamourDresserItems.Contains(x.ItemId)).ToList(); ImGui.Text( $"Complete Sets: {ownedSets.Count} / {_glamourSets.Count(x => x.SetType != ESetType.Unobtainable || ownedSets.Contains(x))}"); @@ -267,7 +286,9 @@ internal sealed class GlamourSetter : Window, IDisposable var ownedItems = GetOwnedItems(); DrawMissingItemHeader(glamourSets, setType, ownedSets, ownedItems); - DrawSetRange(glamourSets, ownedSets, ownedItems); + + using (ImRaii.Child("Sets")) + DrawSetRange(glamourSets, ownedSets, ownedItems); } private void DrawSpecialtyTab(List ownedSets) @@ -290,7 +311,7 @@ internal sealed class GlamourSetter : Window, IDisposable DrawSetRange(glamourSets.Where(x => UndyedRathalosSets.Contains(x.ItemId)).ToList(), ownedSets, ownedItems); } - private static void DrawMissingItemHeader(List glamourSets, ESetType setType, List ownedSets, + private void DrawMissingItemHeader(List glamourSets, ESetType setType, List ownedSets, HashSet ownedItems) { var missingItems = glamourSets @@ -300,15 +321,15 @@ internal sealed class GlamourSetter : Window, IDisposable if (setType == ESetType.PvP) { ImGui.Text( - $"Wolf Marks: {missingItems.Where(x => x is { ShopItem.CostItemId: ItemWolfMarks }).Sum(x => x.ShopItem!.CostQuantity):N0}"); + $"Wolf Marks: {_ownedCurrencies.GetValueOrDefault(ItemWolfMarks):N0} / {missingItems.Where(x => x is { ShopItem.CostItemId: ItemWolfMarks }).Sum(x => x.ShopItem!.CostQuantity):N0}"); ImGui.Text( - $"Trophy Crystals: {missingItems.Where(x => x is { ShopItem.CostItemId: ItemTrophyCrystals }).Sum(x => x.ShopItem!.CostQuantity):N0}"); + $"Trophy Crystals: {_ownedCurrencies.GetValueOrDefault(ItemTrophyCrystals):N0} / {missingItems.Where(x => x is { ShopItem.CostItemId: ItemTrophyCrystals }).Sum(x => x.ShopItem!.CostQuantity):N0}"); ImGui.Separator(); } else if (setType is ESetType.MGP or ESetType.Special) { ImGui.Text( - $"MGP: {missingItems.Where(x => x is { ShopItem.CostItemId: ItemMgp }).Sum(x => x.ShopItem!.CostQuantity):N0}"); + $"MGP: {_ownedCurrencies.GetValueOrDefault(ItemMgp):N0} / {missingItems.Where(x => x is { ShopItem.CostItemId: ItemMgp }).Sum(x => x.ShopItem!.CostQuantity):N0}"); ImGui.Separator(); } } @@ -325,12 +346,13 @@ internal sealed class GlamourSetter : Window, IDisposable int ownedCount = glamourSet.Items.Count(x => ownedItems.Contains(x.ItemId)); if (ownedCount == glamourSet.Items.Count) ImGui.TextColored(ImGuiColors.ParsedBlue, $"{glamourSet.Name} (Can be completed)"); + else if (CanAffordAllMissingGearPieces(glamourSet, ownedItems)) + ImGui.TextColored(ImGuiColors.DalamudViolet, $"{glamourSet.Name} (Can afford)"); else if (ownedCount > 0) ImGui.TextColored(ImGuiColors.DalamudYellow, glamourSet.Name); else ImGui.Text(glamourSet.Name); - using (ImRaii.PushIndent()) { foreach (var item in glamourSet.Items) @@ -384,6 +406,25 @@ internal sealed class GlamourSetter : Window, IDisposable return ownedItems; } + private bool CanAffordAllMissingGearPieces(GlamourSet glamourSet, HashSet ownedItems) + { + uint costItemId = 0; + uint costQuantity = 0; + foreach (var item in glamourSet.Items) + { + if (ownedItems.Contains(item.ItemId)) + continue; + + if (item.ShopItem == null) + return false; + + costItemId = item.ShopItem.CostItemId; + costQuantity += item.ShopItem.CostQuantity; + } + + return costQuantity <= _ownedCurrencies.GetValueOrDefault(costItemId); + } + private unsafe void UpdateFromGlamourDresser(AddonEvent type, AddonArgs args) { if (_characterData == null) diff --git a/KitchenSink/KitchenSink.csproj b/KitchenSink/KitchenSink.csproj index 6ac1de3..4c5f06a 100644 --- a/KitchenSink/KitchenSink.csproj +++ b/KitchenSink/KitchenSink.csproj @@ -1,6 +1,6 @@  - 2.0 + 2.1 dist