Update KTK, rework some things

This commit is contained in:
Zeffuro
2026-01-14 04:24:34 +01:00
parent 2172ff0a51
commit 652d583747
16 changed files with 85 additions and 63 deletions
@@ -14,7 +14,7 @@ namespace AetherBags.Addons;
public class AddonCategoryConfigurationWindow : NativeAddon public class AddonCategoryConfigurationWindow : NativeAddon
{ {
private ModifyListNode<CategoryWrapper>? _selectionListNode; private ModifyListNode<CategoryWrapper, CategoryListItemNode>? _selectionListNode;
private VerticalLineNode? _separatorLine; private VerticalLineNode? _separatorLine;
private CategoryConfigurationNode? _configNode; private CategoryConfigurationNode? _configNode;
private TextNode? _nothingSelectedTextNode; private TextNode? _nothingSelectedTextNode;
@@ -28,21 +28,24 @@ public class AddonCategoryConfigurationWindow : NativeAddon
{ {
_categoryWrappers = CreateCategoryWrappers(); _categoryWrappers = CreateCategoryWrappers();
_selectionListNode = new ModifyListNode<CategoryWrapper> _selectionListNode = new ModifyListNode<CategoryWrapper, CategoryListItemNode>
{ {
Position = ContentStartPosition, Position = ContentStartPosition,
Size = new Vector2(250.0f, ContentSize.Y), Size = ContentSize with { X = 250.0f },
SelectionOptions = _categoryWrappers, Options = _categoryWrappers,
OnOptionChanged = OnOptionChanged, SelectionChanged = OnOptionChanged,
AddNewEntry = OnAddNewCategory, AddNewEntry = OnAddNewCategory,
RemoveEntry = OnRemoveCategory, 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); _selectionListNode.AttachNode(this);
_separatorLine = new VerticalLineNode _separatorLine = new VerticalLineNode
{ {
Position = ContentStartPosition + new Vector2(250.0f + 8.0f, 0.0f), 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); _separatorLine.AttachNode(this);
@@ -78,6 +81,24 @@ public class AddonCategoryConfigurationWindow : NativeAddon
.ToList(); .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) private void OnOptionChanged(CategoryWrapper? newOption)
{ {
if (_configNode is null) return; if (_configNode is null) return;
@@ -99,29 +120,11 @@ public class AddonCategoryConfigurationWindow : NativeAddon
if (_pendingSelectionListRefresh) if (_pendingSelectionListRefresh)
{ {
_pendingSelectionListRefresh = false; _pendingSelectionListRefresh = false;
_selectionListNode?.UpdateList(); _selectionListNode?.RefreshList();
} }
} }
} }
private void OnAddNewCategory(ModifyListNode<CategoryWrapper> 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) private void OnRemoveCategory(CategoryWrapper categoryWrapper)
{ {
if (categoryWrapper.CategoryDefinition is null) return; if (categoryWrapper.CategoryDefinition is null) return;
@@ -146,6 +149,16 @@ public class AddonCategoryConfigurationWindow : NativeAddon
return; return;
} }
_selectionListNode?.UpdateList(); _selectionListNode?.RefreshList();
}
protected override unsafe void OnFinalize(AtkUnitBase* addon)
{
_selectionListNode?.Dispose();
_selectionListNode = null;
_configNode?.Dispose();
_configNode = null;
base.OnFinalize(addon);
} }
} }
+14
View File
@@ -0,0 +1,14 @@
using KamiToolKit.Premade.GenericSearchListItemNodes;
namespace AetherBags.Addons;
public class CategoryListItemNode : GenericListItemNode<CategoryWrapper>
{
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();
}
+6 -16
View File
@@ -1,17 +1,14 @@
using AetherBags.Configuration; using AetherBags.Configuration;
using AetherBags.Inventory.Categories; using AetherBags.Inventory.Categories;
using KamiToolKit.Premade;
namespace AetherBags.Addons; namespace AetherBags.Addons;
public class CategoryWrapper(UserCategoryDefinition categoryDefinition) : IInfoNodeData // Removed IInfoNodeData implementation
public class CategoryWrapper(UserCategoryDefinition categoryDefinition)
{ {
public UserCategoryDefinition? CategoryDefinition { get; } = categoryDefinition; public UserCategoryDefinition? CategoryDefinition { get; } = categoryDefinition;
public string GetLabel() { public string GetLabel() => CategoryDefinition!.Name;
return CategoryDefinition!.Name;
}
public string GetSubLabel() { public string GetSubLabel() {
if(UserCategoryMatcher.IsCatchAll(CategoryDefinition!)) return " No valid rules!"; if(UserCategoryMatcher.IsCatchAll(CategoryDefinition!)) return " No valid rules!";
@@ -20,16 +17,9 @@ public class CategoryWrapper(UserCategoryDefinition categoryDefinition) : IInfoN
public uint? GetId() => null; public uint? GetId() => null;
public uint? GetIconId() { public uint? GetIconId() => 0;
return 0;
}
public string? GetTexturePath() public int Compare(CategoryWrapper other, string sortingMode) {
=> null; return CategoryDefinition!.Order.CompareTo(other.CategoryDefinition!.Order);
public int Compare(IInfoNodeData other, string sortingMode) {
if (other is not CategoryWrapper otherWrapper) return 0;
return CategoryDefinition!.Order.CompareTo(otherWrapper.CategoryDefinition!.Order);
} }
} }
+1 -1
View File
@@ -17,7 +17,7 @@ using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using KamiToolKit; using KamiToolKit;
using KamiToolKit.Classes; using KamiToolKit.Classes;
using KamiToolKit.Classes.ContextMenu; using KamiToolKit.ContextMenu;
using KamiToolKit.Nodes; using KamiToolKit.Nodes;
namespace AetherBags.Addons; namespace AetherBags.Addons;
@@ -2,7 +2,7 @@ using AetherBags.Configuration;
using AetherBags.Inventory; using AetherBags.Inventory;
using AetherBags.Inventory.Context; using AetherBags.Inventory.Context;
using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using KamiToolKit.Classes.ContextMenu; using KamiToolKit.ContextMenu;
namespace AetherBags.Addons; namespace AetherBags.Addons;
+8 -3
View File
@@ -1,22 +1,27 @@
using System.Diagnostics;
using Dalamud.Plugin.Services;
namespace AetherBags.Extensions; namespace AetherBags.Extensions;
public static class LoggerExtensions public static class LoggerExtensions
{ {
extension(object logger) extension(IPluginLog logger)
{ {
[Conditional("DEBUG")]
public void DebugOnly(string message) public void DebugOnly(string message)
{ {
if (System.Config?.General?.DebugEnabled == true) if (System.Config?.General?.DebugEnabled == true)
{ {
Services.Logger.Debug(message); logger.Debug(message);
} }
} }
[Conditional("DEBUG")]
public void DebugOnly(string message, params object[] args) public void DebugOnly(string message, params object[] args)
{ {
if (System.Config?.General?.DebugEnabled == true) if (System.Config?.General?.DebugEnabled == true)
{ {
Services.Logger.Debug(message, args); logger.Debug(message, args);
} }
} }
} }
+1
View File
@@ -3,6 +3,7 @@ using System.Numerics;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using KamiToolKit.Nodes; using KamiToolKit.Nodes;
using KamiToolKit.Premade.Addons; using KamiToolKit.Premade.Addons;
using KamiToolKit.Premade.Color;
namespace AetherBags.Nodes.Color; namespace AetherBags.Nodes.Color;
+1 -1
View File
@@ -2,7 +2,7 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Numerics; using System.Numerics;
using Dalamud.Interface; using Dalamud.Interface;
using KamiToolKit.Classes; using KamiToolKit.Enums;
using KamiToolKit.Nodes; using KamiToolKit.Nodes;
namespace AetherBags.Nodes.Color; namespace AetherBags.Nodes.Color;
@@ -3,6 +3,7 @@ using AetherBags.Helpers;
using AetherBags.Inventory; using AetherBags.Inventory;
using Dalamud.Game.ClientState.Keys; using Dalamud.Game.ClientState.Keys;
using KamiToolKit.Classes; using KamiToolKit.Classes;
using KamiToolKit.Enums;
using KamiToolKit.Nodes; using KamiToolKit.Nodes;
namespace AetherBags.Nodes.Configuration.General; namespace AetherBags.Nodes.Configuration.General;
@@ -1,9 +1,9 @@
using AetherBags.Configuration; using AetherBags.Configuration;
using KamiToolKit.Classes.Timelines;
using KamiToolKit.Nodes; using KamiToolKit.Nodes;
using System.Numerics; using System.Numerics;
using AetherBags.Inventory; using AetherBags.Inventory;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using KamiToolKit.Timelines;
namespace AetherBags.Nodes.Configuration.Layout; namespace AetherBags.Nodes.Configuration.Layout;
@@ -61,7 +61,7 @@ public class InventoryCategoryNode : InventoryCategoryNodeBase
_categoryNameTextNode.TextFlags |= TextFlags.OverflowHidden | TextFlags.Ellipsis; _categoryNameTextNode.TextFlags |= TextFlags.OverflowHidden | TextFlags.Ellipsis;
_categoryNameTextNode.TextFlags &= ~(TextFlags.WordWrap | TextFlags.MultiLine); _categoryNameTextNode.TextFlags &= ~(TextFlags.WordWrap | TextFlags.MultiLine);
_categoryNameTextNode.AddFlags(NodeFlags.EmitsEvents | NodeFlags.HasCollision); _categoryNameTextNode.AddNodeFlags(NodeFlags.EmitsEvents | NodeFlags.HasCollision);
_categoryNameTextNode.AttachNode(this); _categoryNameTextNode.AttachNode(this);
_itemGridNode = new HybridDirectionalFlexNode<DragDropNode> _itemGridNode = new HybridDirectionalFlexNode<DragDropNode>
@@ -2,8 +2,8 @@ using System.Numerics;
using AetherBags.Inventory.Context; using AetherBags.Inventory.Context;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using KamiToolKit.Classes; using KamiToolKit.Classes;
using KamiToolKit.Classes.Timelines;
using KamiToolKit.Nodes; using KamiToolKit.Nodes;
using KamiToolKit.Timelines;
namespace AetherBags.Nodes.Inventory; namespace AetherBags.Nodes.Inventory;
@@ -13,8 +13,6 @@ public sealed class InventoryNotificationNode : SimpleComponentNode
private readonly TextNode titleTextNode; private readonly TextNode titleTextNode;
private readonly TextNode messageTextNode; private readonly TextNode messageTextNode;
private static readonly InventoryNotificationState NotificationState = new();
public InventoryNotificationNode() public InventoryNotificationNode()
{ {
AddTimeline(ParentLabels); AddTimeline(ParentLabels);
@@ -5,6 +5,7 @@ using System.Runtime.CompilerServices;
using AetherBags.Inventory.Items; using AetherBags.Inventory.Items;
using AetherBags.Nodes.Layout; using AetherBags.Nodes.Layout;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using KamiToolKit.Classes;
using KamiToolKit.Nodes; using KamiToolKit.Nodes;
namespace AetherBags.Nodes.Inventory; namespace AetherBags.Nodes.Inventory;
@@ -62,7 +63,7 @@ public class LootedItemsCategoryNode : InventoryCategoryNodeBase
AlignmentType = AlignmentType.Left, AlignmentType = AlignmentType.Left,
String = "Recently Looted", String = "Recently Looted",
TextFlags = TextFlags.OverflowHidden | TextFlags.Ellipsis, 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); _headerTextNode.AddEvent(AtkEventType.MouseOver, BeginHeaderHover);
@@ -71,7 +72,7 @@ public class LootedItemsCategoryNode : InventoryCategoryNodeBase
_headerTextNode.TextFlags |= TextFlags.OverflowHidden | TextFlags.Ellipsis; _headerTextNode.TextFlags |= TextFlags.OverflowHidden | TextFlags.Ellipsis;
_headerTextNode.TextFlags &= ~(TextFlags.WordWrap | TextFlags.MultiLine); _headerTextNode.TextFlags &= ~(TextFlags.WordWrap | TextFlags.MultiLine);
_headerTextNode.AddFlags(NodeFlags.EmitsEvents | NodeFlags.HasCollision); _headerTextNode.AddNodeFlags(NodeFlags.EmitsEvents | NodeFlags.HasCollision);
_headerTextNode.AttachNode(this); _headerTextNode.AttachNode(this);
_clearButton = new CircleButtonNode _clearButton = new CircleButtonNode
@@ -197,7 +198,7 @@ public class LootedItemsCategoryNode : InventoryCategoryNodeBase
private void SyncItemGrid() private void SyncItemGrid()
{ {
_itemGridNode.SyncWithListDataByKey<LootedItemInfo, LootedItemDisplayNode, int>( _itemGridNode.SyncWithListDataByKey(
dataList: _lootedItems, dataList: _lootedItems,
getKeyFromData: item => item.Index, getKeyFromData: item => item.Index,
getKeyFromNode: node => node.LootedItem?.Index ?? -1, getKeyFromNode: node => node.LootedItem?.Index ?? -1,
@@ -221,6 +222,7 @@ public class LootedItemsCategoryNode : InventoryCategoryNodeBase
private void OnItemDismissed(LootedItemDisplayNode node) private void OnItemDismissed(LootedItemDisplayNode node)
{ {
if(node.LootedItem is null) return;
int index = node.LootedItem.Index; int index = node.LootedItem.Index;
OnDismissItem?.Invoke(index); OnDismissItem?.Invoke(index);
} }
@@ -49,9 +49,9 @@ public abstract class DeferrableLayoutListNode : SimpleComponentNode
set set
{ {
if (value) if (value)
AddFlags(NodeFlags.Clip); AddNodeFlags(NodeFlags.Clip);
else else
RemoveFlags(NodeFlags.Clip); RemoveNodeFlags(NodeFlags.Clip);
} }
} }
+2 -4
View File
@@ -99,10 +99,8 @@ public class Plugin : IDalamudPlugin
System.Config = Util.LoadConfigOrDefault(); System.Config = Util.LoadConfigOrDefault();
System.LootedItemsTracker.Enable(); System.LootedItemsTracker.Enable();
#if DEBUG System.AddonInventoryWindow.DebugOpen();
System.AddonInventoryWindow.Toggle(); System.AddonConfigurationWindow.DebugOpen();
System.AddonConfigurationWindow.Toggle();
#endif
} }
private void OnLogout(int type, int code) private void OnLogout(int type, int code)