mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add Generic Helper (#2403)
This commit is contained in:
parent
0047e24031
commit
f07b308757
2 changed files with 19 additions and 2 deletions
|
|
@ -182,6 +182,10 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
||||||
return (nint)unitManager->GetAddonByName(name, index);
|
return (nint)unitManager->GetAddonByName(name, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public T* GetAddonByName<T>(string name, int index = 1) where T : unmanaged
|
||||||
|
=> (T*)this.GetAddonByName(name, index).Address;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public AgentInterfacePtr GetAgentById(int id)
|
public AgentInterfacePtr GetAgentById(int id)
|
||||||
{
|
{
|
||||||
|
|
@ -328,7 +332,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void SetUiVisibilityDetour(RaptureAtkModule* thisPtr, bool uiVisible)
|
private void SetUiVisibilityDetour(RaptureAtkModule* thisPtr, bool uiVisible)
|
||||||
{
|
{
|
||||||
this.setUiVisibilityHook.Original(thisPtr, uiVisible);
|
this.setUiVisibilityHook.Original(thisPtr, uiVisible);
|
||||||
|
|
||||||
|
|
@ -441,6 +445,10 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
||||||
public AtkUnitBasePtr GetAddonByName(string name, int index = 1)
|
public AtkUnitBasePtr GetAddonByName(string name, int index = 1)
|
||||||
=> this.gameGuiService.GetAddonByName(name, index);
|
=> this.gameGuiService.GetAddonByName(name, index);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public unsafe T* GetAddonByName<T>(string name, int index = 1) where T : unmanaged
|
||||||
|
=> (T*)this.gameGuiService.GetAddonByName(name, index).Address;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public AgentInterfacePtr GetAgentById(int id)
|
public AgentInterfacePtr GetAgentById(int id)
|
||||||
=> this.gameGuiService.GetAgentById(id);
|
=> this.gameGuiService.GetAgentById(id);
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,15 @@ public unsafe interface IGameGui
|
||||||
/// <returns>A pointer wrapper to the addon.</returns>
|
/// <returns>A pointer wrapper to the addon.</returns>
|
||||||
public AtkUnitBasePtr GetAddonByName(string name, int index = 1);
|
public AtkUnitBasePtr GetAddonByName(string name, int index = 1);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the pointer to the Addon with the given name and index.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of addon to find.</param>
|
||||||
|
/// <param name="index">Index of addon to find (1-indexed).</param>
|
||||||
|
/// <returns>A pointer wrapper to the addon.</returns>
|
||||||
|
/// <typeparam name="T">Type of addon pointer AtkUnitBase or any derived struct.</typeparam>
|
||||||
|
public T* GetAddonByName<T>(string name, int index = 1) where T : unmanaged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Find the agent associated with an addon, if possible.
|
/// Find the agent associated with an addon, if possible.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue