mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-22 08:29:18 +01:00
Add additional dtr click events
This commit is contained in:
parent
dfd0f19490
commit
124c024c4d
2 changed files with 70 additions and 10 deletions
|
|
@ -5,7 +5,6 @@ using System.Threading;
|
||||||
|
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Game.Addon.Events;
|
using Dalamud.Game.Addon.Events;
|
||||||
using Dalamud.Game.Addon.Events.EventDataTypes;
|
|
||||||
using Dalamud.Game.Addon.Lifecycle;
|
using Dalamud.Game.Addon.Lifecycle;
|
||||||
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
|
|
@ -629,7 +628,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dtrBarEntry is { OnClick: not null })
|
if (dtrBarEntry is not null)
|
||||||
{
|
{
|
||||||
switch (atkEventType)
|
switch (atkEventType)
|
||||||
{
|
{
|
||||||
|
|
@ -642,7 +641,22 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AddonEventType.MouseClick:
|
case AddonEventType.MouseClick:
|
||||||
dtrBarEntry.OnClick?.Invoke(new AddonMouseEventData(eventData));
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Game.Addon.Events.EventDataTypes;
|
using Dalamud.Game.Addon.Events;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Plugin.Internal.Types;
|
using Dalamud.Plugin.Internal.Types;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
|
@ -43,6 +43,13 @@ public interface IReadOnlyDtrBarEntry
|
||||||
/// Gets a value indicating whether the user has hidden this entry from view through the Dalamud settings.
|
/// Gets a value indicating whether the user has hidden this entry from view through the Dalamud settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UserHidden { get; }
|
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>
|
/// <summary>
|
||||||
|
|
@ -66,9 +73,25 @@ public interface IDtrBarEntry : IReadOnlyDtrBarEntry
|
||||||
public new bool Shown { get; set; }
|
public new bool Shown { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets an action to be invoked when the user clicks on the dtr entry.
|
/// Gets or sets a action to be invoked when the user clicks on the dtr entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<AddonMouseEventData>? OnClick { get; set; }
|
[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; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove this entry from the bar.
|
/// Remove this entry from the bar.
|
||||||
|
|
@ -117,11 +140,23 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
|
||||||
/// <inheritdoc cref="IDtrBarEntry.Tooltip" />
|
/// <inheritdoc cref="IDtrBarEntry.Tooltip" />
|
||||||
public SeString? Tooltip { get; set; }
|
public SeString? Tooltip { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <summary>
|
||||||
public Action<AddonMouseEventData>? OnClick { get; set; }
|
/// 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/>
|
/// <inheritdoc/>
|
||||||
public bool HasClickAction => this.OnClick != null;
|
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;
|
||||||
|
|
||||||
/// <inheritdoc cref="IDtrBarEntry.Shown" />
|
/// <inheritdoc cref="IDtrBarEntry.Shown" />
|
||||||
public bool Shown
|
public bool Shown
|
||||||
|
|
@ -138,7 +173,7 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
[Api13ToDo("Maybe make this config scoped to internal name?")]
|
[Api13ToDo("Maybe make this config scoped to internalname?")]
|
||||||
public bool UserHidden => this.configuration.DtrIgnore?.Contains(this.Title) ?? false;
|
public bool UserHidden => this.configuration.DtrIgnore?.Contains(this.Title) ?? false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -171,6 +206,17 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal LocalPlugin? OwnerPlugin { get; set; }
|
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>
|
/// <summary>
|
||||||
/// Remove this entry from the bar.
|
/// Remove this entry from the bar.
|
||||||
/// You will need to re-acquire it from DtrBar to reuse it.
|
/// You will need to re-acquire it from DtrBar to reuse it.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue