From 564c220ed242bed6c9875d2c019b6a551bc07b09 Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Sat, 26 Jul 2025 21:50:42 +0200 Subject: [PATCH] [Api13] Remove obsoletes (#2323) * Remove IFate.HasExpBonus * Remove IAddonEventManager.AddonEventHandler * Remove obsolete filesystem functions from Util * Remove more obsoletes --- .../Internal/DalamudConfiguration.cs | 12 ----- Dalamud/Game/Addon/Events/AddonEventEntry.cs | 11 +--- .../Game/Addon/Events/AddonEventManager.cs | 27 ---------- Dalamud/Game/Addon/Events/AddonEventType.cs | 6 --- .../Addon/Events/PluginEventController.cs | 50 +------------------ .../ClientState/Conditions/ConditionFlag.cs | 36 ------------- Dalamud/Game/ClientState/Fates/Fate.cs | 11 ---- Dalamud/Game/Gui/Dtr/DtrBar.cs | 6 +-- .../Internals/FontAtlasFactory.cs | 20 +++----- Dalamud/Plugin/Services/IAddonEventManager.cs | 22 +------- Dalamud/Utility/Util.cs | 31 ------------ 11 files changed, 13 insertions(+), 219 deletions(-) diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs index 8dafd897e..1943f4ba3 100644 --- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs +++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs @@ -152,23 +152,11 @@ internal sealed class DalamudConfiguration : IInternalDisposableService /// public float GlobalUiScale { get; set; } = 1.0f; - /// - /// Gets or sets a value indicating whether to use AXIS fonts from the game. - /// - [Obsolete($"See {nameof(DefaultFontSpec)}")] - public bool UseAxisFontsFromGame { get; set; } = true; - /// /// Gets or sets the default font spec. /// public IFontSpec? DefaultFontSpec { get; set; } - /// - /// Gets or sets the gamma value to apply for Dalamud fonts. Do not use. - /// - [Obsolete("It happens that nobody touched this setting", true)] - public float FontGammaLevel { get; set; } = 1.4f; - /// Gets or sets the opacity of the IME state indicator. /// 0 will hide the state indicator. 1 will make the state indicator fully visible. Values outside the /// range will be clamped to [0, 1]. diff --git a/Dalamud/Game/Addon/Events/AddonEventEntry.cs b/Dalamud/Game/Addon/Events/AddonEventEntry.cs index 50b9c7ec4..30d0465dc 100644 --- a/Dalamud/Game/Addon/Events/AddonEventEntry.cs +++ b/Dalamud/Game/Addon/Events/AddonEventEntry.cs @@ -1,4 +1,4 @@ -using Dalamud.Plugin.Services; +using Dalamud.Plugin.Services; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Component.GUI; @@ -33,17 +33,10 @@ internal unsafe class AddonEventEntry /// public required nint Node { get; init; } - /// - /// Gets the handler that gets called when this event is triggered. - /// - [Obsolete("Use AddonEventDelegate Delegate instead")] - public IAddonEventManager.AddonEventHandler Handler { get; init; } - /// /// Gets the delegate that gets called when this event is triggered. /// - [Api13ToDo("Make this field required")] - public IAddonEventManager.AddonEventDelegate Delegate { get; init; } + public required IAddonEventManager.AddonEventDelegate Delegate { get; init; } /// /// Gets the unique id for this event. diff --git a/Dalamud/Game/Addon/Events/AddonEventManager.cs b/Dalamud/Game/Addon/Events/AddonEventManager.cs index 0990c1f5f..945197e2b 100644 --- a/Dalamud/Game/Addon/Events/AddonEventManager.cs +++ b/Dalamud/Game/Addon/Events/AddonEventManager.cs @@ -73,29 +73,6 @@ internal unsafe class AddonEventManager : IInternalDisposableService this.addonLifecycle.UnregisterListener(this.finalizeEventListener); } - /// - /// Registers an event handler for the specified addon, node, and type. - /// - /// Unique ID for this plugin. - /// The parent addon for this event. - /// The node that will trigger this event. - /// The event type for this event. - /// The handler to call when event is triggered. - /// IAddonEventHandle used to remove the event. - 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; - } - /// /// Registers an event handler for the specified addon, node, and type. /// @@ -260,10 +237,6 @@ internal class AddonEventManagerPluginScoped : IInternalDisposableService, IAddo }).Wait(); } - /// - public IAddonEventHandle? AddEvent(IntPtr atkUnitBase, IntPtr atkResNode, AddonEventType eventType, IAddonEventManager.AddonEventHandler eventHandler) - => this.eventManagerService.AddEvent(this.plugin.EffectiveWorkingPluginId, atkUnitBase, atkResNode, eventType, eventHandler); - /// public IAddonEventHandle? AddEvent(nint atkUnitBase, nint atkResNode, AddonEventType eventType, IAddonEventManager.AddonEventDelegate eventDelegate) => this.eventManagerService.AddEvent(this.plugin.EffectiveWorkingPluginId, atkUnitBase, atkResNode, eventType, eventDelegate); diff --git a/Dalamud/Game/Addon/Events/AddonEventType.cs b/Dalamud/Game/Addon/Events/AddonEventType.cs index cd04152ca..2c88c797b 100644 --- a/Dalamud/Game/Addon/Events/AddonEventType.cs +++ b/Dalamud/Game/Addon/Events/AddonEventType.cs @@ -121,12 +121,6 @@ public enum AddonEventType : byte /// ListItemClick = 35, - /// - /// AtkComponentList Toggle. - /// - [Obsolete("Use ListItemClick")] - ListItemToggle = 35, - /// /// AtkComponentList Double Click. /// diff --git a/Dalamud/Game/Addon/Events/PluginEventController.cs b/Dalamud/Game/Addon/Events/PluginEventController.cs index 0b1491e77..b1251855b 100644 --- a/Dalamud/Game/Addon/Events/PluginEventController.cs +++ b/Dalamud/Game/Addon/Events/PluginEventController.cs @@ -29,49 +29,6 @@ internal unsafe class PluginEventController : IDisposable private List Events { get; } = new(); - /// - /// Adds a tracked event. - /// - /// The Parent addon for the event. - /// The Node for the event. - /// The Event Type. - /// The delegate to call when invoking this event. - /// IAddonEventHandle used to remove the event. - [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; - } - /// /// Adds a tracked event. /// @@ -100,7 +57,6 @@ internal unsafe class PluginEventController : IDisposable { Addon = atkUnitBase, Delegate = eventDelegate, - Handler = null, Node = atkResNode, EventType = atkEventType, ParamKey = eventId, @@ -230,7 +186,6 @@ internal unsafe class PluginEventController : IDisposable 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) { try @@ -238,10 +193,7 @@ internal unsafe class PluginEventController : IDisposable if (eventPtr is null) 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.Handler?.Invoke((AddonEventType)eventType, (nint)eventPtr->Node, (nint)eventPtr->Target); - - eventInfo.Delegate?.Invoke((AddonEventType)eventType, new AddonEventData + eventInfo.Delegate.Invoke((AddonEventType)eventType, new AddonEventData { AddonPointer = (nint)eventPtr->Node, NodeTargetPointer = (nint)eventPtr->Target, diff --git a/Dalamud/Game/ClientState/Conditions/ConditionFlag.cs b/Dalamud/Game/ClientState/Conditions/ConditionFlag.cs index ef6649d7d..df4620f93 100644 --- a/Dalamud/Game/ClientState/Conditions/ConditionFlag.cs +++ b/Dalamud/Game/ClientState/Conditions/ConditionFlag.cs @@ -188,12 +188,6 @@ public enum ConditionFlag /// ExecutingCraftingAction = 40, - /// - /// Unable to execute command while crafting. - /// - [Obsolete("Renamed to ExecutingCraftingAction.")] - Crafting40 = 40, - /// /// Unable to execute command while preparing to craft. /// @@ -205,12 +199,6 @@ public enum ConditionFlag /// Includes fishing. ExecutingGatheringAction = 42, - /// - /// Unable to execute command while gathering. - /// - [Obsolete("Renamed to ExecutingGatheringAction.")] - Gathering42 = 42, - /// /// Unable to execute command while fishing. /// @@ -235,12 +223,6 @@ public enum ConditionFlag /// Jumping = 48, - /// - /// Unable to execute command while auto-run is active. - /// - [Obsolete("To avoid confusion, renamed to UsingChocoboTaxi.")] - AutorunActive = 49, - /// /// Unable to execute command while auto-run is active. /// @@ -282,12 +264,6 @@ public enum ConditionFlag /// BoundByDuty56 = 56, - /// - /// Unable to execute command at this time. - /// - [Obsolete("Renamed to MountOrOrnamentTransition.")] - Unknown57 = 57, - /// /// Unable to execute command at this time. /// @@ -461,12 +437,6 @@ public enum ConditionFlag /// RolePlaying = 90, - /// - /// Unable to execute command while bound by duty. - /// - [Obsolete("Use InDutyQueue")] - BoundToDuty97 = 91, - /// /// Unable to execute command while bound by duty. /// Specifically triggered when you are in a queue for a duty but not inside a duty. @@ -483,12 +453,6 @@ public enum ConditionFlag /// WaitingToVisitOtherWorld = 93, - /// - /// Unable to execute command while using a parasol. - /// - [Obsolete("Renamed to UsingFashionAccessory.")] - UsingParasol = 94, - /// /// Unable to execute command while using a fashion accessory. /// diff --git a/Dalamud/Game/ClientState/Fates/Fate.cs b/Dalamud/Game/ClientState/Fates/Fate.cs index 2da2dde9d..504b690c3 100644 --- a/Dalamud/Game/ClientState/Fates/Fate.cs +++ b/Dalamud/Game/ClientState/Fates/Fate.cs @@ -3,7 +3,6 @@ using System.Numerics; using Dalamud.Data; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Memory; -using Dalamud.Utility; using Lumina.Excel; @@ -69,12 +68,6 @@ public interface IFate : IEquatable /// byte Progress { get; } - /// - /// Gets a value indicating whether this has a EXP bonus. - /// - [Obsolete($"Use {nameof(HasBonus)} instead")] - bool HasExpBonus { get; } - /// /// Gets a value indicating whether this has a bonus. /// @@ -222,10 +215,6 @@ internal unsafe partial class Fate : IFate /// public byte Progress => this.Struct->Progress; - /// - [Api13ToDo("Remove")] - public bool HasExpBonus => this.HasBonus; - /// public bool HasBonus => this.Struct->IsBonus; diff --git a/Dalamud/Game/Gui/Dtr/DtrBar.cs b/Dalamud/Game/Gui/Dtr/DtrBar.cs index 6f3f9a8dd..8339838fd 100644 --- a/Dalamud/Game/Gui/Dtr/DtrBar.cs +++ b/Dalamud/Game/Gui/Dtr/DtrBar.cs @@ -610,10 +610,10 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar return newTextNode; } - private void DtrEventHandler(AddonEventType atkEventType, IntPtr atkUnitBase, IntPtr atkResNode) + private void DtrEventHandler(AddonEventType atkEventType, AddonEventData data) { - var addon = (AtkUnitBase*)atkUnitBase; - var node = (AtkResNode*)atkResNode; + var addon = (AtkUnitBase*)data.AddonPointer; + var node = (AtkResNode*)data.NodeTargetPointer; DtrBarEntry? dtrBarEntry = null; this.entriesLock.EnterReadLock(); diff --git a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.cs b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.cs index c084d88e2..9d7dc006a 100644 --- a/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.cs +++ b/Dalamud/Interface/ManagedFontAtlas/Internals/FontAtlasFactory.cs @@ -1,4 +1,4 @@ -using System.Buffers; +using System.Buffers; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -120,19 +120,11 @@ internal sealed partial class FontAtlasFactory public IFontSpec DefaultFontSpec => this.DefaultFontSpecOverride ?? Service.Get().DefaultFontSpec -#pragma warning disable CS0618 // Type or member is obsolete - ?? (Service.Get().UseAxisFontsFromGame -#pragma warning restore CS0618 // Type or member is obsolete - ? new() - { - FontId = new GameFontAndFamilyId(GameFontFamily.Axis), - SizePx = InterfaceManager.DefaultFontSizePx, - } - : new SingleFontSpec - { - FontId = new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansJpMedium), - SizePx = InterfaceManager.DefaultFontSizePx + 1, - }); + ?? new SingleFontSpec() + { + FontId = new GameFontAndFamilyId(GameFontFamily.Axis), + SizePx = InterfaceManager.DefaultFontSizePx, + }; /// /// Gets the service instance of . diff --git a/Dalamud/Plugin/Services/IAddonEventManager.cs b/Dalamud/Plugin/Services/IAddonEventManager.cs index e534eafb4..e50548c58 100644 --- a/Dalamud/Plugin/Services/IAddonEventManager.cs +++ b/Dalamud/Plugin/Services/IAddonEventManager.cs @@ -1,4 +1,4 @@ -using Dalamud.Game.Addon.Events; +using Dalamud.Game.Addon.Events; namespace Dalamud.Plugin.Services; @@ -7,15 +7,6 @@ namespace Dalamud.Plugin.Services; /// public interface IAddonEventManager { - /// - /// Delegate to be called when an event is received. - /// - /// Event type for this event handler. - /// The parent addon for this event handler. - /// The specific node that will trigger this event handler. - [Obsolete("Use AddonEventDelegate instead")] - public delegate void AddonEventHandler(AddonEventType atkEventType, nint atkUnitBase, nint atkResNode); - /// /// Delegate to be called when an event is received. /// @@ -23,17 +14,6 @@ public interface IAddonEventManager /// The event data object for use in handling this event. public delegate void AddonEventDelegate(AddonEventType atkEventType, AddonEventData data); - /// - /// Registers an event handler for the specified addon, node, and type. - /// - /// The parent addon for this event. - /// The node that will trigger this event. - /// The event type for this event. - /// The handler to call when event is triggered. - /// IAddonEventHandle used to remove the event. Null if no event was added. - [Obsolete("Use AddEvent with AddonEventDelegate instead of AddonEventHandler")] - IAddonEventHandle? AddEvent(nint atkUnitBase, nint atkResNode, AddonEventType eventType, AddonEventHandler eventHandler); - /// /// Registers an event handler for the specified addon, node, and type. /// diff --git a/Dalamud/Utility/Util.cs b/Dalamud/Utility/Util.cs index 1d96523be..2e6ed7684 100644 --- a/Dalamud/Utility/Util.cs +++ b/Dalamud/Utility/Util.cs @@ -605,37 +605,6 @@ public static class Util NativeFunctions.FlashWindowEx(ref flashInfo); } - /// - /// Overwrite text in a file by first writing it to a temporary file, and then - /// moving that file to the path specified. - /// - /// The path of the file to write to. - /// The text to write. - [Api13ToDo("Remove.")] - [Obsolete("Replaced with FilesystemUtil.WriteAllTextSafe()")] - public static void WriteAllTextSafe(string path, string text) => FilesystemUtil.WriteAllTextSafe(path, text); - - /// - /// Overwrite text in a file by first writing it to a temporary file, and then - /// moving that file to the path specified. - /// - /// The path of the file to write to. - /// The text to write. - /// Encoding to use. - [Api13ToDo("Remove.")] - [Obsolete("Replaced with FilesystemUtil.WriteAllTextSafe()")] - public static void WriteAllTextSafe(string path, string text, Encoding encoding) => FilesystemUtil.WriteAllTextSafe(path, text, encoding); - - /// - /// Overwrite data in a file by first writing it to a temporary file, and then - /// moving that file to the path specified. - /// - /// The path of the file to write to. - /// The data to write. - [Api13ToDo("Remove.")] - [Obsolete("Replaced with FilesystemUtil.WriteAllBytesSafe()")] - public static void WriteAllBytesSafe(string path, byte[] bytes) => FilesystemUtil.WriteAllBytesSafe(path, bytes); - /// Gets a temporary file name, for use as the sourceFileName in /// . /// The target file.