diff --git a/AetherBags.sln.DotSettings.user b/AetherBags.sln.DotSettings.user index cf7e7c4..6ef2c30 100644 --- a/AetherBags.sln.DotSettings.user +++ b/AetherBags.sln.DotSettings.user @@ -1,5 +1,7 @@  + ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded diff --git a/AetherBags/Addons/AddonInventoryWindow.cs b/AetherBags/Addons/AddonInventoryWindow.cs index b32f375..6ab3fd7 100644 --- a/AetherBags/Addons/AddonInventoryWindow.cs +++ b/AetherBags/Addons/AddonInventoryWindow.cs @@ -9,6 +9,7 @@ using AetherBags.Nodes.Inventory; using AetherBags.Nodes.Layout; using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; +using Dalamud.Game.Gui; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Component.GUI; using KamiToolKit; @@ -22,6 +23,7 @@ public class AddonInventoryWindow : NativeAddon private readonly InventoryCategoryHoverCoordinator _hoverCoordinator = new(); private readonly HashSet _hoverSubscribed = new(); + private InventoryNotificationNode _notificationNode = null!; private WrappingGridNode _categoriesNode = null!; private TextInputWithHintNode _searchInputNode = null!; private CircleButtonNode _settingsButtonNode = null!; @@ -69,13 +71,12 @@ public class AddonInventoryWindow : NativeAddon float x = headerX + (headerW - size.X) * 0.5f; float y = headerY + (headerH - size.Y) * 0.5f; - InventoryNotificationNode notificationNode = new InventoryNotificationNode + _notificationNode = new InventoryNotificationNode { Position = new Vector2(WindowNode!.X - 4f, WindowNode!.Y - 32f), Size = new Vector2(headerW, 28f), }; - notificationNode.AttachNode(this); - //notificationNode.NotificationType = InventoryNotificationType.SaddleBag; + _notificationNode.AttachNode(this); _searchInputNode = new TextInputWithHintNode { @@ -113,7 +114,6 @@ public class AddonInventoryWindow : NativeAddon base.OnSetup(addon); } - protected override unsafe void OnUpdate(AtkUnitBase* addon) { if (_refreshQueued) @@ -125,6 +125,9 @@ public class AddonInventoryWindow : NativeAddon RefreshCategoriesCore(doAutosize); } + InventoryNotificationType currentNotificationType = (InventoryNotificationType) AgentInventory.Instance()->OpenTitleId; + if(currentNotificationType != _notificationNode.NotificationType) _notificationNode.NotificationType = currentNotificationType; + base.OnUpdate(addon); } diff --git a/AetherBags/Inventory/InventoryNotificationState.cs b/AetherBags/Inventory/InventoryNotificationState.cs new file mode 100644 index 0000000..065fdf5 --- /dev/null +++ b/AetherBags/Inventory/InventoryNotificationState.cs @@ -0,0 +1,99 @@ +using System.Collections.Generic; +using Lumina.Excel; +using Lumina.Excel.Sheets; +using Lumina.Text.ReadOnly; + +namespace AetherBags.Inventory; + +public class InventoryNotificationState +{ + private readonly Dictionary notificationCache; + + public InventoryNotificationState() + { + var addonSheet = Services.DataManager.GetExcelSheet(); + notificationCache = new Dictionary + { + { InventoryNotificationType.Sell, new InventoryNotificationInfo(addonSheet.GetRow(530).Text, addonSheet.GetRow(3576).Text) }, + { InventoryNotificationType.Trade, new InventoryNotificationInfo(addonSheet.GetRow(531).Text, addonSheet.GetRow(3572).Text) }, + { InventoryNotificationType.Letters, new InventoryNotificationInfo(addonSheet.GetRow(549).Text, addonSheet.GetRow(3575).Text) }, + { InventoryNotificationType.Retainer, new InventoryNotificationInfo(addonSheet.GetRow(532).Text, addonSheet.GetRow(3573).Text) }, + { InventoryNotificationType.RetainerEquip, new InventoryNotificationInfo(addonSheet.GetRow(778).Text, addonSheet.GetRow(3585).Text) }, + { InventoryNotificationType.Equip, new InventoryNotificationInfo(addonSheet.GetRow(538).Text, addonSheet.GetRow(3577).Text) }, + { InventoryNotificationType.Armory, new InventoryNotificationInfo(addonSheet.GetRow(775).Text, addonSheet.GetRow(3578).Text) }, + { InventoryNotificationType.Markets, new InventoryNotificationInfo(addonSheet.GetRow(548).Text, addonSheet.GetRow(3574).Text) }, + { InventoryNotificationType.Trade2, new InventoryNotificationInfo(addonSheet.GetRow(531).Text, addonSheet.GetRow(3572).Text) }, + { InventoryNotificationType.CompanyChest, new InventoryNotificationInfo(addonSheet.GetRow(776).Text, addonSheet.GetRow(3579).Text) }, + { InventoryNotificationType.Exterior, new InventoryNotificationInfo(addonSheet.GetRow(3583).Text, addonSheet.GetRow(3581).Text) }, + { InventoryNotificationType.Interior, new InventoryNotificationInfo(addonSheet.GetRow(3584).Text, addonSheet.GetRow(3582).Text) }, + { InventoryNotificationType.Layout, new InventoryNotificationInfo(addonSheet.GetRow(6237).Text, addonSheet.GetRow(3580).Text) }, + { InventoryNotificationType.Plant, new InventoryNotificationInfo(addonSheet.GetRow(6416).Text, addonSheet.GetRow(6418).Text) }, + { InventoryNotificationType.Fertilize, new InventoryNotificationInfo(addonSheet.GetRow(6417).Text, addonSheet.GetRow(6419).Text) }, + { InventoryNotificationType.Transmutation, new InventoryNotificationInfo(addonSheet.GetRow(3911).Text, addonSheet.GetRow(3901).Text) }, + { InventoryNotificationType.Reward, new InventoryNotificationInfo(addonSheet.GetRow(6503).Text, addonSheet.GetRow(6502).Text) }, + { InventoryNotificationType.Feed, new InventoryNotificationInfo(addonSheet.GetRow(6519).Text, addonSheet.GetRow(6518).Text) }, + { InventoryNotificationType.Charge, new InventoryNotificationInfo(addonSheet.GetRow(8638).Text, addonSheet.GetRow(8637).Text) }, + { InventoryNotificationType.Convert, new InventoryNotificationInfo(addonSheet.GetRow(8647).Text, addonSheet.GetRow(8646).Text) }, + { InventoryNotificationType.Covering, new InventoryNotificationInfo(addonSheet.GetRow(9029).Text, addonSheet.GetRow(9028).Text) }, + { InventoryNotificationType.Feed2, new InventoryNotificationInfo(addonSheet.GetRow(9041).Text, addonSheet.GetRow(9040).Text) }, + { InventoryNotificationType.Manual, new InventoryNotificationInfo(addonSheet.GetRow(9044).Text, addonSheet.GetRow(9043).Text) }, + { InventoryNotificationType.Chocobo, new InventoryNotificationInfo(addonSheet.GetRow(9073).Text, addonSheet.GetRow(9072).Text) }, + { InventoryNotificationType.Outfit, new InventoryNotificationInfo(addonSheet.GetRow(6578).Text, addonSheet.GetRow(6579).Text) }, + { InventoryNotificationType.Outfit2, new InventoryNotificationInfo(addonSheet.GetRow(6578).Text, addonSheet.GetRow(6579).Text) }, + { InventoryNotificationType.Plant2, new InventoryNotificationInfo(addonSheet.GetRow(6416).Text, addonSheet.GetRow(6418).Text) }, + { InventoryNotificationType.Aquarium, new InventoryNotificationInfo(addonSheet.GetRow(6808).Text, addonSheet.GetRow(6807).Text) }, + { InventoryNotificationType.SaddleBag, new InventoryNotificationInfo(addonSheet.GetRow(891).Text, addonSheet.GetRow(892).Text) }, + { InventoryNotificationType.Donate, new InventoryNotificationInfo(addonSheet.GetRow(11595).Text, addonSheet.GetRow(11596).Text) }, + { InventoryNotificationType.Trade3, new InventoryNotificationInfo(addonSheet.GetRow(531).Text, addonSheet.GetRow(3572).Text) }, + { InventoryNotificationType.Trade4, new InventoryNotificationInfo(addonSheet.GetRow(531).Text, addonSheet.GetRow(3572).Text) }, + { InventoryNotificationType.Exterior2, new InventoryNotificationInfo(addonSheet.GetRow(3583).Text, addonSheet.GetRow(3581).Text) }, + { InventoryNotificationType.Interior2, new InventoryNotificationInfo(addonSheet.GetRow(6237).Text, addonSheet.GetRow(3580).Text) }, + }; + } + + public InventoryNotificationInfo? GetNotificationInfo(uint openTitleId) + { + return notificationCache.GetValueOrDefault((InventoryNotificationType)openTitleId); + } + + public record InventoryNotificationInfo(ReadOnlySeString Title, ReadOnlySeString Message); +} + +public enum InventoryNotificationType : uint +{ + None = 0, + Sell = 1, + Trade = 2, + Letters = 3, + Retainer = 4, + RetainerEquip = 5, + Equip = 6, + Armory = 7, + Markets = 8, + Trade2 = 9, + CompanyChest = 10, + Exterior = 11, + Interior = 12, + Layout = 13, + Plant = 14, + Fertilize = 15, + Transmutation = 16, + Reward = 17, + Feed = 18, + Charge = 19, + Convert = 20, + Covering = 21, + Feed2 = 22, + Manual = 23, + Chocobo = 24, + Outfit = 25, + Outfit2 = 26, + Plant2 = 27, + Aquarium = 28, + SaddleBag = 29, + Donate = 30, + Trade3 = 31, + Trade4 = 32, + Exterior2 = 33, + Interior2 = 34 +} \ No newline at end of file diff --git a/AetherBags/Nodes/Inventory/InventoryNotificationNode.cs b/AetherBags/Nodes/Inventory/InventoryNotificationNode.cs index 739a42b..a3d260d 100644 --- a/AetherBags/Nodes/Inventory/InventoryNotificationNode.cs +++ b/AetherBags/Nodes/Inventory/InventoryNotificationNode.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Numerics; +using AetherBags.Inventory; using FFXIVClientStructs.FFXIV.Component.GUI; using KamiToolKit; using KamiToolKit.Classes; @@ -18,12 +19,10 @@ public sealed class InventoryNotificationNode : SimpleComponentNode private readonly TextNode titleTextNode; private readonly TextNode messageTextNode; - private Dictionary notificationCache = null!; + private static readonly InventoryNotificationState NotificationState = new(); public InventoryNotificationNode() { - PopulateNotificationCache(); - AddTimeline(ParentLabels); glowNode = new SimpleNineGridNode { @@ -76,26 +75,6 @@ public sealed class InventoryNotificationNode : SimpleComponentNode messageTextNode.Size = Size with { Y = 16 }; } - private void PopulateNotificationCache() - { - ExcelSheet addonSheet = Services.DataManager.GetExcelSheet(); - notificationCache = new Dictionary - { - { - InventoryNotificationType.SaddleBag, - new InventoryNotificationInfo(addonSheet.GetRow(891).Text, addonSheet.GetRow(892).Text) - }, - { - InventoryNotificationType.RetainerEntrust, - new InventoryNotificationInfo(addonSheet.GetRow(910).Text, addonSheet.GetRow(3573).Text) - }, - { - InventoryNotificationType.RetainerEquip, - new InventoryNotificationInfo(addonSheet.GetRow(910).Text, addonSheet.GetRow(3585).Text) - } - }; - } - public InventoryNotificationType NotificationType { get; @@ -108,11 +87,15 @@ public sealed class InventoryNotificationNode : SimpleComponentNode messageTextNode.String = string.Empty; Timeline?.PlayAnimation(17); // Hide } - else if (notificationCache.TryGetValue(value, out var texts)) + else { - titleTextNode.SeString = texts.Title; - messageTextNode.SeString = texts.Message; - Timeline?.PlayAnimation(101); // Show + var info = NotificationState.GetNotificationInfo((uint)value); + if (info != null) + { + titleTextNode.SeString = info.Title; + messageTextNode.SeString = info.Message; + Timeline?.PlayAnimation(101); // Show + } } } } = InventoryNotificationType.None; @@ -148,15 +131,4 @@ public sealed class InventoryNotificationNode : SimpleComponentNode .AddFrame(59, alpha: 255, addColor: new Vector3(0, 0, 0)) .EndFrameSet() .Build(); - - - private record InventoryNotificationInfo(ReadOnlySeString Title, ReadOnlySeString Message); -} - -public enum InventoryNotificationType -{ - None, - SaddleBag, - RetainerEntrust, - RetainerEquip -} +} \ No newline at end of file diff --git a/AetherBags/Services.cs b/AetherBags/Services.cs index 00eeddf..1569de2 100644 --- a/AetherBags/Services.cs +++ b/AetherBags/Services.cs @@ -13,6 +13,7 @@ public class Services [PluginService] public static IDataManager DataManager { get; set; } = null!; [PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!; [PluginService] public static IFramework Framework { get; private set; } = null!; + [PluginService] public static IGameGui GameGui { get; private set; } = null!; [PluginService] public static IKeyState KeyState { get; private set; } = null!; [PluginService] public static IPluginLog Logger { get; private set; } = null!; [PluginService] public static INotificationManager NotificationManager { get; private set; } = null!;