Add implicit cast for void*

This commit is contained in:
Haselnussbomber 2025-07-31 14:36:15 +02:00
parent a839575028
commit 85a9e59dad
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
6 changed files with 18 additions and 16 deletions

View file

@ -71,6 +71,8 @@ public readonly unsafe struct AgentInterfacePtr(nint address) : IEquatable<Agent
public static implicit operator AgentInterfacePtr(nint address) => 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;

View file

@ -113,6 +113,8 @@ public readonly unsafe struct AtkUnitBasePtr(nint address) : IEquatable<AtkUnitB
public static implicit operator AtkUnitBasePtr(nint address) => 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;

View file

@ -32,6 +32,8 @@ public readonly unsafe struct UIModulePtr(nint address) : IEquatable<UIModulePtr
public static implicit operator UIModulePtr(nint address) => 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;

View file

@ -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<GameGui>.Get().FindAgentInterface((nint)atkUnitBase);
var agent = Service<GameGui>.Get().FindAgentInterface(atkUnitBase);
ImGui.Text($"{addonName}");
ImGui.SameLine();

View file

@ -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}"),

View file

@ -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;
/// <inheritdoc/>
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"));
}
}
}