Include free inventory slots in character stats

This commit is contained in:
Liza 2024-03-24 10:21:26 +01:00
parent 1174413b9a
commit 4f9bc6cbe4
Signed by: liza
GPG Key ID: 7199F8D727D55F67
6 changed files with 15 additions and 2 deletions

View File

@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Allagan/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/UserDictionary/Words/=Allagan/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ceruleum/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@ -5,6 +5,7 @@ using Dalamud.Plugin;
using Dalamud.Plugin.Ipc; using Dalamud.Plugin.Ipc;
using Dalamud.Plugin.Ipc.Exceptions; using Dalamud.Plugin.Ipc.Exceptions;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
using LLib; using LLib;
namespace Influx.AllaganTools; namespace Influx.AllaganTools;
@ -129,6 +130,7 @@ internal sealed class AllaganToolsIpc : IDisposable
Ventures = inv.Sum(21072), Ventures = inv.Sum(21072),
CeruleumTanks = inv.Sum(10155), CeruleumTanks = inv.Sum(10155),
RepairKits = inv.Sum(10373), RepairKits = inv.Sum(10373),
FreeSlots = inv.FreeInventorySlots,
}; };
}); });
} }
@ -144,5 +146,7 @@ internal sealed class AllaganToolsIpc : IDisposable
private sealed class InventoryWrapper(IEnumerable<InventoryItem> items) private sealed class InventoryWrapper(IEnumerable<InventoryItem> items)
{ {
public long Sum(int itemId) => items.Where(x => x.ItemId == itemId).Sum(x => x.Quantity); public long Sum(int itemId) => items.Where(x => x.ItemId == itemId).Sum(x => x.Quantity);
public int FreeInventorySlots => 140 - items.Count(x => x.Category == 1);
} }
} }

View File

@ -10,4 +10,5 @@ internal struct Currencies
public long Ventures { get; init; } public long Ventures { get; init; }
public long CeruleumTanks { get; init; } public long CeruleumTanks { get; init; }
public long RepairKits { get; init; } public long RepairKits { get; init; }
public int FreeSlots { get; init; }
} }

View File

@ -27,5 +27,6 @@ internal sealed class Inventory
.SelectMany(x => x.Cast<object?>()) .SelectMany(x => x.Cast<object?>())
.Where(x => x != null) .Where(x => x != null)
.Select(x => new InventoryItem(x!)) .Select(x => new InventoryItem(x!))
.Where(x => x.ItemId != 0)
.ToList(); .ToList();
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using FFXIVClientStructs.FFXIV.Client.Game;
namespace Influx.AllaganTools; namespace Influx.AllaganTools;
@ -7,10 +8,14 @@ internal sealed class InventoryItem
public InventoryItem(object @delegate) public InventoryItem(object @delegate)
{ {
ArgumentNullException.ThrowIfNull(@delegate); ArgumentNullException.ThrowIfNull(@delegate);
Category = (int)@delegate.GetType().GetField("SortedCategory")!.GetValue(@delegate)!;
Container = (int)@delegate.GetType().GetField("SortedContainer")!.GetValue(@delegate)!;
ItemId = (uint)@delegate.GetType().GetField("ItemId")!.GetValue(@delegate)!; ItemId = (uint)@delegate.GetType().GetField("ItemId")!.GetValue(@delegate)!;
Quantity = (uint)@delegate.GetType().GetField("Quantity")!.GetValue(@delegate)!; Quantity = (uint)@delegate.GetType().GetField("Quantity")!.GetValue(@delegate)!;
} }
public int Category { get; }
public int Container { get; }
public uint ItemId { get; } public uint ItemId { get; }
public uint Quantity { get; } public uint Quantity { get; }
} }

View File

@ -171,7 +171,8 @@ internal sealed class InfluxStatisticsClient : IDisposable
.Field("mgp", localStats?.MGP ?? 0) .Field("mgp", localStats?.MGP ?? 0)
.Field("ventures", currencies.Ventures) .Field("ventures", currencies.Ventures)
.Field("ceruleum_tanks", currencies.CeruleumTanks) .Field("ceruleum_tanks", currencies.CeruleumTanks)
.Field("repair_kits", currencies.RepairKits); .Field("repair_kits", currencies.RepairKits)
.Field("free_inventory", currencies.FreeSlots);
if (localStats != null) if (localStats != null)
{ {