mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-23 08:17:47 +01:00
Live addon rework
This commit is contained in:
parent
6e66829c6d
commit
ee99fe4499
3 changed files with 34 additions and 96 deletions
|
|
@ -1,66 +1,63 @@
|
|||
using System;
|
||||
|
||||
namespace Dalamud.Game.Internal.Gui.Addon
|
||||
using Dalamud.Memory;
|
||||
|
||||
namespace Dalamud.Game.Gui.Addons
|
||||
{
|
||||
/// <summary>
|
||||
/// This class represents an in-game UI "Addon".
|
||||
/// </summary>
|
||||
public class Addon
|
||||
public unsafe class Addon
|
||||
{
|
||||
/// <summary>
|
||||
/// The address of the addon.
|
||||
/// </summary>
|
||||
public IntPtr Address;
|
||||
|
||||
/// <summary>
|
||||
/// The addon interop data.
|
||||
/// </summary>
|
||||
protected Structs.Addon addonStruct;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Addon"/> class.
|
||||
/// </summary>
|
||||
/// <param name="address">The address of the addon.</param>
|
||||
/// <param name="addonStruct">The addon interop data.</param>
|
||||
public Addon(IntPtr address, Structs.Addon addonStruct)
|
||||
public Addon(IntPtr address)
|
||||
{
|
||||
this.Address = address;
|
||||
this.addonStruct = addonStruct;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the addon.
|
||||
/// </summary>
|
||||
public IntPtr Address { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the addon.
|
||||
/// </summary>
|
||||
public string Name => this.addonStruct.Name;
|
||||
public string Name => MemoryHelper.ReadString((IntPtr)this.Struct->Name, 0x20);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the X position of the addon on screen.
|
||||
/// </summary>
|
||||
public short X => this.addonStruct.X;
|
||||
public short X => this.Struct->X;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Y position of the addon on screen.
|
||||
/// </summary>
|
||||
public short Y => this.addonStruct.Y;
|
||||
public short Y => this.Struct->Y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the addon.
|
||||
/// </summary>
|
||||
public float Scale => this.addonStruct.Scale;
|
||||
public float Scale => this.Struct->Scale;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the width of the addon. This may include non-visible parts.
|
||||
/// </summary>
|
||||
public unsafe float Width => this.addonStruct.RootNode->Width * this.Scale;
|
||||
public unsafe float Width => this.Struct->RootNode->Width * this.Scale;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the height of the addon. This may include non-visible parts.
|
||||
/// </summary>
|
||||
public unsafe float Height => this.addonStruct.RootNode->Height * this.Scale;
|
||||
public unsafe float Height => this.Struct->RootNode->Height * this.Scale;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the addon is visible.
|
||||
/// </summary>
|
||||
public bool Visible => (this.addonStruct.Flags & 0x20) == 0x20;
|
||||
public bool Visible => this.Struct->IsVisible;
|
||||
|
||||
private FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase* Struct => (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)this.Address;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace Dalamud.Game.Internal.Gui.Structs
|
||||
{
|
||||
/// <summary>
|
||||
/// Native memory representation of an FFXIV UI addon.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Addon
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the addon.
|
||||
/// </summary>
|
||||
[FieldOffset(AddonOffsets.Name)]
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
|
||||
public string Name;
|
||||
|
||||
/// <summary>
|
||||
/// Various flags that can be set on the addon.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is a bitfield.
|
||||
/// </remarks>
|
||||
[FieldOffset(AddonOffsets.Flags)]
|
||||
public byte Flags;
|
||||
|
||||
/// <summary>
|
||||
/// The X position of the addon on screen.
|
||||
/// </summary>
|
||||
[FieldOffset(AddonOffsets.X)]
|
||||
public short X;
|
||||
|
||||
/// <summary>
|
||||
/// The Y position of the addon on screen.
|
||||
/// </summary>
|
||||
[FieldOffset(AddonOffsets.Y)]
|
||||
public short Y;
|
||||
|
||||
/// <summary>
|
||||
/// The scale of the addon.
|
||||
/// </summary>
|
||||
[FieldOffset(AddonOffsets.Scale)]
|
||||
public float Scale;
|
||||
|
||||
/// <summary>
|
||||
/// The root node of the addon's node tree.
|
||||
/// </summary>
|
||||
[FieldOffset(AddonOffsets.RootNode)]
|
||||
public unsafe AtkResNode* RootNode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Memory offsets for the <see cref="Addon"/> type.
|
||||
/// </summary>
|
||||
public static class AddonOffsets
|
||||
{
|
||||
public const int Name = 0x8;
|
||||
public const int RootNode = 0xC8;
|
||||
public const int Flags = 0x182;
|
||||
public const int X = 0x1BC;
|
||||
public const int Y = 0x1BE;
|
||||
public const int Scale = 0x1AC;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue