mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Apply breaking changes
This commit is contained in:
parent
08c1768286
commit
386828005b
15 changed files with 114 additions and 261 deletions
|
|
@ -5,19 +5,24 @@ namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base class for AddonLifecycle AddonArgTypes.
|
/// Base class for AddonLifecycle AddonArgTypes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class AddonArgs
|
public class AddonArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constant string representing the name of an addon that is invalid.
|
/// Constant string representing the name of an addon that is invalid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string InvalidAddon = "NullAddon";
|
public const string InvalidAddon = "NullAddon";
|
||||||
|
|
||||||
private string? addonName;
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AddonArgs"/> class.
|
||||||
|
/// </summary>
|
||||||
|
internal AddonArgs()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the addon this args referrers to.
|
/// Gets the name of the addon this args referrers to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AddonName => this.GetAddonName();
|
public string AddonName { get; private set; } = InvalidAddon;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the pointer to the addons AtkUnitBase.
|
/// Gets the pointer to the addons AtkUnitBase.
|
||||||
|
|
@ -25,28 +30,17 @@ public abstract class AddonArgs
|
||||||
public AtkUnitBasePtr Addon
|
public AtkUnitBasePtr Addon
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
internal set;
|
internal set
|
||||||
|
{
|
||||||
|
field = value;
|
||||||
|
|
||||||
|
if (!this.Addon.IsNull && !string.IsNullOrEmpty(value.Name))
|
||||||
|
this.AddonName = value.Name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the type of these args.
|
/// Gets the type of these args.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract AddonArgsType Type { get; }
|
public virtual AddonArgsType Type => AddonArgsType.Generic;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Helper method for ensuring the name of the addon is valid.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The name of the addon for this object. <see cref="InvalidAddon"/> when invalid.</returns>
|
|
||||||
private string GetAddonName()
|
|
||||||
{
|
|
||||||
if (this.Addon.IsNull)
|
|
||||||
return InvalidAddon;
|
|
||||||
|
|
||||||
var name = this.Addon.Name;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(name))
|
|
||||||
return InvalidAddon;
|
|
||||||
|
|
||||||
return this.addonName ??= name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
using Dalamud.Utility;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Addon argument data for Draw events.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use AddonGenericArgs instead.")]
|
|
||||||
[Api15ToDo("Remove this")]
|
|
||||||
public class AddonDrawArgs : AddonArgs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="AddonDrawArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
internal AddonDrawArgs()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override AddonArgsType Type => AddonArgsType.Draw;
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
using Dalamud.Utility;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Addon argument data for ReceiveEvent events.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use AddonGenericArgs instead.")]
|
|
||||||
[Api15ToDo("Remove this")]
|
|
||||||
public class AddonFinalizeArgs : AddonArgs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="AddonFinalizeArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
internal AddonFinalizeArgs()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override AddonArgsType Type => AddonArgsType.Finalize;
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Addon argument data for Draw events.
|
|
||||||
/// </summary>
|
|
||||||
public class AddonGenericArgs : AddonArgs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="AddonGenericArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
internal AddonGenericArgs()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override AddonArgsType Type => AddonArgsType.Generic;
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
using Dalamud.Utility;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -35,6 +33,5 @@ public class AddonReceiveEventArgs : AddonArgs
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the pointer to an AtkEventData for this event message.
|
/// Gets or sets the pointer to an AtkEventData for this event message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Api14ToDo("Rename to AtkEventData")]
|
public nint AtkEventData { get; set; }
|
||||||
public nint Data { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
using Dalamud.Utility;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Addon argument data for Update events.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use AddonGenericArgs instead.")]
|
|
||||||
[Api15ToDo("Remove this")]
|
|
||||||
public class AddonUpdateArgs : AddonArgs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="AddonUpdateArgs"/> class.
|
|
||||||
/// </summary>
|
|
||||||
internal AddonUpdateArgs()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override AddonArgsType Type => AddonArgsType.Update;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the time since the last update.
|
|
||||||
/// </summary>
|
|
||||||
internal float TimeDeltaInternal { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the time since the last update.
|
|
||||||
/// </summary>
|
|
||||||
private float TimeDelta
|
|
||||||
{
|
|
||||||
get => this.TimeDeltaInternal;
|
|
||||||
init => this.TimeDeltaInternal = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,26 +5,16 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum AddonArgsType
|
public enum AddonArgsType
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generic arg type that contains no meaningful data.
|
||||||
|
/// </summary>
|
||||||
|
Generic,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains argument data for Setup.
|
/// Contains argument data for Setup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Setup,
|
Setup,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Contains argument data for Update.
|
|
||||||
/// </summary>
|
|
||||||
Update,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Contains argument data for Draw.
|
|
||||||
/// </summary>
|
|
||||||
Draw,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Contains argument data for Finalize.
|
|
||||||
/// </summary>
|
|
||||||
Finalize,
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains argument data for RequestedUpdate.
|
/// Contains argument data for RequestedUpdate.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -39,9 +29,4 @@ public enum AddonArgsType
|
||||||
/// Contains argument data for ReceiveEvent.
|
/// Contains argument data for ReceiveEvent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ReceiveEvent,
|
ReceiveEvent,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generic arg type that contains no meaningful data.
|
|
||||||
/// </summary>
|
|
||||||
Generic,
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ public enum AddonEvent
|
||||||
/// An event that is fired before an addon begins its update cycle via <see cref="AtkUnitBase.Update"/>. This event
|
/// An event that is fired before an addon begins its update cycle via <see cref="AtkUnitBase.Update"/>. This event
|
||||||
/// is fired every frame that an addon is loaded, regardless of visibility.
|
/// is fired every frame that an addon is loaded, regardless of visibility.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="AddonUpdateArgs"/>
|
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -42,7 +41,6 @@ public enum AddonEvent
|
||||||
/// An event that is fired before an addon begins drawing to screen via <see cref="AtkUnitBase.Draw"/>. Unlike
|
/// An event that is fired before an addon begins drawing to screen via <see cref="AtkUnitBase.Draw"/>. Unlike
|
||||||
/// <see cref="PreUpdate"/>, this event is only fired if an addon is visible or otherwise drawing to screen.
|
/// <see cref="PreUpdate"/>, this event is only fired if an addon is visible or otherwise drawing to screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="AddonDrawArgs"/>
|
|
||||||
PreDraw,
|
PreDraw,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -62,7 +60,6 @@ public enum AddonEvent
|
||||||
/// <br />
|
/// <br />
|
||||||
/// As this is part of the destruction process for an addon, this event does not have an associated Post event.
|
/// As this is part of the destruction process for an addon, this event does not have an associated Post event.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <seealso cref="AddonFinalizeArgs"/>
|
|
||||||
PreFinalize,
|
PreFinalize,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,15 @@ internal unsafe class AddonLifecycle : IInternalDisposableService
|
||||||
{
|
{
|
||||||
if (!this.EventListeners.ContainsKey(listener.EventType))
|
if (!this.EventListeners.ContainsKey(listener.EventType))
|
||||||
{
|
{
|
||||||
this.EventListeners.TryAdd(listener.EventType, []);
|
if (!this.EventListeners.TryAdd(listener.EventType, []))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: string.Empty is a valid addon name, as that will trigger on any addon for this event type
|
// Note: string.Empty is a valid addon name, as that will trigger on any addon for this event type
|
||||||
if (!this.EventListeners[listener.EventType].ContainsKey(listener.AddonName))
|
if (!this.EventListeners[listener.EventType].ContainsKey(listener.AddonName))
|
||||||
{
|
{
|
||||||
this.EventListeners[listener.EventType].TryAdd(listener.AddonName, []);
|
if (!this.EventListeners[listener.EventType].TryAdd(listener.AddonName, []))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.EventListeners[listener.EventType][listener.AddonName].Add(listener);
|
this.EventListeners[listener.EventType][listener.AddonName].Add(listener);
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
using Dalamud.Utility;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.Addon.Lifecycle;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// AddonLifecycleService memory address resolver.
|
|
||||||
/// </summary>
|
|
||||||
[Api14ToDo("Remove this class entirely, its not used by AddonLifecycle anymore, also need to use something else for HookWidget")]
|
|
||||||
internal class AddonLifecycleAddressResolver : BaseAddressResolver
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the address of the addon finalize hook invoked by the AtkUnitManager.
|
|
||||||
/// </summary>
|
|
||||||
public nint AddonFinalize { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Scan for and setup any configured address pointers.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sig">The signature scanner to facilitate setup.</param>
|
|
||||||
protected override void Setup64Bit(ISigScanner sig)
|
|
||||||
{
|
|
||||||
this.AddonFinalize = sig.ScanText("E8 ?? ?? ?? ?? 48 83 EF 01 75 D5");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -25,17 +25,12 @@ internal class AddonLifecycleEventListener
|
||||||
/// string.Empty if it wants to be called for any addon.
|
/// string.Empty if it wants to be called for any addon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AddonName { get; init; }
|
public string AddonName { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether this event has been unregistered.
|
|
||||||
/// </summary>
|
|
||||||
public bool Removed { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the event type this listener is looking for.
|
/// Gets the event type this listener is looking for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AddonEvent EventType { get; init; }
|
public AddonEvent EventType { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the delegate this listener invokes.
|
/// Gets the delegate this listener invokes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,18 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
|
|
||||||
private readonly AddonLifecycle lifecycleService;
|
private readonly AddonLifecycle lifecycleService;
|
||||||
|
|
||||||
private readonly AddonSetupArgs addonSetupArg = new();
|
// Each addon gets its own set of args that are used to mutate the original call when used in pre-calls
|
||||||
private readonly AddonFinalizeArgs addonFinalizeArg = new();
|
private readonly AddonSetupArgs setupArgs = new();
|
||||||
private readonly AddonDrawArgs addonDrawArg = new();
|
private readonly AddonArgs finalizeArgs = new();
|
||||||
private readonly AddonUpdateArgs addonUpdateArg = new();
|
private readonly AddonArgs drawArgs = new();
|
||||||
private readonly AddonRefreshArgs addonRefreshArg = new();
|
private readonly AddonArgs updateArgs = new();
|
||||||
private readonly AddonRequestedUpdateArgs addonRequestedUpdateArg = new();
|
private readonly AddonRefreshArgs refreshArgs = new();
|
||||||
private readonly AddonReceiveEventArgs addonReceiveEventArg = new();
|
private readonly AddonRequestedUpdateArgs requestedUpdateArgs = new();
|
||||||
private readonly AddonGenericArgs addonGenericArg = new();
|
private readonly AddonReceiveEventArgs receiveEventArgs = new();
|
||||||
|
private readonly AddonArgs openArgs = new();
|
||||||
|
private readonly AddonArgs closeArgs = new();
|
||||||
|
private readonly AddonArgs showArgs = new();
|
||||||
|
private readonly AddonArgs hideArgs = new();
|
||||||
|
|
||||||
private readonly AtkUnitBase* atkUnitBase;
|
private readonly AtkUnitBase* atkUnitBase;
|
||||||
|
|
||||||
|
|
@ -133,12 +137,13 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
{
|
{
|
||||||
this.LogEvent(EnableLogging);
|
this.LogEvent(EnableLogging);
|
||||||
|
|
||||||
this.addonSetupArg.Addon = addon;
|
this.setupArgs.Addon = addon;
|
||||||
this.addonSetupArg.AtkValueCount = valueCount;
|
this.setupArgs.AtkValueCount = valueCount;
|
||||||
this.addonSetupArg.AtkValues = (nint)values;
|
this.setupArgs.AtkValues = (nint)values;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreSetup, this.addonSetupArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreSetup, this.setupArgs);
|
||||||
valueCount = this.addonSetupArg.AtkValueCount;
|
|
||||||
values = (AtkValue*)this.addonSetupArg.AtkValues;
|
valueCount = this.setupArgs.AtkValueCount;
|
||||||
|
values = (AtkValue*)this.setupArgs.AtkValues;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -149,15 +154,15 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonSetup. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonSetup. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostSetup, this.addonSetupArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostSetup, this.setupArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAddonFinalize(AtkUnitBase* thisPtr)
|
private void OnAddonFinalize(AtkUnitBase* thisPtr)
|
||||||
{
|
{
|
||||||
this.LogEvent(EnableLogging);
|
this.LogEvent(EnableLogging);
|
||||||
|
|
||||||
this.addonFinalizeArg.Addon = thisPtr;
|
this.finalizeArgs.Addon = thisPtr;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreFinalize, this.addonFinalizeArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreFinalize, this.finalizeArgs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -173,8 +178,8 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
{
|
{
|
||||||
this.LogEvent(EnableLogging);
|
this.LogEvent(EnableLogging);
|
||||||
|
|
||||||
this.addonDrawArg.Addon = addon;
|
this.drawArgs.Addon = addon;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreDraw, this.addonDrawArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreDraw, this.drawArgs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -185,16 +190,15 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonDraw. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonDraw. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostDraw, this.addonDrawArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostDraw, this.drawArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAddonUpdate(AtkUnitBase* addon, float delta)
|
private void OnAddonUpdate(AtkUnitBase* addon, float delta)
|
||||||
{
|
{
|
||||||
this.LogEvent(EnableLogging);
|
this.LogEvent(EnableLogging);
|
||||||
|
|
||||||
this.addonUpdateArg.Addon = addon;
|
this.updateArgs.Addon = addon;
|
||||||
this.addonUpdateArg.TimeDeltaInternal = delta;
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreUpdate, this.updateArgs);
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreUpdate, this.addonUpdateArg);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -205,7 +209,7 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonUpdate. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonUpdate. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostUpdate, this.addonUpdateArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostUpdate, this.updateArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OnAddonRefresh(AtkUnitBase* addon, uint valueCount, AtkValue* values)
|
private bool OnAddonRefresh(AtkUnitBase* addon, uint valueCount, AtkValue* values)
|
||||||
|
|
@ -214,12 +218,13 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
|
|
||||||
var result = false;
|
var result = false;
|
||||||
|
|
||||||
this.addonRefreshArg.Addon = addon;
|
this.refreshArgs.Addon = addon;
|
||||||
this.addonRefreshArg.AtkValueCount = valueCount;
|
this.refreshArgs.AtkValueCount = valueCount;
|
||||||
this.addonRefreshArg.AtkValues = (nint)values;
|
this.refreshArgs.AtkValues = (nint)values;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreRefresh, this.addonRefreshArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreRefresh, this.refreshArgs);
|
||||||
valueCount = this.addonRefreshArg.AtkValueCount;
|
|
||||||
values = (AtkValue*)this.addonRefreshArg.AtkValues;
|
valueCount = this.refreshArgs.AtkValueCount;
|
||||||
|
values = (AtkValue*)this.refreshArgs.AtkValues;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -230,7 +235,7 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonRefresh. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonRefresh. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostRefresh, this.addonRefreshArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostRefresh, this.refreshArgs);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,12 +243,13 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
{
|
{
|
||||||
this.LogEvent(EnableLogging);
|
this.LogEvent(EnableLogging);
|
||||||
|
|
||||||
this.addonRequestedUpdateArg.Addon = addon;
|
this.requestedUpdateArgs.Addon = addon;
|
||||||
this.addonRequestedUpdateArg.NumberArrayData = (nint)numberArrayData;
|
this.requestedUpdateArgs.NumberArrayData = (nint)numberArrayData;
|
||||||
this.addonRequestedUpdateArg.StringArrayData = (nint)stringArrayData;
|
this.requestedUpdateArgs.StringArrayData = (nint)stringArrayData;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreRequestedUpdate, this.addonRequestedUpdateArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreRequestedUpdate, this.requestedUpdateArgs);
|
||||||
numberArrayData = (NumberArrayData**)this.addonRequestedUpdateArg.NumberArrayData;
|
|
||||||
stringArrayData = (StringArrayData**)this.addonRequestedUpdateArg.StringArrayData;
|
numberArrayData = (NumberArrayData**)this.requestedUpdateArgs.NumberArrayData;
|
||||||
|
stringArrayData = (StringArrayData**)this.requestedUpdateArgs.StringArrayData;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -254,23 +260,24 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonRequestedUpdate. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonRequestedUpdate. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostRequestedUpdate, this.addonRequestedUpdateArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostRequestedUpdate, this.requestedUpdateArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAddonReceiveEvent(AtkUnitBase* addon, AtkEventType eventType, int eventParam, AtkEvent* atkEvent, AtkEventData* atkEventData)
|
private void OnAddonReceiveEvent(AtkUnitBase* addon, AtkEventType eventType, int eventParam, AtkEvent* atkEvent, AtkEventData* atkEventData)
|
||||||
{
|
{
|
||||||
this.LogEvent(EnableLogging);
|
this.LogEvent(EnableLogging);
|
||||||
|
|
||||||
this.addonReceiveEventArg.Addon = (nint)addon;
|
this.receiveEventArgs.Addon = (nint)addon;
|
||||||
this.addonReceiveEventArg.AtkEventType = (byte)eventType;
|
this.receiveEventArgs.AtkEventType = (byte)eventType;
|
||||||
this.addonReceiveEventArg.EventParam = eventParam;
|
this.receiveEventArgs.EventParam = eventParam;
|
||||||
this.addonReceiveEventArg.AtkEvent = (IntPtr)atkEvent;
|
this.receiveEventArgs.AtkEvent = (IntPtr)atkEvent;
|
||||||
this.addonReceiveEventArg.Data = (nint)atkEventData;
|
this.receiveEventArgs.AtkEventData = (nint)atkEventData;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreReceiveEvent, this.addonReceiveEventArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreReceiveEvent, this.receiveEventArgs);
|
||||||
eventType = (AtkEventType)this.addonReceiveEventArg.AtkEventType;
|
|
||||||
eventParam = this.addonReceiveEventArg.EventParam;
|
eventType = (AtkEventType)this.receiveEventArgs.AtkEventType;
|
||||||
atkEvent = (AtkEvent*)this.addonReceiveEventArg.AtkEvent;
|
eventParam = this.receiveEventArgs.EventParam;
|
||||||
atkEventData = (AtkEventData*)this.addonReceiveEventArg.Data;
|
atkEvent = (AtkEvent*)this.receiveEventArgs.AtkEvent;
|
||||||
|
atkEventData = (AtkEventData*)this.receiveEventArgs.AtkEventData;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -281,7 +288,7 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonReceiveEvent. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonReceiveEvent. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostReceiveEvent, this.addonReceiveEventArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostReceiveEvent, this.receiveEventArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OnAddonOpen(AtkUnitBase* thisPtr, uint depthLayer)
|
private bool OnAddonOpen(AtkUnitBase* thisPtr, uint depthLayer)
|
||||||
|
|
@ -290,8 +297,8 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
|
|
||||||
var result = false;
|
var result = false;
|
||||||
|
|
||||||
this.addonGenericArg.Addon = thisPtr;
|
this.openArgs.Addon = thisPtr;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreOpen, this.addonGenericArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreOpen, this.openArgs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -302,7 +309,7 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonOpen. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonOpen. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostOpen, this.addonGenericArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostOpen, this.openArgs);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -313,8 +320,8 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
|
|
||||||
var result = false;
|
var result = false;
|
||||||
|
|
||||||
this.addonGenericArg.Addon = thisPtr;
|
this.closeArgs.Addon = thisPtr;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreClose, this.addonGenericArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreClose, this.closeArgs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -325,7 +332,7 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonClose. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonClose. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostClose, this.addonGenericArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostClose, this.closeArgs);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -334,8 +341,8 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
{
|
{
|
||||||
this.LogEvent(EnableLogging);
|
this.LogEvent(EnableLogging);
|
||||||
|
|
||||||
this.addonGenericArg.Addon = thisPtr;
|
this.showArgs.Addon = thisPtr;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreShow, this.addonGenericArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreShow, this.showArgs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -346,15 +353,15 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonShow. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonShow. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostShow, this.addonGenericArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostShow, this.showArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAddonHide(AtkUnitBase* thisPtr, bool unkBool, bool callHideCallback, uint setShowHideFlags)
|
private void OnAddonHide(AtkUnitBase* thisPtr, bool unkBool, bool callHideCallback, uint setShowHideFlags)
|
||||||
{
|
{
|
||||||
this.LogEvent(EnableLogging);
|
this.LogEvent(EnableLogging);
|
||||||
|
|
||||||
this.addonGenericArg.Addon = thisPtr;
|
this.hideArgs.Addon = thisPtr;
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreHide, this.addonGenericArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreHide, this.hideArgs);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -365,7 +372,7 @@ internal unsafe class AddonVirtualTable : IDisposable
|
||||||
Log.Error(e, "Caught exception when calling original AddonHide. This may be a bug in the game or another plugin hooking this method.");
|
Log.Error(e, "Caught exception when calling original AddonHide. This may be a bug in the game or another plugin hooking this method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostHide, this.addonGenericArg);
|
this.lifecycleService.InvokeListenersSafely(AddonEvent.PostHide, this.hideArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,8 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.Addon.Lifecycle;
|
using Dalamud.Game.ClientState;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Windows.Win32.Foundation;
|
using Windows.Win32.Foundation;
|
||||||
using Windows.Win32.UI.WindowsAndMessaging;
|
using Windows.Win32.UI.WindowsAndMessaging;
|
||||||
|
|
@ -17,7 +16,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Widget for displaying hook information.
|
/// Widget for displaying hook information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal unsafe class HookWidget : IDataWindowWidget
|
internal class HookWidget : IDataWindowWidget
|
||||||
{
|
{
|
||||||
private readonly List<IDalamudHook> hookStressTestList = [];
|
private readonly List<IDalamudHook> hookStressTestList = [];
|
||||||
|
|
||||||
|
|
@ -32,9 +31,9 @@ internal unsafe class HookWidget : IDataWindowWidget
|
||||||
private bool hookStressTestRunning = false;
|
private bool hookStressTestRunning = false;
|
||||||
|
|
||||||
private MessageBoxWDelegate? messageBoxWOriginal;
|
private MessageBoxWDelegate? messageBoxWOriginal;
|
||||||
private AddonFinalizeDelegate? addonFinalizeOriginal;
|
private HandleZoneInitPacketDelegate? zoneInitOriginal;
|
||||||
|
|
||||||
private AddonLifecycleAddressResolver? address;
|
private ClientStateAddressResolver? address;
|
||||||
|
|
||||||
private delegate int MessageBoxWDelegate(
|
private delegate int MessageBoxWDelegate(
|
||||||
IntPtr hWnd,
|
IntPtr hWnd,
|
||||||
|
|
@ -42,12 +41,12 @@ internal unsafe class HookWidget : IDataWindowWidget
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string caption,
|
[MarshalAs(UnmanagedType.LPWStr)] string caption,
|
||||||
MESSAGEBOX_STYLE type);
|
MESSAGEBOX_STYLE type);
|
||||||
|
|
||||||
private delegate void AddonFinalizeDelegate(AtkUnitManager* unitManager, AtkUnitBase** atkUnitBase);
|
private delegate void HandleZoneInitPacketDelegate(nint a1, uint localPlayerEntityId, nint packet, byte type);
|
||||||
|
|
||||||
private enum StressTestHookTarget
|
private enum StressTestHookTarget
|
||||||
{
|
{
|
||||||
MessageBoxW,
|
MessageBoxW,
|
||||||
AddonFinalize,
|
ZoneInit,
|
||||||
Random,
|
Random,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +64,7 @@ internal unsafe class HookWidget : IDataWindowWidget
|
||||||
{
|
{
|
||||||
this.Ready = true;
|
this.Ready = true;
|
||||||
|
|
||||||
this.address = new AddonLifecycleAddressResolver();
|
this.address = new ClientStateAddressResolver();
|
||||||
this.address.Setup(Service<TargetSigScanner>.Get());
|
this.address.Setup(Service<TargetSigScanner>.Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,7 +178,7 @@ internal unsafe class HookWidget : IDataWindowWidget
|
||||||
return target switch
|
return target switch
|
||||||
{
|
{
|
||||||
StressTestHookTarget.MessageBoxW => "MessageBoxW (Hook)",
|
StressTestHookTarget.MessageBoxW => "MessageBoxW (Hook)",
|
||||||
StressTestHookTarget.AddonFinalize => "AddonFinalize (Hook)",
|
StressTestHookTarget.ZoneInit => "ZoneInit (Hook)",
|
||||||
_ => target.ToString(),
|
_ => target.ToString(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -198,15 +197,10 @@ internal unsafe class HookWidget : IDataWindowWidget
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAddonFinalize(AtkUnitManager* unitManager, AtkUnitBase** atkUnitBase)
|
private void OnZoneInit(IntPtr a1, uint localPlayerEntityId, IntPtr packet, byte type)
|
||||||
{
|
{
|
||||||
Log.Information("OnAddonFinalize");
|
Log.Information("OnZoneInit");
|
||||||
this.addonFinalizeOriginal!(unitManager, atkUnitBase);
|
this.zoneInitOriginal!.Invoke(a1, localPlayerEntityId, packet, type);
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAddonUpdate(AtkUnitBase* thisPtr, float delta)
|
|
||||||
{
|
|
||||||
Log.Information("OnAddonUpdate");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDalamudHook HookMessageBoxW()
|
private IDalamudHook HookMessageBoxW()
|
||||||
|
|
@ -222,11 +216,11 @@ internal unsafe class HookWidget : IDataWindowWidget
|
||||||
return hook;
|
return hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDalamudHook HookAddonFinalize()
|
private IDalamudHook HookZoneInit()
|
||||||
{
|
{
|
||||||
var hook = Hook<AddonFinalizeDelegate>.FromAddress(this.address!.AddonFinalize, this.OnAddonFinalize);
|
var hook = Hook<HandleZoneInitPacketDelegate>.FromAddress(this.address!.HandleZoneInitPacket, this.OnZoneInit);
|
||||||
|
|
||||||
this.addonFinalizeOriginal = hook.Original;
|
this.zoneInitOriginal = hook.Original;
|
||||||
hook.Enable();
|
hook.Enable();
|
||||||
return hook;
|
return hook;
|
||||||
}
|
}
|
||||||
|
|
@ -241,7 +235,7 @@ internal unsafe class HookWidget : IDataWindowWidget
|
||||||
return target switch
|
return target switch
|
||||||
{
|
{
|
||||||
StressTestHookTarget.MessageBoxW => this.HookMessageBoxW(),
|
StressTestHookTarget.MessageBoxW => this.HookMessageBoxW(),
|
||||||
StressTestHookTarget.AddonFinalize => this.HookAddonFinalize(),
|
StressTestHookTarget.ZoneInit => this.HookZoneInit(),
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(target), target, null),
|
_ => throw new ArgumentOutOfRangeException(nameof(target), target, null),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -471,9 +471,9 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
||||||
|
|
||||||
private unsafe void OnVersionStringDraw(AddonEvent ev, AddonArgs args)
|
private unsafe void OnVersionStringDraw(AddonEvent ev, AddonArgs args)
|
||||||
{
|
{
|
||||||
if (args is not AddonDrawArgs drawArgs) return;
|
if (ev is not (AddonEvent.PostDraw or AddonEvent.PreDraw)) return;
|
||||||
|
|
||||||
var addon = drawArgs.Addon.Struct;
|
var addon = args.Addon.Struct;
|
||||||
var textNode = addon->GetTextNodeById(3);
|
var textNode = addon->GetTextNodeById(3);
|
||||||
|
|
||||||
// look and feel init. should be harmless to set.
|
// look and feel init. should be harmless to set.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<TargetFramework>net10.0-windows</TargetFramework>
|
<TargetFramework>net10.0-windows</TargetFramework>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<Platforms>x64</Platforms>
|
<Platforms>x64</Platforms>
|
||||||
<LangVersion>13.0</LangVersion>
|
<LangVersion>14.0</LangVersion>
|
||||||
|
|
||||||
<!-- Disable Intel CET. Causes crashes on unpatched Windows 10 systems. -->
|
<!-- Disable Intel CET. Causes crashes on unpatched Windows 10 systems. -->
|
||||||
<!-- https://github.com/dotnet/runtime/issues/108589 -->
|
<!-- https://github.com/dotnet/runtime/issues/108589 -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue