diff --git a/Dalamud/Game/Gui/Dtr/DtrBar.cs b/Dalamud/Game/Gui/Dtr/DtrBar.cs index b637791f0..54c3b2f95 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBar.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBar.cs @@ -5,7 +5,6 @@ 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; @@ -629,7 +628,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar } } - if (dtrBarEntry is { OnClick: not null }) + if (dtrBarEntry is not null) { switch (atkEventType) { @@ -642,7 +641,22 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar break; 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; } } diff --git a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs index 54847705d..2b9634588 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBarEntry.cs @@ -1,5 +1,5 @@ using Dalamud.Configuration.Internal; -using Dalamud.Game.Addon.Events.EventDataTypes; +using Dalamud.Game.Addon.Events; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Plugin.Internal.Types; 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. /// public bool UserHidden { get; } + + /// + /// 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(); } /// @@ -66,9 +73,25 @@ public interface IDtrBarEntry : IReadOnlyDtrBarEntry public new bool Shown { get; set; } /// - /// 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. /// - public Action? OnClick { get; set; } + [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. @@ -117,11 +140,23 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry /// public SeString? Tooltip { get; set; } - /// - public Action? OnClick { get; set; } + /// + /// 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 @@ -138,7 +173,7 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry } /// - [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; /// @@ -171,6 +206,17 @@ 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) + return false; + + this.OnClick.Invoke(); + return true; + } + /// /// Remove this entry from the bar. /// You will need to re-acquire it from DtrBar to reuse it.