mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Remove AddonEventManagerAddressResolver.cs
This commit is contained in:
parent
ddc743aae1
commit
3c7dbf9f81
2 changed files with 12 additions and 39 deletions
|
|
@ -9,7 +9,6 @@ using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Plugin.Internal.Types;
|
using Dalamud.Plugin.Internal.Types;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
|
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
|
||||||
namespace Dalamud.Game.Addon.Events;
|
namespace Dalamud.Game.Addon.Events;
|
||||||
|
|
@ -32,25 +31,21 @@ internal unsafe class AddonEventManager : IInternalDisposableService
|
||||||
|
|
||||||
private readonly AddonLifecycleEventListener finalizeEventListener;
|
private readonly AddonLifecycleEventListener finalizeEventListener;
|
||||||
|
|
||||||
private readonly AddonEventManagerAddressResolver address;
|
private readonly Hook<AtkUnitManager.Delegates.UpdateCursor> onUpdateCursor;
|
||||||
private readonly Hook<UpdateCursorDelegate> onUpdateCursor;
|
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<Guid, PluginEventController> pluginEventControllers;
|
private readonly ConcurrentDictionary<Guid, PluginEventController> pluginEventControllers;
|
||||||
|
|
||||||
private AddonCursorType? cursorOverride;
|
private AtkCursor.CursorType? cursorOverride;
|
||||||
|
|
||||||
[ServiceManager.ServiceConstructor]
|
[ServiceManager.ServiceConstructor]
|
||||||
private AddonEventManager(TargetSigScanner sigScanner)
|
private AddonEventManager()
|
||||||
{
|
{
|
||||||
this.address = new AddonEventManagerAddressResolver();
|
|
||||||
this.address.Setup(sigScanner);
|
|
||||||
|
|
||||||
this.pluginEventControllers = new ConcurrentDictionary<Guid, PluginEventController>();
|
this.pluginEventControllers = new ConcurrentDictionary<Guid, PluginEventController>();
|
||||||
this.pluginEventControllers.TryAdd(DalamudInternalKey, new PluginEventController());
|
this.pluginEventControllers.TryAdd(DalamudInternalKey, new PluginEventController());
|
||||||
|
|
||||||
this.cursorOverride = null;
|
this.cursorOverride = null;
|
||||||
|
|
||||||
this.onUpdateCursor = Hook<UpdateCursorDelegate>.FromAddress(this.address.UpdateCursor, this.UpdateCursorDetour);
|
this.onUpdateCursor = Hook<AtkUnitManager.Delegates.UpdateCursor>.FromAddress(AtkUnitManager.Addresses.UpdateCursor.Value, this.UpdateCursorDetour);
|
||||||
|
|
||||||
this.finalizeEventListener = new AddonLifecycleEventListener(AddonEvent.PreFinalize, string.Empty, this.OnAddonFinalize);
|
this.finalizeEventListener = new AddonLifecycleEventListener(AddonEvent.PreFinalize, string.Empty, this.OnAddonFinalize);
|
||||||
this.addonLifecycle.RegisterListener(this.finalizeEventListener);
|
this.addonLifecycle.RegisterListener(this.finalizeEventListener);
|
||||||
|
|
@ -58,8 +53,6 @@ internal unsafe class AddonEventManager : IInternalDisposableService
|
||||||
this.onUpdateCursor.Enable();
|
this.onUpdateCursor.Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private delegate nint UpdateCursorDelegate(RaptureAtkModule* module);
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
void IInternalDisposableService.DisposeService()
|
void IInternalDisposableService.DisposeService()
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +110,7 @@ internal unsafe class AddonEventManager : IInternalDisposableService
|
||||||
/// Force the game cursor to be the specified cursor.
|
/// Force the game cursor to be the specified cursor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cursor">Which cursor to use.</param>
|
/// <param name="cursor">Which cursor to use.</param>
|
||||||
internal void SetCursor(AddonCursorType cursor) => this.cursorOverride = cursor;
|
internal void SetCursor(AddonCursorType cursor) => this.cursorOverride = (AtkCursor.CursorType)cursor;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Un-forces the game cursor.
|
/// Un-forces the game cursor.
|
||||||
|
|
@ -168,7 +161,7 @@ internal unsafe class AddonEventManager : IInternalDisposableService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private nint UpdateCursorDetour(RaptureAtkModule* module)
|
private void UpdateCursorDetour(AtkUnitManager* thisPtr)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -176,13 +169,14 @@ internal unsafe class AddonEventManager : IInternalDisposableService
|
||||||
|
|
||||||
if (this.cursorOverride is not null && atkStage is not null)
|
if (this.cursorOverride is not null && atkStage is not null)
|
||||||
{
|
{
|
||||||
var cursor = (AddonCursorType)atkStage->AtkCursor.Type;
|
ref var atkCursor = ref atkStage->AtkCursor;
|
||||||
if (cursor != this.cursorOverride)
|
|
||||||
|
if (atkCursor.Type != this.cursorOverride)
|
||||||
{
|
{
|
||||||
AtkStage.Instance()->AtkCursor.SetCursorType((AtkCursor.CursorType)this.cursorOverride, 1);
|
atkCursor.SetCursorType((AtkCursor.CursorType)this.cursorOverride, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nint.Zero;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -190,7 +184,7 @@ internal unsafe class AddonEventManager : IInternalDisposableService
|
||||||
Log.Error(e, "Exception in UpdateCursorDetour.");
|
Log.Error(e, "Exception in UpdateCursorDetour.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.onUpdateCursor!.Original(module);
|
this.onUpdateCursor!.Original(thisPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
namespace Dalamud.Game.Addon.Events;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// AddonEventManager memory address resolver.
|
|
||||||
/// </summary>
|
|
||||||
internal class AddonEventManagerAddressResolver : BaseAddressResolver
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the address of the AtkModule UpdateCursor method.
|
|
||||||
/// </summary>
|
|
||||||
public nint UpdateCursor { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Scan for and setup any configured address pointers.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="scanner">The signature scanner to facilitate setup.</param>
|
|
||||||
protected override void Setup64Bit(ISigScanner scanner)
|
|
||||||
{
|
|
||||||
this.UpdateCursor = scanner.ScanText("48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC 20 4C 8B F1 E8 ?? ?? ?? ?? 49 8B CE"); // unnamed in CS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue