Bunch of stuff...

This commit is contained in:
MidoriKami 2025-11-30 10:39:35 -08:00
parent eb9555ee22
commit 08c1768286
17 changed files with 74 additions and 116 deletions

View file

@ -11,7 +11,7 @@ namespace Dalamud.Configuration;
/// <summary>
/// Configuration to store settings for a dalamud plugin.
/// </summary>
[Api13ToDo("Make this a service. We need to be able to dispose it reliably to write configs asynchronously. Maybe also let people write files with vfs.")]
[Api14ToDo("Make this a service. We need to be able to dispose it reliably to write configs asynchronously. Maybe also let people write files with vfs.")]
public sealed class PluginConfigurations
{
private readonly DirectoryInfo configDirectory;

View file

@ -33,41 +33,14 @@ public abstract class AddonArgs
/// </summary>
public abstract AddonArgsType Type { get; }
/// <summary>
/// Checks if addon name matches the given span of char.
/// </summary>
/// <param name="name">The name to check.</param>
/// <returns>Whether it is the case.</returns>
internal bool IsAddon(string name)
{
if (this.Addon.IsNull)
return false;
if (name.Length is 0 or > 32)
return false;
if (string.IsNullOrEmpty(this.Addon.Name))
return false;
return name == this.Addon.Name;
}
/// <summary>
/// Clears this AddonArgs values.
/// </summary>
internal virtual void Clear()
{
this.addonName = null;
this.Addon = 0;
}
/// <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;
if (this.Addon.IsNull)
return InvalidAddon;
var name = this.Addon.Name;

View file

@ -1,15 +1,18 @@
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
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>
[Obsolete("Not intended for public construction.", false)]
public AddonDrawArgs()
internal AddonDrawArgs()
{
}

View file

@ -1,15 +1,18 @@
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>
[Obsolete("Not intended for public construction.", false)]
public AddonFinalizeArgs()
internal AddonFinalizeArgs()
{
}

View file

@ -8,8 +8,7 @@ public class AddonGenericArgs : AddonArgs
/// <summary>
/// Initializes a new instance of the <see cref="AddonGenericArgs"/> class.
/// </summary>
[Obsolete("Not intended for public construction.", false)]
public AddonGenericArgs()
internal AddonGenericArgs()
{
}

View file

@ -1,3 +1,5 @@
using Dalamud.Utility;
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
/// <summary>
@ -8,8 +10,7 @@ public class AddonReceiveEventArgs : AddonArgs
/// <summary>
/// Initializes a new instance of the <see cref="AddonReceiveEventArgs"/> class.
/// </summary>
[Obsolete("Not intended for public construction.", false)]
public AddonReceiveEventArgs()
internal AddonReceiveEventArgs()
{
}
@ -32,17 +33,8 @@ public class AddonReceiveEventArgs : AddonArgs
public nint AtkEvent { get; set; }
/// <summary>
/// Gets or sets the pointer to a block of data for this event message.
/// Gets or sets the pointer to an AtkEventData for this event message.
/// </summary>
[Api14ToDo("Rename to AtkEventData")]
public nint Data { get; set; }
/// <inheritdoc cref="AddonArgs.Clear"/>
internal override void Clear()
{
base.Clear();
this.AtkEventType = 0;
this.EventParam = 0;
this.AtkEvent = 0;
this.Data = 0;
}
}

View file

@ -1,3 +1,5 @@
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
@ -10,8 +12,7 @@ public class AddonRefreshArgs : AddonArgs
/// <summary>
/// Initializes a new instance of the <see cref="AddonRefreshArgs"/> class.
/// </summary>
[Obsolete("Not intended for public construction.", false)]
public AddonRefreshArgs()
internal AddonRefreshArgs()
{
}
@ -31,13 +32,7 @@ public class AddonRefreshArgs : AddonArgs
/// <summary>
/// Gets the AtkValues in the form of a span.
/// </summary>
[Obsolete("Pending removal, unsafe to use when using custom ClientStructs")]
[Api15ToDo("Remove this")]
public unsafe Span<AtkValue> AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount);
/// <inheritdoc cref="AddonArgs.Clear"/>
internal override void Clear()
{
base.Clear();
this.AtkValueCount = 0;
this.AtkValues = 0;
}
}

View file

@ -8,8 +8,7 @@ public class AddonRequestedUpdateArgs : AddonArgs
/// <summary>
/// Initializes a new instance of the <see cref="AddonRequestedUpdateArgs"/> class.
/// </summary>
[Obsolete("Not intended for public construction.", false)]
public AddonRequestedUpdateArgs()
internal AddonRequestedUpdateArgs()
{
}
@ -25,12 +24,4 @@ public class AddonRequestedUpdateArgs : AddonArgs
/// Gets or sets the StringArrayData** for this event.
/// </summary>
public nint StringArrayData { get; set; }
/// <inheritdoc cref="AddonArgs.Clear"/>
internal override void Clear()
{
base.Clear();
this.NumberArrayData = 0;
this.StringArrayData = 0;
}
}

