mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-28 19:39:19 +01:00
Add additional dtr click events
This commit is contained in:
parent
b425ee0a2a
commit
d41f591fc2
2 changed files with 50 additions and 17 deletions
|
|
@ -596,24 +596,13 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
|||
newTextNode->TextColor = new ByteColor { R = 255, G = 255, B = 255, A = 255 };
|
||||
newTextNode->EdgeColor = new ByteColor { R = 142, G = 106, B = 12, A = 255 };
|
||||
|
||||
// ICreatable was restored, this may be necessary if AtkUldManager.CreateAtkTextNode(); is used instead of Create<T>
|
||||
// // Memory is filled with random data after being created, zero out some things to avoid issues.
|
||||
// newTextNode->UnkPtr_1 = null;
|
||||
// newTextNode->SelectStart = 0;
|
||||
// newTextNode->SelectEnd = 0;
|
||||
// newTextNode->FontCacheHandle = 0;
|
||||
// newTextNode->CharSpacing = 0;
|
||||
// newTextNode->BackgroundColor = new ByteColor { R = 0, G = 0, B = 0, A = 0 };
|
||||
// newTextNode->TextId = 0;
|
||||
// newTextNode->SheetType = 0;
|
||||
|
||||
return newTextNode;
|
||||
}
|
||||
|
||||
private void DtrEventHandler(AddonEventType atkEventType, AddonEventData data)
|
||||
private void DtrEventHandler(AddonEventType atkEventType, AddonEventData eventData)
|
||||
{
|
||||
var addon = (AtkUnitBase*)data.AddonPointer;
|
||||
var node = (AtkResNode*)data.NodeTargetPointer;
|
||||
var addon = (AtkUnitBase*)eventData.AddonPointer;
|
||||
var node = (AtkResNode*)eventData.NodeTargetPointer;
|
||||
|
||||
DtrBarEntry? dtrBarEntry = null;
|
||||
this.entriesLock.EnterReadLock();
|
||||
|
|
@ -639,7 +628,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
|||
}
|
||||
}
|
||||
|
||||
if (dtrBarEntry is { OnClick: not null })
|
||||
if (dtrBarEntry is not null)
|
||||
{
|
||||
switch (atkEventType)
|
||||
{
|
||||
|
|
@ -652,7 +641,22 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
|||
break;
|
||||
|
||||
case AddonEventType.MouseClick:
|
||||
dtrBarEntry.OnClick.Invoke();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Game.Addon.Events;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Utility;
|
||||
|
|
@ -47,6 +48,7 @@ public interface IReadOnlyDtrBarEntry
|
|||
/// 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();
|
||||
}
|
||||
|
||||
|
|
@ -73,8 +75,24 @@ public interface IDtrBarEntry : IReadOnlyDtrBarEntry
|
|||
/// <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; }
|
||||
|
||||
/// <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>
|
||||
/// Remove this entry from the bar.
|
||||
/// You will need to re-acquire it from DtrBar to reuse it.
|
||||
|
|
@ -125,10 +143,20 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
|
|||
/// <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 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" />
|
||||
public bool Shown
|
||||
|
|
@ -179,6 +207,7 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
|
|||
internal LocalPlugin? OwnerPlugin { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[Api13ToDo("Remove, doesn't mesh well with new click actions")]
|
||||
public bool TriggerClickAction()
|
||||
{
|
||||
if (this.OnClick == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue