-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1415 from MidoriKami/AddonLifecycle_IAddonArgs
- Loading branch information
Showing
12 changed files
with
245 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Dalamud.Memory; | ||
using FFXIVClientStructs.FFXIV.Component.GUI; | ||
|
||
namespace Dalamud.Game.Addon; | ||
|
||
/// <summary> | ||
/// Base class for AddonLifecycle AddonArgTypes. | ||
/// </summary> | ||
public abstract unsafe class AddonArgs | ||
{ | ||
/// <summary> | ||
/// Constant string representing the name of an addon that is invalid. | ||
/// </summary> | ||
public const string InvalidAddon = "NullAddon"; | ||
|
||
private string? addonName; | ||
|
||
/// <summary> | ||
/// Gets the name of the addon this args referrers to. | ||
/// </summary> | ||
public string AddonName => this.GetAddonName(); | ||
|
||
/// <summary> | ||
/// Gets the pointer to the addons AtkUnitBase. | ||
/// </summary> | ||
public nint Addon { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the type of these args. | ||
/// </summary> | ||
public abstract AddonArgsType Type { get; } | ||
|
||
/// <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 == nint.Zero) return InvalidAddon; | ||
|
||
var addonPointer = (AtkUnitBase*)this.Addon; | ||
if (addonPointer->Name is null) return InvalidAddon; | ||
|
||
return this.addonName ??= MemoryHelper.ReadString((nint)addonPointer->Name, 0x20); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonDrawArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Dalamud.Game.Addon; | ||
|
||
/// <summary> | ||
/// Addon argument data for Finalize events. | ||
/// </summary> | ||
public class AddonDrawArgs : AddonArgs | ||
{ | ||
/// <inheritdoc/> | ||
public override AddonArgsType Type => AddonArgsType.Draw; | ||
} |
10 changes: 10 additions & 0 deletions
10
Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonFinalizeArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Dalamud.Game.Addon; | ||
|
||
/// <summary> | ||
/// Addon argument data for Finalize events. | ||
/// </summary> | ||
public class AddonFinalizeArgs : AddonArgs | ||
{ | ||
/// <inheritdoc/> | ||
public override AddonArgsType Type => AddonArgsType.Finalize; | ||
} |
28 changes: 28 additions & 0 deletions
28
Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonRefreshArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using FFXIVClientStructs.FFXIV.Component.GUI; | ||
|
||
namespace Dalamud.Game.Addon; | ||
|
||
/// <summary> | ||
/// Addon argument data for Finalize events. | ||
/// </summary> | ||
public class AddonRefreshArgs : AddonArgs | ||
{ | ||
/// <inheritdoc/> | ||
public override AddonArgsType Type => AddonArgsType.Refresh; | ||
|
||
/// <summary> | ||
/// Gets the number of AtkValues. | ||
/// </summary> | ||
public uint AtkValueCount { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the address of the AtkValue array. | ||
/// </summary> | ||
public nint AtkValues { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the AtkValues in the form of a span. | ||
/// </summary> | ||
public unsafe Span<AtkValue> AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount); | ||
} |
20 changes: 20 additions & 0 deletions
20
Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonRequestedUpdateArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Dalamud.Game.Addon; | ||
|
||
/// <summary> | ||
/// Addon argument data for Finalize events. | ||
/// </summary> | ||
public class AddonRequestedUpdateArgs : AddonArgs | ||
{ | ||
/// <inheritdoc/> | ||
public override AddonArgsType Type => AddonArgsType.RequestedUpdate; | ||
|
||
/// <summary> | ||
/// Gets the NumberArrayData** for this event. | ||
/// </summary> | ||
public nint NumberArrayData { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the StringArrayData** for this event. | ||
/// </summary> | ||
public nint StringArrayData { get; init; } | ||
} |
29 changes: 29 additions & 0 deletions
29
Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonSetupArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
|
||
using FFXIVClientStructs.FFXIV.Component.GUI; | ||
|
||
namespace Dalamud.Game.Addon; | ||
|
||
/// <summary> | ||
/// Addon argument data for Setup events. | ||
/// </summary> | ||
public class AddonSetupArgs : AddonArgs | ||
{ | ||
/// <inheritdoc/> | ||
public override AddonArgsType Type => AddonArgsType.Setup; | ||
|
||
/// <summary> | ||
/// Gets the number of AtkValues. | ||
/// </summary> | ||
public uint AtkValueCount { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the address of the AtkValue array. | ||
/// </summary> | ||
public nint AtkValues { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the AtkValues in the form of a span. | ||
/// </summary> | ||
public unsafe Span<AtkValue> AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount); | ||
} |
15 changes: 15 additions & 0 deletions
15
Dalamud/Game/AddonLifecycle/AddonArgTypes/AddonUpdateArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Dalamud.Game.Addon; | ||
|
||
/// <summary> | ||
/// Addon argument data for Finalize events. | ||
/// </summary> | ||
public class AddonUpdateArgs : AddonArgs | ||
{ | ||
/// <inheritdoc/> | ||
public override AddonArgsType Type => AddonArgsType.Update; | ||
|
||
/// <summary> | ||
/// Gets the time since the last update. | ||
/// </summary> | ||
public float TimeDelta { get; init; } | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Dalamud.Game.Addon; | ||
|
||
/// <summary> | ||
/// Enumeration for available AddonLifecycle arg data. | ||
/// </summary> | ||
public enum AddonArgsType | ||
{ | ||
/// <summary> | ||
/// Contains argument data for Setup. | ||
/// </summary> | ||
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> | ||
/// Contains argument data for RequestedUpdate. | ||
/// </summary> | ||
RequestedUpdate, | ||
|
||
/// <summary> | ||
/// Contains argument data for Refresh. | ||
/// </summary> | ||
Refresh, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.