View file

@ -1,3 +1,5 @@
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
@ -10,8 +12,7 @@ public class AddonSetupArgs : AddonArgs
/// <summary>
/// Initializes a new instance of the <see cref="AddonSetupArgs"/> class.
/// </summary>
[Obsolete("Not intended for public construction.", false)]
public AddonSetupArgs()
internal AddonSetupArgs()
{
}
@ -31,13 +32,7 @@ public class AddonSetupArgs : AddonArgs
/// <summary>
/// Gets the AtkValues in the form of a span.
/// </summary>
[Obsolete("Pending removal, unsafe to use when using custom ClientStructs")]
[Api15ToDo("Remove this")]
public unsafe Span<AtkValue> AtkValueSpan => new(this.AtkValues.ToPointer(), (int)this.AtkValueCount);
/// <inheritdoc cref="AddonArgs.Clear"/>
internal override void Clear()
{
base.Clear();
this.AtkValueCount = 0;
this.AtkValues = 0;
}
}

View file

@ -1,39 +1,35 @@
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>
[Obsolete("Not intended for public construction.", false)]
public AddonUpdateArgs()
internal AddonUpdateArgs()
{
}
/// <inheritdoc/>
public override AddonArgsType Type => AddonArgsType.Update;
/// <summary>
/// Gets the time since the last update.
/// </summary>
public float TimeDelta
{
get => this.TimeDeltaInternal;
init => this.TimeDeltaInternal = value;
}
/// <summary>
/// Gets or sets the time since the last update.
/// </summary>
internal float TimeDeltaInternal { get; set; }
/// <inheritdoc cref="AddonArgs.Clear"/>
internal override void Clear()
/// <summary>
/// Gets the time since the last update.
/// </summary>
private float TimeDelta
{
base.Clear();
this.TimeDeltaInternal = 0;
get => this.TimeDeltaInternal;
init => this.TimeDeltaInternal = value;
}
}

View file

@ -5,7 +5,7 @@ namespace Dalamud.Game.Addon.Lifecycle;
/// <summary>
/// AddonLifecycleService memory address resolver.
/// </summary>
[Api13ToDo("Remove this class entirely, its not used by AddonLifecycle anymore, also need to use something else for HookWidget")]
[Api14ToDo("Remove this class entirely, its not used by AddonLifecycle anymore, also need to use something else for HookWidget")]
internal class AddonLifecycleAddressResolver : BaseAddressResolver
{
/// <summary>

View file

@ -26,8 +26,6 @@ internal unsafe class AddonVirtualTable : IDisposable
private readonly AddonLifecycle lifecycleService;
// Obsolete warning is only to prevent users from creating their own event objects.
#pragma warning disable CS0618 // Type or member is obsolete
private readonly AddonSetupArgs addonSetupArg = new();
private readonly AddonFinalizeArgs addonFinalizeArg = new();
private readonly AddonDrawArgs addonDrawArg = new();
@ -36,7 +34,6 @@ internal unsafe class AddonVirtualTable : IDisposable
private readonly AddonRequestedUpdateArgs addonRequestedUpdateArg = new();
private readonly AddonReceiveEventArgs addonReceiveEventArg = new();
private readonly AddonGenericArgs addonGenericArg = new();
#pragma warning restore CS0618 // Type or member is obsolete
private readonly AtkUnitBase* atkUnitBase;
@ -136,7 +133,6 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonSetupArg.Clear();
this.addonSetupArg.Addon = addon;
this.addonSetupArg.AtkValueCount = valueCount;
this.addonSetupArg.AtkValues = (nint)values;
@ -160,7 +156,6 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonFinalizeArg.Clear();
this.addonFinalizeArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreFinalize, this.addonFinalizeArg);
@ -178,7 +173,6 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonDrawArg.Clear();
this.addonDrawArg.Addon = addon;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreDraw, this.addonDrawArg);
@ -198,7 +192,6 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonUpdateArg.Clear();
this.addonUpdateArg.Addon = addon;
this.addonUpdateArg.TimeDeltaInternal = delta;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreUpdate, this.addonUpdateArg);
@ -221,7 +214,6 @@ internal unsafe class AddonVirtualTable : IDisposable
var result = false;
this.addonRefreshArg.Clear();
this.addonRefreshArg.Addon = addon;
this.addonRefreshArg.AtkValueCount = valueCount;
this.addonRefreshArg.AtkValues = (nint)values;
@ -246,7 +238,6 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonRequestedUpdateArg.Clear();
this.addonRequestedUpdateArg.Addon = addon;
this.addonRequestedUpdateArg.NumberArrayData = (nint)numberArrayData;
this.addonRequestedUpdateArg.StringArrayData = (nint)stringArrayData;
@ -270,7 +261,6 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonReceiveEventArg.Clear();
this.addonReceiveEventArg.Addon = (nint)addon;
this.addonReceiveEventArg.AtkEventType = (byte)eventType;
this.addonReceiveEventArg.EventParam = eventParam;
@ -300,7 +290,6 @@ internal unsafe class AddonVirtualTable : IDisposable
var result = false;
this.addonGenericArg.Clear();
this.addonGenericArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreOpen, this.addonGenericArg);
@ -324,7 +313,6 @@ internal unsafe class AddonVirtualTable : IDisposable
var result = false;
this.addonGenericArg.Clear();
this.addonGenericArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreClose, this.addonGenericArg);
@ -346,7 +334,6 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonGenericArg.Clear();
this.addonGenericArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreShow, this.addonGenericArg);
@ -366,7 +353,6 @@ internal unsafe class AddonVirtualTable : IDisposable
{
this.LogEvent(EnableLogging);
this.addonGenericArg.Clear();
this.addonGenericArg.Addon = thisPtr;
this.lifecycleService.InvokeListenersSafely(AddonEvent.PreHide, this.addonGenericArg);

View file

@ -150,7 +150,7 @@ internal sealed unsafe class DtrBarEntry : IDisposable, IDtrBarEntry
}
/// <inheritdoc/>
[Api13ToDo("Maybe make this config scoped to internal name?")]
[Api14ToDo("Maybe make this config scoped to internal name?")]
public bool UserHidden => this.configuration.DtrIgnore?.Contains(this.Title) ?? false;
/// <inheritdoc/>

