From 7547db5e9c06168ef016a41e3e0ccb47066c7638 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 21 Sep 2023 11:48:49 +0200 Subject: [PATCH] Context menu integration for armoury chest --- ARDiscard/ARDiscard.csproj | 2 +- ARDiscard/ContextMenuIntegration.cs | 19 +++++++++++++++---- .../GameData/Agents/AgentArmouryBoard.cs | 12 ++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 ARDiscard/GameData/Agents/AgentArmouryBoard.cs diff --git a/ARDiscard/ARDiscard.csproj b/ARDiscard/ARDiscard.csproj index f0d8663..118526e 100644 --- a/ARDiscard/ARDiscard.csproj +++ b/ARDiscard/ARDiscard.csproj @@ -1,7 +1,7 @@ net7.0-windows - 2.3 + 2.4 11.0 enable true diff --git a/ARDiscard/ContextMenuIntegration.cs b/ARDiscard/ContextMenuIntegration.cs index 0e1702e..c36037f 100644 --- a/ARDiscard/ContextMenuIntegration.cs +++ b/ARDiscard/ContextMenuIntegration.cs @@ -1,12 +1,12 @@ using System; using System.Linq; using ARDiscard.GameData; +using ARDiscard.GameData.Agents; using ARDiscard.Windows; using Dalamud.ContextMenu; -using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; -using Dalamud.Logging; +using FFXIVClientStructs.FFXIV.Client.UI.Agent; namespace ARDiscard; @@ -37,7 +37,7 @@ internal sealed class ContextMenuIntegration : IDisposable _dalamudContextMenu.OnOpenInventoryContextMenu += OpenInventoryContextMenu; } - private void OpenInventoryContextMenu(InventoryContextMenuOpenArgs args) + private unsafe void OpenInventoryContextMenu(InventoryContextMenuOpenArgs args) { if (!_configuration.ContextMenu.Enabled) return; @@ -45,7 +45,18 @@ internal sealed class ContextMenuIntegration : IDisposable if (_configuration.ContextMenu.OnlyWhenConfigIsOpen && !_configWindow.IsOpen) return; - if (!(args.ParentAddonName is "Inventory" or "InventoryExpansion" or "InventoryLarge")) + if (args.ParentAddonName == "ArmouryBoard") + { + var agent = AgentModule.Instance()->GetAgentByInternalId(AgentId.ArmouryBoard); + if (agent == null || !agent->IsAgentActive()) + return; + + // don't add it in the main/off hand weapon tabs, as we don't use these for discarding + var agentArmouryBoard = (AgentArmouryBoard*)agent; + if (agentArmouryBoard->CurrentTab is 0 or 6) + return; + } + else if (!(args.ParentAddonName is "Inventory" or "InventoryExpansion" or "InventoryLarge")) return; if (!_configWindow.CanItemBeConfigured(args.ItemId)) diff --git a/ARDiscard/GameData/Agents/AgentArmouryBoard.cs b/ARDiscard/GameData/Agents/AgentArmouryBoard.cs new file mode 100644 index 0000000..396ff4e --- /dev/null +++ b/ARDiscard/GameData/Agents/AgentArmouryBoard.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; +using FFXIVClientStructs.Attributes; +using FFXIVClientStructs.FFXIV.Client.UI.Agent; + +namespace ARDiscard.GameData.Agents; + +[Agent(AgentId.ArmouryBoard)] +[StructLayout(LayoutKind.Explicit, Size = 0x2E)] +public struct AgentArmouryBoard +{ + [FieldOffset(0x2C)] public byte CurrentTab; +}