Basic Saddlebags

This commit is contained in:
Zeffuro
2025-12-30 01:25:57 +01:00
parent acdd79f73a
commit 5f73a47fee
9 changed files with 81 additions and 9 deletions
+25
View File
@@ -7,6 +7,7 @@ using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using KamiToolKit.Classes;
using KamiToolKit.Nodes;
namespace AetherBags.Addons;
@@ -14,16 +15,20 @@ namespace AetherBags.Addons;
public unsafe class AddonSaddleBagWindow : InventoryAddonBase
{
private readonly SaddleBagState _inventoryState = new();
private TextNode _slotCounterNode = null!;
protected override InventoryStateBase InventoryState => _inventoryState;
protected override bool HasFooter => false;
protected override bool HasSlotCounter => true;
protected override float MinWindowWidth => 400;
protected override float MaxWindowWidth => 600;
protected override void OnSetup(AtkUnitBase* addon)
{
WindowNode?.AddColor = new Vector3(-16f / 255f, -4f / 255f, 8f / 255f);
CategoriesNode = new WrappingGridNode<InventoryCategoryNode>
{
Position = ContentStartPosition,
@@ -64,6 +69,19 @@ public unsafe class AddonSaddleBagWindow : InventoryAddonBase
};
SettingsButtonNode.AttachNode(this);
_slotCounterNode = new TextNode
{
Position = new Vector2(Size.X - 10, 0),
Size = new Vector2(82, 20),
AlignmentType = AlignmentType.Right,
FontType = FontType.MiedingerMed,
TextFlags = TextFlags.Glare,
TextColor = ColorHelper.GetColor(50),
TextOutlineColor = ColorHelper.GetColor(32) // Could also be Color 65
};
_slotCounterNode.AttachNode(this);
SlotCounterNode = _slotCounterNode;
LayoutContent();
Services.AddonLifecycle.RegisterListener(AddonEvent.PostRequestedUpdate, "InventoryBuddy", OnSaddleBagUpdate);
@@ -74,6 +92,13 @@ public unsafe class AddonSaddleBagWindow : InventoryAddonBase
base.OnSetup(addon);
}
protected override void RefreshCategoriesCore(bool autosize)
{
_slotCounterNode.String = _inventoryState.GetEmptySlotsString();
base.RefreshCategoriesCore(autosize);
}
protected override void OnUpdate(AtkUnitBase* addon)
{
if (RefreshQueued)
+11 -3
View File
@@ -21,6 +21,7 @@ public abstract unsafe class InventoryAddonBase : NativeAddon
protected WrappingGridNode<InventoryCategoryNode> CategoriesNode = null!;
protected TextInputWithHintNode SearchInputNode = null!;
protected InventoryFooterNode FooterNode = null!;
protected TextNode? SlotCounterNode { get; set; }
protected CircleButtonNode SettingsButtonNode = null!;
protected virtual float MinWindowWidth => 600;
@@ -41,6 +42,7 @@ public abstract unsafe class InventoryAddonBase : NativeAddon
protected virtual bool HasFooter => true;
protected virtual bool HasPinning => true;
protected virtual bool HasSlotCounter => false;
public void ManualInventoryRefresh()
{
@@ -127,10 +129,16 @@ public abstract unsafe class InventoryAddonBase : NativeAddon
Vector2 contentPos = ContentStartPosition;
Vector2 contentSize = ContentSize;
float footerH = HasFooter || HasSlotCounter ? FooterHeight : 0;
if (HasFooter)
{
FooterNode.Position = new Vector2(contentPos.X, contentPos.Y + contentSize.Y - FooterHeight);
FooterNode.Size = new Vector2(contentSize.X, FooterHeight);
FooterNode.Position = new Vector2(contentPos.X, contentPos.Y + contentSize.Y - footerH);
FooterNode.Size = new Vector2(contentSize.X, footerH);
}
else if (HasSlotCounter && SlotCounterNode != null)
{
SlotCounterNode.Position = new Vector2(contentSize.X -80f, contentPos.Y + contentSize.Y - footerH + 4f);
}
float gridH = contentSize.Y - (HasFooter ? FooterHeight + FooterTopSpacing : 0);
@@ -168,7 +176,7 @@ public abstract unsafe class InventoryAddonBase : NativeAddon
float contentWidth = finalWidth - (ContentStartPosition.X * 2);
float footerSpace = HasFooter ? FooterHeight + FooterTopSpacing : 0;
float footerSpace = HasFooter || HasSlotCounter ? FooterHeight + FooterTopSpacing : 0;
float gridBudget = Math.Max(0f, MaxWindowHeight - footerSpace);
CategoriesNode.Position = ContentStartPosition;