View file

@ -48,7 +48,7 @@ public abstract class Easing
/// Gets the current value of the animation, following unclamped logic.
/// </summary>
[Obsolete($"This field has been deprecated. Use either {nameof(ValueClamped)} or {nameof(ValueUnclamped)} instead.", true)]
[Api13ToDo("Map this field to ValueClamped, probably.")]
[Api14ToDo("Map this field to ValueClamped, probably.")]
public double Value => this.ValueUnclamped;
/// <summary>

View file

@ -4,7 +4,7 @@ namespace Dalamud.Utility;
/// Utility class for marking something to be changed for API 13, for ease of lookup.
/// </summary>
[AttributeUsage(AttributeTargets.All, Inherited = false)]
internal sealed class Api13ToDoAttribute : Attribute
internal sealed class Api14ToDoAttribute : Attribute
{
/// <summary>
/// Marks that this should be made internal.
@ -12,11 +12,11 @@ internal sealed class Api13ToDoAttribute : Attribute
public const string MakeInternal = "Make internal.";
/// <summary>
/// Initializes a new instance of the <see cref="Api13ToDoAttribute"/> class.
/// Initializes a new instance of the <see cref="Api14ToDoAttribute"/> class.
/// </summary>
/// <param name="what">The explanation.</param>
/// <param name="what2">The explanation 2.</param>
public Api13ToDoAttribute(string what, string what2 = "")
public Api14ToDoAttribute(string what, string what2 = "")
{
_ = what;
_ = what2;

View file

@ -0,0 +1,25 @@
namespace Dalamud.Utility;
/// <summary>
/// Utility class for marking something to be changed for API 13, for ease of lookup.
/// Intended to represent not the upcoming API, but the one after it for more major changes.
/// </summary>
[AttributeUsage(AttributeTargets.All, Inherited = false)]
internal sealed class Api15ToDoAttribute : Attribute
{
/// <summary>
/// Marks that this should be made internal.
/// </summary>
public const string MakeInternal = "Make internal.";
/// <summary>
/// Initializes a new instance of the <see cref="Api15ToDoAttribute"/> class.
/// </summary>
/// <param name="what">The explanation.</param>
/// <param name="what2">The explanation 2.</param>
public Api15ToDoAttribute(string what, string what2 = "")
{
_ = what;
_ = what2;
}
}

View file

@ -79,7 +79,7 @@ public static partial class Util
/// <summary>
/// Gets the Dalamud version.
/// </summary>
[Api13ToDo("Remove. Make both versions here internal. Add an API somewhere.")]
[Api14ToDo("Remove. Make both versions here internal. Add an API somewhere.")]
public static string AssemblyVersion { get; } =
Assembly.GetAssembly(typeof(ChatHandlers))!.GetName().Version!.ToString();