diff --git a/Dalamud/Game/Gui/Dtr/DtrBar.cs b/Dalamud/Game/Gui/Dtr/DtrBar.cs index 8339838fd..54c3b2f95 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBar.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBar.cs @@ -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 - // // 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; } } diff --git a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs index 26708eb4c..2b9634588 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs @@ -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. /// /// True, if a click action was registered and executed. + [Api13ToDo("Remove, doesn't mesh well with new click actions")] public bool TriggerClickAction(); } @@ -73,8 +75,24 @@ public interface IDtrBarEntry : IReadOnlyDtrBarEntry /// /// Gets or sets a action to be invoked when the user clicks on the dtr entry. /// + [Api13ToDo("Remove this, and rename OnClicked to OnClick")] public Action? OnClick { get; set; } + /// + /// Gets or sets a action to be invoked when the user left-clicks on the dtr entry. + /// + public Action? OnLeftClick { get; set; } + + /// + /// Gets or sets a action to be invoked when the user right-clicks on the dtr entry. + /// + public Action? OnRightClick { get; set; } + + /// + /// Gets or sets a action to be invoked when the user clicks on the dtr entry. + /// + public Action? OnClicked { get; set; } + /// /// 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 /// /// Gets or sets a action to be invoked when the user clicks on the dtr entry. /// + [Api13ToDo("Remove this and rename OnClicked to OnClick")] public Action? OnClick { get; set; } /// - public bool HasClickAction => this.OnClick != null; + public Action? OnLeftClick { get; set; } + + /// + public Action? OnRightClick { get; set; } + + /// + public Action? OnClicked { get; set; } + + /// + public bool HasClickAction => this.OnClick != null || this.OnLeftClick != null || this.OnRightClick != null || this.OnClicked != null; /// public bool Shown @@ -179,6 +207,7 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry internal LocalPlugin? OwnerPlugin { get; set; } /// + [Api13ToDo("Remove, doesn't mesh well with new click actions")] public bool TriggerClickAction() { if (this.OnClick == null)