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