Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
cfc4189bc7 |
@ -84,6 +84,8 @@ internal sealed class GlamourSetter : Window, IDisposable
|
|||||||
private readonly IAddonLifecycle _addonLifecycle;
|
private readonly IAddonLifecycle _addonLifecycle;
|
||||||
private readonly Configuration _configuration;
|
private readonly Configuration _configuration;
|
||||||
private readonly ReadOnlyCollection<GlamourSet> _glamourSets;
|
private readonly ReadOnlyCollection<GlamourSet> _glamourSets;
|
||||||
|
|
||||||
|
private readonly Dictionary<uint, int> _ownedCurrencies = [];
|
||||||
private Configuration.CharacterData? _characterData;
|
private Configuration.CharacterData? _characterData;
|
||||||
|
|
||||||
public GlamourSetter(IDalamudPluginInterface pluginInterface, IDataManager dataManager, IClientState clientState,
|
public GlamourSetter(IDalamudPluginInterface pluginInterface, IDataManager dataManager, IClientState clientState,
|
||||||
@ -98,6 +100,10 @@ internal sealed class GlamourSetter : Window, IDisposable
|
|||||||
_addonLifecycle = addonLifecycle;
|
_addonLifecycle = addonLifecycle;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
|
|
||||||
|
SizeConstraints = new WindowSizeConstraints
|
||||||
|
{
|
||||||
|
MinimumSize = new(300, 400)
|
||||||
|
};
|
||||||
|
|
||||||
var armoireItems = dataManager.GetExcelSheet<Cabinet>()
|
var armoireItems = dataManager.GetExcelSheet<Cabinet>()
|
||||||
.Where(x => x.RowId > 0)
|
.Where(x => x.RowId > 0)
|
||||||
@ -227,6 +233,19 @@ internal sealed class GlamourSetter : Window, IDisposable
|
|||||||
return;
|
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();
|
var ownedSets = _glamourSets.Where(x => _characterData.GlamourDresserItems.Contains(x.ItemId)).ToList();
|
||||||
ImGui.Text(
|
ImGui.Text(
|
||||||
$"Complete Sets: {ownedSets.Count} / {_glamourSets.Count(x => x.SetType != ESetType.Unobtainable || ownedSets.Contains(x))}");
|
$"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();
|
var ownedItems = GetOwnedItems();
|
||||||
DrawMissingItemHeader(glamourSets, setType, ownedSets, ownedItems);
|
DrawMissingItemHeader(glamourSets, setType, ownedSets, ownedItems);
|
||||||
|
|
||||||
|
using (ImRaii.Child("Sets"))
|
||||||
DrawSetRange(glamourSets, ownedSets, ownedItems);
|
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);
|
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)
|
HashSet<uint> ownedItems)
|
||||||
{
|
{
|
||||||
var missingItems = glamourSets
|
var missingItems = glamourSets
|
||||||
@ -300,15 +321,15 @@ internal sealed class GlamourSetter : Window, IDisposable
|
|||||||
if (setType == ESetType.PvP)
|
if (setType == ESetType.PvP)
|
||||||
{
|
{
|
||||||
ImGui.Text(
|
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(
|
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();
|
ImGui.Separator();
|
||||||
}
|
}
|
||||||
else if (setType is ESetType.MGP or ESetType.Special)
|
else if (setType is ESetType.MGP or ESetType.Special)
|
||||||
{
|
{
|
||||||
ImGui.Text(
|
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();
|
ImGui.Separator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,12 +346,13 @@ internal sealed class GlamourSetter : Window, IDisposable
|
|||||||
int ownedCount = glamourSet.Items.Count(x => ownedItems.Contains(x.ItemId));
|
int ownedCount = glamourSet.Items.Count(x => ownedItems.Contains(x.ItemId));
|
||||||
if (ownedCount == glamourSet.Items.Count)
|
if (ownedCount == glamourSet.Items.Count)
|
||||||
ImGui.TextColored(ImGuiColors.ParsedBlue, $"{glamourSet.Name} (Can be completed)");
|
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)
|
else if (ownedCount > 0)
|
||||||
ImGui.TextColored(ImGuiColors.DalamudYellow, glamourSet.Name);
|
ImGui.TextColored(ImGuiColors.DalamudYellow, glamourSet.Name);
|
||||||
else
|
else
|
||||||
ImGui.Text(glamourSet.Name);
|
ImGui.Text(glamourSet.Name);
|
||||||
|
|
||||||
|
|
||||||
using (ImRaii.PushIndent())
|
using (ImRaii.PushIndent())
|
||||||
{
|
{
|
||||||
foreach (var item in glamourSet.Items)
|
foreach (var item in glamourSet.Items)
|
||||||
@ -384,6 +406,25 @@ internal sealed class GlamourSetter : Window, IDisposable
|
|||||||
return ownedItems;
|
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)
|
private unsafe void UpdateFromGlamourDresser(AddonEvent type, AddonArgs args)
|
||||||
{
|
{
|
||||||
if (_characterData == null)
|
if (_characterData == null)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Dalamud.NET.Sdk/11.0.0">
|
<Project Sdk="Dalamud.NET.Sdk/11.0.0">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>2.0</Version>
|
<Version>2.1</Version>
|
||||||
<OutputPath>dist</OutputPath>
|
<OutputPath>dist</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user