diff --git a/Globetrotter/Globetrotter.csproj b/Globetrotter/Globetrotter.csproj index 1dbc2ee..dbc4265 100755 --- a/Globetrotter/Globetrotter.csproj +++ b/Globetrotter/Globetrotter.csproj @@ -27,10 +27,6 @@ $(DalamudLibPath)\ImGui.NET.dll False - - $(DalamudLibPath)\ImGuiScene.dll - False - $(DalamudLibPath)\Lumina.dll False diff --git a/Globetrotter/GlobetrotterPlugin.cs b/Globetrotter/Plugin.cs similarity index 81% rename from Globetrotter/GlobetrotterPlugin.cs rename to Globetrotter/Plugin.cs index 98acca5..3c6dd66 100644 --- a/Globetrotter/GlobetrotterPlugin.cs +++ b/Globetrotter/Plugin.cs @@ -1,38 +1,41 @@ using Dalamud.Game.Command; using Dalamud.Plugin; using System; -using Dalamud.Data; using Dalamud.Game; -using Dalamud.Game.Gui; using Dalamud.IoC; +using Dalamud.Plugin.Services; namespace Globetrotter { // ReSharper disable once ClassNeverInstantiated.Global - public class GlobetrotterPlugin : IDalamudPlugin { + public class Plugin : IDalamudPlugin { private bool _disposedValue; - public string Name => "Globetrotter"; + [PluginService] + internal static IPluginLog Log { get; private set; } = null!; [PluginService] private DalamudPluginInterface Interface { get; init; } = null!; [PluginService] - private CommandManager CommandManager { get; init; } = null!; + private ICommandManager CommandManager { get; init; } = null!; [PluginService] - internal DataManager DataManager { get; init; } = null!; + internal IDataManager DataManager { get; init; } = null!; [PluginService] - internal GameGui GameGui { get; init; } = null!; + internal IGameGui GameGui { get; init; } = null!; [PluginService] - internal SigScanner SigScanner { get; init; } = null!; + internal ISigScanner SigScanner { get; init; } = null!; + + [PluginService] + internal IGameInteropProvider GameInteropProvider { get; init; } = null!; internal Configuration Config { get; } private PluginUi Ui { get; } private TreasureMaps Maps { get; } - public GlobetrotterPlugin() { + public Plugin() { this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration(); this.Config.Initialize(this.Interface); diff --git a/Globetrotter/PluginUi.cs b/Globetrotter/PluginUi.cs index d09fa2e..d82ef50 100644 --- a/Globetrotter/PluginUi.cs +++ b/Globetrotter/PluginUi.cs @@ -3,7 +3,7 @@ using System.Numerics; namespace Globetrotter { internal class PluginUi { - private GlobetrotterPlugin Plugin { get; } + private Plugin Plugin { get; } private bool _displaySettings; @@ -12,7 +12,7 @@ namespace Globetrotter { set => this._displaySettings = value; } - public PluginUi(GlobetrotterPlugin plugin) { + public PluginUi(Plugin plugin) { this.Plugin = plugin; } diff --git a/Globetrotter/TreasureMaps.cs b/Globetrotter/TreasureMaps.cs index 04e3e4e..370a89a 100644 --- a/Globetrotter/TreasureMaps.cs +++ b/Globetrotter/TreasureMaps.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using Dalamud.Game.Text.SeStringHandling.Payloads; -using Dalamud.Logging; namespace Globetrotter { internal sealed class TreasureMaps : IDisposable { @@ -48,7 +47,7 @@ namespace Globetrotter { } } - private GlobetrotterPlugin Plugin { get; } + private Plugin Plugin { get; } private TreasureMapPacket? _lastMap; private delegate char HandleActorControlSelfDelegate(long a1, long a2, IntPtr dataPtr); @@ -58,15 +57,15 @@ namespace Globetrotter { private readonly Hook _acsHook; private readonly Hook _showMapHook; - public TreasureMaps(GlobetrotterPlugin plugin) { + public TreasureMaps(Plugin plugin) { this.Plugin = plugin; var acsPtr = this.Plugin.SigScanner.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 48 8B D9 49 8B F8 41 0F B7 08"); - this._acsHook = Hook.FromAddress(acsPtr, this.OnACS); + this._acsHook = this.Plugin.GameInteropProvider.HookFromAddress(acsPtr, this.OnACS); this._acsHook.Enable(); var showMapPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? 40 84 FF 0F 85 ?? ?? ?? ?? 48 8B 0D"); - this._showMapHook = Hook.FromAddress(showMapPtr, this.OnShowMap); + this._showMapHook = this.Plugin.GameInteropProvider.HookFromAddress(showMapPtr, this.OnShowMap); this._showMapHook.Enable(); } @@ -89,7 +88,7 @@ namespace Globetrotter { return IntPtr.Zero; } } catch (Exception ex) { - PluginLog.LogError(ex, "Exception on show map"); + Plugin.Log.Error(ex, "Exception on show map"); } return this._showMapHook.Original(manager, rowId, subRowId, a4); @@ -117,7 +116,7 @@ namespace Globetrotter { try { this.OnACSInner(dataPtr); } catch (Exception ex) { - PluginLog.LogError(ex, "Exception on ACS"); + Plugin.Log.Error(ex, "Exception on ACS"); } return this._acsHook.Original(a1, a2, dataPtr);