[Api13] Add native wrapper structs (#2330)

This commit is contained in:
Haselnussbomber 2025-08-04 02:43:52 +02:00 committed by GitHub
parent b425ee0a2a
commit 57c6089fc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 682 additions and 149 deletions

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;
@ -102,8 +100,8 @@ internal unsafe class UiDebug
}
ImGui.Separator();
ImGuiHelpers.ClickToCopyText($"Address: {(ulong)atkUnitBase:X}", $"{(ulong)atkUnitBase:X}");
ImGuiHelpers.ClickToCopyText($"Agent: {(ulong)agent:X}", $"{(ulong)agent:X}");
ImGuiHelpers.ClickToCopyText($"Address: {(nint)atkUnitBase:X}", $"{(nint)atkUnitBase:X}");
ImGuiHelpers.ClickToCopyText($"Agent: {(nint)agent:X}", $"{(nint)agent:X}");
ImGui.Separator();
ImGui.Text($"Position: [ {atkUnitBase->X} , {atkUnitBase->Y} ]");

View file

@ -81,7 +81,7 @@ public unsafe partial class AddonTree : IDisposable
{
var ptr = GameGui.GetAddonByName(name);
if ((AtkUnitBase*)ptr != null)
if (!ptr.IsNull)
{
if (AddonTrees.TryGetValue(name, out var tree))
{
@ -152,7 +152,7 @@ public unsafe partial class AddonTree : IDisposable
var uldManager = addon->UldManager;
PrintFieldValuePair("Address", $"{(nint)addon:X}");
PrintFieldValuePair("Agent", $"{GameGui.FindAgentInterface(addon):X}");
PrintFieldValuePair("Agent", $"{(nint)GameGui.FindAgentInterface(addon):X}");
PrintFieldValuePairs(
("X", $"{addon->X}"),
@ -234,7 +234,7 @@ public unsafe partial class AddonTree : IDisposable
/// <returns>true if the addon is found.</returns>
private bool ValidateAddon(out AtkUnitBase* addon)
{
addon = (AtkUnitBase*)GameGui.GetAddonByName(this.AddonName);
addon = GameGui.GetAddonByName(this.AddonName).Struct;
if (addon == null || (nint)addon != this.InitialPtr)
{
this.Dispose();

View file

@ -49,7 +49,7 @@ internal unsafe partial class UiDebug2
/// Gets the base address for all unit lists.
/// </summary>
/// <returns>The address, if found.</returns>
internal static AtkUnitList* GetUnitListBaseAddr() => &((UIModule*)GameGui.GetUIModule())->GetRaptureAtkModule()->RaptureAtkUnitManager.AtkUnitManager.DepthLayerOneList;
internal static AtkUnitList* GetUnitListBaseAddr() => &RaptureAtkUnitManager.Instance()->DepthLayerOneList;
private void DrawSidebar()
{

View file

@ -1,6 +1,7 @@
using Dalamud.Game.Gui;
using Dalamud.Memory;
using Dalamud.Game.Gui;
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 = (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)address;
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"));
}
}
}

View file

@ -477,7 +477,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
{
if (args is not AddonDrawArgs drawArgs) return;
var addon = (AtkUnitBase*)drawArgs.Addon;
var addon = drawArgs.Addon.Struct;
var textNode = addon->GetTextNodeById(3);
// look and feel init. should be harmless to set.