mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 05:43:40 +01:00
Add AddonLifecycle Service (#1361)
Adds new service to manage addon lifecycle events, such as setup/teardown.
This commit is contained in:
parent
49bffccf82
commit
efefcd70cf
3 changed files with 246 additions and 0 deletions
50
Dalamud/Plugin/Services/IAddonLifecycle.cs
Normal file
50
Dalamud/Plugin/Services/IAddonLifecycle.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
|
||||
using Dalamud.Memory;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
||||
/// <summary>
|
||||
/// This class provides events for in-game addon lifecycles.
|
||||
/// </summary>
|
||||
public interface IAddonLifecycle
|
||||
{
|
||||
/// <summary>
|
||||
/// Event that fires before an addon is being setup.
|
||||
/// </summary>
|
||||
public event Action<AddonArgs> AddonPreSetup;
|
||||
|
||||
/// <summary>
|
||||
/// Event that fires after an addon is done being setup.
|
||||
/// </summary>
|
||||
public event Action<AddonArgs> AddonPostSetup;
|
||||
|
||||
/// <summary>
|
||||
/// Event that fires before an addon is being finalized.
|
||||
/// </summary>
|
||||
public event Action<AddonArgs> AddonPreFinalize;
|
||||
|
||||
/// <summary>
|
||||
/// Event that fires after an addon is done being finalized.
|
||||
/// </summary>
|
||||
public event Action<AddonArgs> AddonPostFinalize;
|
||||
|
||||
/// <summary>
|
||||
/// Addon argument data for use in event subscribers.
|
||||
/// </summary>
|
||||
public unsafe class AddonArgs
|
||||
{
|
||||
private string? addonName;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the addon this args referrers to.
|
||||
/// </summary>
|
||||
public string AddonName => this.addonName ??= MemoryHelper.ReadString((nint)((AtkUnitBase*)this.Addon)->Name, 0x20);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pointer to the addons AtkUnitBase.
|
||||
/// </summary>
|
||||
required public nint Addon { get; init; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue