From 652d58374797158e51f47fea138d6ff35c0109f1 Mon Sep 17 00:00:00 2001 From: Zeffuro Date: Wed, 14 Jan 2026 04:24:34 +0100 Subject: [PATCH] Update KTK, rework some things --- .../AddonCategoryConfigurationWindow.cs | 65 +++++++++++-------- AetherBags/Addons/CategoryListItemNode.cs | 14 ++++ AetherBags/Addons/CategoryWrapper.cs | 22 ++----- AetherBags/Addons/InventoryAddonBase.cs | 2 +- .../Addons/InventoryAddonContextMenu.cs | 2 +- AetherBags/Extensions/LoggerExtensions.cs | 11 +++- AetherBags/Nodes/Color/ColorInputRow.cs | 1 + AetherBags/Nodes/Color/ColorPreviewNode.cs | 2 +- .../General/ImportExportResetNode.cs | 1 + .../Layout/CompactLookaheadNode.cs | 2 +- .../Nodes/Inventory/InventoryCategoryNode.cs | 2 +- .../Inventory/InventoryNotificationNode.cs | 4 +- .../Inventory/LootedItemsCategoryNode.cs | 8 ++- .../Nodes/Layout/DeferrableLayoutListNode.cs | 4 +- AetherBags/Plugin.cs | 6 +- KamiToolKit | 2 +- 16 files changed, 85 insertions(+), 63 deletions(-) create mode 100644 AetherBags/Addons/CategoryListItemNode.cs diff --git a/AetherBags/Addons/AddonCategoryConfigurationWindow.cs b/AetherBags/Addons/AddonCategoryConfigurationWindow.cs index 484e1e4..8c2cb68 100644 --- a/AetherBags/Addons/AddonCategoryConfigurationWindow.cs +++ b/AetherBags/Addons/AddonCategoryConfigurationWindow.cs @@ -14,7 +14,7 @@ namespace AetherBags.Addons; public class AddonCategoryConfigurationWindow : NativeAddon { - private ModifyListNode? _selectionListNode; + private ModifyListNode? _selectionListNode; private VerticalLineNode? _separatorLine; private CategoryConfigurationNode? _configNode; private TextNode? _nothingSelectedTextNode; @@ -28,21 +28,24 @@ public class AddonCategoryConfigurationWindow : NativeAddon { _categoryWrappers = CreateCategoryWrappers(); - _selectionListNode = new ModifyListNode + _selectionListNode = new ModifyListNode { Position = ContentStartPosition, - Size = new Vector2(250.0f, ContentSize.Y), - SelectionOptions = _categoryWrappers, - OnOptionChanged = OnOptionChanged, + Size = ContentSize with { X = 250.0f }, + Options = _categoryWrappers, + SelectionChanged = OnOptionChanged, AddNewEntry = OnAddNewCategory, RemoveEntry = OnRemoveCategory, + SortOptions = [ "Order" ], + ItemComparer = (left, right, mode) => left.Compare(right, mode), + IsSearchMatch = (data, search) => data.GetLabel().Contains(search, global::System.StringComparison.OrdinalIgnoreCase) }; _selectionListNode.AttachNode(this); _separatorLine = new VerticalLineNode { Position = ContentStartPosition + new Vector2(250.0f + 8.0f, 0.0f), - Size = new Vector2(4.0f, ContentSize.Y), + Size = ContentSize with { X = 4.0f }, }; _separatorLine.AttachNode(this); @@ -78,6 +81,24 @@ public class AddonCategoryConfigurationWindow : NativeAddon .ToList(); } + private void OnAddNewCategory() + { + var newCategory = new UserCategoryDefinition + { + Name = $"New Category {System.Config.Categories.UserCategories.Count + 1}", + Order = System.Config.Categories.UserCategories.Count, + }; + + System.Config.Categories.UserCategories.Add(newCategory); + + var newWrapper = new CategoryWrapper(newCategory); + _categoryWrappers.Add(newWrapper); + + RefreshSelectionList(); + _selectionListNode?.RefreshList(); + InventoryOrchestrator.RefreshAll(updateMaps: true); + } + private void OnOptionChanged(CategoryWrapper? newOption) { if (_configNode is null) return; @@ -99,29 +120,11 @@ public class AddonCategoryConfigurationWindow : NativeAddon if (_pendingSelectionListRefresh) { _pendingSelectionListRefresh = false; - _selectionListNode?.UpdateList(); + _selectionListNode?.RefreshList(); } } } - private void OnAddNewCategory(ModifyListNode listNode) - { - var newCategory = new UserCategoryDefinition - { - Name = $"New Category {System.Config.Categories.UserCategories.Count + 1}", - Order = System.Config.Categories.UserCategories.Count, - }; - - System.Config.Categories.UserCategories.Add(newCategory); - - var newWrapper = new CategoryWrapper(newCategory); - _categoryWrappers.Add(newWrapper); - listNode.AddOption(newWrapper); - - RefreshSelectionList(); - InventoryOrchestrator.RefreshAll(updateMaps: true); - } - private void OnRemoveCategory(CategoryWrapper categoryWrapper) { if (categoryWrapper.CategoryDefinition is null) return; @@ -146,6 +149,16 @@ public class AddonCategoryConfigurationWindow : NativeAddon return; } - _selectionListNode?.UpdateList(); + _selectionListNode?.RefreshList(); + } + + protected override unsafe void OnFinalize(AtkUnitBase* addon) + { + _selectionListNode?.Dispose(); + _selectionListNode = null; + + _configNode?.Dispose(); + _configNode = null; + base.OnFinalize(addon); } } \ No newline at end of file diff --git a/AetherBags/Addons/CategoryListItemNode.cs b/AetherBags/Addons/CategoryListItemNode.cs new file mode 100644 index 0000000..2933d7a --- /dev/null +++ b/AetherBags/Addons/CategoryListItemNode.cs @@ -0,0 +1,14 @@ +using KamiToolKit.Premade.GenericSearchListItemNodes; + +namespace AetherBags.Addons; + +public class CategoryListItemNode : GenericListItemNode +{ + protected override uint GetIconId(CategoryWrapper data) => data.GetIconId() ?? 0; + + protected override string GetLabelText(CategoryWrapper data) => data.GetLabel(); + + protected override string GetSubLabelText(CategoryWrapper data) => data.GetSubLabel(); + + protected override uint? GetId(CategoryWrapper data) => data.GetId(); +} \ No newline at end of file diff --git a/AetherBags/Addons/CategoryWrapper.cs b/AetherBags/Addons/CategoryWrapper.cs index 7729881..a3f78ad 100644 --- a/AetherBags/Addons/CategoryWrapper.cs +++ b/AetherBags/Addons/CategoryWrapper.cs @@ -1,17 +1,14 @@ using AetherBags.Configuration; using AetherBags.Inventory.Categories; -using KamiToolKit.Premade; namespace AetherBags.Addons; -public class CategoryWrapper(UserCategoryDefinition categoryDefinition) : IInfoNodeData +// Removed IInfoNodeData implementation +public class CategoryWrapper(UserCategoryDefinition categoryDefinition) { public UserCategoryDefinition? CategoryDefinition { get; } = categoryDefinition; - public string GetLabel() { - - return CategoryDefinition!.Name; - } + public string GetLabel() => CategoryDefinition!.Name; public string GetSubLabel() { if(UserCategoryMatcher.IsCatchAll(CategoryDefinition!)) return " No valid rules!"; @@ -20,16 +17,9 @@ public class CategoryWrapper(UserCategoryDefinition categoryDefinition) : IInfoN public uint? GetId() => null; - public uint? GetIconId() { - return 0; - } + public uint? GetIconId() => 0; - public string? GetTexturePath() - => null; - - public int Compare(IInfoNodeData other, string sortingMode) { - if (other is not CategoryWrapper otherWrapper) return 0; - - return CategoryDefinition!.Order.CompareTo(otherWrapper.CategoryDefinition!.Order); + public int Compare(CategoryWrapper other, string sortingMode) { + return CategoryDefinition!.Order.CompareTo(other.CategoryDefinition!.Order); } } \ No newline at end of file diff --git a/AetherBags/Addons/InventoryAddonBase.cs b/AetherBags/Addons/InventoryAddonBase.cs index 1c756f8..522955b 100644 --- a/AetherBags/Addons/InventoryAddonBase.cs +++ b/AetherBags/Addons/InventoryAddonBase.cs @@ -17,7 +17,7 @@ using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Component.GUI; using KamiToolKit; using KamiToolKit.Classes; -using KamiToolKit.Classes.ContextMenu; +using KamiToolKit.ContextMenu; using KamiToolKit.Nodes; namespace AetherBags.Addons; diff --git a/AetherBags/Addons/InventoryAddonContextMenu.cs b/AetherBags/Addons/InventoryAddonContextMenu.cs index 3824ded..366be17 100644 --- a/AetherBags/Addons/InventoryAddonContextMenu.cs +++ b/AetherBags/Addons/InventoryAddonContextMenu.cs @@ -2,7 +2,7 @@ using AetherBags.Configuration; using AetherBags.Inventory; using AetherBags.Inventory.Context; using FFXIVClientStructs.FFXIV.Client.UI.Agent; -using KamiToolKit.Classes.ContextMenu; +using KamiToolKit.ContextMenu; namespace AetherBags.Addons; diff --git a/AetherBags/Extensions/LoggerExtensions.cs b/AetherBags/Extensions/LoggerExtensions.cs index dce0eae..3758e25 100644 --- a/AetherBags/Extensions/LoggerExtensions.cs +++ b/AetherBags/Extensions/LoggerExtensions.cs @@ -1,22 +1,27 @@ +using System.Diagnostics; +using Dalamud.Plugin.Services; + namespace AetherBags.Extensions; public static class LoggerExtensions { - extension(object logger) + extension(IPluginLog logger) { + [Conditional("DEBUG")] public void DebugOnly(string message) { if (System.Config?.General?.DebugEnabled == true) { - Services.Logger.Debug(message); + logger.Debug(message); } } + [Conditional("DEBUG")] public void DebugOnly(string message, params object[] args) { if (System.Config?.General?.DebugEnabled == true) { - Services.Logger.Debug(message, args); + logger.Debug(message, args); } } } diff --git a/AetherBags/Nodes/Color/ColorInputRow.cs b/AetherBags/Nodes/Color/ColorInputRow.cs index 16f2961..582d2bd 100644 --- a/AetherBags/Nodes/Color/ColorInputRow.cs +++ b/AetherBags/Nodes/Color/ColorInputRow.cs @@ -3,6 +3,7 @@ using System.Numerics; using FFXIVClientStructs.FFXIV.Component.GUI; using KamiToolKit.Nodes; using KamiToolKit.Premade.Addons; +using KamiToolKit.Premade.Color; namespace AetherBags.Nodes.Color; diff --git a/AetherBags/Nodes/Color/ColorPreviewNode.cs b/AetherBags/Nodes/Color/ColorPreviewNode.cs index 871c896..d929efa 100644 --- a/AetherBags/Nodes/Color/ColorPreviewNode.cs +++ b/AetherBags/Nodes/Color/ColorPreviewNode.cs @@ -2,7 +2,7 @@ using System.Drawing; using System.IO; using System.Numerics; using Dalamud.Interface; -using KamiToolKit.Classes; +using KamiToolKit.Enums; using KamiToolKit.Nodes; namespace AetherBags.Nodes.Color; diff --git a/AetherBags/Nodes/Configuration/General/ImportExportResetNode.cs b/AetherBags/Nodes/Configuration/General/ImportExportResetNode.cs index ed9ab36..cac1e17 100644 --- a/AetherBags/Nodes/Configuration/General/ImportExportResetNode.cs +++ b/AetherBags/Nodes/Configuration/General/ImportExportResetNode.cs @@ -3,6 +3,7 @@ using AetherBags.Helpers; using AetherBags.Inventory; using Dalamud.Game.ClientState.Keys; using KamiToolKit.Classes; +using KamiToolKit.Enums; using KamiToolKit.Nodes; namespace AetherBags.Nodes.Configuration.General; diff --git a/AetherBags/Nodes/Configuration/Layout/CompactLookaheadNode.cs b/AetherBags/Nodes/Configuration/Layout/CompactLookaheadNode.cs index 5c2e597..a98b783 100644 --- a/AetherBags/Nodes/Configuration/Layout/CompactLookaheadNode.cs +++ b/AetherBags/Nodes/Configuration/Layout/CompactLookaheadNode.cs @@ -1,9 +1,9 @@ using AetherBags.Configuration; -using KamiToolKit.Classes.Timelines; using KamiToolKit.Nodes; using System.Numerics; using AetherBags.Inventory; using FFXIVClientStructs.FFXIV.Component.GUI; +using KamiToolKit.Timelines; namespace AetherBags.Nodes.Configuration.Layout; diff --git a/AetherBags/Nodes/Inventory/InventoryCategoryNode.cs b/AetherBags/Nodes/Inventory/InventoryCategoryNode.cs index e1af79d..0a26458 100644 --- a/AetherBags/Nodes/Inventory/InventoryCategoryNode.cs +++ b/AetherBags/Nodes/Inventory/InventoryCategoryNode.cs @@ -61,7 +61,7 @@ public class InventoryCategoryNode : InventoryCategoryNodeBase _categoryNameTextNode.TextFlags |= TextFlags.OverflowHidden | TextFlags.Ellipsis; _categoryNameTextNode.TextFlags &= ~(TextFlags.WordWrap | TextFlags.MultiLine); - _categoryNameTextNode.AddFlags(NodeFlags.EmitsEvents | NodeFlags.HasCollision); + _categoryNameTextNode.AddNodeFlags(NodeFlags.EmitsEvents | NodeFlags.HasCollision); _categoryNameTextNode.AttachNode(this); _itemGridNode = new HybridDirectionalFlexNode diff --git a/AetherBags/Nodes/Inventory/InventoryNotificationNode.cs b/AetherBags/Nodes/Inventory/InventoryNotificationNode.cs index 8b26f29..68d1a2a 100644 --- a/AetherBags/Nodes/Inventory/InventoryNotificationNode.cs +++ b/AetherBags/Nodes/Inventory/InventoryNotificationNode.cs @@ -2,8 +2,8 @@ using System.Numerics; using AetherBags.Inventory.Context; using FFXIVClientStructs.FFXIV.Component.GUI; using KamiToolKit.Classes; -using KamiToolKit.Classes.Timelines; using KamiToolKit.Nodes; +using KamiToolKit.Timelines; namespace AetherBags.Nodes.Inventory; @@ -13,8 +13,6 @@ public sealed class InventoryNotificationNode : SimpleComponentNode private readonly TextNode titleTextNode; private readonly TextNode messageTextNode; - private static readonly InventoryNotificationState NotificationState = new(); - public InventoryNotificationNode() { AddTimeline(ParentLabels); diff --git a/AetherBags/Nodes/Inventory/LootedItemsCategoryNode.cs b/AetherBags/Nodes/Inventory/LootedItemsCategoryNode.cs index 99f6688..cd55089 100644 --- a/AetherBags/Nodes/Inventory/LootedItemsCategoryNode.cs +++ b/AetherBags/Nodes/Inventory/LootedItemsCategoryNode.cs @@ -5,6 +5,7 @@ using System.Runtime.CompilerServices; using AetherBags.Inventory.Items; using AetherBags.Nodes.Layout; using FFXIVClientStructs.FFXIV.Component.GUI; +using KamiToolKit.Classes; using KamiToolKit.Nodes; namespace AetherBags.Nodes.Inventory; @@ -62,7 +63,7 @@ public class LootedItemsCategoryNode : InventoryCategoryNodeBase AlignmentType = AlignmentType.Left, String = "Recently Looted", TextFlags = TextFlags.OverflowHidden | TextFlags.Ellipsis, - TextColor = new Vector4(0.9f, 0.8f, 0.5f, 1.0f), // Gold-ish color + TextColor = ColorHelper.GetColor(26), // Gold-ish color }; _headerTextNode.AddEvent(AtkEventType.MouseOver, BeginHeaderHover); @@ -71,7 +72,7 @@ public class LootedItemsCategoryNode : InventoryCategoryNodeBase _headerTextNode.TextFlags |= TextFlags.OverflowHidden | TextFlags.Ellipsis; _headerTextNode.TextFlags &= ~(TextFlags.WordWrap | TextFlags.MultiLine); - _headerTextNode.AddFlags(NodeFlags.EmitsEvents | NodeFlags.HasCollision); + _headerTextNode.AddNodeFlags(NodeFlags.EmitsEvents | NodeFlags.HasCollision); _headerTextNode.AttachNode(this); _clearButton = new CircleButtonNode @@ -197,7 +198,7 @@ public class LootedItemsCategoryNode : InventoryCategoryNodeBase private void SyncItemGrid() { - _itemGridNode.SyncWithListDataByKey( + _itemGridNode.SyncWithListDataByKey( dataList: _lootedItems, getKeyFromData: item => item.Index, getKeyFromNode: node => node.LootedItem?.Index ?? -1, @@ -221,6 +222,7 @@ public class LootedItemsCategoryNode : InventoryCategoryNodeBase private void OnItemDismissed(LootedItemDisplayNode node) { + if(node.LootedItem is null) return; int index = node.LootedItem.Index; OnDismissItem?.Invoke(index); } diff --git a/AetherBags/Nodes/Layout/DeferrableLayoutListNode.cs b/AetherBags/Nodes/Layout/DeferrableLayoutListNode.cs index 3c5f43d..12da585 100644 --- a/AetherBags/Nodes/Layout/DeferrableLayoutListNode.cs +++ b/AetherBags/Nodes/Layout/DeferrableLayoutListNode.cs @@ -49,9 +49,9 @@ public abstract class DeferrableLayoutListNode : SimpleComponentNode set { if (value) - AddFlags(NodeFlags.Clip); + AddNodeFlags(NodeFlags.Clip); else - RemoveFlags(NodeFlags.Clip); + RemoveNodeFlags(NodeFlags.Clip); } } diff --git a/AetherBags/Plugin.cs b/AetherBags/Plugin.cs index cac7b99..1da387c 100644 --- a/AetherBags/Plugin.cs +++ b/AetherBags/Plugin.cs @@ -99,10 +99,8 @@ public class Plugin : IDalamudPlugin System.Config = Util.LoadConfigOrDefault(); System.LootedItemsTracker.Enable(); -#if DEBUG - System.AddonInventoryWindow.Toggle(); - System.AddonConfigurationWindow.Toggle(); -#endif + System.AddonInventoryWindow.DebugOpen(); + System.AddonConfigurationWindow.DebugOpen(); } private void OnLogout(int type, int code) diff --git a/KamiToolKit b/KamiToolKit index 5886600..30789be 160000 --- a/KamiToolKit +++ b/KamiToolKit @@ -1 +1 @@ -Subproject commit 5886600a043640588a7e89eba35d6385b923db6c +Subproject commit 30789be03b5926ac065677cda72055a12da9926c