diff --git a/Dalamud/Game/NativeWrapper/AgentInterfacePtr.cs b/Dalamud/Game/NativeWrapper/AgentInterfacePtr.cs index a8d2de455..932a02af7 100644 --- a/Dalamud/Game/NativeWrapper/AgentInterfacePtr.cs +++ b/Dalamud/Game/NativeWrapper/AgentInterfacePtr.cs @@ -71,6 +71,8 @@ public readonly unsafe struct AgentInterfacePtr(nint address) : IEquatable new(address); + public static implicit operator AgentInterfacePtr(void* ptr) => new((nint)ptr); + public static bool operator ==(AgentInterfacePtr left, AgentInterfacePtr right) => left.Address == right.Address; public static bool operator !=(AgentInterfacePtr left, AgentInterfacePtr right) => left.Address != right.Address; diff --git a/Dalamud/Game/NativeWrapper/AtkUnitBasePtr.cs b/Dalamud/Game/NativeWrapper/AtkUnitBasePtr.cs index df9dc31dd..28ef33f6f 100644 --- a/Dalamud/Game/NativeWrapper/AtkUnitBasePtr.cs +++ b/Dalamud/Game/NativeWrapper/AtkUnitBasePtr.cs @@ -113,6 +113,8 @@ public readonly unsafe struct AtkUnitBasePtr(nint address) : IEquatable new(address); + public static implicit operator AtkUnitBasePtr(void* ptr) => new((nint)ptr); + public static bool operator ==(AtkUnitBasePtr left, AtkUnitBasePtr right) => left.Address == right.Address; public static bool operator !=(AtkUnitBasePtr left, AtkUnitBasePtr right) => left.Address != right.Address; diff --git a/Dalamud/Game/NativeWrapper/UIModulePtr.cs b/Dalamud/Game/NativeWrapper/UIModulePtr.cs index 1604ea6bc..4f7480d02 100644 --- a/Dalamud/Game/NativeWrapper/UIModulePtr.cs +++ b/Dalamud/Game/NativeWrapper/UIModulePtr.cs @@ -32,6 +32,8 @@ public readonly unsafe struct UIModulePtr(nint address) : IEquatable new(address); + public static implicit operator UIModulePtr(void* ptr) => new((nint)ptr); + public static bool operator ==(UIModulePtr left, UIModulePtr right) => left.Address == right.Address; public static bool operator !=(UIModulePtr left, UIModulePtr right) => left.Address != right.Address; diff --git a/Dalamud/Interface/Internal/UiDebug.cs b/Dalamud/Interface/Internal/UiDebug.cs index 21ec6964c..d88255de3 100644 --- a/Dalamud/Interface/Internal/UiDebug.cs +++ b/Dalamud/Interface/Internal/UiDebug.cs @@ -12,8 +12,6 @@ using FFXIVClientStructs.FFXIV.Client.UI.Misc; using FFXIVClientStructs.FFXIV.Component.GUI; using ImGuiNET; -using Lumina.Text.ReadOnly; - // Customised version of https://github.com/aers/FFXIVUIDebug namespace Dalamud.Interface.Internal; @@ -87,7 +85,7 @@ internal unsafe class UiDebug { var isVisible = atkUnitBase->IsVisible; var addonName = atkUnitBase->NameString; - var agent = Service.Get().FindAgentInterface((nint)atkUnitBase); + var agent = Service.Get().FindAgentInterface(atkUnitBase); ImGui.Text($"{addonName}"); ImGui.SameLine(); diff --git a/Dalamud/Interface/Internal/UiDebug2/Browsing/AddonTree.cs b/Dalamud/Interface/Internal/UiDebug2/Browsing/AddonTree.cs index 39aa9f4a8..2dc1b6cfd 100644 --- a/Dalamud/Interface/Internal/UiDebug2/Browsing/AddonTree.cs +++ b/Dalamud/Interface/Internal/UiDebug2/Browsing/AddonTree.cs @@ -152,7 +152,7 @@ public unsafe partial class AddonTree : IDisposable var uldManager = addon->UldManager; PrintFieldValuePair("Address", $"{(nint)addon:X}"); - PrintFieldValuePair("Agent", $"{GameGui.FindAgentInterface((nint)addon):X}"); + PrintFieldValuePair("Agent", $"{GameGui.FindAgentInterface(addon):X}"); PrintFieldValuePairs( ("X", $"{addon->X}"), diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/AddonWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/AddonWidget.cs index 16bdc8bb3..bd699e111 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/AddonWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/AddonWidget.cs @@ -1,6 +1,7 @@ using Dalamud.Game.Gui; -using Dalamud.Memory; +using Dalamud.Game.NativeWrapper; using Dalamud.Utility; + using ImGuiNET; namespace Dalamud.Interface.Internal.Windows.Data.Widgets; @@ -12,7 +13,7 @@ internal unsafe class AddonWidget : IDataWindowWidget { private string inputAddonName = string.Empty; private int inputAddonIndex; - private nint findAgentInterfacePtr; + private AgentInterfacePtr agentInterfacePtr; /// public string DisplayName { get; init; } = "Addon"; @@ -40,30 +41,27 @@ internal unsafe class AddonWidget : IDataWindowWidget if (this.inputAddonName.IsNullOrEmpty()) return; - var address = gameGui.GetAddonByName(this.inputAddonName, this.inputAddonIndex); - - if (address == nint.Zero) + var addon = gameGui.GetAddonByName(this.inputAddonName, this.inputAddonIndex); + if (addon.IsNull) { ImGui.Text("Null"); return; } - var addon = address.Struct; - var name = addon->NameString; - ImGui.TextUnformatted($"{name} - {Util.DescribeAddress(address)}\n v:{addon->IsVisible} x:{addon->X} y:{addon->Y} s:{addon->Scale}, w:{addon->RootNode->Width}, h:{addon->RootNode->Height}"); + ImGui.TextUnformatted($"{addon.Name} - {Util.DescribeAddress(addon)}\n v:{addon.IsVisible} x:{addon.X} y:{addon.Y} s:{addon.Scale}, w:{addon.Width}, h:{addon.Height}"); if (ImGui.Button("Find Agent")) { - this.findAgentInterfacePtr = gameGui.FindAgentInterface(address); + this.agentInterfacePtr = gameGui.FindAgentInterface(addon); } - if (this.findAgentInterfacePtr != nint.Zero) + if (!this.agentInterfacePtr.IsNull) { - ImGui.TextUnformatted($"Agent: {Util.DescribeAddress(this.findAgentInterfacePtr)}"); + ImGui.TextUnformatted($"Agent: {Util.DescribeAddress(this.agentInterfacePtr)}"); ImGui.SameLine(); if (ImGui.Button("C")) - ImGui.SetClipboardText(this.findAgentInterfacePtr.ToInt64().ToString("X")); + ImGui.SetClipboardText(this.agentInterfacePtr.Address.ToString("X")); } } }