Use AtkUnitBasePtr on IGameGui.GetAddonByName

This commit is contained in:
Haselnussbomber 2025-07-30 22:48:01 +02:00
parent 4cc3d4b3e0
commit 59003f8cd5
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
2 changed files with 10 additions and 8 deletions

View file

@ -1,5 +1,6 @@
using System.Runtime.InteropServices;
using Dalamud.Game.Gui.NativeWrapper;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Hooking;
using Dalamud.Interface.Utility;
@ -181,21 +182,21 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
}
/// <inheritdoc/>
public IntPtr GetAddonByName(string name, int index = 1)
public AtkUnitBasePtr GetAddonByName(string name, int index = 1)
{
var atkStage = AtkStage.Instance();
if (atkStage == null)
return IntPtr.Zero;
return 0;
var unitMgr = atkStage->RaptureAtkUnitManager;
if (unitMgr == null)
return IntPtr.Zero;
return 0;
var addon = unitMgr->GetAddonByName(name, index);
if (addon == null)
return IntPtr.Zero;
return 0;
return (IntPtr)addon;
return (nint)addon;
}
/// <inheritdoc/>
@ -458,7 +459,7 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
=> this.gameGuiService.GetUIModule();
/// <inheritdoc/>
public IntPtr GetAddonByName(string name, int index = 1)
public AtkUnitBasePtr GetAddonByName(string name, int index = 1)
=> this.gameGuiService.GetAddonByName(name, index);
/// <inheritdoc/>

View file

@ -1,6 +1,7 @@
using System.Numerics;
using System.Numerics;
using Dalamud.Game.Gui;
using Dalamud.Game.Gui.NativeWrapper;
using Dalamud.Game.Text.SeStringHandling.Payloads;
namespace Dalamud.Plugin.Services;
@ -86,7 +87,7 @@ public unsafe interface IGameGui
/// <param name="name">Name of addon to find.</param>
/// <param name="index">Index of addon to find (1-indexed).</param>
/// <returns>nint.Zero if unable to find UI, otherwise nint pointing to the start of the addon.</returns>
public nint GetAddonByName(string name, int index = 1);
public AtkUnitBasePtr GetAddonByName(string name, int index = 1);
/// <summary>
/// Find the agent associated with an addon, if possible.