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
{
private ModifyListNode<CategoryWrapper>? _selectionListNode;
private ModifyListNode<CategoryWrapper, CategoryListItemNode>? _selectionListNode;
private VerticalLineNode? _separatorLine;
private CategoryConfigurationNode? _configNode;
private TextNode? _nothingSelectedTextNode;
@@ -28,21 +28,24 @@ public class AddonCategoryConfigurationWindow : NativeAddon
{
_categoryWrappers = CreateCategoryWrappers();
_selectionListNode = new ModifyListNode<CategoryWrapper>
_selectionListNode = new ModifyListNode<CategoryWrapper, CategoryListItemNode>
{
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<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)
{
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);
}
}
+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.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);
}
}
+1 -1
View File
@@ -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;
@@ -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;
+8 -3
View File
@@ -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);
}
}
}
+1
View File
@@ -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;
+1 -1
View File
@@ -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;
@@ -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;
@@ -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;
@@ -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<DragDropNode>
@@ -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);
@@ -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<LootedItemInfo, LootedItemDisplayNode, int>(
_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);
}
@@ -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);
}
}
+2 -4
View File
@@ -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)