Skip to content

Commit

Permalink
Update to scoped services
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Aug 22, 2023
1 parent 5f0a8fa commit 9dd7698
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 5 additions & 7 deletions Craftimizer/Icons.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
using Dalamud.Interface.Internal;
using ImGuiScene;
using System.Collections.Generic;

namespace Craftimizer.Plugin;

internal static class Icons
{
private static readonly Dictionary<string, TextureWrap> Cache = new();
private static readonly Dictionary<ushort, IDalamudTextureWrap> 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");
}
16 changes: 9 additions & 7 deletions Craftimizer/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@
using Dalamud.Interface.Windowing;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;

namespace Craftimizer.Plugin;

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; }
Expand Down
2 changes: 1 addition & 1 deletion Craftimizer/Utils/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9dd7698

Please sign in to comment.