Let's just break things and make them really nice

This commit is contained in:
MidoriKami 2025-07-26 11:12:03 -07:00
parent 124c024c4d
commit 76543ee743
2 changed files with 10 additions and 70 deletions

View file

@ -5,6 +5,7 @@ using System.Threading;
using Dalamud.Configuration.Internal;
using Dalamud.Game.Addon.Events;
using Dalamud.Game.Addon.Events.EventDataTypes;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using Dalamud.Game.Text.SeStringHandling;
@ -628,7 +629,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
}
}
if (dtrBarEntry is not null)
if (dtrBarEntry is { OnClick: not null })
{
switch (atkEventType)
{
@ -641,22 +642,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
break;
case AddonEventType.MouseClick:
dtrBarEntry.OnClick?.Invoke();
dtrBarEntry.OnClicked?.Invoke(eventData);
var dataPointer = (AtkEventData*)eventData.AtkEventDataPointer;
var mouseData = dataPointer->MouseData;
if (mouseData.ButtonId is 0)
{
dtrBarEntry.OnLeftClick?.Invoke();
}
if (mouseData.ButtonId is 1)
{
dtrBarEntry.OnRightClick?.Invoke();
}
dtrBarEntry.OnClick?.Invoke(new AddonMouseEventData(eventData));
break;
}
}

View file

@ -1,5 +1,5 @@
using Dalamud.Configuration.Internal;
using Dalamud.Game.Addon.Events;
using Dalamud.Game.Addon.Events.EventDataTypes;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Plugin.Internal.Types;
using Dalamud.Utility;
@ -43,13 +43,6 @@ public interface IReadOnlyDtrBarEntry
/// Gets a value indicating whether the user has hidden this entry from view through the Dalamud settings.
/// </summary>
public bool UserHidden { get; }
/// <summary>
/// Triggers the click action of this entry.
/// </summary>
/// <returns>True, if a click action was registered and executed.</returns>
[Api13ToDo("Remove, doesn't mesh well with new click actions")]
public bool TriggerClickAction();
}
/// <summary>
@ -73,25 +66,9 @@ public interface IDtrBarEntry : IReadOnlyDtrBarEntry
public new bool Shown { get; set; }
/// <summary>
/// Gets or sets a action to be invoked when the user clicks on the dtr entry.
/// Gets or sets an action to be invoked when the user clicks on the dtr entry.
/// </summary>
[Api13ToDo("Remove this, and rename OnClicked to OnClick")]
public Action? OnClick { get; set; }
/// <summary>
/// Gets or sets a action to be invoked when the user left-clicks on the dtr entry.
/// </summary>
public Action? OnLeftClick { get; set; }
/// <summary>
/// Gets or sets a action to be invoked when the user right-clicks on the dtr entry.
/// </summary>
public Action? OnRightClick { get; set; }
/// <summary>
/// Gets or sets a action to be invoked when the user clicks on the dtr entry.
/// </summary>
public Action<AddonEventData>? OnClicked { get; set; }
public Action<AddonMouseEventData>? OnClick { get; set; }
/// <summary>
/// Remove this entry from the bar.
@ -140,23 +117,11 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
/// <inheritdoc cref="IDtrBarEntry.Tooltip" />
public SeString? Tooltip { get; set; }
/// <summary>
/// Gets or sets a action to be invoked when the user clicks on the dtr entry.
/// </summary>
[Api13ToDo("Remove this and rename OnClicked to OnClick")]
public Action? OnClick { get; set; }
/// <inheritdoc/>
public Action<AddonMouseEventData>? OnClick { get; set; }
/// <inheritdoc/>
public Action? OnLeftClick { get; set; }
/// <inheritdoc/>
public Action? OnRightClick { get; set; }
/// <inheritdoc/>
public Action<AddonEventData>? OnClicked { get; set; }
/// <inheritdoc/>
public bool HasClickAction => this.OnClick != null || this.OnLeftClick != null || this.OnRightClick != null || this.OnClicked != null;
public bool HasClickAction => this.OnClick != null;
/// <inheritdoc cref="IDtrBarEntry.Shown" />
public bool Shown
@ -173,7 +138,7 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
}
/// <inheritdoc/>
[Api13ToDo("Maybe make this config scoped to internalname?")]
[Api13ToDo("Maybe make this config scoped to internal name?")]
public bool UserHidden => this.configuration.DtrIgnore?.Contains(this.Title) ?? false;
/// <summary>
@ -206,17 +171,6 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
/// </summary>
internal LocalPlugin? OwnerPlugin { get; set; }
/// <inheritdoc/>
[Api13ToDo("Remove, doesn't mesh well with new click actions")]
public bool TriggerClickAction()
{
if (this.OnClick == null)
return false;
this.OnClick.Invoke();
return true;
}
/// <summary>
/// Remove this entry from the bar.
/// You will need to re-acquire it from DtrBar to reuse it.