Add a property to get the bounds of a DTR entry

This commit is contained in:
Exter-N 2025-11-11 21:28:30 +01:00
parent f6cd6d31ff
commit 4cfe561c1c

View file

@ -1,4 +1,6 @@
using Dalamud.Configuration.Internal; using System.Numerics;
using Dalamud.Configuration.Internal;
using Dalamud.Game.Addon.Events.EventDataTypes; using Dalamud.Game.Addon.Events.EventDataTypes;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Internal.Types;
@ -48,6 +50,11 @@ public interface IReadOnlyDtrBarEntry
/// Gets an action to be invoked when the user clicks on the dtr entry. /// Gets an action to be invoked when the user clicks on the dtr entry.
/// </summary> /// </summary>
public Action<DtrInteractionEvent>? OnClick { get; } public Action<DtrInteractionEvent>? OnClick { get; }
/// <summary>
/// Gets the axis-aligned bounding box of this entry, in screen coordinates.
/// </summary>
public (Vector2 Min, Vector2 Max) ScreenBounds { get; }
} }
/// <summary> /// <summary>
@ -146,6 +153,17 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
[Api13ToDo("Maybe make this config scoped to internal name?")] [Api13ToDo("Maybe make this config scoped to internal name?")]
public bool UserHidden => this.configuration.DtrIgnore?.Contains(this.Title) ?? false; public bool UserHidden => this.configuration.DtrIgnore?.Contains(this.Title) ?? false;
/// <inheritdoc/>
public (Vector2 Min, Vector2 Max) ScreenBounds
=> this.TextNode switch
{
null => default,
var node => node->IsVisible()
? (new(node->ScreenX, node->ScreenY),
new(node->ScreenX + node->GetWidth(), node->ScreenY + node->GetHeight()))
: default,
};
/// <summary> /// <summary>
/// Gets or sets the internal text node of this entry. /// Gets or sets the internal text node of this entry.
/// </summary> /// </summary>