diff --git a/RoleplayersToolbox/Plugin.cs b/RoleplayersToolbox/Plugin.cs index cf5fa9f..4a37595 100755 --- a/RoleplayersToolbox/Plugin.cs +++ b/RoleplayersToolbox/Plugin.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; +using Dalamud.ContextMenu; using Dalamud.Data; using Dalamud.Game; using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Objects; using Dalamud.Game.Command; using Dalamud.Game.Gui; -using Dalamud.Game.Gui.ContextMenus; using Dalamud.IoC; using Dalamud.Plugin; using RoleplayersToolbox.Tools; @@ -38,9 +38,11 @@ namespace RoleplayersToolbox { [PluginService] internal CommandManager CommandManager { get; init; } = null!; - - [PluginService] - internal ContextMenu ContextMenu { get; init; } = null!; + + // [PluginService] + // internal ContextMenu ContextMenu { get; init; } = null!; + + internal DalamudContextMenu ContextMenu { get; } [PluginService] internal DataManager DataManager { get; init; } = null!; @@ -67,6 +69,8 @@ namespace RoleplayersToolbox { this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration(); this.Common = new XivCommonBase(Hooks.PartyFinderListings); + this.ContextMenu = new DalamudContextMenu(); + this.Tools.Add(new HousingTool(this)); this.Tools.Add(new TargetingTool(this)); diff --git a/RoleplayersToolbox/RoleplayersToolbox.csproj b/RoleplayersToolbox/RoleplayersToolbox.csproj index d7b5175..32f0795 100755 --- a/RoleplayersToolbox/RoleplayersToolbox.csproj +++ b/RoleplayersToolbox/RoleplayersToolbox.csproj @@ -62,6 +62,7 @@ + diff --git a/RoleplayersToolbox/Tools/Housing/HousingTool.cs b/RoleplayersToolbox/Tools/Housing/HousingTool.cs index b381d7c..370a172 100755 --- a/RoleplayersToolbox/Tools/Housing/HousingTool.cs +++ b/RoleplayersToolbox/Tools/Housing/HousingTool.cs @@ -1,9 +1,9 @@ using System; using System.Linq; using System.Runtime.InteropServices; +using Dalamud.ContextMenu; using Dalamud.Game; using Dalamud.Game.Command; -using Dalamud.Game.Gui.ContextMenus; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; using FFXIVClientStructs.FFXIV.Client.UI; @@ -58,7 +58,7 @@ namespace RoleplayersToolbox.Tools.Housing { this._addonMapHide = Marshal.GetDelegateForFunctionPointer(addonMapHidePtr); } - this.Plugin.ContextMenu.ContextMenuOpened += this.OnContextMenu; + this.Plugin.ContextMenu.OnOpenGameObjectContextMenu += this.OnContextMenu; this.Plugin.Framework.Update += this.OnFramework; this.Plugin.CommandManager.AddHandler("/route", new CommandInfo(this.OnRouteCommand) { HelpMessage = "Extract housing information from the given text and open the routing window", @@ -72,7 +72,7 @@ namespace RoleplayersToolbox.Tools.Housing { this.Plugin.CommandManager.RemoveHandler("/bookmarks"); this.Plugin.CommandManager.RemoveHandler("/route"); this.Plugin.Framework.Update -= this.OnFramework; - this.Plugin.ContextMenu.ContextMenuOpened -= this.OnContextMenu; + this.Plugin.ContextMenu.OnOpenGameObjectContextMenu -= this.OnContextMenu; } public override void DrawSettings(ref bool anyChanged) { @@ -198,20 +198,18 @@ namespace RoleplayersToolbox.Tools.Housing { this.BookmarksUi.ShouldDraw ^= true; } - private void OnContextMenu(ContextMenuOpenedArgs args) { - if (args.ParentAddonName != "LookingForGroup" || args.GameObjectContext?.ContentId is null or 0) { + private void OnContextMenu(GameObjectContextMenuOpenArgs args) { + if (args.ParentAddonName != "LookingForGroup" || args.ContentIdLower is 0) { return; } - args.AddCustomSubMenu("Roleplayer's Toolbox", args => { - args.AddCustomItem("Select as Destination", this.SelectDestination); - args.AddCustomItem("Add Bookmark", this.AddBookmark); - }); + args.AddCustomItem(new GameObjectContextMenuItem("Select as Destination", this.SelectDestination)); + args.AddCustomItem(new GameObjectContextMenuItem("Add Bookmark", this.AddBookmark)); } - private void SelectDestination(CustomContextMenuItemSelectedArgs args) { - var contentId = args.ContextMenuOpenedArgs.GameObjectContext?.ContentId; - if (contentId is null or 0) { + private void SelectDestination(GameObjectContextMenuItemSelectedArgs args) { + var contentId = args.ContentIdLower; + if (contentId is 0) { return; } @@ -226,9 +224,9 @@ namespace RoleplayersToolbox.Tools.Housing { this.Destination = InfoExtractor.Extract(listing.Description.TextValue, listing.World.Value.DataCenter.Row, this.Plugin.DataManager, this.Info); } - private void AddBookmark(CustomContextMenuItemSelectedArgs args) { - var contentId = args.ContextMenuOpenedArgs.GameObjectContext?.ContentId; - if (contentId is null or 0) { + private void AddBookmark(GameObjectContextMenuItemSelectedArgs args) { + var contentId = args.ContentIdLower; + if (contentId is 0) { return; }