Compare commits

..

1 Commits
v2.0 ... master

2 changed files with 48 additions and 7 deletions

View File

@ -84,6 +84,8 @@ internal sealed class GlamourSetter : Window, IDisposable
private readonly IAddonLifecycle _addonLifecycle;
private readonly Configuration _configuration;
private readonly ReadOnlyCollection<GlamourSet> _glamourSets;
private readonly Dictionary<uint, int> _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<Cabinet>()
.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,6 +286,8 @@ internal sealed class GlamourSetter : Window, IDisposable
var ownedItems = GetOwnedItems();
DrawMissingItemHeader(glamourSets, setType, ownedSets, ownedItems);
using (ImRaii.Child("Sets"))
DrawSetRange(glamourSets, ownedSets, ownedItems);
}
@ -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<GlamourSet> glamourSets, ESetType setType, List<GlamourSet> ownedSets,
private void DrawMissingItemHeader(List<GlamourSet> glamourSets, ESetType setType, List<GlamourSet> ownedSets,
HashSet<uint> 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<uint> 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)

View File

@ -1,6 +1,6 @@
<Project Sdk="Dalamud.NET.Sdk/11.0.0">
<PropertyGroup>
<Version>2.0</Version>
<Version>2.1</Version>
<OutputPath>dist</OutputPath>
</PropertyGroup>