refactor: migrate to net5
This commit is contained in:
parent
19f3ebdef9
commit
15d103c3e3
|
@ -3,7 +3,6 @@ using System.Runtime.InteropServices;
|
|||
using Dalamud.Game;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
namespace XivCommon.Functions {
|
||||
/// <summary>
|
||||
|
@ -47,7 +46,7 @@ namespace XivCommon.Functions {
|
|||
this.AddBattleTalk = Marshal.GetDelegateForFunctionPointer<AddBattleTalkDelegate>(addBattleTalkPtr);
|
||||
|
||||
if (this.HookEnabled) {
|
||||
this.AddBattleTalkHook = new Hook<AddBattleTalkDelegate>(addBattleTalkPtr, new AddBattleTalkDelegate(this.AddBattleTalkDetour));
|
||||
this.AddBattleTalkHook = new Hook<AddBattleTalkDelegate>(addBattleTalkPtr, this.AddBattleTalkDetour);
|
||||
this.AddBattleTalkHook.Enable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.ClientState;
|
||||
using Dalamud.Game.ClientState.Actors.Types;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
namespace XivCommon.Functions {
|
||||
/// <summary>
|
||||
|
@ -16,7 +16,7 @@ namespace XivCommon.Functions {
|
|||
internal const string ChatBubbleUpdate = "48 85 D2 0F 84 ?? ?? ?? ?? 48 89 5C 24 ?? 57 48 83 EC 20 8B 41 0C";
|
||||
}
|
||||
|
||||
private Dalamud.Dalamud Dalamud { get; }
|
||||
private ClientState ClientState { get; }
|
||||
private SeStringManager SeStringManager { get; }
|
||||
|
||||
private delegate void OpenChatBubbleDelegate(IntPtr manager, IntPtr actor, IntPtr text, byte a4);
|
||||
|
@ -57,8 +57,8 @@ namespace XivCommon.Functions {
|
|||
/// </summary>
|
||||
public event OnUpdateChatBubbleDelegate? OnUpdateBubble;
|
||||
|
||||
internal ChatBubbles(Dalamud.Dalamud dalamud, SigScanner scanner, SeStringManager manager, bool hookEnabled) {
|
||||
this.Dalamud = dalamud;
|
||||
internal ChatBubbles(ClientState clientState, SigScanner scanner, SeStringManager manager, bool hookEnabled) {
|
||||
this.ClientState = clientState;
|
||||
this.SeStringManager = manager;
|
||||
|
||||
if (!hookEnabled) {
|
||||
|
@ -66,12 +66,12 @@ namespace XivCommon.Functions {
|
|||
}
|
||||
|
||||
if (scanner.TryScanText(Signatures.ChatBubbleOpen, out var openPtr, "chat bubbles open")) {
|
||||
this.OpenChatBubbleHook = new Hook<OpenChatBubbleDelegate>(openPtr, new OpenChatBubbleDelegate(this.OpenChatBubbleDetour));
|
||||
this.OpenChatBubbleHook = new Hook<OpenChatBubbleDelegate>(openPtr, this.OpenChatBubbleDetour);
|
||||
this.OpenChatBubbleHook.Enable();
|
||||
}
|
||||
|
||||
if (scanner.TryScanText(Signatures.ChatBubbleUpdate, out var updatePtr, "chat bubbles update")) {
|
||||
this.UpdateChatBubbleHook = new Hook<UpdateChatBubbleDelegate>(updatePtr + 9, new UpdateChatBubbleDelegate(this.UpdateChatBubbleDetour));
|
||||
this.UpdateChatBubbleHook = new Hook<UpdateChatBubbleDelegate>(updatePtr + 9, this.UpdateChatBubbleDetour);
|
||||
this.UpdateChatBubbleHook.Enable();
|
||||
}
|
||||
}
|
||||
|
@ -92,8 +92,7 @@ namespace XivCommon.Functions {
|
|||
}
|
||||
|
||||
private void OpenChatBubbleDetourInner(IntPtr manager, IntPtr actorPtr, IntPtr textPtr, byte a4) {
|
||||
var actorStruct = Marshal.PtrToStructure<Dalamud.Game.ClientState.Structs.Actor>(actorPtr);
|
||||
var actor = new Actor(actorPtr, actorStruct, this.Dalamud);
|
||||
var actor = this.ClientState.Actors.CreateActorReference(actorPtr);
|
||||
|
||||
var text = Util.ReadSeString(textPtr, this.SeStringManager);
|
||||
|
||||
|
@ -123,8 +122,7 @@ namespace XivCommon.Functions {
|
|||
|
||||
private void UpdateChatBubbleDetourInner(IntPtr bubblePtr, IntPtr actorPtr) {
|
||||
// var bubble = (ChatBubble*) bubblePtr;
|
||||
var actorStruct = Marshal.PtrToStructure<Dalamud.Game.ClientState.Structs.Actor>(actorPtr);
|
||||
var actor = new Actor(actorPtr, actorStruct, this.Dalamud);
|
||||
var actor = this.ClientState.Actors.CreateActorReference(actorPtr);
|
||||
|
||||
try {
|
||||
this.OnUpdateBubble?.Invoke(ref actor);
|
||||
|
|
|
@ -213,7 +213,7 @@ namespace XivCommon.Functions.ContextMenu {
|
|||
// }
|
||||
|
||||
if (scanner.TryScanText(Signatures.SomeOpenAddonThing, out var thingPtr, "Context Menu (some OpenAddon thing)")) {
|
||||
this.SomeOpenAddonThingHook = new Hook<SomeOpenAddonThingDelegate>(thingPtr, new SomeOpenAddonThingDelegate(this.SomeOpenAddonThingDetour));
|
||||
this.SomeOpenAddonThingHook = new Hook<SomeOpenAddonThingDelegate>(thingPtr, this.SomeOpenAddonThingDetour);
|
||||
this.SomeOpenAddonThingHook.Enable();
|
||||
} else {
|
||||
return;
|
||||
|
@ -221,7 +221,7 @@ namespace XivCommon.Functions.ContextMenu {
|
|||
|
||||
if (scanner.TryScanText(Signatures.ContextMenuOpen, out var openPtr, "Context Menu open")) {
|
||||
unsafe {
|
||||
this.ContextMenuOpenHook = new Hook<ContextMenuOpenDelegate>(openPtr, new ContextMenuOpenDelegate(this.OpenMenuDetour));
|
||||
this.ContextMenuOpenHook = new Hook<ContextMenuOpenDelegate>(openPtr, this.OpenMenuDetour);
|
||||
}
|
||||
|
||||
this.ContextMenuOpenHook.Enable();
|
||||
|
@ -230,20 +230,20 @@ namespace XivCommon.Functions.ContextMenu {
|
|||
}
|
||||
|
||||
if (scanner.TryScanText(Signatures.ContextMenuSelected, out var selectedPtr, "Context Menu selected")) {
|
||||
this.ContextMenuItemSelectedHook = new Hook<ContextMenuItemSelectedInternalDelegate>(selectedPtr, new ContextMenuItemSelectedInternalDelegate(this.ItemSelectedDetour));
|
||||
this.ContextMenuItemSelectedHook = new Hook<ContextMenuItemSelectedInternalDelegate>(selectedPtr, this.ItemSelectedDetour);
|
||||
this.ContextMenuItemSelectedHook.Enable();
|
||||
}
|
||||
|
||||
if (scanner.TryScanText(Signatures.TitleContextMenuOpen, out var titleOpenPtr, "Context Menu (title menu open)")) {
|
||||
unsafe {
|
||||
this.TitleContextMenuOpenHook = new Hook<ContextMenuOpenDelegate>(titleOpenPtr, new ContextMenuOpenDelegate(this.TitleContextMenuOpenDetour));
|
||||
this.TitleContextMenuOpenHook = new Hook<ContextMenuOpenDelegate>(titleOpenPtr, this.TitleContextMenuOpenDetour);
|
||||
}
|
||||
|
||||
this.TitleContextMenuOpenHook.Enable();
|
||||
}
|
||||
|
||||
if (scanner.TryScanText(Signatures.ContextMenuEvent66, out var event66Ptr, "Context Menu (event 66)")) {
|
||||
this.ContextMenuEvent66Hook = new Hook<ContextMenuEvent66Delegate>(event66Ptr, new ContextMenuEvent66Delegate(this.ContextMenuEvent66Detour));
|
||||
this.ContextMenuEvent66Hook = new Hook<ContextMenuEvent66Delegate>(event66Ptr, this.ContextMenuEvent66Detour);
|
||||
this.ContextMenuEvent66Hook.Enable();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace XivCommon.Functions {
|
|||
/// </summary>
|
||||
/// <param name="actorId">Actor ID to open window for</param>
|
||||
/// <exception cref="InvalidOperationException">If the signature for this function could not be found</exception>
|
||||
public void OpenExamineWindow(int actorId) {
|
||||
public void OpenExamineWindow(uint actorId) {
|
||||
if (this.RequestCharacterInfo == null) {
|
||||
throw new InvalidOperationException("Could not find signature for Examine function");
|
||||
}
|
||||
|
@ -57,11 +57,11 @@ namespace XivCommon.Functions {
|
|||
unsafe {
|
||||
// offsets at sig E8 ?? ?? ?? ?? 33 C0 EB 4C
|
||||
// this is called at the end of the 2c case
|
||||
var raw = (int*) rciData;
|
||||
var raw = (uint*) rciData;
|
||||
*(raw + 10) = actorId;
|
||||
*(raw + 11) = actorId;
|
||||
*(raw + 12) = actorId;
|
||||
*(raw + 13) = -536870912;
|
||||
*(raw + 13) = 0xE0000000;
|
||||
*(raw + 311) = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics;
|
||||
|
||||
namespace XivCommon.Functions.NamePlates {
|
||||
/// <summary>
|
||||
|
@ -55,7 +54,7 @@ namespace XivCommon.Functions.NamePlates {
|
|||
/// <summary>
|
||||
/// The colour of this name plate.
|
||||
/// </summary>
|
||||
public ByteColor Colour { get; set; }
|
||||
public RgbaColour Colour { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace XivCommon.Functions.NamePlates {
|
|||
|
||||
if (scanner.TryScanText(Signatures.NamePlateUpdate, out var updatePtr)) {
|
||||
unsafe {
|
||||
this._namePlateUpdateHook = new Hook<NamePlateUpdateDelegate>(updatePtr, new NamePlateUpdateDelegate(this.NamePlateUpdateDetour));
|
||||
this._namePlateUpdateHook = new Hook<NamePlateUpdateDelegate>(updatePtr, this.NamePlateUpdateDetour);
|
||||
}
|
||||
|
||||
this._namePlateUpdateHook.Enable();
|
||||
|
@ -209,7 +209,7 @@ namespace XivCommon.Functions.NamePlates {
|
|||
numbers->SetValue(numbersIndex + IconIndex, (int) args.Icon);
|
||||
}
|
||||
|
||||
var colour = args.Colour;
|
||||
var colour = (ByteColor) args.Colour;
|
||||
var colourInt = *(int*) &colour;
|
||||
if (colourInt != numbers->IntArray[numbersIndex + ColourIndex]) {
|
||||
numbers->SetValue(numbersIndex + ColourIndex, colourInt);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics;
|
||||
|
||||
namespace XivCommon.Functions.NamePlates {
|
||||
[StructLayout(LayoutKind.Explicit, Size = 0x28)]
|
||||
|
@ -90,4 +91,86 @@ namespace XivCommon.Functions.NamePlates {
|
|||
/// </summary>
|
||||
LowTitleNoFc = 8,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A colour, represented in the RGBA format.
|
||||
/// </summary>
|
||||
public class RgbaColour {
|
||||
/// <summary>
|
||||
/// The red component of the colour.
|
||||
/// </summary>
|
||||
public byte R { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The green component of the colour.
|
||||
/// </summary>
|
||||
public byte G { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The blue component of the colour.
|
||||
/// </summary>
|
||||
public byte B { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The alpha component of the colour.
|
||||
/// </summary>
|
||||
public byte A { get; set; } = byte.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// Converts an unsigned integer into an RgbaColour.
|
||||
/// </summary>
|
||||
/// <param name="rgba">32-bit integer representing an RGBA colour</param>
|
||||
/// <returns>an RgbaColour equivalent to the integer representation</returns>
|
||||
public static implicit operator RgbaColour(uint rgba) {
|
||||
var r = (byte) ((rgba >> 24) & 0xFF);
|
||||
var g = (byte) ((rgba >> 16) & 0xFF);
|
||||
var b = (byte) ((rgba >> 8) & 0xFF);
|
||||
var a = (byte) (rgba & 0xFF);
|
||||
|
||||
return new RgbaColour {
|
||||
R = r,
|
||||
G = g,
|
||||
B = b,
|
||||
A = a,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts an RgbaColour into an unsigned integer representation.
|
||||
/// </summary>
|
||||
/// <param name="rgba">an RgbaColour to convert</param>
|
||||
/// <returns>32-bit integer representing an RGBA colour</returns>
|
||||
public static implicit operator uint(RgbaColour rgba) {
|
||||
return (uint) ((rgba.R << 24)
|
||||
| (rgba.G << 16)
|
||||
| (rgba.B << 8)
|
||||
| rgba.A);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a ByteColor into an RgbaColour.
|
||||
/// </summary>
|
||||
/// <param name="rgba">ByteColor</param>
|
||||
/// <returns>equivalent RgbaColour</returns>
|
||||
public static implicit operator RgbaColour(ByteColor rgba) {
|
||||
return (uint) ((rgba.R << 24)
|
||||
| (rgba.G << 16)
|
||||
| (rgba.B << 8)
|
||||
| rgba.A);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts an RgbaColour into a ByteColor.
|
||||
/// </summary>
|
||||
/// <param name="rgba">RgbaColour</param>
|
||||
/// <returns>equivalent ByteColour</returns>
|
||||
public static implicit operator ByteColor(RgbaColour rgba) {
|
||||
return new() {
|
||||
R = rgba.R,
|
||||
G = rgba.G,
|
||||
B = rgba.B,
|
||||
A = rgba.A,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,13 +73,13 @@ namespace XivCommon.Functions {
|
|||
this.RequestPartyFinderListings = Marshal.GetDelegateForFunctionPointer<RequestPartyFinderListingsDelegate>(requestPfPtr);
|
||||
|
||||
if (this.ListingsEnabled) {
|
||||
this.RequestPfListingsHook = new Hook<RequestPartyFinderListingsDelegate>(requestPfPtr, new RequestPartyFinderListingsDelegate(this.OnRequestPartyFinderListings));
|
||||
this.RequestPfListingsHook = new Hook<RequestPartyFinderListingsDelegate>(requestPfPtr, this.OnRequestPartyFinderListings);
|
||||
this.RequestPfListingsHook.Enable();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.JoinsEnabled && scanner.TryScanText(Signatures.JoinCrossParty, out var joinPtr, "Party Finder joins")) {
|
||||
this.JoinPfHook = new Hook<JoinPfDelegate>(joinPtr, new JoinPfDelegate(this.JoinPfDetour));
|
||||
this.JoinPfHook = new Hook<JoinPfDelegate>(joinPtr, this.JoinPfDetour);
|
||||
this.JoinPfHook.Enable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Runtime.InteropServices;
|
|||
using Dalamud.Game;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
namespace XivCommon.Functions {
|
||||
/// <summary>
|
||||
|
@ -59,7 +58,7 @@ namespace XivCommon.Functions {
|
|||
}
|
||||
|
||||
if (scanner.TryScanText(Signatures.ShowMessageBox, out var showMessageBoxPtr, "Talk")) {
|
||||
this.AddonTalkV45Hook = new Hook<AddonTalkV45Delegate>(showMessageBoxPtr, new AddonTalkV45Delegate(this.AddonTalkV45Detour));
|
||||
this.AddonTalkV45Hook = new Hook<AddonTalkV45Delegate>(showMessageBoxPtr, this.AddonTalkV45Detour);
|
||||
this.AddonTalkV45Hook.Enable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace XivCommon.Functions.Tooltips {
|
|||
|
||||
if (scanner.TryScanText(Signatures.AgentItemDetailUpdateTooltip, out var updateItemPtr, "Tooltips - Items")) {
|
||||
unsafe {
|
||||
this.ItemUpdateTooltipHook = new Hook<ItemUpdateTooltipDelegate>(updateItemPtr, new ItemUpdateTooltipDelegate(this.ItemUpdateTooltipDetour));
|
||||
this.ItemUpdateTooltipHook = new Hook<ItemUpdateTooltipDelegate>(updateItemPtr, this.ItemUpdateTooltipDetour);
|
||||
}
|
||||
|
||||
this.ItemUpdateTooltipHook.Enable();
|
||||
|
@ -92,7 +92,7 @@ namespace XivCommon.Functions.Tooltips {
|
|||
|
||||
if (scanner.TryScanText(Signatures.AgentActionDetailUpdateTooltip, out var updateActionPtr, "Tooltips - Actions")) {
|
||||
unsafe {
|
||||
this.ActionGenerateTooltipHook = new Hook<ActionUpdateTooltipDelegate>(updateActionPtr, new ActionUpdateTooltipDelegate(this.ActionUpdateTooltipDetour));
|
||||
this.ActionGenerateTooltipHook = new Hook<ActionUpdateTooltipDelegate>(updateActionPtr, this.ActionUpdateTooltipDetour);
|
||||
}
|
||||
|
||||
this.ActionGenerateTooltipHook.Enable();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using Dalamud.Plugin;
|
||||
using XivCommon.Functions;
|
||||
|
@ -95,16 +94,13 @@ namespace XivCommon {
|
|||
var scanner = @interface.TargetModuleScanner;
|
||||
var seStringManager = @interface.SeStringManager;
|
||||
|
||||
var dalamudField = @interface.GetType().GetField("dalamud", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
var dalamud = (Dalamud.Dalamud) dalamudField!.GetValue(@interface);
|
||||
|
||||
this.UiAlloc = new UiAlloc(scanner);
|
||||
this.Chat = new Chat(this, scanner);
|
||||
this.PartyFinder = new PartyFinder(scanner, @interface.Framework.Gui.PartyFinder, hooks);
|
||||
this.BattleTalk = new BattleTalk(this, scanner, seStringManager, hooks.HasFlag(Hooks.BattleTalk));
|
||||
this.Examine = new Examine(this, scanner);
|
||||
this.Talk = new Talk(scanner, seStringManager, hooks.HasFlag(Hooks.Talk));
|
||||
this.ChatBubbles = new ChatBubbles(dalamud, scanner, seStringManager, hooks.HasFlag(Hooks.ChatBubbles));
|
||||
this.ChatBubbles = new ChatBubbles(@interface.ClientState, scanner, seStringManager, hooks.HasFlag(Hooks.ChatBubbles));
|
||||
this.ContextMenu = new ContextMenu(this, scanner, seStringManager, @interface.ClientState.ClientLanguage, hooks);
|
||||
this.Tooltips = new Tooltips(scanner, @interface.Framework, @interface.Framework.Gui, seStringManager, hooks.HasFlag(Hooks.Tooltips));
|
||||
this.NamePlates = new NamePlates(this, scanner, seStringManager, hooks.HasFlag(Hooks.NamePlates));
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace XivCommon {
|
|||
internal static byte[] Terminate(this byte[] array) {
|
||||
var terminated = new byte[array.Length + 1];
|
||||
Array.Copy(array, terminated, array.Length);
|
||||
terminated[terminated.Length - 1] = 0;
|
||||
terminated[^1] = 0;
|
||||
|
||||
return terminated;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net472;net48</TargetFrameworks>
|
||||
<TargetFramework>net5-windows</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>2.3.0</Version>
|
||||
<Version>3.0.0-alpha.1</Version>
|
||||
<DebugType>full</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
Loading…
Reference in New Issue