[Api13] Remove obsoletes (#2323)

* Remove IFate.HasExpBonus

* Remove IAddonEventManager.AddonEventHandler

* Remove obsolete filesystem functions from Util

* Remove more obsoletes
This commit is contained in:
Haselnussbomber 2025-07-26 21:50:42 +02:00 committed by GitHub
parent 2aba71f8f2
commit 564c220ed2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 13 additions and 219 deletions

View file

@ -152,23 +152,11 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
/// </summary> /// </summary>
public float GlobalUiScale { get; set; } = 1.0f; public float GlobalUiScale { get; set; } = 1.0f;
/// <summary>
/// Gets or sets a value indicating whether to use AXIS fonts from the game.
/// </summary>
[Obsolete($"See {nameof(DefaultFontSpec)}")]
public bool UseAxisFontsFromGame { get; set; } = true;
/// <summary> /// <summary>
/// Gets or sets the default font spec. /// Gets or sets the default font spec.
/// </summary> /// </summary>
public IFontSpec? DefaultFontSpec { get; set; } public IFontSpec? DefaultFontSpec { get; set; }
/// <summary>
/// Gets or sets the gamma value to apply for Dalamud fonts. Do not use.
/// </summary>
[Obsolete("It happens that nobody touched this setting", true)]
public float FontGammaLevel { get; set; } = 1.4f;
/// <summary>Gets or sets the opacity of the IME state indicator.</summary> /// <summary>Gets or sets the opacity of the IME state indicator.</summary>
/// <value>0 will hide the state indicator. 1 will make the state indicator fully visible. Values outside the /// <value>0 will hide the state indicator. 1 will make the state indicator fully visible. Values outside the
/// range will be clamped to [0, 1].</value> /// range will be clamped to [0, 1].</value>

View file

@ -1,4 +1,4 @@
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Dalamud.Utility; using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
@ -33,17 +33,10 @@ internal unsafe class AddonEventEntry
/// </summary> /// </summary>
public required nint Node { get; init; } public required nint Node { get; init; }
/// <summary>
/// Gets the handler that gets called when this event is triggered.
/// </summary>
[Obsolete("Use AddonEventDelegate Delegate instead")]
public IAddonEventManager.AddonEventHandler Handler { get; init; }
/// <summary> /// <summary>
/// Gets the delegate that gets called when this event is triggered. /// Gets the delegate that gets called when this event is triggered.
/// </summary> /// </summary>
[Api13ToDo("Make this field required")] public required IAddonEventManager.AddonEventDelegate Delegate { get; init; }
public IAddonEventManager.AddonEventDelegate Delegate { get; init; }
/// <summary> /// <summary>
/// Gets the unique id for this event. /// Gets the unique id for this event.

View file

@ -73,29 +73,6 @@ internal unsafe class AddonEventManager : IInternalDisposableService
this.addonLifecycle.UnregisterListener(this.finalizeEventListener); this.addonLifecycle.UnregisterListener(this.finalizeEventListener);
} }
/// <summary>
/// Registers an event handler for the specified addon, node, and type.
/// </summary>
/// <param name="pluginId">Unique ID for this plugin.</param>
/// <param name="atkUnitBase">The parent addon for this event.</param>
/// <param name="atkResNode">The node that will trigger this event.</param>
/// <param name="eventType">The event type for this event.</param>
/// <param name="eventHandler">The handler to call when event is triggered.</param>
/// <returns>IAddonEventHandle used to remove the event.</returns>
internal IAddonEventHandle? AddEvent(Guid pluginId, IntPtr atkUnitBase, IntPtr atkResNode, AddonEventType eventType, IAddonEventManager.AddonEventHandler eventHandler)
{
if (this.pluginEventControllers.TryGetValue(pluginId, out var controller))
{
return controller.AddEvent(atkUnitBase, atkResNode, eventType, eventHandler);
}
else
{
Log.Verbose($"Unable to locate controller for {pluginId}. No event was added.");
}
return null;
}
/// <summary> /// <summary>
/// Registers an event handler for the specified addon, node, and type. /// Registers an event handler for the specified addon, node, and type.
/// </summary> /// </summary>
@ -260,10 +237,6 @@ internal class AddonEventManagerPluginScoped : IInternalDisposableService, IAddo
}).Wait(); }).Wait();
} }
/// <inheritdoc/>
public IAddonEventHandle? AddEvent(IntPtr atkUnitBase, IntPtr atkResNode, AddonEventType eventType, IAddonEventManager.AddonEventHandler eventHandler)
=> this.eventManagerService.AddEvent(this.plugin.EffectiveWorkingPluginId, atkUnitBase, atkResNode, eventType, eventHandler);
/// <inheritdoc/> /// <inheritdoc/>
public IAddonEventHandle? AddEvent(nint atkUnitBase, nint atkResNode, AddonEventType eventType, IAddonEventManager.AddonEventDelegate eventDelegate) public IAddonEventHandle? AddEvent(nint atkUnitBase, nint atkResNode, AddonEventType eventType, IAddonEventManager.AddonEventDelegate eventDelegate)
=> this.eventManagerService.AddEvent(this.plugin.EffectiveWorkingPluginId, atkUnitBase, atkResNode, eventType, eventDelegate); => this.eventManagerService.AddEvent(this.plugin.EffectiveWorkingPluginId, atkUnitBase, atkResNode, eventType, eventDelegate);

View file

@ -121,12 +121,6 @@ public enum AddonEventType : byte
/// </summary> /// </summary>
ListItemClick = 35, ListItemClick = 35,
/// <summary>
/// AtkComponentList Toggle.
/// </summary>
[Obsolete("Use ListItemClick")]
ListItemToggle = 35,
/// <summary> /// <summary>
/// AtkComponentList Double Click. /// AtkComponentList Double Click.
/// </summary> /// </summary>

View file

@ -29,49 +29,6 @@ internal unsafe class PluginEventController : IDisposable
private List<AddonEventEntry> Events { get; } = new(); private List<AddonEventEntry> Events { get; } = new();
/// <summary>
/// Adds a tracked event.
/// </summary>
/// <param name="atkUnitBase">The Parent addon for the event.</param>
/// <param name="atkResNode">The Node for the event.</param>
/// <param name="atkEventType">The Event Type.</param>
/// <param name="handler">The delegate to call when invoking this event.</param>
/// <returns>IAddonEventHandle used to remove the event.</returns>
[Obsolete("Use AddEvent that uses AddonEventDelegate instead of AddonEventHandler")]
public IAddonEventHandle AddEvent(nint atkUnitBase, nint atkResNode, AddonEventType atkEventType, IAddonEventManager.AddonEventHandler handler)
{
var node = (AtkResNode*)atkResNode;
var addon = (AtkUnitBase*)atkUnitBase;
var eventType = (AtkEventType)atkEventType;
var eventId = this.GetNextParamKey();
var eventGuid = Guid.NewGuid();
var eventHandle = new AddonEventHandle
{
AddonName = addon->NameString,
ParamKey = eventId,
EventType = atkEventType,
EventGuid = eventGuid,
};
var eventEntry = new AddonEventEntry
{
Addon = atkUnitBase,
Handler = handler,
Delegate = null,
Node = atkResNode,
EventType = atkEventType,
ParamKey = eventId,
Handle = eventHandle,
};
Log.Verbose($"Adding Event. {eventEntry.LogString}");
this.EventListener.RegisterEvent(addon, node, eventType, eventId);
this.Events.Add(eventEntry);
return eventHandle;
}
/// <summary> /// <summary>
/// Adds a tracked event. /// Adds a tracked event.
/// </summary> /// </summary>
@ -100,7 +57,6 @@ internal unsafe class PluginEventController : IDisposable
{ {
Addon = atkUnitBase, Addon = atkUnitBase,
Delegate = eventDelegate, Delegate = eventDelegate,
Handler = null,
Node = atkResNode, Node = atkResNode,
EventType = atkEventType, EventType = atkEventType,
ParamKey = eventId, ParamKey = eventId,
@ -230,7 +186,6 @@ internal unsafe class PluginEventController : IDisposable
this.EventListener.UnregisterEvent(atkResNode, eventType, eventEntry.ParamKey); this.EventListener.UnregisterEvent(atkResNode, eventType, eventEntry.ParamKey);
} }
[Api13ToDo("Remove invoke from eventInfo.Handler, and remove nullability from eventInfo.Delegate?.Invoke")]
private void PluginEventListHandler(AtkEventListener* self, AtkEventType eventType, uint eventParam, AtkEvent* eventPtr, AtkEventData* eventDataPtr) private void PluginEventListHandler(AtkEventListener* self, AtkEventType eventType, uint eventParam, AtkEvent* eventPtr, AtkEventData* eventDataPtr)
{ {
try try
@ -238,10 +193,7 @@ internal unsafe class PluginEventController : IDisposable
if (eventPtr is null) return; if (eventPtr is null) return;
if (this.Events.FirstOrDefault(handler => handler.ParamKey == eventParam) is not { } eventInfo) return; if (this.Events.FirstOrDefault(handler => handler.ParamKey == eventParam) is not { } eventInfo) return;
// We stored the AtkUnitBase* in EventData->Node, and EventData->Target contains the node that triggered the event. eventInfo.Delegate.Invoke((AddonEventType)eventType, new AddonEventData
eventInfo.Handler?.Invoke((AddonEventType)eventType, (nint)eventPtr->Node, (nint)eventPtr->Target);
eventInfo.Delegate?.Invoke((AddonEventType)eventType, new AddonEventData
{ {
AddonPointer = (nint)eventPtr->Node, AddonPointer = (nint)eventPtr->Node,
NodeTargetPointer = (nint)eventPtr->Target, NodeTargetPointer = (nint)eventPtr->Target,

View file

@ -188,12 +188,6 @@ public enum ConditionFlag
/// </summary> /// </summary>
ExecutingCraftingAction = 40, ExecutingCraftingAction = 40,
/// <summary>
/// Unable to execute command while crafting.
/// </summary>
[Obsolete("Renamed to ExecutingCraftingAction.")]
Crafting40 = 40,
/// <summary> /// <summary>
/// Unable to execute command while preparing to craft. /// Unable to execute command while preparing to craft.
/// </summary> /// </summary>
@ -205,12 +199,6 @@ public enum ConditionFlag
/// <remarks> Includes fishing. </remarks> /// <remarks> Includes fishing. </remarks>
ExecutingGatheringAction = 42, ExecutingGatheringAction = 42,
/// <summary>
/// Unable to execute command while gathering.
/// </summary>
[Obsolete("Renamed to ExecutingGatheringAction.")]
Gathering42 = 42,
/// <summary> /// <summary>
/// Unable to execute command while fishing. /// Unable to execute command while fishing.
/// </summary> /// </summary>
@ -235,12 +223,6 @@ public enum ConditionFlag
/// </summary> /// </summary>
Jumping = 48, Jumping = 48,
/// <summary>
/// Unable to execute command while auto-run is active.
/// </summary>
[Obsolete("To avoid confusion, renamed to UsingChocoboTaxi.")]
AutorunActive = 49,
/// <summary> /// <summary>
/// Unable to execute command while auto-run is active. /// Unable to execute command while auto-run is active.
/// </summary> /// </summary>
@ -282,12 +264,6 @@ public enum ConditionFlag
/// </summary> /// </summary>
BoundByDuty56 = 56, BoundByDuty56 = 56,
/// <summary>
/// Unable to execute command at this time.
/// </summary>
[Obsolete("Renamed to MountOrOrnamentTransition.")]
Unknown57 = 57,
/// <summary> /// <summary>
/// Unable to execute command at this time. /// Unable to execute command at this time.
/// </summary> /// </summary>
@ -461,12 +437,6 @@ public enum ConditionFlag
/// </summary> /// </summary>
RolePlaying = 90, RolePlaying = 90,
/// <summary>
/// Unable to execute command while bound by duty.
/// </summary>
[Obsolete("Use InDutyQueue")]
BoundToDuty97 = 91,
/// <summary> /// <summary>
/// Unable to execute command while bound by duty. /// Unable to execute command while bound by duty.
/// Specifically triggered when you are in a queue for a duty but not inside a duty. /// Specifically triggered when you are in a queue for a duty but not inside a duty.
@ -483,12 +453,6 @@ public enum ConditionFlag
/// </summary> /// </summary>
WaitingToVisitOtherWorld = 93, WaitingToVisitOtherWorld = 93,
/// <summary>
/// Unable to execute command while using a parasol.
/// </summary>
[Obsolete("Renamed to UsingFashionAccessory.")]
UsingParasol = 94,
/// <summary> /// <summary>
/// Unable to execute command while using a fashion accessory. /// Unable to execute command while using a fashion accessory.
/// </summary> /// </summary>

View file

@ -3,7 +3,6 @@ using System.Numerics;
using Dalamud.Data; using Dalamud.Data;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Memory; using Dalamud.Memory;
using Dalamud.Utility;
using Lumina.Excel; using Lumina.Excel;
@ -69,12 +68,6 @@ public interface IFate : IEquatable<IFate>
/// </summary> /// </summary>
byte Progress { get; } byte Progress { get; }
/// <summary>
/// Gets a value indicating whether this <see cref="Fate"/> has a EXP bonus.
/// </summary>
[Obsolete($"Use {nameof(HasBonus)} instead")]
bool HasExpBonus { get; }
/// <summary> /// <summary>
/// Gets a value indicating whether this <see cref="Fate"/> has a bonus. /// Gets a value indicating whether this <see cref="Fate"/> has a bonus.
/// </summary> /// </summary>
@ -222,10 +215,6 @@ internal unsafe partial class Fate : IFate
/// <inheritdoc/> /// <inheritdoc/>
public byte Progress => this.Struct->Progress; public byte Progress => this.Struct->Progress;
/// <inheritdoc/>
[Api13ToDo("Remove")]
public bool HasExpBonus => this.HasBonus;
/// <inheritdoc/> /// <inheritdoc/>
public bool HasBonus => this.Struct->IsBonus; public bool HasBonus => this.Struct->IsBonus;

View file

@ -610,10 +610,10 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
return newTextNode; return newTextNode;
} }
private void DtrEventHandler(AddonEventType atkEventType, IntPtr atkUnitBase, IntPtr atkResNode) private void DtrEventHandler(AddonEventType atkEventType, AddonEventData data)
{ {
var addon = (AtkUnitBase*)atkUnitBase; var addon = (AtkUnitBase*)data.AddonPointer;
var node = (AtkResNode*)atkResNode; var node = (AtkResNode*)data.NodeTargetPointer;
DtrBarEntry? dtrBarEntry = null; DtrBarEntry? dtrBarEntry = null;
this.entriesLock.EnterReadLock(); this.entriesLock.EnterReadLock();

View file

@ -1,4 +1,4 @@
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
@ -120,19 +120,11 @@ internal sealed partial class FontAtlasFactory
public IFontSpec DefaultFontSpec => public IFontSpec DefaultFontSpec =>
this.DefaultFontSpecOverride this.DefaultFontSpecOverride
?? Service<DalamudConfiguration>.Get().DefaultFontSpec ?? Service<DalamudConfiguration>.Get().DefaultFontSpec
#pragma warning disable CS0618 // Type or member is obsolete ?? new SingleFontSpec()
?? (Service<DalamudConfiguration>.Get().UseAxisFontsFromGame {
#pragma warning restore CS0618 // Type or member is obsolete FontId = new GameFontAndFamilyId(GameFontFamily.Axis),
? new() SizePx = InterfaceManager.DefaultFontSizePx,
{ };
FontId = new GameFontAndFamilyId(GameFontFamily.Axis),
SizePx = InterfaceManager.DefaultFontSizePx,
}
: new SingleFontSpec
{
FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansJpMedium),
SizePx = InterfaceManager.DefaultFontSizePx + 1,
});
/// <summary> /// <summary>
/// Gets the service instance of <see cref="Framework"/>. /// Gets the service instance of <see cref="Framework"/>.

View file

@ -1,4 +1,4 @@
using Dalamud.Game.Addon.Events; using Dalamud.Game.Addon.Events;
namespace Dalamud.Plugin.Services; namespace Dalamud.Plugin.Services;
@ -7,15 +7,6 @@ namespace Dalamud.Plugin.Services;
/// </summary> /// </summary>
public interface IAddonEventManager public interface IAddonEventManager
{ {
/// <summary>
/// Delegate to be called when an event is received.
/// </summary>
/// <param name="atkEventType">Event type for this event handler.</param>
/// <param name="atkUnitBase">The parent addon for this event handler.</param>
/// <param name="atkResNode">The specific node that will trigger this event handler.</param>
[Obsolete("Use AddonEventDelegate instead")]
public delegate void AddonEventHandler(AddonEventType atkEventType, nint atkUnitBase, nint atkResNode);
/// <summary> /// <summary>
/// Delegate to be called when an event is received. /// Delegate to be called when an event is received.
/// </summary> /// </summary>
@ -23,17 +14,6 @@ public interface IAddonEventManager
/// <param name="data">The event data object for use in handling this event.</param> /// <param name="data">The event data object for use in handling this event.</param>
public delegate void AddonEventDelegate(AddonEventType atkEventType, AddonEventData data); public delegate void AddonEventDelegate(AddonEventType atkEventType, AddonEventData data);
/// <summary>
/// Registers an event handler for the specified addon, node, and type.
/// </summary>
/// <param name="atkUnitBase">The parent addon for this event.</param>
/// <param name="atkResNode">The node that will trigger this event.</param>
/// <param name="eventType">The event type for this event.</param>
/// <param name="eventHandler">The handler to call when event is triggered.</param>
/// <returns>IAddonEventHandle used to remove the event. Null if no event was added.</returns>
[Obsolete("Use AddEvent with AddonEventDelegate instead of AddonEventHandler")]
IAddonEventHandle? AddEvent(nint atkUnitBase, nint atkResNode, AddonEventType eventType, AddonEventHandler eventHandler);
/// <summary> /// <summary>
/// Registers an event handler for the specified addon, node, and type. /// Registers an event handler for the specified addon, node, and type.
/// </summary> /// </summary>

View file

@ -605,37 +605,6 @@ public static class Util
NativeFunctions.FlashWindowEx(ref flashInfo); NativeFunctions.FlashWindowEx(ref flashInfo);
} }
/// <summary>
/// Overwrite text in a file by first writing it to a temporary file, and then
/// moving that file to the path specified.
/// </summary>
/// <param name="path">The path of the file to write to.</param>
/// <param name="text">The text to write.</param>
[Api13ToDo("Remove.")]
[Obsolete("Replaced with FilesystemUtil.WriteAllTextSafe()")]
public static void WriteAllTextSafe(string path, string text) => FilesystemUtil.WriteAllTextSafe(path, text);
/// <summary>
/// Overwrite text in a file by first writing it to a temporary file, and then
/// moving that file to the path specified.
/// </summary>
/// <param name="path">The path of the file to write to.</param>
/// <param name="text">The text to write.</param>
/// <param name="encoding">Encoding to use.</param>
[Api13ToDo("Remove.")]
[Obsolete("Replaced with FilesystemUtil.WriteAllTextSafe()")]
public static void WriteAllTextSafe(string path, string text, Encoding encoding) => FilesystemUtil.WriteAllTextSafe(path, text, encoding);
/// <summary>
/// Overwrite data in a file by first writing it to a temporary file, and then
/// moving that file to the path specified.
/// </summary>
/// <param name="path">The path of the file to write to.</param>
/// <param name="bytes">The data to write.</param>
[Api13ToDo("Remove.")]
[Obsolete("Replaced with FilesystemUtil.WriteAllBytesSafe()")]
public static void WriteAllBytesSafe(string path, byte[] bytes) => FilesystemUtil.WriteAllBytesSafe(path, bytes);
/// <summary>Gets a temporary file name, for use as the sourceFileName in /// <summary>Gets a temporary file name, for use as the sourceFileName in
/// <see cref="File.Replace(string,string,string?)"/>.</summary> /// <see cref="File.Replace(string,string,string?)"/>.</summary>
/// <param name="targetFile">The target file.</param> /// <param name="targetFile">The target file.</param>