diff --git a/TargetFurniture/ContextMenuHousing.cs b/TargetFurniture/ContextMenuHousing.cs index a07a611..8184fd2 100644 --- a/TargetFurniture/ContextMenuHousing.cs +++ b/TargetFurniture/ContextMenuHousing.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Dalamud.ContextMenu; +using Dalamud.Game.Gui.ContextMenu; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; @@ -8,36 +9,37 @@ namespace TargetFurniture; public unsafe class ContextMenuHousing : IDisposable { - private DalamudContextMenu _contextMenu = null!; - - private GameObjectContextMenuItem? _contextMenuItem; + private MenuItem _menuItemAddConductor; public void Dispose() { - _contextMenu.OnOpenGameObjectContextMenu -= OnOpenContextMenu; - _contextMenu.Dispose(); + Service.ContextMenu.OnMenuOpened -= OnOpenContextMenu; } public void Toggle() { - _contextMenu = new DalamudContextMenu(Service.PluginInterface); - _contextMenuItem = - new GameObjectContextMenuItem(new SeString(new TextPayload("Target Item")), SetFurnitureActive); - _contextMenu.OnOpenGameObjectContextMenu += OnOpenContextMenu; + _menuItemAddConductor = new MenuItem() + { + Name = new SeString(new TextPayload("Target Item")), + PrefixChar = 'T', + OnClicked = SetFurnitureActive, + }; + Service.ContextMenu.OnMenuOpened += OnOpenContextMenu; } - private void OnOpenContextMenu(GameObjectContextMenuOpenArgs args) + private void OnOpenContextMenu(IMenuOpenedArgs args) { - if (args.ParentAddonName is "HousingGoods" && - _contextMenuItem != null) // To make sure it doesnt appear in the Stored tab - args.AddCustomItem(_contextMenuItem); + if (args.AddonName is "HousingGoods" && + _menuItemAddConductor != null) // To make sure it doesnt appear in the Stored tab + args.AddMenuItem(_menuItemAddConductor); } - private void SetFurnitureActive(GameObjectContextMenuItemSelectedArgs args) + private void SetFurnitureActive(IMenuItemClickedArgs args) { if (Service.Memory.HousingStructure->Mode == HousingLayoutMode.Rotate && Service.Memory.HousingStructure->State == ItemState.SoftSelect) { + Service.PluginLog.Debug("1"); Service.Memory.SelectItem((IntPtr)Service.Memory.HousingStructure, (IntPtr)Service.Memory.HousingStructure->ActiveItem); } @@ -51,6 +53,7 @@ private void SetFurnitureActive(GameObjectContextMenuItemSelectedArgs args) } else { + Service.PluginLog.Debug("3"); // To make the item follow the cursor you need to retarget it, for reasons idk you need a small delay before the second target for it to work TargetItem(); if (Service.Configuration.MoveToCursor) @@ -58,6 +61,10 @@ private void SetFurnitureActive(GameObjectContextMenuItemSelectedArgs args) //PluginLog.Debug($"Finished"); } } + else + { + Service.PluginLog.Debug("None"); + } } public static void TargetItem() diff --git a/TargetFurniture/PluginMemory.cs b/TargetFurniture/PluginMemory.cs index 8be3052..6fd7c33 100644 --- a/TargetFurniture/PluginMemory.cs +++ b/TargetFurniture/PluginMemory.cs @@ -21,14 +21,14 @@ public PluginMemory() // Pointers for housing structures. _layoutWorldPtr = Service.SigScanner.GetStaticAddressFromSig( - "48 8B 0D ?? ?? ?? ?? 48 85 C9 74 ?? 48 8B 49 40 E9 ?? ?? ?? ??"); + "48 8B D1 48 8B 0D ?? ?? ?? ?? 48 85 C9 74 0A", 3); // Read the pointers. _layoutWorldPtr = Marshal.ReadIntPtr(_layoutWorldPtr); // Select housing item. var selectItemAddress = - Service.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B CE E8 ?? ?? ?? ?? 48 8B 6C 24 40 48 8B CE"); + Service.SigScanner.ScanText("48 85 D2 0F 84 49 09 00 00 53 41 56 48 83 EC 48 48 89 6C 24 60 48 8B DA 48 89 74 24 70 4C 8B F1"); SelectItem = Marshal.GetDelegateForFunctionPointer(selectItemAddress); } catch (Exception) diff --git a/TargetFurniture/Service.cs b/TargetFurniture/Service.cs index 8be2d1b..d816275 100644 --- a/TargetFurniture/Service.cs +++ b/TargetFurniture/Service.cs @@ -10,15 +10,19 @@ public class Service { public const string PluginName = "Target Furniture"; - [PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } = null!; + [PluginService] public static IDalamudPluginInterface PluginInterface { get; private set; } = null!; [PluginService] public static ISigScanner SigScanner { get; private set; } = null!; [PluginService] public static ICommandManager Commands { get; private set; } = null!; + [PluginService] public static IContextMenu ContextMenu { get; private set; } = null!; + [PluginService] public static IPluginLog PluginLog { get; private set; } = null!; + + public static PluginMemory Memory { get; set; } = null!; public static Configuration Configuration { get; set; } = null!; public static WindowSystem WindowSystem { get; } = new(PluginName); - public static void Initialize(DalamudPluginInterface pluginInterface) + public static void Initialize(IDalamudPluginInterface pluginInterface) { pluginInterface.Create(); } diff --git a/TargetFurniture/TargetFurniture.cs b/TargetFurniture/TargetFurniture.cs index 5647a94..00e91ad 100644 --- a/TargetFurniture/TargetFurniture.cs +++ b/TargetFurniture/TargetFurniture.cs @@ -14,7 +14,7 @@ public class TargetFurniture : IDalamudPlugin private readonly ContextMenuHousing _pluginContextMenu; - public TargetFurniture(DalamudPluginInterface pluginInterface) + public TargetFurniture(IDalamudPluginInterface pluginInterface) { Service.Initialize(pluginInterface); Service.Configuration = Configuration.Load(); diff --git a/TargetFurniture/TargetFurniture.csproj b/TargetFurniture/TargetFurniture.csproj index ec47936..dd57482 100644 --- a/TargetFurniture/TargetFurniture.csproj +++ b/TargetFurniture/TargetFurniture.csproj @@ -2,13 +2,13 @@ Det - 1.0.1.8 + 1.0.2.0 You can now select furnitures from the Housing Menu https://github.com/InitialDet/TargetForniture - net7.0-windows + net8.0-windows x64 Release latest @@ -41,8 +41,7 @@ - - + $(DalamudLibPath)FFXIVClientStructs.dll false diff --git a/TargetFurniture/packages.lock.json b/TargetFurniture/packages.lock.json index 537ed1a..19fcea9 100644 --- a/TargetFurniture/packages.lock.json +++ b/TargetFurniture/packages.lock.json @@ -1,18 +1,12 @@ { "version": 1, "dependencies": { - "net7.0-windows7.0": { - "Dalamud.ContextMenu": { - "type": "Direct", - "requested": "[1.3.1, )", - "resolved": "1.3.1", - "contentHash": "ptAxut5PiLnzZ4G/KQdHJVcyklC/BF3otHJ7zYVUPiKBjsOCoF0n/6h2jK7e+8ev2Y1yAY3Wtx2GuXLFQgt9Uw==" - }, + "net8.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[2.1.12, )", - "resolved": "2.1.12", - "contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg==" + "requested": "[2.1.13, )", + "resolved": "2.1.13", + "contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ==" } } }