refactor: update Dalamud
This commit is contained in:
parent
6af666f968
commit
8102be6fce
|
@ -8,13 +8,13 @@ namespace TheGreatSeparator {
|
|||
internal Commands(TheGreatSeparator plugin) {
|
||||
this.Plugin = plugin;
|
||||
|
||||
this.Plugin.Interface.CommandManager.AddHandler("/tgs", new CommandInfo(this.OnCommand) {
|
||||
this.Plugin.CommandManager.AddHandler("/tgs", new CommandInfo(this.OnCommand) {
|
||||
HelpMessage = "Open The Great Separator",
|
||||
});
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.Plugin.Interface.CommandManager.RemoveHandler("/tgs");
|
||||
this.Plugin.CommandManager.RemoveHandler("/tgs");
|
||||
}
|
||||
|
||||
private void OnCommand(string command, string args) {
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
using Dalamud.Plugin;
|
||||
|
||||
namespace TheGreatSeparator {
|
||||
public class Plugin : IDalamudPlugin {
|
||||
public string Name => "The Great Separator";
|
||||
|
||||
private TheGreatSeparator? Separator { get; set; }
|
||||
|
||||
public void Initialize(DalamudPluginInterface pluginInterface) {
|
||||
this.Separator = new TheGreatSeparator(pluginInterface);
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.Separator?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,16 +10,16 @@ namespace TheGreatSeparator {
|
|||
internal PluginUi(TheGreatSeparator plugin) {
|
||||
this.Plugin = plugin;
|
||||
|
||||
this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw;
|
||||
this.Plugin.Interface.UiBuilder.OnOpenConfigUi += this.Toggle;
|
||||
this.Plugin.Interface.UiBuilder.Draw += this.Draw;
|
||||
this.Plugin.Interface.UiBuilder.OpenConfigUi += this.Toggle;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.Plugin.Interface.UiBuilder.OnOpenConfigUi -= this.Toggle;
|
||||
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw;
|
||||
this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.Toggle;
|
||||
this.Plugin.Interface.UiBuilder.Draw -= this.Draw;
|
||||
}
|
||||
|
||||
internal void Toggle(object? sender = null, object? args = null) {
|
||||
internal void Toggle() {
|
||||
this._showWindow = !this._showWindow;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,18 @@ using System.Linq;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Dalamud;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace TheGreatSeparator {
|
||||
public class TheGreatSeparator : IDisposable {
|
||||
// ReSharper disable once ClassNeverInstantiated.Global
|
||||
public class TheGreatSeparator : IDalamudPlugin {
|
||||
public string Name => "The Great Separator";
|
||||
|
||||
private static class Signatures {
|
||||
internal const string ShowFlyText = "E8 ?? ?? ?? ?? FF C7 41 D1 C7";
|
||||
internal const string SprintfNumber = "48 83 EC 28 44 8B C9";
|
||||
|
@ -34,7 +40,15 @@ namespace TheGreatSeparator {
|
|||
|
||||
private Hook<SprintfNumberDelegate>? SprintfNumberHook { get; }
|
||||
|
||||
internal DalamudPluginInterface Interface { get; }
|
||||
[PluginService]
|
||||
internal DalamudPluginInterface Interface { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal CommandManager CommandManager { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal SigScanner SigScanner { get; init; } = null!;
|
||||
|
||||
internal Configuration Config { get; }
|
||||
internal PluginUi Ui { get; }
|
||||
private Commands Commands { get; }
|
||||
|
@ -42,9 +56,7 @@ namespace TheGreatSeparator {
|
|||
private byte OriginalSeparator { get; }
|
||||
private IntPtr SeparatorPtr { get; } = IntPtr.Zero;
|
||||
|
||||
internal TheGreatSeparator(DalamudPluginInterface @interface) {
|
||||
this.Interface = @interface;
|
||||
|
||||
internal TheGreatSeparator() {
|
||||
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
this.Config.Initialise(this.Interface);
|
||||
|
||||
|
@ -53,17 +65,17 @@ namespace TheGreatSeparator {
|
|||
this.Ui = new PluginUi(this);
|
||||
this.Commands = new Commands(this);
|
||||
|
||||
if (this.Interface.TargetModuleScanner.TryScanText(Signatures.ShowFlyText, out var showFlyPtr)) {
|
||||
this.ShowFlyTextHook = new Hook<ShowFlyTextDelegate>(showFlyPtr + 9, new ShowFlyTextDelegate(this.ShowFlyTextDetour));
|
||||
if (this.SigScanner.TryScanText(Signatures.ShowFlyText, out var showFlyPtr)) {
|
||||
this.ShowFlyTextHook = new Hook<ShowFlyTextDelegate>(showFlyPtr + 9, this.ShowFlyTextDetour);
|
||||
this.ShowFlyTextHook.Enable();
|
||||
}
|
||||
|
||||
if (this.Interface.TargetModuleScanner.TryScanText(Signatures.SprintfNumber, out var sprintfPtr)) {
|
||||
this.SprintfNumberHook = new Hook<SprintfNumberDelegate>(sprintfPtr, new SprintfNumberDelegate(this.SprintfNumberDetour));
|
||||
if (this.SigScanner.TryScanText(Signatures.SprintfNumber, out var sprintfPtr)) {
|
||||
this.SprintfNumberHook = new Hook<SprintfNumberDelegate>(sprintfPtr, this.SprintfNumberDetour);
|
||||
this.SprintfNumberHook.Enable();
|
||||
}
|
||||
|
||||
if (this.Interface.TargetModuleScanner.TryGetStaticAddressFromSig(Signatures.Separator, out var separatorPtr)) {
|
||||
if (this.SigScanner.TryGetStaticAddressFromSig(Signatures.Separator, out var separatorPtr)) {
|
||||
this.SeparatorPtr = separatorPtr;
|
||||
this.OriginalSeparator = Marshal.ReadByte(this.SeparatorPtr);
|
||||
}
|
||||
|
@ -102,7 +114,7 @@ namespace TheGreatSeparator {
|
|||
}
|
||||
|
||||
private void ConfigureInstruction(string sig, bool enabled) {
|
||||
if (!this.Interface.TargetModuleScanner.TryScanText(sig, out var ptr)) {
|
||||
if (!this.SigScanner.TryScanText(sig, out var ptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<TargetFramework>net5-windows</TargetFramework>
|
||||
<Version>1.2.0</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
|
Loading…
Reference in New Issue