refactor: require DalamudPluginInterface
This commit is contained in:
parent
b0f3597a9f
commit
ec04d85934
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
@ -82,16 +82,21 @@ public class GameFunctions : IDisposable {
|
|||
/// </summary>
|
||||
public Housing Housing { get; }
|
||||
|
||||
internal GameFunctions(Hooks hooks) {
|
||||
Logger.Log = Util.GetService<IPluginLog>();
|
||||
internal GameFunctions(DalamudPluginInterface @interface, Hooks hooks) {
|
||||
var services = @interface.Create<Services>();
|
||||
if (services == null) {
|
||||
throw new Exception("could not create services");
|
||||
}
|
||||
|
||||
this.Framework = Util.GetService<IFramework>();
|
||||
this.GameGui = Util.GetService<IGameGui>();
|
||||
Logger.Log = services.Log;
|
||||
|
||||
var interop = Util.GetService<IGameInteropProvider>();
|
||||
var objectTable = Util.GetService<IObjectTable>();
|
||||
var partyFinderGui = Util.GetService<IPartyFinderGui>();
|
||||
var scanner = Util.GetService<ISigScanner>();
|
||||
this.Framework = services.Framework;
|
||||
this.GameGui = services.GameGui;
|
||||
|
||||
var interop = services.GameInteropProvider;
|
||||
var objectTable = services.ObjectTable;
|
||||
var partyFinderGui = services.PartyFinderGui;
|
||||
var scanner = services.SigScanner;
|
||||
|
||||
this.UiAlloc = new UiAlloc(scanner);
|
||||
this.Chat = new Chat(scanner);
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using Dalamud.Game;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
namespace XivCommon;
|
||||
|
||||
internal class Services {
|
||||
[PluginService]
|
||||
internal IPluginLog Log { get; private set; }
|
||||
|
||||
[PluginService]
|
||||
internal IFramework Framework { get; private set; }
|
||||
|
||||
[PluginService]
|
||||
internal IGameGui GameGui { get; private set; }
|
||||
|
||||
[PluginService]
|
||||
internal IGameInteropProvider GameInteropProvider { get; private set; }
|
||||
|
||||
[PluginService]
|
||||
internal IObjectTable ObjectTable { get; private set; }
|
||||
|
||||
[PluginService]
|
||||
internal IPartyFinderGui PartyFinderGui { get; private set; }
|
||||
|
||||
[PluginService]
|
||||
internal ISigScanner SigScanner { get; private set; }
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
namespace XivCommon;
|
||||
|
||||
|
@ -40,12 +38,6 @@ internal static class Util {
|
|||
Logger.Log.Warning($"Could not find signature for {name}. This functionality will be disabled.");
|
||||
}
|
||||
|
||||
internal static T GetService<T>() {
|
||||
var service = typeof(IDalamudPlugin).Assembly.GetType("Dalamud.Service`1")!.MakeGenericType(typeof(T));
|
||||
var get = service.GetMethod("Get", BindingFlags.Public | BindingFlags.Static)!;
|
||||
return (T) get.Invoke(null, null)!;
|
||||
}
|
||||
|
||||
internal static unsafe IntPtr FollowPointerChain(IntPtr start, IEnumerable<int> offsets) {
|
||||
if (start == IntPtr.Zero) {
|
||||
return IntPtr.Zero;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<LangVersion>latest</LangVersion>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>8.0.0</Version>
|
||||
<Version>9.0.0</Version>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
namespace XivCommon;
|
||||
|
||||
|
@ -20,8 +21,8 @@ public class XivCommonBase : IDisposable {
|
|||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="hooks">Flags indicating which hooks to enable</param>
|
||||
public XivCommonBase(Hooks hooks = HooksExt.DefaultHooks) {
|
||||
this.Functions = new GameFunctions(hooks);
|
||||
public XivCommonBase(DalamudPluginInterface @interface, Hooks hooks = HooksExt.DefaultHooks) {
|
||||
this.Functions = new GameFunctions(@interface, hooks);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
Loading…
Reference in New Issue