mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add placeholder UIModulePtr struct
This commit is contained in:
parent
1119fd0ec7
commit
a839575028
3 changed files with 59 additions and 14 deletions
|
|
@ -168,7 +168,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IntPtr GetUIModule()
|
||||
public UIModulePtr GetUIModule()
|
||||
{
|
||||
return (nint)UIModule.Instance();
|
||||
}
|
||||
|
|
@ -180,11 +180,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
|||
if (unitManager == null)
|
||||
return 0;
|
||||
|
||||
var addon = unitManager->GetAddonByName(name, index);
|
||||
if (addon == null)
|
||||
return 0;
|
||||
|
||||
return (nint)addon;
|
||||
return (nint)unitManager->GetAddonByName(name, index);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
@ -439,7 +435,7 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
|||
=> this.gameGuiService.ScreenToWorld(screenPos, out worldPos, rayDistance);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IntPtr GetUIModule()
|
||||
public UIModulePtr GetUIModule()
|
||||
=> this.gameGuiService.GetUIModule();
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
|
|||
49
Dalamud/Game/NativeWrapper/UIModulePtr.cs
Normal file
49
Dalamud/Game/NativeWrapper/UIModulePtr.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
|
||||
namespace Dalamud.Game.NativeWrapper;
|
||||
|
||||
/// <summary>
|
||||
/// A wrapper for UIModule.
|
||||
/// </summary>
|
||||
/// <param name="address">The address to the UIModule.</param>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x08)]
|
||||
public readonly unsafe struct UIModulePtr(nint address) : IEquatable<UIModulePtr>
|
||||
{
|
||||
/// <summary>
|
||||
/// The address to the UIModule.
|
||||
/// </summary>
|
||||
[FieldOffset(0x00)]
|
||||
public readonly nint Address = address;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the underlying pointer is a nullptr.
|
||||
/// </summary>
|
||||
public readonly bool IsNull => this.Address == 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the UIModule*.
|
||||
/// </summary>
|
||||
/// <remarks> Internal use only. </remarks>
|
||||
internal readonly UIModule* Struct => (UIModule*)this.Address;
|
||||
|
||||
public static implicit operator nint(UIModulePtr wrapper) => wrapper.Address;
|
||||
|
||||
public static implicit operator UIModulePtr(nint address) => new(address);
|
||||
|
||||
public static bool operator ==(UIModulePtr left, UIModulePtr right) => left.Address == right.Address;
|
||||
|
||||
public static bool operator !=(UIModulePtr left, UIModulePtr right) => left.Address != right.Address;
|
||||
|
||||
/// <summary>Determines whether the specified UIModulePtr is equal to the current UIModulePtr.</summary>
|
||||
/// <param name="other">The UIModulePtr to compare with the current UIModulePtr.</param>
|
||||
/// <returns><c>true</c> if the specified UIModulePtr is equal to the current UIModulePtr; otherwise, <c>false</c>.</returns>
|
||||
public readonly bool Equals(UIModulePtr other) => this.Address == other.Address;
|
||||
|
||||
/// <inheritdoc cref="object.Equals(object?)"/>
|
||||
public override readonly bool Equals(object obj) => obj is UIModulePtr wrapper && this.Equals(wrapper);
|
||||
|
||||
/// <inheritdoc cref="object.GetHashCode()"/>
|
||||
public override readonly int GetHashCode() => ((nuint)this.Address).GetHashCode();
|
||||
}
|
||||
|
|
@ -76,37 +76,37 @@ public unsafe interface IGameGui
|
|||
public bool ScreenToWorld(Vector2 screenPos, out Vector3 worldPos, float rayDistance = 100000.0f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a pointer to the game's UI module.
|
||||
/// Gets a pointer to the game's UIModule instance.
|
||||
/// </summary>
|
||||
/// <returns>IntPtr pointing to UI module.</returns>
|
||||
public nint GetUIModule();
|
||||
/// <returns>A pointer wrapper to UIModule.</returns>
|
||||
public UIModulePtr GetUIModule();
|
||||
|
||||
/// <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 to the addon.</returns>
|
||||
/// <returns>A pointer wrapper to the addon.</returns>
|
||||
public AtkUnitBasePtr GetAddonByName(string name, int index = 1);
|
||||
|
||||
/// <summary>
|
||||
/// Find the agent associated with an addon, if possible.
|
||||
/// </summary>
|
||||
/// <param name="id">The agent id.</param>
|
||||
/// <returns>A pointer to the agent interface.</returns>
|
||||
/// <returns>A pointer wrapper to the agent interface.</returns>
|
||||
public AgentInterfacePtr GetAgentById(int id);
|
||||
|
||||
/// <summary>
|
||||
/// Find the agent associated with an addon, if possible.
|
||||
/// </summary>
|
||||
/// <param name="addonName">The addon name.</param>
|
||||
/// <returns>A pointer to the agent interface.</returns>
|
||||
/// <returns>A pointer wrapper to the agent interface.</returns>
|
||||
public AgentInterfacePtr FindAgentInterface(string addonName);
|
||||
|
||||
/// <summary>
|
||||
/// Find the agent associated with an addon, if possible.
|
||||
/// </summary>
|
||||
/// <param name="addon">The addon address.</param>
|
||||
/// <returns>A pointer to the agent interface.</returns>
|
||||
/// <returns>A pointer wrapper to the agent interface.</returns>
|
||||
public AgentInterfacePtr FindAgentInterface(AtkUnitBasePtr addon);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue