Compare commits

...

3 Commits
v2.0 ... master

16 changed files with 91 additions and 252 deletions

View File

@ -4,6 +4,7 @@ using System.Linq;
using Gearsetter.GameData;
using Gearsetter.Model;
using LLib.GameData;
using LLib.Gear;
using Lumina.Excel.Sheets;
using Xunit;
@ -16,6 +17,10 @@ public sealed class ItemSortingTest
[Fact]
public void Test1()
{
var gearStatsCalculator = new GearStatsCalculator(_lumina.GetExcelSheet<ItemLevel>()!,
_lumina.GetExcelSheet<ExtendedBaseParam>()!,
_lumina.GetExcelSheet<Materia>()!,
_lumina.GetExcelSheet<Item>()!);
var items = _lumina.GetExcelSheet<Item>()!;
List<uint> initialItemIds =
[
@ -30,12 +35,13 @@ public sealed class ItemSortingTest
32558,
];
var itemList = new ItemList
{
ClassJob = EClassJob.Marauder,
EquipSlotCategory = EEquipSlotCategory.Ears,
ItemUiCategory = 41,
Items = initialItemIds.Select(rowId => new EquipmentItem(items.GetRow(rowId), false))
Items = initialItemIds.Select(rowId => new EquipmentItem(items.GetRow(rowId), false, gearStatsCalculator.CalculateGearStats(items.GetRow(rowId), false, [])))
.Cast<BaseItem>()
.ToList(),
};

View File

@ -1,6 +1,6 @@
using System.Collections.Generic;
using Dalamud.Configuration;
using Gearsetter.GameData;
using LLib.Gear;
namespace Gearsetter;

View File

@ -1,34 +0,0 @@
namespace Gearsetter.GameData;
internal enum EBaseParam : byte
{
None = 0,
Strength = 1,
Dexterity = 2,
Vitality = 3,
Intelligence = 4,
Mind = 5,
Piety = 6,
GP = 10,
CP = 11,
DamagePhys = 12,
DamageMag = 13,
DefensePhys = 21,
DefenseMag = 24,
Tenacity = 19,
Crit = 27,
DirectHit = 22,
Determination = 44,
SpellSpeed = 46,
SkillSpeed = 45,
Craftsmanship = 70,
Control = 71,
Gathering = 72,
Perception = 73,
}

View File

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud;
using Dalamud.Game;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
using Gearsetter.Model;
using LLib.GameData;
using LLib.Gear;
using Lumina.Excel.Sheets;
namespace Gearsetter.GameData;
@ -14,12 +14,15 @@ namespace Gearsetter.GameData;
internal sealed class GameDataHolder
{
private readonly Configuration _configuration;
private readonly GearStatsCalculator _gearStatsCalculator;
private readonly Dictionary<uint, List<EClassJob>> _classJobCategories;
private readonly IReadOnlyList<ItemList> _allItemLists;
public GameDataHolder(IDataManager dataManager, Configuration configuration)
public GameDataHolder(IDataManager dataManager, Configuration configuration,
GearStatsCalculator gearStatsCalculator)
{
_configuration = configuration;
_gearStatsCalculator = gearStatsCalculator;
_classJobCategories = dataManager.GetExcelSheet<ClassJobCategory>()
.ToDictionary(x => x.RowId, x =>
new Dictionary<EClassJob, bool>
@ -87,9 +90,6 @@ internal sealed class GameDataHolder
.ThenBy(x => x.OrderMinor)
.Select(x => (x.RowId, x.Name.ToString()))
.ToList();
Materias = dataManager.GetExcelSheet<Materia>()
.Where(x => x.RowId > 0 && Enum.IsDefined(typeof(EBaseParam), (byte)x.BaseParam.RowId))
.ToDictionary(x => x.RowId, x => new MateriaStat((EBaseParam)x.BaseParam.RowId, x.Value.ToArray()));
_allItemLists =
dataManager.GetExcelSheet<Item>()
@ -135,7 +135,6 @@ internal sealed class GameDataHolder
public IReadOnlyList<(EClassJob ClassJob, string Name)> ClassJobNames { get; }
public IReadOnlyList<(uint ItemUiCategory, string Name)> ItemUiCategoryNames { get; }
public Dictionary<EClassJob, EBaseParam> PrimaryStats { get; }
public Dictionary<uint, MateriaStat> Materias { get; set; }
public Dictionary<EBaseParam, string> StatNames { get; } = new()
{
@ -207,8 +206,14 @@ internal sealed class GameDataHolder
private IEnumerable<(EquipmentItem Item, List<EClassJob> ClassJobs)> LoadItem(Item item)
{
var classJobCategories = _classJobCategories[item.ClassJobCategory.RowId];
yield return (new EquipmentItem(item, false), classJobCategories);
yield return (
new EquipmentItem(item, false, _gearStatsCalculator.CalculateGearStats(item, false, [])),
classJobCategories);
if (item.CanBeHq)
yield return (new EquipmentItem(item, true), classJobCategories);
{
yield return (
new EquipmentItem(item, true, _gearStatsCalculator.CalculateGearStats(item, true, [])),
classJobCategories);
}
}
}

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>

View File

@ -17,6 +17,7 @@ using Gearsetter.GameData;
using Gearsetter.Model;
using Gearsetter.Windows;
using LLib.GameData;
using LLib.Gear;
using Lumina.Excel.Sheets;
using GrandCompany = FFXIVClientStructs.FFXIV.Client.UI.Agent.GrandCompany;
using InventoryItem = FFXIVClientStructs.FFXIV.Client.Game.InventoryItem;
@ -35,6 +36,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
private readonly IClientState _clientState;
private readonly GearsetterIpc _gearsetterIpc;
private readonly Configuration _configuration;
private readonly GearStatsCalculator _gearStatsCalculator;
private readonly GameDataHolder _gameDataHolder;
private readonly EquipmentBrowserWindow _equipmentBrowserWindow;
private readonly ConfigWindow _configWindow;
@ -62,7 +64,8 @@ public sealed class GearsetterPlugin : IDalamudPlugin
}
_configuration = configuration;
_gameDataHolder = new GameDataHolder(dataManager, _configuration);
_gearStatsCalculator = new GearStatsCalculator(dataManager);
_gameDataHolder = new GameDataHolder(dataManager, _configuration, _gearStatsCalculator);
_equipmentBrowserWindow = new EquipmentBrowserWindow(this, _gameDataHolder, _clientState, _chatGui);
_windowSystem.AddWindow(_equipmentBrowserWindow);
_configWindow = new ConfigWindow(_pluginInterface, _configuration);
@ -175,19 +178,19 @@ public sealed class GearsetterPlugin : IDalamudPlugin
name.Contains("Bozja", StringComparison.OrdinalIgnoreCase))
return null;
return new GearsetData(_dataManager, gearset, name);
return new GearsetData(_dataManager, _gearStatsCalculator, gearset, name);
}
internal unsafe List<RecommendedItemChange> GetRecommendedUpgrades(RaptureGearsetModule.GearsetEntry* gearset,
byte? level = null)
{
GearsetData gearsetData = new GearsetData(_dataManager, gearset, GetGearsetName(gearset));
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems = GetAllInventoryItems();
GearsetData gearsetData = new GearsetData(_dataManager, _gearStatsCalculator, gearset, GetGearsetName(gearset));
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems = GetAllInventoryItems();
return GetRecommendedUpgrades(gearsetData, inventoryItems, level);
}
private List<RecommendedItemChange> GetRecommendedUpgrades(GearsetData gearset,
Dictionary<(uint ItemId, bool Hql), List<MateriaStats>> inventoryItems, byte? level)
Dictionary<(uint ItemId, bool Hql), List<EquipmentStats>> inventoryItems, byte? level)
{
List<RecommendedItemChange> Handle(string label,
(EquipmentItem?, RaptureGearsetModule.GearsetItemIndex)[] gearsetItems,
@ -225,7 +228,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
private bool HandleGearset(GearsetData gearset,
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems, byte? level)
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems, byte? level)
{
List<RecommendedItemChange> upgrades = GetRecommendedUpgrades(gearset, inventoryItems, level);
if (upgrades.Count == 0)
@ -258,7 +261,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
private List<RecommendedItemChange> HandleGearsetItem(string label, GearsetData gearset,
(EquipmentItem? Item, RaptureGearsetModule.GearsetItemIndex Slot)[] gearsetItems,
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems,
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems,
EEquipSlotCategory equipSlotCategory, byte? level)
{
EClassJob classJob = gearset.ClassJob;
@ -338,7 +341,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
}
private List<RecommendedItemChange> HandleOffHand(GearsetData gearset,
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems, byte? level)
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems, byte? level)
{
var mainHand = gearset.MainHand;
if (mainHand == null)
@ -372,8 +375,8 @@ public sealed class GearsetterPlugin : IDalamudPlugin
if (item != null && item->ItemId == baseItem.ItemId &&
item->Flags.HasFlag(InventoryItem.ItemFlags.HighQuality) == baseItem.Hq)
{
MateriaStats expectedMateriaStats = baseItem.MateriaStats ?? new([]);
MateriaStats actualMateriaStats = FetchMateriaStats(item);
EquipmentStats expectedMateriaStats = baseItem.Stats;
EquipmentStats actualMateriaStats = FetchMateriaStats(item);
if (expectedMateriaStats == actualMateriaStats)
return new RecommendedItemChange(item->ItemId, inventoryType, i, targetSlot, text);
@ -384,9 +387,9 @@ public sealed class GearsetterPlugin : IDalamudPlugin
return new RecommendedItemChange(baseItem.ItemId, null, null, targetSlot, text);
}
internal unsafe Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> GetAllInventoryItems()
internal unsafe Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> GetAllInventoryItems()
{
Dictionary<(uint, bool), List<MateriaStats>> inventoryItems = new();
Dictionary<(uint, bool), List<EquipmentStats>> inventoryItems = new();
InventoryManager* inventoryManager = InventoryManager.Instance();
foreach (var inventoryType in _gameDataHolder.DefaultInventoryTypes)
{
@ -399,7 +402,7 @@ public sealed class GearsetterPlugin : IDalamudPlugin
var key = (item->ItemId, item->Flags.HasFlag(InventoryItem.ItemFlags.HighQuality));
if (!inventoryItems.TryGetValue(key, out var list))
{
list = new List<MateriaStats>();
list = new List<EquipmentStats>();
inventoryItems[key] = list;
}
@ -411,22 +414,8 @@ public sealed class GearsetterPlugin : IDalamudPlugin
return inventoryItems;
}
private unsafe MateriaStats FetchMateriaStats(InventoryItem* item)
{
// FIXME item->GetMateriaCount is broken on API 10, so this seems to be somewhat slow
List<(MateriaStat, byte)> materias = new();
for (int slot = 0; slot < 5; ++slot)
{
var materiaId = item->Materia[slot];
if (materiaId == 0)
break;
if (_gameDataHolder.Materias.TryGetValue(materiaId, out MateriaStat? value))
materias.Add((value, item->MateriaGrades[slot]));
}
return new MateriaStats(materias);
}
private unsafe EquipmentStats FetchMateriaStats(InventoryItem* item)
=> _gearStatsCalculator.CalculateGearStats(item);
internal unsafe byte GetLevel(EClassJob classJob)
{

View File

@ -1,10 +1,12 @@
using Gearsetter.GameData;
using System.Linq;
using Gearsetter.GameData;
using LLib.GameData;
using LLib.Gear;
using Lumina.Excel.Sheets;
namespace Gearsetter.Model;
internal abstract record BaseItem(Item Item, bool Hq, MateriaStats? MateriaStats = null)
internal abstract record BaseItem(Item Item, bool Hq, EquipmentStats Stats)
{
public Item Item { get; } = Item;
public uint ItemId { get; } = Item.RowId;
@ -17,7 +19,7 @@ internal abstract record BaseItem(Item Item, bool Hq, MateriaStats? MateriaStats
public EEquipSlotCategory EquipSlotCategory { get; } = (EEquipSlotCategory)Item.EquipSlotCategory.RowId;
public uint ItemUiCategory { get; } = Item.ItemUICategory.RowId;
public abstract EClassJob ClassJob { get; init; }
public EquipmentStats Stats { get; } = new(Item, Hq, MateriaStats);
public EquipmentStats Stats { get; } = Stats;
public int PrimaryStat { get; init; } = -1;
@ -35,15 +37,7 @@ internal abstract record BaseItem(Item Item, bool Hq, MateriaStats? MateriaStats
}
public bool HasAnyStat(params EBaseParam[] substats)
{
foreach (EBaseParam substat in substats)
{
if (Stats.Get(substat) > 0)
return true;
}
return false;
}
=> substats.Any(x => Stats.Has(x));
public bool IsCombatRelicWithoutSubstats()
{

View File

@ -1,10 +1,10 @@
using Gearsetter.GameData;
using LLib.GameData;
using LLib.GameData;
using LLib.Gear;
using Lumina.Excel.Sheets;
namespace Gearsetter.Model;
internal sealed record EquipmentItem(Item Item, bool Hq) : BaseItem(Item, Hq)
internal sealed record EquipmentItem(Item Item, bool Hq, EquipmentStats Stats) : BaseItem(Item, Hq, Stats)
{
public override EClassJob ClassJob { get; init; } = EClassJob.Adventurer;
}

View File

@ -1,63 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Gearsetter.GameData;
using Lumina.Excel.Sheets;
using LLib.Gear;
namespace Gearsetter.Model;
internal sealed class EquipmentStats
{
private readonly Dictionary<EBaseParam, short> _equipmentValues;
private readonly Dictionary<EBaseParam, short> _materiaValues;
public EquipmentStats(Item item, bool hq, MateriaStats? materiaStats)
{
_equipmentValues = Enumerable.Range(0, item.BaseParam.Count)
.Where(i => item.BaseParam[i].RowId > 0)
.ToDictionary(i => (EBaseParam)item.BaseParam[i].RowId, i => item.BaseParamValue[i]);
if (hq)
{
for (int i = 0; i < item.BaseParamSpecial.Count; ++i)
{
EBaseParam baseParam = (EBaseParam)item.BaseParamSpecial[i].RowId;
if (baseParam == EBaseParam.None)
continue;
var baseParamValue = item.BaseParamValueSpecial[i];
if (_equipmentValues.TryGetValue(baseParam, out var stat))
_equipmentValues[baseParam] = (short)(stat + baseParamValue);
else
_equipmentValues[baseParam] = baseParamValue;
}
}
_materiaValues = new();
if (materiaStats != null)
{
foreach (var materiaStat in materiaStats.Values)
{
if (_materiaValues.TryGetValue(materiaStat.Key, out var stat))
_materiaValues[materiaStat.Key] = (short)(stat + materiaStat.Value);
else
_materiaValues[materiaStat.Key] = materiaStat.Value;
}
}
}
public short Get(EBaseParam param)
{
return (short)(GetEquipment(param) + GetMateria(param));
}
public short GetEquipment(EBaseParam param)
{
_equipmentValues.TryGetValue(param, out short v);
return v;
}
public short GetMateria(EBaseParam param)
{
_materiaValues.TryGetValue(param, out short v);
return v;
}
}

View File

@ -1,40 +1,43 @@
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using LLib.GameData;
using LLib.Gear;
using Lumina.Excel.Sheets;
namespace Gearsetter.Model;
internal sealed class GearsetData
{
public unsafe GearsetData(IDataManager dataManager, RaptureGearsetModule.GearsetEntry* gearset, string name)
public unsafe GearsetData(IDataManager dataManager, GearStatsCalculator gearStatsCalculator,
RaptureGearsetModule.GearsetEntry* gearset, string name)
{
Id = gearset->Id;
ClassJob = (EClassJob)gearset->ClassJob;
Name = name;
MainHand = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.MainHand);
OffHand = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.OffHand);
Head = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Head);
Body = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Body);
Hands = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Hands);
Legs = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Legs);
Feet = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Feet);
Ears = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Ears);
Neck = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Neck);
Wrists = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.Wrists);
RingLeft = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.RingLeft);
RingRight = GetItem(dataManager, gearset, RaptureGearsetModule.GearsetItemIndex.RingRight);
MainHand = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.MainHand);
OffHand = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.OffHand);
Head = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Head);
Body = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Body);
Hands = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Hands);
Legs = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Legs);
Feet = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Feet);
Ears = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Ears);
Neck = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Neck);
Wrists = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.Wrists);
RingLeft = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.RingLeft);
RingRight = GetItem(dataManager, gearStatsCalculator, gearset, RaptureGearsetModule.GearsetItemIndex.RingRight);
}
private static unsafe EquipmentItem? GetItem(IDataManager dataManager, RaptureGearsetModule.GearsetEntry* gearset,
RaptureGearsetModule.GearsetItemIndex index)
private static unsafe EquipmentItem? GetItem(IDataManager dataManager, GearStatsCalculator gearStatsCalculator,
RaptureGearsetModule.GearsetEntry* gearset, RaptureGearsetModule.GearsetItemIndex index)
{
var gearsetItem = gearset->GetItem(index);
if (gearsetItem.ItemId == 0)
return null;
var item = dataManager.GetExcelSheet<Item>().GetRow(gearsetItem.ItemId % 1_000_000);
return new EquipmentItem(item, gearsetItem.ItemId > 1_000_000);
bool hq = gearsetItem.ItemId > 1_000_000;
return new EquipmentItem(item, hq, gearStatsCalculator.CalculateGearStats(item, hq, []));
}
public byte Id { get; }

View File

@ -1,9 +1,10 @@
using LLib.GameData;
using LLib.Gear;
using Lumina.Excel.Sheets;
namespace Gearsetter.Model;
internal sealed record InventoryItem(Item Item, bool Hq, MateriaStats MateriaStats, EClassJob ClassJob)
: BaseItem(Item, Hq, MateriaStats)
internal sealed record InventoryItem(Item Item, bool Hq, EquipmentStats Stats, EClassJob ClassJob)
: BaseItem(Item, Hq, Stats)
{
}

View File

@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using Gearsetter.GameData;
using LLib.GameData;
using LLib.Gear;
namespace Gearsetter.Model;
@ -22,7 +23,7 @@ internal sealed class ItemList
public required uint ItemUiCategory { get; init; }
public required List<BaseItem> Items { get; set; }
public EBaseParam PrimaryStat { get; set; }
public IReadOnlyList<EBaseParam> SubstatPriorities { get; set; } = new List<EBaseParam>();
public IReadOnlyList<EBaseParam> SubstatPriorities { get; private set; } = new List<EBaseParam>();
public void Sort()
{
@ -62,7 +63,7 @@ internal sealed class ItemList
}
}
public void ApplyFromInventory(Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> inventoryItems,
public void ApplyFromInventory(Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> inventoryItems,
bool includeWithoutMateria)
{
foreach (var inventoryItem in inventoryItems)
@ -72,11 +73,11 @@ internal sealed class ItemList
if (basicItem == null)
continue;
foreach (var materias in inventoryItem.Value)
foreach (var inventoryStats in inventoryItem.Value)
{
if (includeWithoutMateria || materias.Values.Count > 0)
if (includeWithoutMateria || inventoryStats.HasMateria())
Items.Add(
new InventoryItem(basicItem.Item, basicItem.Hq, materias, basicItem.ClassJob)
new InventoryItem(basicItem.Item, basicItem.Hq, inventoryStats, basicItem.ClassJob)
{
PrimaryStat = basicItem.Stats.Get(PrimaryStat)
});
@ -172,7 +173,7 @@ internal sealed class ItemList
return string.CompareOrdinal(a.Name, b.Name);
}
public static bool TryGetPreferredItemPriority(BaseItem self, BaseItem other, out byte priority)
private static bool TryGetPreferredItemPriority(BaseItem self, BaseItem other, out byte priority)
{
if (PreferredItems.TryGetValue(self.ItemId, out byte levelSelf))
{

View File

@ -1,11 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Gearsetter.GameData;
namespace Gearsetter.Model;
internal sealed class MateriaStat(EBaseParam baseParam, short[] values)
{
public EBaseParam BaseParam { get; } = baseParam;
public List<short> Values { get; } = values.ToList();
}

View File

@ -1,64 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Gearsetter.GameData;
namespace Gearsetter.Model;
internal sealed class MateriaStats : IEquatable<MateriaStats>
{
private readonly List<(EBaseParam, short)> _list;
public MateriaStats(IEnumerable<(MateriaStat Stat, byte Grade)> materias)
{
foreach (var materia in materias)
{
if (Values.TryGetValue(materia.Stat.BaseParam, out short value))
Values[materia.Stat.BaseParam] = (short)(value + materia.Stat.Values[materia.Grade]);
else
Values[materia.Stat.BaseParam] = materia.Stat.Values[materia.Grade];
++Count;
}
_list = Enum.GetValues<EBaseParam>()
.Select(x => (x, Values.GetValueOrDefault(x, (short)0)))
.Where(x => x.Item2 > 0)
.ToList();
}
public Dictionary<EBaseParam, short> Values { get; } = new();
public byte Count { get; }
public override bool Equals(object? obj)
{
return ReferenceEquals(this, obj) || obj is MateriaStats other && Equals(other);
}
public override int GetHashCode()
{
return _list.GetHashCode();
}
public bool Equals(MateriaStats? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return _list.SequenceEqual(other._list);
}
public static bool operator ==(MateriaStats? left, MateriaStats? right)
{
return Equals(left, right);
}
public static bool operator !=(MateriaStats? left, MateriaStats? right)
{
return !Equals(left, right);
}
public override string ToString()
{
return $"Materias[{string.Join(", ", _list.Select(x => $"{x.Item1}:{x.Item2}"))}]";
}
}

View File

@ -11,6 +11,7 @@ using Gearsetter.GameData;
using Gearsetter.Model;
using ImGuiNET;
using LLib.GameData;
using LLib.Gear;
using LLib.ImGui;
namespace Gearsetter.Windows;
@ -111,7 +112,7 @@ internal sealed class EquipmentBrowserWindow : LWindow
ImGui.SameLine();
ImGui.Checkbox("Hide normal quality items", ref _hideNormalQualityItems);
Dictionary<(uint ItemId, bool Hq), List<MateriaStats>> ownedItems = _plugin.GetAllInventoryItems();
Dictionary<(uint ItemId, bool Hq), List<EquipmentStats>> ownedItems = _plugin.GetAllInventoryItems();
try
{
itemList.ApplyFromInventory(ownedItems, _onlyShowOwnedItems);
@ -144,7 +145,7 @@ internal sealed class EquipmentBrowserWindow : LWindow
ImGui.PushStyleColor(ImGuiCol.HeaderHovered, hoverColor);
foreach (var item in itemList.Items.DistinctBy(x => new
{ x.ItemId, x.Hq, Materia = x.MateriaStats?.GetHashCode() }))
{ x.ItemId, x.Hq, Stats = x.Stats.GetHashCode() }))
{
if (item is not InventoryItem)
{
@ -174,9 +175,9 @@ internal sealed class EquipmentBrowserWindow : LWindow
string name = item.Name;
if (item.Hq)
name += $" {SeIconChar.HighQuality.ToIconString()}";
if (item is InventoryItem { MateriaStats: not null } inventoryItem)
if (item is InventoryItem { Stats.MateriaCount: > 0 } inventoryItem)
name +=
$" {string.Join("", Enumerable.Repeat(SeIconChar.Circle.ToIconString(), inventoryItem.MateriaStats!.Count))}";
$" {string.Join("", Enumerable.Repeat(SeIconChar.Circle.ToIconString(), inventoryItem.Stats.MateriaCount))}";
if (color != null)
ImGui.PushStyleColor(ImGuiCol.Text, color.Value);
@ -222,6 +223,12 @@ internal sealed class EquipmentBrowserWindow : LWindow
ImGui.Text(string.Create(CultureInfo.InvariantCulture, $"{estat}"));
else
ImGui.Text(string.Create(CultureInfo.InvariantCulture, $"{estat} +{mstat}"));
if (item.Stats.IsOvercapped(substat))
{
ImGui.SameLine();
ImGui.Text(SeIconChar.Debuff.ToIconString());
}
}
}
}

2
LLib

@ -1 +1 @@
Subproject commit e4bbc05ede6f6f01e7028b24614ed8cb333e909c
Subproject commit 783fea977a2524dd63e717367fc026c52efe6c23