mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Unify IconReplacer and IconReplaceChecker, cleanup
This commit is contained in:
parent
a3fe81d310
commit
1bd4eed72c
5 changed files with 29 additions and 78 deletions
|
|
@ -42,8 +42,6 @@ namespace Dalamud {
|
|||
|
||||
public readonly IconReplacer IconReplacer;
|
||||
|
||||
public readonly IconReplaceChecker IconReplaceChecker;
|
||||
|
||||
public Dalamud(DalamudStartInfo info) {
|
||||
this.StartInfo = info;
|
||||
|
||||
|
|
@ -71,9 +69,7 @@ namespace Dalamud {
|
|||
|
||||
this.PluginManager = new PluginManager(this, info.PluginDirectory, info.DefaultPluginDirectory);
|
||||
|
||||
this.IconReplaceChecker = new IconReplaceChecker(this.targetModule, this.sigScanner);
|
||||
|
||||
this.IconReplacer = new IconReplacer(this, this.targetModule, this.sigScanner);
|
||||
this.IconReplacer = new IconReplacer(this, this.sigScanner);
|
||||
|
||||
try {
|
||||
this.PluginManager.LoadPlugins();
|
||||
|
|
@ -89,8 +85,6 @@ namespace Dalamud {
|
|||
|
||||
this.BotManager.Start();
|
||||
|
||||
this.IconReplaceChecker.Enable();
|
||||
|
||||
this.IconReplacer.Enable();
|
||||
}
|
||||
|
||||
|
|
@ -109,8 +103,6 @@ namespace Dalamud {
|
|||
|
||||
this.unloadSignal.Dispose();
|
||||
|
||||
this.IconReplaceChecker.Dispose();
|
||||
|
||||
this.IconReplacer.Dispose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Dalamud.Hooking;
|
||||
|
||||
namespace Dalamud.Game.Internal.Gui {
|
||||
public class IconReplaceChecker {
|
||||
private IconReplaceCheckerAddressResolver address;
|
||||
private Hook<OnCheckDetour> checkerHook;
|
||||
|
||||
public IconReplaceChecker(ProcessModule module, SigScanner scanner) {
|
||||
this.address = new IconReplaceCheckerAddressResolver();
|
||||
this.address.Setup(scanner);
|
||||
hookChecker();
|
||||
}
|
||||
|
||||
private void hookChecker() {
|
||||
this.checkerHook = new Hook<OnCheckDetour>(this.address.BaseAddress, (Delegate)new OnCheckDetour(this.HandleChecker), (object)this);
|
||||
}
|
||||
|
||||
public void Enable() {
|
||||
this.checkerHook.Enable();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.checkerHook.Dispose();
|
||||
}
|
||||
|
||||
// I hate this function. This is the dumbest function to exist in the game. Just return 1.
|
||||
// Determines which abilities are allowed to have their icons updated.
|
||||
private ulong HandleChecker(int actionID) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private delegate ulong OnCheckDetour(int actionID);
|
||||
|
||||
public delegate ulong OnCheckDelegate(int actionID);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Dalamud.Game.Internal.Gui {
|
||||
class IconReplaceCheckerAddressResolver : BaseAddressResolver {
|
||||
public IntPtr BaseAddress { get; private set; }
|
||||
protected bool IsResolved { get; set; }
|
||||
|
||||
protected override void Setup64Bit(SigScanner sig)
|
||||
{
|
||||
this.BaseAddress = sig.ScanText("81 f9 d4 08 00 00 7f 33 0f 84 fa 01 00 00 83 c1 eb 81 f9 a3 00 00 00");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,14 @@ using System.Runtime.InteropServices;
|
|||
|
||||
namespace Dalamud.Game.Internal.Gui {
|
||||
public class IconReplacer {
|
||||
private IconReplacerAddressResolver address;
|
||||
private Hook<OnIconDetour> iconHook;
|
||||
public delegate ulong OnGetIconDelegate(byte param1, uint param2);
|
||||
public delegate ulong OnCheckIsIconReplaceableDelegate(int actionID);
|
||||
|
||||
private Hook<OnGetIconDelegate> iconHook;
|
||||
private Hook<OnCheckIsIconReplaceableDelegate> checkerHook;
|
||||
|
||||
private IconReplacerAddressResolver Address;
|
||||
|
||||
private IntPtr comboTimer;
|
||||
private IntPtr lastComboMove;
|
||||
private IntPtr activeBuffArray = IntPtr.Zero;
|
||||
|
|
@ -19,28 +25,39 @@ namespace Dalamud.Game.Internal.Gui {
|
|||
private Dalamud dalamud;
|
||||
private PlayerCharacter localCharacter = null;
|
||||
|
||||
public unsafe IconReplacer(Dalamud dalamud, ProcessModule module, SigScanner scanner) {
|
||||
public unsafe IconReplacer(Dalamud dalamud, SigScanner scanner) {
|
||||
this.dalamud = dalamud;
|
||||
this.address = new IconReplacerAddressResolver();
|
||||
this.address.Setup(scanner);
|
||||
this.Address = new IconReplacerAddressResolver();
|
||||
this.Address.Setup(scanner);
|
||||
|
||||
this.byteBase = scanner.Module.BaseAddress;
|
||||
this.jobInfo = byteBase + 0x1b2d4b4;
|
||||
this.comboTimer = byteBase + 0x1AE1B10;
|
||||
this.lastComboMove = byteBase + 0x1AE1B14;
|
||||
|
||||
this.iconHook = new Hook<OnIconDetour>(this.address.BaseAddress, (Delegate)new OnIconDetour(this.HandleIconUpdate), (object)this);
|
||||
Log.Verbose("===== H O T B A R S =====");
|
||||
Log.Verbose("IsIconReplaceable address {IsIconReplaceable}", Address.IsIconReplaceable);
|
||||
Log.Verbose("GetIcon address {GetIcon}", Address.GetIcon);
|
||||
|
||||
this.iconHook = new Hook<OnGetIconDelegate>(this.Address.GetIcon, new OnGetIconDelegate(GetIconDetour), this);
|
||||
this.checkerHook = new Hook<OnCheckIsIconReplaceableDelegate>(this.Address.IsIconReplaceable, new OnCheckIsIconReplaceableDelegate(CheckIsIconReplaceableDetour), this);
|
||||
}
|
||||
|
||||
public void Enable() {
|
||||
this.iconHook.Enable();
|
||||
this.checkerHook.Enable();
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
this.iconHook.Dispose();
|
||||
this.checkerHook.Dispose();
|
||||
}
|
||||
|
||||
// I hate this function. This is the dumbest function to exist in the game. Just return 1.
|
||||
// Determines which abilities are allowed to have their icons updated.
|
||||
private ulong CheckIsIconReplaceableDetour(int actionID) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace an ability with another ability
|
||||
|
|
@ -51,7 +68,7 @@ namespace Dalamud.Game.Internal.Gui {
|
|||
/// For example, Souleater combo on DRK happens by dragging Souleater
|
||||
/// onto your bar and mashing it.
|
||||
/// </summary>
|
||||
private unsafe ulong HandleIconUpdate(byte self, uint actionID) {
|
||||
private unsafe ulong GetIconDetour(byte self, uint actionID) {
|
||||
|
||||
// TODO: BRD, RDM, level checking for everything.
|
||||
|
||||
|
|
@ -498,10 +515,6 @@ namespace Dalamud.Game.Internal.Gui {
|
|||
return false;
|
||||
}
|
||||
|
||||
private delegate ulong OnIconDetour(byte param1, uint param2);
|
||||
|
||||
public delegate ulong OnIconDelegate(byte param1, uint param2);
|
||||
|
||||
private unsafe delegate int* getArray(long* address);
|
||||
|
||||
private unsafe IntPtr FindBuffAddress() {
|
||||
|
|
|
|||
|
|
@ -6,11 +6,12 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Dalamud.Game.Internal.Gui {
|
||||
class IconReplacerAddressResolver : BaseAddressResolver {
|
||||
public IntPtr BaseAddress { get; private set; }
|
||||
protected bool IsResolved { get; set; }
|
||||
public IntPtr GetIcon { get; private set; }
|
||||
public IntPtr IsIconReplaceable { get; private set; }
|
||||
|
||||
protected override void Setup64Bit(SigScanner sig) {
|
||||
this.BaseAddress = sig.ScanText("81 fa d4 08 00 00 7f 4b 74 44 8d 42 eb 3d a3 00 00 00");
|
||||
this.GetIcon = sig.ScanText("81 fa d4 08 00 00 7f 4b 74 44 8d 42 eb 3d a3 00 00 00");
|
||||
this.IsIconReplaceable = sig.ScanText("81 f9 d4 08 00 00 7f 33 0f 84 fa 01 00 00 83 c1 eb 81 f9 a3 00 00 00");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue