mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +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;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,8 @@ using Dalamud.Game.ClientState;
|
|||
using Dalamud.Game.ClientState.Actors.Types;
|
||||
using Dalamud.Game.ClientState.Actors.Types.NonPlayer;
|
||||
using Dalamud.Game.ClientState.Structs.JobGauge;
|
||||
using Dalamud.Game.Gui.Addons;
|
||||
using Dalamud.Game.Gui.Toast;
|
||||
using Dalamud.Game.Internal.Gui.Addon;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin;
|
||||
|
|
@ -104,6 +104,17 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
Gamepad,
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void OnOpen()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void OnClose()
|
||||
{
|
||||
this.resultAddon = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the DataKind dropdown menu.
|
||||
/// </summary>
|
||||
|
|
@ -562,9 +573,7 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
|
||||
if (ImGui.Button("Get Addon"))
|
||||
{
|
||||
this.resultAddon =
|
||||
this.dalamud.Framework.Gui.GetAddonByName(
|
||||
this.inputAddonName, this.inputAddonIndex);
|
||||
this.resultAddon = this.dalamud.Framework.Gui.GetAddonByName(this.inputAddonName, this.inputAddonIndex);
|
||||
}
|
||||
|
||||
if (ImGui.Button("Find Agent"))
|
||||
|
|
@ -572,14 +581,12 @@ namespace Dalamud.Interface.Internal.Windows
|
|||
|
||||
if (this.resultAddon != null)
|
||||
{
|
||||
ImGui.TextUnformatted(
|
||||
$"{this.resultAddon.Name} - 0x{this.resultAddon.Address.ToInt64():x}\n v:{this.resultAddon.Visible} x:{this.resultAddon.X} y:{this.resultAddon.Y} s:{this.resultAddon.Scale}, w:{this.resultAddon.Width}, h:{this.resultAddon.Height}");
|
||||
ImGui.TextUnformatted($"{this.resultAddon.Name} - 0x{this.resultAddon.Address.ToInt64():x}\n v:{this.resultAddon.Visible} x:{this.resultAddon.X} y:{this.resultAddon.Y} s:{this.resultAddon.Scale}, w:{this.resultAddon.Width}, h:{this.resultAddon.Height}");
|
||||
}
|
||||
|
||||
if (this.findAgentInterfacePtr != IntPtr.Zero)
|
||||
{
|
||||
ImGui.TextUnformatted(
|
||||
$"Agent: 0x{this.findAgentInterfacePtr.ToInt64():x}");
|
||||
ImGui.TextUnformatted($"Agent: 0x{this.findAgentInterfacePtr.ToInt64():x}");
|
||||
ImGui.SameLine();
|
||||
|
||||
if (ImGui.Button("C"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue