Initial project

This commit is contained in:
Zeffuro
2025-12-20 04:04:31 +01:00
parent e59da8ab0b
commit 659c295c16
26 changed files with 923 additions and 14 deletions
+11
View File
@@ -0,0 +1,11 @@
using System.Numerics;
using KamiToolKit.Classes;
namespace AetherBags.Inventory;
public class CategoryInfo
{
public required string Name { get; set; }
public Vector4 Color { get; set; } = ColorHelper.GetColor(50);
public string Description { get; set; } = string.Empty;
}
+63
View File
@@ -0,0 +1,63 @@
using System.Collections.Generic;
using System.Linq;
using Dalamud.Game.Inventory;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
namespace AetherBags.Inventory;
public static unsafe class InventoryState
{
public static List<InventoryType> StandardInventories => [
InventoryType.Inventory1,
InventoryType.Inventory2,
InventoryType.Inventory3,
InventoryType.Inventory4,
InventoryType.EquippedItems,
InventoryType.ArmoryMainHand,
InventoryType.ArmoryHead,
InventoryType.ArmoryBody,
InventoryType.ArmoryHands,
InventoryType.ArmoryWaist,
InventoryType.ArmoryLegs,
InventoryType.ArmoryFeets,
InventoryType.ArmoryOffHand,
InventoryType.ArmoryEar,
InventoryType.ArmoryNeck,
InventoryType.ArmoryWrist,
InventoryType.ArmoryRings,
InventoryType.Currency,
InventoryType.Crystals,
InventoryType.ArmorySoulCrystal,
];
public static bool Contains(this List<InventoryType> inventoryTypes, GameInventoryType type)
=> inventoryTypes.Contains((InventoryType)type);
public static List<ItemInfo> GetInventoryItems() {
List<InventoryType> inventories = [ InventoryType.Inventory1, InventoryType.Inventory2, InventoryType.Inventory3, InventoryType.Inventory4 ];
List<InventoryItem> items = [];
foreach (var inventory in inventories) {
var container = InventoryManager.Instance()->GetInventoryContainer(inventory);
for (var index = 0; index < container->Size; ++index) {
ref var item = ref container->Items[index];
if (item.ItemId is 0) continue;
items.Add(item);
}
}
List<ItemInfo> itemInfos = [];
itemInfos.AddRange(from itemGroups in items.GroupBy(item => item.ItemId)
where itemGroups.Key is not 0
let item = itemGroups.First()
let itemCount = itemGroups.Sum(duplicateItem => duplicateItem.Quantity)
select new ItemInfo {
Item = item, ItemCount = itemCount,
});
return itemInfos;
}
}
+60
View File
@@ -0,0 +1,60 @@
using System;
using System.Numerics;
using System.Text.RegularExpressions;
using AetherBags.Extensions;
using FFXIVClientStructs.FFXIV.Client.Game;
using Lumina.Excel.Sheets;
namespace AetherBags.Inventory;
public class ItemInfo : IEquatable<ItemInfo> {
public required InventoryItem Item { get; set; }
public required int ItemCount { get; set; }
private Item ItemData => Services.DataManager.GetExcelSheet<Item>().GetRow(Item.ItemId);
public Vector4 RarityColor => ItemData.RarityColor;
public uint IconId => ItemData.Icon;
public string Name => ItemData.Name.ToString();
public int Level => ItemData.LevelEquip;
public int ItemLevel => (int) ItemData.LevelItem.RowId;
public int Rarity => ItemData.Rarity;
public int UiCategory => (int) ItemData.ItemUICategory.RowId;
private string Description => ItemData.Description.ToString();
public bool IsRegexMatch(string searchTerms) {
const RegexOptions regexOptions = RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;
if (Regex.IsMatch(Name, searchTerms, regexOptions)) return true;
if (Regex.IsMatch(Description, searchTerms, regexOptions)) return true;
if (Regex.IsMatch(Level.ToString(), searchTerms, regexOptions)) return true;
if (Regex.IsMatch(ItemLevel.ToString(), searchTerms, regexOptions)) return true;
return false;
}
public bool Equals(ItemInfo? other) {
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return Item.ItemId.Equals(other.Item.ItemId) && ItemCount == other.ItemCount;
}
public override bool Equals(object? obj) {
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((ItemInfo) obj);
}
public override int GetHashCode()
// ReSharper disable NonReadonlyMemberInGetHashCode
=> HashCode.Combine(Item.ItemId, ItemCount);
// ReSharper restore NonReadonlyMemberInGetHashCode
}