mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 14:27:45 +01:00
IDtrBar Add Additional Click Events (#2325)
* Add additional dtr click events * Let's just break things and make them really nice * Add additional dtr click events * Let's just break things and make them really nice * Add additional dtr click events * Let's just break things and make them really nice * git is stupid * Documentation fixing
This commit is contained in:
parent
6a1d5db50e
commit
6369982b48
6 changed files with 121 additions and 42 deletions
|
|
@ -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;
|
||||
|
|
@ -596,24 +597,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();
|
||||
|
|
@ -652,7 +642,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
|
|||
break;
|
||||
|
||||
case AddonEventType.MouseClick:
|
||||
dtrBarEntry.OnClick.Invoke();
|
||||
dtrBarEntry.OnClick?.Invoke(new AddonMouseEventData(eventData));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Game.Addon.Events.EventDataTypes;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Utility;
|
||||
|
|
@ -42,12 +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>
|
||||
public bool TriggerClickAction();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -71,9 +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>
|
||||
public Action? OnClick { get; set; }
|
||||
public Action<AddonMouseEventData>? OnClick { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Remove this entry from the bar.
|
||||
|
|
@ -122,10 +117,8 @@ 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>
|
||||
public Action? OnClick { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public Action<AddonMouseEventData>? OnClick { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool HasClickAction => this.OnClick != null;
|
||||
|
|
@ -145,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>
|
||||
|
|
@ -178,16 +171,6 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
|
|||
/// </summary>
|
||||
internal LocalPlugin? OwnerPlugin { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue