From 9dd76980938064aae630c9b7613b578a4c33097b Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Tue, 22 Aug 2023 08:58:19 -0700 Subject: [PATCH] Update to scoped services --- Craftimizer/Icons.cs | 12 +++++------- Craftimizer/Service.cs | 16 +++++++++------- Craftimizer/Utils/Hooks.cs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Craftimizer/Icons.cs b/Craftimizer/Icons.cs index 37ebeb0..612c1ce 100644 --- a/Craftimizer/Icons.cs +++ b/Craftimizer/Icons.cs @@ -1,3 +1,4 @@ +using Dalamud.Interface.Internal; using ImGuiScene; using System.Collections.Generic; @@ -5,15 +6,12 @@ namespace Craftimizer.Plugin; internal static class Icons { - private static readonly Dictionary Cache = new(); + private static readonly Dictionary Cache = new(); - public static TextureWrap GetIconFromPath(string path) + public static TextureWrap GetIconFromId(ushort id) { - if (!Cache.TryGetValue(path, out var ret)) - Cache.Add(path, ret = Service.DataManager.GetImGuiTexture(path)!); + if (!Cache.TryGetValue(id, out var ret)) + Cache.Add(id, ret = Service.TextureProvider.GetIcon(id)!); return ret; } - - public static TextureWrap GetIconFromId(ushort id) => - GetIconFromPath($"ui/icon/{id / 1000 * 1000:000000}/{id:000000}_hr1.tex"); } diff --git a/Craftimizer/Service.cs b/Craftimizer/Service.cs index 0c02ad0..fa4e1c6 100644 --- a/Craftimizer/Service.cs +++ b/Craftimizer/Service.cs @@ -8,6 +8,7 @@ using Dalamud.Interface.Windowing; using Dalamud.IoC; using Dalamud.Plugin; +using Dalamud.Plugin.Services; namespace Craftimizer.Plugin; @@ -15,15 +16,16 @@ public sealed class Service { #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. [PluginService] public static DalamudPluginInterface PluginInterface { get; private set; } - [PluginService] public static CommandManager CommandManager { get; private set; } - [PluginService] public static ObjectTable Objects { get; private set; } - [PluginService] public static SigScanner SigScanner { get; private set; } - [PluginService] public static GameGui GameGui { get; private set; } - [PluginService] public static ClientState ClientState { get; private set; } - [PluginService] public static DataManager DataManager { get; private set; } - [PluginService] public static TargetManager TargetManager { get; private set; } + [PluginService] public static ICommandManager CommandManager { get; private set; } + [PluginService] public static IObjectTable Objects { get; private set; } + [PluginService] public static ISigScanner SigScanner { get; private set; } + [PluginService] public static IGameGui GameGui { get; private set; } + [PluginService] public static IClientState ClientState { get; private set; } + [PluginService] public static IDataManager DataManager { get; private set; } + [PluginService] public static ITargetManager TargetManager { get; private set; } [PluginService] public static Condition Condition { get; private set; } [PluginService] public static Framework Framework { get; private set; } + [PluginService] public static ITextureProvider TextureProvider { get; private set; } public static Plugin Plugin { get; internal set; } public static Configuration Configuration { get; internal set; } diff --git a/Craftimizer/Utils/Hooks.cs b/Craftimizer/Utils/Hooks.cs index a535ed3..52bef7c 100644 --- a/Craftimizer/Utils/Hooks.cs +++ b/Craftimizer/Utils/Hooks.cs @@ -11,7 +11,7 @@ namespace Craftimizer.Utils; public sealed unsafe class Hooks : IDisposable { public delegate void OnActionUsedDelegate(ActionType action); - + public event OnActionUsedDelegate? OnActionUsed; public delegate bool UseActionDelegate(ActionManager* manager, CSActionType actionType, uint actionId, ulong targetId, uint param, uint useType, int pvp, nint a8);