diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index e9357c4a6..be4278ec5 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -7,11 +7,9 @@ using System.Threading; using Dalamud.Configuration.Internal; using Dalamud.Data; using Dalamud.Game; -using Dalamud.Game.Addon; using Dalamud.Game.ClientState; using Dalamud.Game.Command; using Dalamud.Game.Internal; -using Dalamud.Game.Network; using Dalamud.Game.Network.Internal; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Hooking.Internal; diff --git a/Dalamud/Game/Internal/Framework.cs b/Dalamud/Game/Framework.cs similarity index 98% rename from Dalamud/Game/Internal/Framework.cs rename to Dalamud/Game/Framework.cs index adef8e3c8..cd16fb829 100644 --- a/Dalamud/Game/Internal/Framework.cs +++ b/Dalamud/Game/Framework.cs @@ -5,13 +5,13 @@ using System.Linq; using System.Runtime.InteropServices; using System.Threading; -using Dalamud.Game.Internal.Gui; -using Dalamud.Game.Internal.Network; +using Dalamud.Game.Gui; using Dalamud.Game.Libc; +using Dalamud.Game.Network; using Dalamud.Hooking; using Serilog; -namespace Dalamud.Game.Internal +namespace Dalamud.Game { /// /// This class represents the Framework of the native game client and grants access to various subsystems. @@ -90,7 +90,7 @@ namespace Dalamud.Game.Internal /// /// Gets the stats history mapping. /// - public static Dictionary> StatsHistory = new(); + public static Dictionary> StatsHistory { get; } = new(); #region Subsystems diff --git a/Dalamud/Game/Internal/FrameworkAddressResolver.cs b/Dalamud/Game/FrameworkAddressResolver.cs similarity index 97% rename from Dalamud/Game/Internal/FrameworkAddressResolver.cs rename to Dalamud/Game/FrameworkAddressResolver.cs index 1af2e9263..7bcae5045 100644 --- a/Dalamud/Game/Internal/FrameworkAddressResolver.cs +++ b/Dalamud/Game/FrameworkAddressResolver.cs @@ -1,7 +1,9 @@ using System; using System.Runtime.InteropServices; -namespace Dalamud.Game.Internal +using Dalamud.Game.Internal; + +namespace Dalamud.Game { /// /// The address resolver for the class. diff --git a/Dalamud/Game/Internal/Gui/Addon/Addon.cs b/Dalamud/Game/Gui/Addons/Addon.cs similarity index 56% rename from Dalamud/Game/Internal/Gui/Addon/Addon.cs rename to Dalamud/Game/Gui/Addons/Addon.cs index 5a0c4ce98..207443b8b 100644 --- a/Dalamud/Game/Internal/Gui/Addon/Addon.cs +++ b/Dalamud/Game/Gui/Addons/Addon.cs @@ -1,66 +1,63 @@ using System; -namespace Dalamud.Game.Internal.Gui.Addon +using Dalamud.Memory; + +namespace Dalamud.Game.Gui.Addons { /// /// This class represents an in-game UI "Addon". /// - public class Addon + public unsafe class Addon { - /// - /// The address of the addon. - /// - public IntPtr Address; - - /// - /// The addon interop data. - /// - protected Structs.Addon addonStruct; - /// /// Initializes a new instance of the class. /// /// The address of the addon. - /// The addon interop data. - public Addon(IntPtr address, Structs.Addon addonStruct) + public Addon(IntPtr address) { this.Address = address; - this.addonStruct = addonStruct; } + /// + /// Gets the address of the addon. + /// + public IntPtr Address { get; } + /// /// Gets the name of the addon. /// - public string Name => this.addonStruct.Name; + public string Name => MemoryHelper.ReadString((IntPtr)this.Struct->Name, 0x20); /// /// Gets the X position of the addon on screen. /// - public short X => this.addonStruct.X; + public short X => this.Struct->X; /// /// Gets the Y position of the addon on screen. /// - public short Y => this.addonStruct.Y; + public short Y => this.Struct->Y; /// /// Gets the scale of the addon. /// - public float Scale => this.addonStruct.Scale; + public float Scale => this.Struct->Scale; /// /// Gets the width of the addon. This may include non-visible parts. /// - public unsafe float Width => this.addonStruct.RootNode->Width * this.Scale; + public unsafe float Width => this.Struct->RootNode->Width * this.Scale; /// /// Gets the height of the addon. This may include non-visible parts. /// - public unsafe float Height => this.addonStruct.RootNode->Height * this.Scale; + public unsafe float Height => this.Struct->RootNode->Height * this.Scale; /// /// Gets a value indicating whether the addon is visible. /// - public bool Visible => (this.addonStruct.Flags & 0x20) == 0x20; + public bool Visible => this.Struct->IsVisible; + + private FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase* Struct => (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)this.Address; } } diff --git a/Dalamud/Game/Internal/Gui/ChatGui.cs b/Dalamud/Game/Gui/ChatGui.cs similarity index 99% rename from Dalamud/Game/Internal/Gui/ChatGui.cs rename to Dalamud/Game/Gui/ChatGui.cs index 9b60b8b46..09f5d2a2a 100644 --- a/Dalamud/Game/Internal/Gui/ChatGui.cs +++ b/Dalamud/Game/Gui/ChatGui.cs @@ -10,7 +10,7 @@ using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Hooking; using Serilog; -namespace Dalamud.Game.Internal.Gui +namespace Dalamud.Game.Gui { /// /// This class handles interacting with the native chat UI. @@ -335,7 +335,7 @@ namespace Dalamud.Game.Internal.Gui this.LastLinkedItemId = Marshal.ReadInt32(itemInfoPtr, 8); this.LastLinkedItemFlags = Marshal.ReadByte(itemInfoPtr, 0x14); - Log.Debug($"HandlePopulateItemLinkDetour {linkObjectPtr} {itemInfoPtr} - linked:{this.LastLinkedItemId}"); + Log.Verbose($"HandlePopulateItemLinkDetour {linkObjectPtr} {itemInfoPtr} - linked:{this.LastLinkedItemId}"); } catch (Exception ex) { diff --git a/Dalamud/Game/Internal/Gui/ChatGuiAddressResolver.cs b/Dalamud/Game/Gui/ChatGuiAddressResolver.cs similarity index 97% rename from Dalamud/Game/Internal/Gui/ChatGuiAddressResolver.cs rename to Dalamud/Game/Gui/ChatGuiAddressResolver.cs index 067558e12..07c154f1f 100644 --- a/Dalamud/Game/Internal/Gui/ChatGuiAddressResolver.cs +++ b/Dalamud/Game/Gui/ChatGuiAddressResolver.cs @@ -1,6 +1,8 @@ using System; -namespace Dalamud.Game.Internal.Gui +using Dalamud.Game.Internal; + +namespace Dalamud.Game.Gui { /// /// The address resolver for the class. @@ -102,7 +104,7 @@ namespace Dalamud.Game.Internal.Gui protected override void Setup64Bit(SigScanner sig) { // PrintMessage = sig.ScanText("4055 57 41 ?? 41 ?? 488DAC24D8FEFFFF 4881EC28020000 488B05???????? 4833C4 488985F0000000 4532D2 48894C2448"); LAST PART FOR 5.1??? - this.PrintMessage = sig.ScanText("4055 53 56 4154 4157 48 8d ac 24 ?? ?? ?? ?? 48 81 ec 20 02 00 00 48 8b 05"); + this.PrintMessage = sig.ScanText("40 55 53 56 41 54 41 57 48 8D AC 24 ?? ?? ?? ?? 48 81 EC 20 02 00 00 48 8B 05"); // PrintMessage = sig.ScanText("4055 57 41 ?? 41 ?? 488DAC24E8FEFFFF 4881EC18020000 488B05???????? 4833C4 488985E0000000 4532D2 48894C2438"); old // PrintMessage = sig.ScanText("40 55 57 41 56 41 57 48 8D AC 24 D8 FE FF FF 48 81 EC 28 02 00 00 48 8B 05 63 47 4A 01 48 33 C4 48 89 85 F0 00 00 00 45 32 D2 48 89 4C 24 48 33"); diff --git a/Dalamud/Game/Internal/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs similarity index 85% rename from Dalamud/Game/Internal/Gui/GameGui.cs rename to Dalamud/Game/Gui/GameGui.cs index f27f75662..8d965c8b2 100644 --- a/Dalamud/Game/Internal/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -1,25 +1,22 @@ using System; +using System.Numerics; using System.Runtime.InteropServices; +using Dalamud.Game.Gui.Addons; +using Dalamud.Game.Gui.PartyFinder; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Hooking; using Dalamud.Interface; +using Dalamud.Utility; using Serilog; -using SharpDX; -namespace Dalamud.Game.Internal.Gui +namespace Dalamud.Game.Gui { /// /// A class handling many aspects of the in-game UI. /// public sealed class GameGui : IDisposable { - /// - /// The delegate of the native method that gets the Client::UI::UIModule address. - /// - /// The Client::UI::UIModule address. - public readonly GetBaseUIObjectDelegate GetBaseUIObject; - private readonly Dalamud dalamud; private readonly GameGuiAddressResolver address; @@ -146,6 +143,12 @@ namespace Dalamud.Game.Internal.Gui /// public event EventHandler OnUiHideToggled; + /// + /// Gets a callable delegate for the GetBaseUIObject game method. + /// + /// The Client::UI::UIModule address. + public GetBaseUIObjectDelegate GetBaseUIObject { get; } + /// /// Gets the instance. /// @@ -227,13 +230,13 @@ namespace Dalamud.Game.Internal.Gui /// Coordinates in the world. /// Converted coordinates. /// True if worldPos corresponds to a position in front of the camera. - public bool WorldToScreen(Vector3 worldPos, out Vector2 screenPos) + public bool WorldToScreen(SharpDX.Vector3 worldPos, out SharpDX.Vector2 screenPos) { // Get base object with matrices var matrixSingleton = this.getMatrixSingleton(); // Read current ViewProjectionMatrix plus game window size - var viewProjectionMatrix = default(Matrix); + var viewProjectionMatrix = default(SharpDX.Matrix); float width, height; var windowPos = ImGuiHelpers.MainViewport.Pos; @@ -248,9 +251,9 @@ namespace Dalamud.Game.Internal.Gui height = *(rawMatrix + 1); } - Vector3.Transform(ref worldPos, ref viewProjectionMatrix, out Vector3 pCoords); + SharpDX.Vector3.Transform(ref worldPos, ref viewProjectionMatrix, out SharpDX.Vector3 pCoords); - screenPos = new Vector2(pCoords.X / pCoords.Z, pCoords.Y / pCoords.Z); + screenPos = new SharpDX.Vector2(pCoords.X / pCoords.Z, pCoords.Y / pCoords.Z); screenPos.X = (0.5f * width * (screenPos.X + 1f)) + windowPos.X; screenPos.Y = (0.5f * height * (1f - screenPos.Y)) + windowPos.Y; @@ -260,6 +263,39 @@ namespace Dalamud.Game.Internal.Gui screenPos.Y > windowPos.Y && screenPos.Y < windowPos.Y + height; } + /// + /// Converts in-world coordinates to screen coordinates (upper left corner origin). + /// + /// Coordinates in the world. + /// Converted coordinates. + /// True if worldPos corresponds to a position in front of the camera. + /// + /// This overload requires a conversion to SharpDX vectors, however the penalty should be negligible. + /// + public bool WorldToScreen(Vector3 worldPos, out Vector2 screenPos) + { + var result = this.WorldToScreen(worldPos.ToSharpDX(), out var sharpScreenPos); + screenPos = sharpScreenPos.ToSystem(); + return result; + } + + /// + /// Converts in-world coordinates to screen coordinates (upper left corner origin). + /// + /// Coordinates in the world. + /// Converted coordinates. + /// True if worldPos corresponds to a position in front of the camera. + /// + /// This overload requires a conversion to SharpDX vectors, however the penalty should be negligible. + /// + public bool WorldToScreen(Position3 worldPos, out Vector2 screenPos) + { + // This overload is necessary due to Positon3 implicit operators. + var result = this.WorldToScreen((SharpDX.Vector3)worldPos, out var sharpScreenPos); + screenPos = sharpScreenPos.ToSystem(); + return result; + } + /// /// Converts screen coordinates to in-world coordinates via raycasting. /// @@ -267,7 +303,7 @@ namespace Dalamud.Game.Internal.Gui /// Converted coordinates. /// How far to search for a collision. /// True if successful. On false, worldPos's contents are undefined. - public bool ScreenToWorld(Vector2 screenPos, out Vector3 worldPos, float rayDistance = 100000.0f) + public bool ScreenToWorld(SharpDX.Vector2 screenPos, out SharpDX.Vector3 worldPos, float rayDistance = 100000.0f) { // The game is only visible in the main viewport, so if the cursor is outside // of the game window, do not bother calculating anything @@ -285,7 +321,7 @@ namespace Dalamud.Game.Internal.Gui var matrixSingleton = this.getMatrixSingleton(); // Read current ViewProjectionMatrix plus game window size - var viewProjectionMatrix = default(Matrix); + var viewProjectionMatrix = default(SharpDX.Matrix); float width, height; unsafe { @@ -300,18 +336,18 @@ namespace Dalamud.Game.Internal.Gui viewProjectionMatrix.Invert(); - var localScreenPos = new Vector2(screenPos.X - windowPos.X, screenPos.Y - windowPos.Y); - var screenPos3D = new Vector3 + var localScreenPos = new SharpDX.Vector2(screenPos.X - windowPos.X, screenPos.Y - windowPos.Y); + var screenPos3D = new SharpDX.Vector3 { X = (localScreenPos.X / width * 2.0f) - 1.0f, Y = -((localScreenPos.Y / height * 2.0f) - 1.0f), Z = 0, }; - Vector3.TransformCoordinate(ref screenPos3D, ref viewProjectionMatrix, out var camPos); + SharpDX.Vector3.TransformCoordinate(ref screenPos3D, ref viewProjectionMatrix, out var camPos); screenPos3D.Z = 1; - Vector3.TransformCoordinate(ref screenPos3D, ref viewProjectionMatrix, out var camPosOne); + SharpDX.Vector3.TransformCoordinate(ref screenPos3D, ref viewProjectionMatrix, out var camPosOne); var clipPos = camPosOne - camPos; clipPos.Normalize(); @@ -341,7 +377,7 @@ namespace Dalamud.Game.Internal.Gui } } - worldPos = new Vector3 + worldPos = new SharpDX.Vector3 { X = worldPosArray[0], Y = worldPosArray[1], @@ -352,6 +388,23 @@ namespace Dalamud.Game.Internal.Gui return isSuccess; } + /// + /// Converts screen coordinates to in-world coordinates via raycasting. + /// + /// Screen coordinates. + /// Converted coordinates. + /// How far to search for a collision. + /// True if successful. On false, worldPos's contents are undefined. + /// + /// This overload requires a conversion to SharpDX vectors, however the penalty should be negligible. + /// + public bool ScreenToWorld(Vector2 screenPos, out Vector3 worldPos, float rayDistance = 100000.0f) + { + var result = this.ScreenToWorld(screenPos.ToSharpDX(), out var sharpworldPos); + worldPos = sharpworldPos.ToSystem(); + return result; + } + /// /// Gets a pointer to the game's UI module. /// @@ -379,12 +432,14 @@ namespace Dalamud.Game.Internal.Gui /// The addon name. /// The index of the addon, starting at 1. /// The native memory representation of the addon, if it exists. - public Addon.Addon GetAddonByName(string name, int index) + public Addon GetAddonByName(string name, int index) { - var addonMem = this.GetUiObjectByName(name, index); - if (addonMem == IntPtr.Zero) return null; - var addonStruct = Marshal.PtrToStructure(addonMem); - return new Addon.Addon(addonMem, addonStruct); + var address = this.GetUiObjectByName(name, index); + + if (address == IntPtr.Zero) + return null; + + return new Addon(address); } /// diff --git a/Dalamud/Game/Internal/Gui/GameGuiAddressResolver.cs b/Dalamud/Game/Gui/GameGuiAddressResolver.cs similarity index 99% rename from Dalamud/Game/Internal/Gui/GameGuiAddressResolver.cs rename to Dalamud/Game/Gui/GameGuiAddressResolver.cs index 12c46faa4..b3e04d68d 100644 --- a/Dalamud/Game/Internal/Gui/GameGuiAddressResolver.cs +++ b/Dalamud/Game/Gui/GameGuiAddressResolver.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.InteropServices; -namespace Dalamud.Game.Internal.Gui +namespace Dalamud.Game.Gui { /// /// The address resolver for the class. diff --git a/Dalamud/Game/Internal/Gui/HoverActionKind.cs b/Dalamud/Game/Gui/HoverActionKind.cs similarity index 96% rename from Dalamud/Game/Internal/Gui/HoverActionKind.cs rename to Dalamud/Game/Gui/HoverActionKind.cs index f069cb614..217ea18fb 100644 --- a/Dalamud/Game/Internal/Gui/HoverActionKind.cs +++ b/Dalamud/Game/Gui/HoverActionKind.cs @@ -1,4 +1,4 @@ -namespace Dalamud.Game.Internal.Gui +namespace Dalamud.Game.Gui { /// /// ActionKinds used in AgentActionDetail. diff --git a/Dalamud/Game/Internal/Gui/HoveredAction.cs b/Dalamud/Game/Gui/HoveredAction.cs similarity index 94% rename from Dalamud/Game/Internal/Gui/HoveredAction.cs rename to Dalamud/Game/Gui/HoveredAction.cs index ebc0dea15..1a7336610 100644 --- a/Dalamud/Game/Internal/Gui/HoveredAction.cs +++ b/Dalamud/Game/Gui/HoveredAction.cs @@ -1,4 +1,4 @@ -namespace Dalamud.Game.Internal.Gui +namespace Dalamud.Game.Gui { /// /// This class represents the hotbar action currently hovered over by the cursor. diff --git a/Dalamud/Game/Gui/PartyFinder/Internal/PartyFinderPacket.cs b/Dalamud/Game/Gui/PartyFinder/Internal/PartyFinderPacket.cs new file mode 100644 index 000000000..9f8834ecd --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Internal/PartyFinderPacket.cs @@ -0,0 +1,28 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace Dalamud.Game.Gui.PartyFinder.Internal +{ + /// + /// The structure of the PartyFinder packet. + /// + [SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "Sequential struct marshaling.")] + [SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:Elements should be ordered by access", Justification = "Sequential struct marshaling.")] + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Document the field usage.")] + [StructLayout(LayoutKind.Sequential)] + internal readonly struct PartyFinderPacket + { + /// + /// Gets the size of this packet. + /// + internal static int PacketSize { get; } = Marshal.SizeOf(); + + internal readonly int BatchNumber; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + private readonly byte[] padding1; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + internal readonly PartyFinderPacketListing[] Listings; + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Internal/PartyFinderPacketListing.cs b/Dalamud/Game/Gui/PartyFinder/Internal/PartyFinderPacketListing.cs new file mode 100644 index 000000000..75f24c88c --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Internal/PartyFinderPacketListing.cs @@ -0,0 +1,99 @@ +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Runtime.InteropServices; + +namespace Dalamud.Game.Gui.PartyFinder.Internal +{ + /// + /// The structure of an individual listing within a packet. + /// + [SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:Elements should be ordered by access", Justification = "Sequential struct marshaling.")] + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Document the field usage.")] + [StructLayout(LayoutKind.Sequential)] + internal readonly struct PartyFinderPacketListing + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + private readonly byte[] header1; + internal readonly uint Id; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + private readonly byte[] header2; + + internal readonly uint ContentIdLower; + private readonly ushort unknownShort1; + private readonly ushort unknownShort2; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] + private readonly byte[] header3; + + internal readonly byte Category; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + private readonly byte[] header4; + + internal readonly ushort Duty; + internal readonly byte DutyType; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + private readonly byte[] header5; + + internal readonly ushort World; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + private readonly byte[] header6; + + internal readonly byte Objective; + internal readonly byte BeginnersWelcome; + internal readonly byte Conditions; + internal readonly byte DutyFinderSettings; + internal readonly byte LootRules; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + private readonly byte[] header7; // all zero in every pf I've examined + + private readonly uint lastPatchHotfixTimestamp; // last time the servers were restarted? + internal readonly ushort SecondsRemaining; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + private readonly byte[] header8; // 00 00 01 00 00 00 in every pf I've examined + + internal readonly ushort MinimumItemLevel; + internal readonly ushort HomeWorld; + internal readonly ushort CurrentWorld; + + private readonly byte header9; + + internal readonly byte NumSlots; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + private readonly byte[] header10; + + internal readonly byte SearchArea; + + private readonly byte header11; + + internal readonly byte NumParties; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + private readonly byte[] header12; // 00 00 00 always. maybe numParties is a u32? + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + internal readonly uint[] Slots; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + internal readonly byte[] JobsPresent; + + // Note that ByValTStr will not work here because the strings are UTF-8 and there's only a CharSet for UTF-16 in C#. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + internal readonly byte[] Name; + + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 192)] + internal readonly byte[] Description; + + internal bool IsNull() + { + // a valid party finder must have at least one slot set + return this.Slots.All(slot => slot == 0); + } + } +} diff --git a/Dalamud/Game/Internal/Gui/PartyFinderAddressResolver.cs b/Dalamud/Game/Gui/PartyFinder/PartyFinderAddressResolver.cs old mode 100755 new mode 100644 similarity index 82% rename from Dalamud/Game/Internal/Gui/PartyFinderAddressResolver.cs rename to Dalamud/Game/Gui/PartyFinder/PartyFinderAddressResolver.cs index 3c0f80e34..75da83180 --- a/Dalamud/Game/Internal/Gui/PartyFinderAddressResolver.cs +++ b/Dalamud/Game/Gui/PartyFinder/PartyFinderAddressResolver.cs @@ -1,11 +1,11 @@ using System; -namespace Dalamud.Game.Internal.Gui +namespace Dalamud.Game.Gui.PartyFinder { /// /// The address resolver for the class. /// - internal class PartyFinderAddressResolver : BaseAddressResolver + public class PartyFinderAddressResolver : BaseAddressResolver { /// /// Gets the address of the native ReceiveListing method. diff --git a/Dalamud/Game/Internal/Gui/PartyFinderGui.cs b/Dalamud/Game/Gui/PartyFinder/PartyFinderGui.cs old mode 100755 new mode 100644 similarity index 79% rename from Dalamud/Game/Internal/Gui/PartyFinderGui.cs rename to Dalamud/Game/Gui/PartyFinder/PartyFinderGui.cs index 24079cf4e..dcfd03c46 --- a/Dalamud/Game/Internal/Gui/PartyFinderGui.cs +++ b/Dalamud/Game/Gui/PartyFinder/PartyFinderGui.cs @@ -1,11 +1,12 @@ using System; using System.Runtime.InteropServices; -using Dalamud.Game.Internal.Gui.Structs; +using Dalamud.Game.Gui.PartyFinder.Internal; +using Dalamud.Game.Gui.PartyFinder.Types; using Dalamud.Hooking; using Serilog; -namespace Dalamud.Game.Internal.Gui +namespace Dalamud.Game.Gui.PartyFinder { /// /// This class handles interacting with the native PartyFinder window. @@ -30,7 +31,7 @@ namespace Dalamud.Game.Internal.Gui this.address = new PartyFinderAddressResolver(); this.address.Setup(scanner); - this.memory = Marshal.AllocHGlobal(PartyFinder.PacketInfo.PacketSize); + this.memory = Marshal.AllocHGlobal(PartyFinderPacket.PacketSize); this.receiveListingHook = new Hook(this.address.ReceiveListing, new ReceiveListingDelegate(this.HandleReceiveListingDetour)); } @@ -87,7 +88,7 @@ namespace Dalamud.Game.Internal.Gui { var dataPtr = data + 0x10; - var packet = Marshal.PtrToStructure(dataPtr); + var packet = Marshal.PtrToStructure(dataPtr); // rewriting is an expensive operation, so only do it if necessary var needToRewrite = false; @@ -125,33 +126,8 @@ namespace Dalamud.Game.Internal.Gui // copy our new memory over the game's unsafe { - Buffer.MemoryCopy((void*)this.memory, (void*)dataPtr, PartyFinder.PacketInfo.PacketSize, PartyFinder.PacketInfo.PacketSize); + Buffer.MemoryCopy((void*)this.memory, (void*)dataPtr, PartyFinderPacket.PacketSize, PartyFinderPacket.PacketSize); } } } - - /// - /// This class represents additional arguments passed by the game. - /// - public class PartyFinderListingEventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The batch number. - internal PartyFinderListingEventArgs(int batchNumber) - { - this.BatchNumber = batchNumber; - } - - /// - /// Gets the batch number. - /// - public int BatchNumber { get; } - - /// - /// Gets or sets a value indicating whether the listing is visible. - /// - public bool Visible { get; set; } = true; - } } diff --git a/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderCategory.cs b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderCategory.cs new file mode 100644 index 000000000..d7ffe568b --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderCategory.cs @@ -0,0 +1,48 @@ +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Category flags for the class. + /// + public enum DutyFinderCategory + { + /// + /// The duty category. + /// + Duty = 0, + + /// + /// The quest battle category. + /// + QuestBattles = 1 << 0, + + /// + /// The fate category. + /// + Fates = 1 << 1, + + /// + /// The treasure hunt category. + /// + TreasureHunt = 1 << 2, + + /// + /// The hunt category. + /// + TheHunt = 1 << 3, + + /// + /// The gathering forays category. + /// + GatheringForays = 1 << 4, + + /// + /// The deep dungeons category. + /// + DeepDungeons = 1 << 5, + + /// + /// The adventuring forays category. + /// + AdventuringForays = 1 << 6, + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderConditionFlags.cs b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderConditionFlags.cs new file mode 100644 index 000000000..2abd371ab --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderConditionFlags.cs @@ -0,0 +1,26 @@ +using System; + +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Condition flags for the class. + /// + [Flags] + public enum DutyFinderConditionFlags : uint + { + /// + /// No duty condition. + /// + None = 1, + + /// + /// The duty complete condition. + /// + DutyComplete = 2, + + /// + /// The duty incomplete condition. + /// + DutyIncomplete = 4, + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderLootRuleFlags.cs b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderLootRuleFlags.cs new file mode 100644 index 000000000..aa75807fd --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderLootRuleFlags.cs @@ -0,0 +1,26 @@ +using System; + +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Loot rule flags for the class. + /// + [Flags] + public enum DutyFinderLootRuleFlags : uint + { + /// + /// No loot rules. + /// + None = 0, + + /// + /// The greed only rule. + /// + GreedOnly = 1, + + /// + /// The lootmaster rule. + /// + Lootmaster = 2, + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderObjectiveFlags.cs b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderObjectiveFlags.cs new file mode 100644 index 000000000..40e34c1fc --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderObjectiveFlags.cs @@ -0,0 +1,31 @@ +using System; + +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Objective flags for the class. + /// + [Flags] + public enum DutyFinderObjectiveFlags : uint + { + /// + /// No objective. + /// + None = 0, + + /// + /// The duty completion objective. + /// + DutyCompletion = 1, + + /// + /// The practice objective. + /// + Practice = 2, + + /// + /// The loot objective. + /// + Loot = 4, + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderSearchAreaFlags.cs b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderSearchAreaFlags.cs new file mode 100644 index 000000000..c9c238e48 --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderSearchAreaFlags.cs @@ -0,0 +1,36 @@ +using System; + +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Search area flags for the class. + /// + [Flags] + public enum DutyFinderSearchAreaFlags : uint + { + /// + /// Datacenter. + /// + DataCentre = 1 << 0, + + /// + /// Private. + /// + Private = 1 << 1, + + /// + /// Alliance raid. + /// + AllianceRaid = 1 << 2, + + /// + /// World. + /// + World = 1 << 3, + + /// + /// One player per job. + /// + OnePlayerPerJob = 1 << 5, + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderSettingsFlags.cs b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderSettingsFlags.cs new file mode 100644 index 000000000..6dfe10c69 --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/DutyFinderSettingsFlags.cs @@ -0,0 +1,31 @@ +using System; + +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Duty finder settings flags for the class. + /// + [Flags] + public enum DutyFinderSettingsFlags : uint + { + /// + /// No duty finder settings. + /// + None = 0, + + /// + /// The undersized party setting. + /// + UndersizedParty = 1 << 0, + + /// + /// The minimum item level setting. + /// + MinimumItemLevel = 1 << 1, + + /// + /// The silence echo setting. + /// + SilenceEcho = 1 << 2, + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/DutyType.cs b/Dalamud/Game/Gui/PartyFinder/Types/DutyType.cs new file mode 100644 index 000000000..3e3342938 --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/DutyType.cs @@ -0,0 +1,23 @@ +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Duty type flags for the class. + /// + public enum DutyType + { + /// + /// No duty type. + /// + Other = 0, + + /// + /// The roulette duty type. + /// + Roulette = 1 << 0, + + /// + /// The normal duty type. + /// + Normal = 1 << 1, + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/JobFlags.cs b/Dalamud/Game/Gui/PartyFinder/Types/JobFlags.cs new file mode 100644 index 000000000..98fa1b1fe --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/JobFlags.cs @@ -0,0 +1,146 @@ +using System; + +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Job flags for the class. + /// + [Flags] + public enum JobFlags + { + /// + /// Gladiator (GLD). + /// + Gladiator = 1 << 1, + + /// + /// Pugilist (PGL). + /// + Pugilist = 1 << 2, + + /// + /// Marauder (MRD). + /// + Marauder = 1 << 3, + + /// + /// Lancer (LNC). + /// + Lancer = 1 << 4, + + /// + /// Archer (ARC). + /// + Archer = 1 << 5, + + /// + /// Conjurer (CNJ). + /// + Conjurer = 1 << 6, + + /// + /// Thaumaturge (THM). + /// + Thaumaturge = 1 << 7, + + /// + /// Paladin (PLD). + /// + Paladin = 1 << 8, + + /// + /// Monk (MNK). + /// + Monk = 1 << 9, + + /// + /// Warrior (WAR). + /// + Warrior = 1 << 10, + + /// + /// Dragoon (DRG). + /// + Dragoon = 1 << 11, + + /// + /// Bard (BRD). + /// + Bard = 1 << 12, + + /// + /// White mage (WHM). + /// + WhiteMage = 1 << 13, + + /// + /// Black mage (BLM). + /// + BlackMage = 1 << 14, + + /// + /// Arcanist (ACN). + /// + Arcanist = 1 << 15, + + /// + /// Summoner (SMN). + /// + Summoner = 1 << 16, + + /// + /// Scholar (SCH). + /// + Scholar = 1 << 17, + + /// + /// Rogue (ROG). + /// + Rogue = 1 << 18, + + /// + /// Ninja (NIN). + /// + Ninja = 1 << 19, + + /// + /// Machinist (MCH). + /// + Machinist = 1 << 20, + + /// + /// Dark Knight (DRK). + /// + DarkKnight = 1 << 21, + + /// + /// Astrologian (AST). + /// + Astrologian = 1 << 22, + + /// + /// Samurai (SAM). + /// + Samurai = 1 << 23, + + /// + /// Red mage (RDM). + /// + RedMage = 1 << 24, + + /// + /// Blue mage (BLM). + /// + BlueMage = 1 << 25, + + /// + /// Gunbreaker (GNB). + /// + Gunbreaker = 1 << 26, + + /// + /// Dancer (DNC). + /// + Dancer = 1 << 27, + } +} diff --git a/Dalamud/Game/Gui/PartyFinder/Types/JobFlagsExtensions.cs b/Dalamud/Game/Gui/PartyFinder/Types/JobFlagsExtensions.cs new file mode 100644 index 000000000..b899dd62f --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/JobFlagsExtensions.cs @@ -0,0 +1,27 @@ +using System; + +using Dalamud.Data; +using Lumina.Excel.GeneratedSheets; + +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// Extensions for the enum. + /// + public static class JobFlagsExtensions + { + /// + /// Get the actual ClassJob from the in-game sheets for this JobFlags. + /// + /// A JobFlags enum member. + /// A DataManager to get the ClassJob from. + /// A ClassJob if found or null if not. + public static ClassJob ClassJob(this JobFlags job, DataManager data) + { + var result = Math.Log2((double)job); + return result % 1 == 0 + ? data.GetExcelSheet().GetRow((uint)result) + : null; + } + } +} diff --git a/Dalamud/Game/Internal/Gui/Structs/PartyFinderListing.cs b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListing.cs similarity index 87% rename from Dalamud/Game/Internal/Gui/Structs/PartyFinderListing.cs rename to Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListing.cs index b533a9741..c75748942 100644 --- a/Dalamud/Game/Internal/Gui/Structs/PartyFinderListing.cs +++ b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListing.cs @@ -3,10 +3,11 @@ using System.Collections.Generic; using System.Linq; using Dalamud.Data; +using Dalamud.Game.Gui.PartyFinder.Internal; using Dalamud.Game.Text.SeStringHandling; using Lumina.Excel.GeneratedSheets; -namespace Dalamud.Game.Internal.Gui.Structs +namespace Dalamud.Game.Gui.PartyFinder.Types { /// /// A single listing in party finder. @@ -31,7 +32,7 @@ namespace Dalamud.Game.Internal.Gui.Structs /// The interop listing data. /// The DataManager instance. /// The SeStringManager instance. - internal PartyFinderListing(PartyFinder.Listing listing, DataManager dataManager, SeStringManager seStringManager) + internal PartyFinderListing(PartyFinderPacketListing listing, DataManager dataManager, SeStringManager seStringManager) { this.objective = listing.Objective; this.conditions = listing.Conditions; @@ -48,7 +49,7 @@ namespace Dalamud.Game.Internal.Gui.Structs this.World = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.World)); this.HomeWorld = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.HomeWorld)); this.CurrentWorld = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.CurrentWorld)); - this.Category = (Category)listing.Category; + this.Category = (DutyFinderCategory)listing.Category; this.RawDuty = listing.Duty; this.Duty = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.Duty)); this.DutyType = (DutyType)listing.DutyType; @@ -103,7 +104,7 @@ namespace Dalamud.Game.Internal.Gui.Structs /// /// Gets the Party Finder category this listing is listed under. /// - public Category Category { get; } + public DutyFinderCategory Category { get; } /// /// Gets the row ID of the duty this listing is for. May be 0 for non-duty listings. @@ -154,12 +155,12 @@ namespace Dalamud.Game.Internal.Gui.Structs /// /// Gets the objective of this listing. /// - public ObjectiveFlags Objective => (ObjectiveFlags)this.objective; + public DutyFinderObjectiveFlags Objective => (DutyFinderObjectiveFlags)this.objective; /// /// Gets the conditions of this listing. /// - public ConditionFlags Conditions => (ConditionFlags)this.conditions; + public DutyFinderConditionFlags Conditions => (DutyFinderConditionFlags)this.conditions; /// /// Gets the Duty Finder settings that will be used for this listing. @@ -169,13 +170,13 @@ namespace Dalamud.Game.Internal.Gui.Structs /// /// Gets the loot rules that will be used for this listing. /// - public LootRuleFlags LootRules => (LootRuleFlags)this.lootRules; + public DutyFinderLootRuleFlags LootRules => (DutyFinderLootRuleFlags)this.lootRules; /// /// Gets where this listing is searching. Note that this is also used for denoting alliance raid listings and one /// player per job. /// - public SearchAreaFlags SearchArea => (SearchAreaFlags)this.searchArea; + public DutyFinderSearchAreaFlags SearchArea => (DutyFinderSearchAreaFlags)this.searchArea; /// /// Gets a list of the class/job IDs that are currently present in the party. @@ -194,14 +195,14 @@ namespace Dalamud.Game.Internal.Gui.Structs /// /// The flag to check for. /// A value indicating whether the flag is present. - public bool this[ObjectiveFlags flag] => this.objective == 0 || (this.objective & (uint)flag) > 0; + public bool this[DutyFinderObjectiveFlags flag] => this.objective == 0 || (this.objective & (uint)flag) > 0; /// /// Check if the given flag is present. /// /// The flag to check for. /// A value indicating whether the flag is present. - public bool this[ConditionFlags flag] => this.conditions == 0 || (this.conditions & (uint)flag) > 0; + public bool this[DutyFinderConditionFlags flag] => this.conditions == 0 || (this.conditions & (uint)flag) > 0; /// /// Check if the given flag is present. @@ -215,14 +216,14 @@ namespace Dalamud.Game.Internal.Gui.Structs /// /// The flag to check for. /// A value indicating whether the flag is present. - public bool this[LootRuleFlags flag] => this.lootRules == 0 || (this.lootRules & (uint)flag) > 0; + public bool this[DutyFinderLootRuleFlags flag] => this.lootRules == 0 || (this.lootRules & (uint)flag) > 0; /// /// Check if the given flag is present. /// /// The flag to check for. /// A value indicating whether the flag is present. - public bool this[SearchAreaFlags flag] => this.searchArea == 0 || (this.searchArea & (uint)flag) > 0; + public bool this[DutyFinderSearchAreaFlags flag] => this.searchArea == 0 || (this.searchArea & (uint)flag) > 0; #endregion diff --git a/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListingEventArgs.cs b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListingEventArgs.cs new file mode 100644 index 000000000..ff6bd607d --- /dev/null +++ b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderListingEventArgs.cs @@ -0,0 +1,27 @@ +namespace Dalamud.Game.Gui.PartyFinder.Types +{ + /// + /// This class represents additional arguments passed by the game. + /// + public class PartyFinderListingEventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// The batch number. + internal PartyFinderListingEventArgs(int batchNumber) + { + this.BatchNumber = batchNumber; + } + + /// + /// Gets the batch number. + /// + public int BatchNumber { get; } + + /// + /// Gets or sets a value indicating whether the listing is visible. + /// + public bool Visible { get; set; } = true; + } +} diff --git a/Dalamud/Game/Internal/Gui/Structs/PartyFinderSlot.cs b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderSlot.cs similarity index 97% rename from Dalamud/Game/Internal/Gui/Structs/PartyFinderSlot.cs rename to Dalamud/Game/Gui/PartyFinder/Types/PartyFinderSlot.cs index 02b549842..d740c0c0a 100644 --- a/Dalamud/Game/Internal/Gui/Structs/PartyFinderSlot.cs +++ b/Dalamud/Game/Gui/PartyFinder/Types/PartyFinderSlot.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace Dalamud.Game.Internal.Gui.Structs +namespace Dalamud.Game.Gui.PartyFinder.Types { /// /// A player slot in a Party Finder listing. diff --git a/Dalamud/Game/Internal/Gui/Toast/QuestToastOptions.cs b/Dalamud/Game/Gui/Toast/QuestToastOptions.cs old mode 100755 new mode 100644 similarity index 96% rename from Dalamud/Game/Internal/Gui/Toast/QuestToastOptions.cs rename to Dalamud/Game/Gui/Toast/QuestToastOptions.cs index 34fa674e7..11f09a523 --- a/Dalamud/Game/Internal/Gui/Toast/QuestToastOptions.cs +++ b/Dalamud/Game/Gui/Toast/QuestToastOptions.cs @@ -1,4 +1,4 @@ -namespace Dalamud.Game.Internal.Gui.Toast +namespace Dalamud.Game.Gui.Toast { /// /// This class represents options that can be used with the class for the quest toast variant. diff --git a/Dalamud/Game/Internal/Gui/Toast/QuestToastPosition.cs b/Dalamud/Game/Gui/Toast/QuestToastPosition.cs old mode 100755 new mode 100644 similarity index 92% rename from Dalamud/Game/Internal/Gui/Toast/QuestToastPosition.cs rename to Dalamud/Game/Gui/Toast/QuestToastPosition.cs index a6ea499b1..cc107ab6e --- a/Dalamud/Game/Internal/Gui/Toast/QuestToastPosition.cs +++ b/Dalamud/Game/Gui/Toast/QuestToastPosition.cs @@ -1,4 +1,4 @@ -namespace Dalamud.Game.Internal.Gui.Toast +namespace Dalamud.Game.Gui.Toast { /// /// The alignment of native quest toast windows. diff --git a/Dalamud/Game/Internal/Gui/Toast/ToastOptions.cs b/Dalamud/Game/Gui/Toast/ToastOptions.cs old mode 100755 new mode 100644 similarity index 92% rename from Dalamud/Game/Internal/Gui/Toast/ToastOptions.cs rename to Dalamud/Game/Gui/Toast/ToastOptions.cs index 5be757393..0939bb5bb --- a/Dalamud/Game/Internal/Gui/Toast/ToastOptions.cs +++ b/Dalamud/Game/Gui/Toast/ToastOptions.cs @@ -1,4 +1,4 @@ -namespace Dalamud.Game.Internal.Gui.Toast +namespace Dalamud.Game.Gui.Toast { /// /// This class represents options that can be used with the class. diff --git a/Dalamud/Game/Internal/Gui/Toast/ToastPosition.cs b/Dalamud/Game/Gui/Toast/ToastPosition.cs old mode 100755 new mode 100644 similarity index 89% rename from Dalamud/Game/Internal/Gui/Toast/ToastPosition.cs rename to Dalamud/Game/Gui/Toast/ToastPosition.cs index 4c01cb709..14f489711 --- a/Dalamud/Game/Internal/Gui/Toast/ToastPosition.cs +++ b/Dalamud/Game/Gui/Toast/ToastPosition.cs @@ -1,4 +1,4 @@ -namespace Dalamud.Game.Internal.Gui.Toast +namespace Dalamud.Game.Gui.Toast { /// /// The positioning of native toast windows. diff --git a/Dalamud/Game/Internal/Gui/Toast/ToastSpeed.cs b/Dalamud/Game/Gui/Toast/ToastSpeed.cs old mode 100755 new mode 100644 similarity index 90% rename from Dalamud/Game/Internal/Gui/Toast/ToastSpeed.cs rename to Dalamud/Game/Gui/Toast/ToastSpeed.cs index 620c65301..0f54df273 --- a/Dalamud/Game/Internal/Gui/Toast/ToastSpeed.cs +++ b/Dalamud/Game/Gui/Toast/ToastSpeed.cs @@ -1,4 +1,4 @@ -namespace Dalamud.Game.Internal.Gui.Toast +namespace Dalamud.Game.Gui.Toast { /// /// The speed at which native toast windows will persist. diff --git a/Dalamud/Game/Internal/Gui/ToastGui.cs b/Dalamud/Game/Gui/ToastGui.cs old mode 100755 new mode 100644 similarity index 99% rename from Dalamud/Game/Internal/Gui/ToastGui.cs rename to Dalamud/Game/Gui/ToastGui.cs index 4c1ce497f..c16066a09 --- a/Dalamud/Game/Internal/Gui/ToastGui.cs +++ b/Dalamud/Game/Gui/ToastGui.cs @@ -2,11 +2,11 @@ using System; using System.Collections.Generic; using System.Text; -using Dalamud.Game.Internal.Gui.Toast; +using Dalamud.Game.Gui.Toast; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Hooking; -namespace Dalamud.Game.Internal.Gui +namespace Dalamud.Game.Gui { /// /// This class facilitates interacting with and creating native toast windows. diff --git a/Dalamud/Game/Internal/Gui/ToastGuiAddressResolver.cs b/Dalamud/Game/Gui/ToastGuiAddressResolver.cs old mode 100755 new mode 100644 similarity index 95% rename from Dalamud/Game/Internal/Gui/ToastGuiAddressResolver.cs rename to Dalamud/Game/Gui/ToastGuiAddressResolver.cs index 93b8eba04..adf5e3190 --- a/Dalamud/Game/Internal/Gui/ToastGuiAddressResolver.cs +++ b/Dalamud/Game/Gui/ToastGuiAddressResolver.cs @@ -1,6 +1,8 @@ using System; -namespace Dalamud.Game.Internal.Gui +using Dalamud.Game.Internal; + +namespace Dalamud.Game.Gui { /// /// An address resolver for the class. diff --git a/Dalamud/Game/Internal/AntiDebug.cs b/Dalamud/Game/Internal/AntiDebug.cs index 57c7fdeb4..59e2a1df4 100644 --- a/Dalamud/Game/Internal/AntiDebug.cs +++ b/Dalamud/Game/Internal/AntiDebug.cs @@ -8,7 +8,7 @@ namespace Dalamud.Game.Internal /// /// This class disables anti-debug functionality in the game client. /// - public sealed partial class AntiDebug + internal sealed partial class AntiDebug { private readonly byte[] nop = new byte[] { 0x31, 0xC0, 0x90, 0x90, 0x90, 0x90 }; private byte[] original; @@ -79,7 +79,7 @@ namespace Dalamud.Game.Internal /// /// Implementing IDisposable. /// - public sealed partial class AntiDebug : IDisposable + internal sealed partial class AntiDebug : IDisposable { private bool disposed = false; diff --git a/Dalamud/Game/Addon/DalamudSystemMenu.cs b/Dalamud/Game/Internal/DalamudSystemMenu.cs similarity index 99% rename from Dalamud/Game/Addon/DalamudSystemMenu.cs rename to Dalamud/Game/Internal/DalamudSystemMenu.cs index e735b6154..673bcb55b 100644 --- a/Dalamud/Game/Addon/DalamudSystemMenu.cs +++ b/Dalamud/Game/Internal/DalamudSystemMenu.cs @@ -8,7 +8,7 @@ using FFXIVClientStructs.FFXIV.Component.GUI; using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType; -namespace Dalamud.Game.Addon +namespace Dalamud.Game.Internal { /// /// This class implements in-game Dalamud options in the in-game System menu. diff --git a/Dalamud/Game/Internal/Gui/Structs/Addon.cs b/Dalamud/Game/Internal/Gui/Structs/Addon.cs deleted file mode 100644 index 57595a2c7..000000000 --- a/Dalamud/Game/Internal/Gui/Structs/Addon.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Runtime.InteropServices; - -using FFXIVClientStructs.FFXIV.Component.GUI; - -namespace Dalamud.Game.Internal.Gui.Structs -{ - /// - /// Native memory representation of an FFXIV UI addon. - /// - [StructLayout(LayoutKind.Explicit)] - public struct Addon - { - /// - /// The name of the addon. - /// - [FieldOffset(AddonOffsets.Name)] - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] - public string Name; - - /// - /// Various flags that can be set on the addon. - /// - /// - /// This is a bitfield. - /// - [FieldOffset(AddonOffsets.Flags)] - public byte Flags; - - /// - /// The X position of the addon on screen. - /// - [FieldOffset(AddonOffsets.X)] - public short X; - - /// - /// The Y position of the addon on screen. - /// - [FieldOffset(AddonOffsets.Y)] - public short Y; - - /// - /// The scale of the addon. - /// - [FieldOffset(AddonOffsets.Scale)] - public float Scale; - - /// - /// The root node of the addon's node tree. - /// - [FieldOffset(AddonOffsets.RootNode)] - public unsafe AtkResNode* RootNode; - } - - /// - /// Memory offsets for the type. - /// - public static class AddonOffsets - { - public const int Name = 0x8; - public const int RootNode = 0xC8; - public const int Flags = 0x182; - public const int X = 0x1BC; - public const int Y = 0x1BE; - public const int Scale = 0x1AC; - } -} diff --git a/Dalamud/Game/Internal/Gui/Structs/PartyFinder.cs b/Dalamud/Game/Internal/Gui/Structs/PartyFinder.cs deleted file mode 100755 index 8fe3204b0..000000000 --- a/Dalamud/Game/Internal/Gui/Structs/PartyFinder.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; - -namespace Dalamud.Game.Internal.Gui.Structs -{ - /// - /// PartyFinder related network structs and static constants. - /// - internal static class PartyFinder - { - /// - /// The structure of the PartyFinder packet. - /// - [StructLayout(LayoutKind.Sequential)] - internal readonly struct Packet - { - internal readonly int BatchNumber; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - private readonly byte[] padding1; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - internal readonly Listing[] Listings; - } - - /// - /// The structure of an individual listing within a packet. - /// - [StructLayout(LayoutKind.Sequential)] - internal readonly struct Listing - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - private readonly byte[] header1; - - internal readonly uint Id; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] - private readonly byte[] header2; - - internal readonly uint ContentIdLower; - private readonly ushort unknownShort1; - private readonly ushort unknownShort2; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] - private readonly byte[] header3; - - internal readonly byte Category; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - private readonly byte[] header4; - - internal readonly ushort Duty; - internal readonly byte DutyType; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - private readonly byte[] header5; - - internal readonly ushort World; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - private readonly byte[] header6; - - internal readonly byte Objective; - internal readonly byte BeginnersWelcome; - internal readonly byte Conditions; - internal readonly byte DutyFinderSettings; - internal readonly byte LootRules; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - private readonly byte[] header7; // all zero in every pf I've examined - - private readonly uint lastPatchHotfixTimestamp; // last time the servers were restarted? - internal readonly ushort SecondsRemaining; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - private readonly byte[] header8; // 00 00 01 00 00 00 in every pf I've examined - - internal readonly ushort MinimumItemLevel; - internal readonly ushort HomeWorld; - internal readonly ushort CurrentWorld; - - private readonly byte header9; - - internal readonly byte NumSlots; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - private readonly byte[] header10; - - internal readonly byte SearchArea; - - private readonly byte header11; - - internal readonly byte NumParties; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - private readonly byte[] header12; // 00 00 00 always. maybe numParties is a u32? - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - internal readonly uint[] Slots; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - internal readonly byte[] JobsPresent; - - // Note that ByValTStr will not work here because the strings are UTF-8 and there's only a CharSet for UTF-16 in C#. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - internal readonly byte[] Name; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 192)] - internal readonly byte[] Description; - - internal bool IsNull() - { - // a valid party finder must have at least one slot set - return this.Slots.All(slot => slot == 0); - } - } - - /// - /// PartyFinder packet constants. - /// - public static class PacketInfo - { - /// - /// The size of the PartyFinder packet. - /// - public static readonly int PacketSize = Marshal.SizeOf(); - } - } -} diff --git a/Dalamud/Game/Internal/Gui/Structs/PartyFinderTypes.cs b/Dalamud/Game/Internal/Gui/Structs/PartyFinderTypes.cs deleted file mode 100644 index 7482b3ba3..000000000 --- a/Dalamud/Game/Internal/Gui/Structs/PartyFinderTypes.cs +++ /dev/null @@ -1,397 +0,0 @@ -using System; - -using Dalamud.Data; -using Lumina.Excel.GeneratedSheets; - -namespace Dalamud.Game.Internal.Gui.Structs -{ - /// - /// Search area flags for the class. - /// - [Flags] - public enum SearchAreaFlags : uint - { - /// - /// Datacenter. - /// - DataCentre = 1 << 0, - - /// - /// Private. - /// - Private = 1 << 1, - - /// - /// Alliance raid. - /// - AllianceRaid = 1 << 2, - - /// - /// World. - /// - World = 1 << 3, - - /// - /// One player per job. - /// - OnePlayerPerJob = 1 << 5, - } - - /// - /// Job flags for the class. - /// - [Flags] - public enum JobFlags - { - /// - /// Gladiator (GLD). - /// - Gladiator = 1 << 1, - - /// - /// Pugilist (PGL). - /// - Pugilist = 1 << 2, - - /// - /// Marauder (MRD). - /// - Marauder = 1 << 3, - - /// - /// Lancer (LNC). - /// - Lancer = 1 << 4, - - /// - /// Archer (ARC). - /// - Archer = 1 << 5, - - /// - /// Conjurer (CNJ). - /// - Conjurer = 1 << 6, - - /// - /// Thaumaturge (THM). - /// - Thaumaturge = 1 << 7, - - /// - /// Paladin (PLD). - /// - Paladin = 1 << 8, - - /// - /// Monk (MNK). - /// - Monk = 1 << 9, - - /// - /// Warrior (WAR). - /// - Warrior = 1 << 10, - - /// - /// Dragoon (DRG). - /// - Dragoon = 1 << 11, - - /// - /// Bard (BRD). - /// - Bard = 1 << 12, - - /// - /// White mage (WHM). - /// - WhiteMage = 1 << 13, - - /// - /// Black mage (BLM). - /// - BlackMage = 1 << 14, - - /// - /// Arcanist (ACN). - /// - Arcanist = 1 << 15, - - /// - /// Summoner (SMN). - /// - Summoner = 1 << 16, - - /// - /// Scholar (SCH). - /// - Scholar = 1 << 17, - - /// - /// Rogue (ROG). - /// - Rogue = 1 << 18, - - /// - /// Ninja (NIN). - /// - Ninja = 1 << 19, - - /// - /// Machinist (MCH). - /// - Machinist = 1 << 20, - - /// - /// Dark Knight (DRK). - /// - DarkKnight = 1 << 21, - - /// - /// Astrologian (AST). - /// - Astrologian = 1 << 22, - - /// - /// Samurai (SAM). - /// - Samurai = 1 << 23, - - /// - /// Red mage (RDM). - /// - RedMage = 1 << 24, - - /// - /// Blue mage (BLM). - /// - BlueMage = 1 << 25, - - /// - /// Gunbreaker (GNB). - /// - Gunbreaker = 1 << 26, - - /// - /// Dancer (DNC). - /// - Dancer = 1 << 27, - } - - /// - /// Objective flags for the class. - /// - [Flags] - public enum ObjectiveFlags : uint - { - /// - /// No objective. - /// - None = 0, - - /// - /// The duty completion objective. - /// - DutyCompletion = 1, - - /// - /// The practice objective. - /// - Practice = 2, - - /// - /// The loot objective. - /// - Loot = 4, - } - - /// - /// Condition flags for the class. - /// - [Flags] - public enum ConditionFlags : uint - { - /// - /// No duty condition. - /// - None = 1, - - /// - /// The duty complete condition. - /// - DutyComplete = 2, - - /// - /// The duty incomplete condition. - /// - DutyIncomplete = 4, - } - - /// - /// Duty finder settings flags for the class. - /// - [Flags] - public enum DutyFinderSettingsFlags : uint - { - /// - /// No duty finder settings. - /// - None = 0, - - /// - /// The undersized party setting. - /// - UndersizedParty = 1 << 0, - - /// - /// The minimum item level setting. - /// - MinimumItemLevel = 1 << 1, - - /// - /// The silence echo setting. - /// - SilenceEcho = 1 << 2, - } - - /// - /// Loot rule flags for the class. - /// - [Flags] - public enum LootRuleFlags : uint - { - /// - /// No loot rules. - /// - None = 0, - - /// - /// The greed only rule. - /// - GreedOnly = 1, - - /// - /// The lootmaster rule. - /// - Lootmaster = 2, - } - - /// - /// Category flags for the class. - /// - public enum Category - { - /// - /// The duty category. - /// - Duty = 0, - - /// - /// The quest battle category. - /// - QuestBattles = 1 << 0, - - /// - /// The fate category. - /// - Fates = 1 << 1, - - /// - /// The treasure hunt category. - /// - TreasureHunt = 1 << 2, - - /// - /// The hunt category. - /// - TheHunt = 1 << 3, - - /// - /// The gathering forays category. - /// - GatheringForays = 1 << 4, - - /// - /// The deep dungeons category. - /// - DeepDungeons = 1 << 5, - - /// - /// The adventuring forays category. - /// - AdventuringForays = 1 << 6, - } - - /// - /// Duty type flags for the class. - /// - public enum DutyType - { - /// - /// No duty type. - /// - Other = 0, - - /// - /// The roulette duty type. - /// - Roulette = 1 << 0, - - /// - /// The normal duty type. - /// - Normal = 1 << 1, - } - - /// - /// Extensions for the enum. - /// - public static class JobFlagsExt - { - /// - /// Get the actual ClassJob from the in-game sheets for this JobFlags. - /// - /// A JobFlags enum member. - /// A DataManager to get the ClassJob from. - /// A ClassJob if found or null if not. - public static ClassJob ClassJob(this JobFlags job, DataManager data) - { - var jobs = data.GetExcelSheet(); - - uint? row = job switch - { - JobFlags.Gladiator => 1, - JobFlags.Pugilist => 2, - JobFlags.Marauder => 3, - JobFlags.Lancer => 4, - JobFlags.Archer => 5, - JobFlags.Conjurer => 6, - JobFlags.Thaumaturge => 7, - JobFlags.Paladin => 19, - JobFlags.Monk => 20, - JobFlags.Warrior => 21, - JobFlags.Dragoon => 22, - JobFlags.Bard => 23, - JobFlags.WhiteMage => 24, - JobFlags.BlackMage => 25, - JobFlags.Arcanist => 26, - JobFlags.Summoner => 27, - JobFlags.Scholar => 28, - JobFlags.Rogue => 29, - JobFlags.Ninja => 30, - JobFlags.Machinist => 31, - JobFlags.DarkKnight => 32, - JobFlags.Astrologian => 33, - JobFlags.Samurai => 34, - JobFlags.RedMage => 35, - JobFlags.BlueMage => 36, - JobFlags.Gunbreaker => 37, - JobFlags.Dancer => 38, - _ => null, - }; - - return row == null ? null : jobs.GetRow((uint)row); - } - } -} diff --git a/Dalamud/Game/Internal/Network/GameNetwork.cs b/Dalamud/Game/Network/GameNetwork.cs similarity index 98% rename from Dalamud/Game/Internal/Network/GameNetwork.cs rename to Dalamud/Game/Network/GameNetwork.cs index dff3ac535..0b982b2b0 100644 --- a/Dalamud/Game/Internal/Network/GameNetwork.cs +++ b/Dalamud/Game/Network/GameNetwork.cs @@ -6,18 +6,13 @@ using Dalamud.Game.Network; using Dalamud.Hooking; using Serilog; -namespace Dalamud.Game.Internal.Network +namespace Dalamud.Game.Network { /// /// This class handles interacting with game network events. /// public sealed class GameNetwork : IDisposable { - /// - /// Event that is called when a network message is sent/received. - /// - public OnNetworkMessageDelegate OnNetworkMessage; - private readonly GameNetworkAddressResolver address; private readonly Hook processZonePacketDownHook; private readonly Hook processZonePacketUpHook; @@ -58,6 +53,11 @@ namespace Dalamud.Game.Internal.Network [UnmanagedFunctionPointer(CallingConvention.ThisCall)] private delegate byte ProcessZonePacketUpDelegate(IntPtr a1, IntPtr dataPtr, IntPtr a3, byte a4); + /// + /// Event that is called when a network message is sent/received. + /// + public event OnNetworkMessageDelegate OnNetworkMessage; + /// /// Enable this module. /// diff --git a/Dalamud/Game/Internal/Network/GameNetworkAddressResolver.cs b/Dalamud/Game/Network/GameNetworkAddressResolver.cs similarity index 95% rename from Dalamud/Game/Internal/Network/GameNetworkAddressResolver.cs rename to Dalamud/Game/Network/GameNetworkAddressResolver.cs index 9c5eb00fc..130986197 100644 --- a/Dalamud/Game/Internal/Network/GameNetworkAddressResolver.cs +++ b/Dalamud/Game/Network/GameNetworkAddressResolver.cs @@ -1,6 +1,8 @@ using System; -namespace Dalamud.Game.Internal.Network +using Dalamud.Game.Internal; + +namespace Dalamud.Game.Network { /// /// The address resolver for the class. diff --git a/Dalamud/Interface/Internal/Windows/DataWindow.cs b/Dalamud/Interface/Internal/Windows/DataWindow.cs index 391520a0b..ac06d5139 100644 --- a/Dalamud/Interface/Internal/Windows/DataWindow.cs +++ b/Dalamud/Interface/Internal/Windows/DataWindow.cs @@ -9,8 +9,8 @@ using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Actors.Types; using Dalamud.Game.ClientState.Actors.Types.NonPlayer; using Dalamud.Game.ClientState.Structs.JobGauge; -using Dalamud.Game.Internal.Gui.Addon; -using Dalamud.Game.Internal.Gui.Toast; +using Dalamud.Game.Gui.Addons; +using Dalamud.Game.Gui.Toast; using Dalamud.Game.Text; using Dalamud.Interface.Windowing; using Dalamud.Plugin; @@ -104,6 +104,17 @@ namespace Dalamud.Interface.Internal.Windows Gamepad, } + /// + public override void OnOpen() + { + } + + /// + public override void OnClose() + { + this.resultAddon = null; + } + /// /// Set the DataKind dropdown menu. /// @@ -562,9 +573,7 @@ namespace Dalamud.Interface.Internal.Windows if (ImGui.Button("Get Addon")) { - this.resultAddon = - this.dalamud.Framework.Gui.GetAddonByName( - this.inputAddonName, this.inputAddonIndex); + this.resultAddon = this.dalamud.Framework.Gui.GetAddonByName(this.inputAddonName, this.inputAddonIndex); } if (ImGui.Button("Find Agent")) @@ -572,14 +581,12 @@ namespace Dalamud.Interface.Internal.Windows if (this.resultAddon != null) { - ImGui.TextUnformatted( - $"{this.resultAddon.Name} - 0x{this.resultAddon.Address.ToInt64():x}\n v:{this.resultAddon.Visible} x:{this.resultAddon.X} y:{this.resultAddon.Y} s:{this.resultAddon.Scale}, w:{this.resultAddon.Width}, h:{this.resultAddon.Height}"); + ImGui.TextUnformatted($"{this.resultAddon.Name} - 0x{this.resultAddon.Address.ToInt64():x}\n v:{this.resultAddon.Visible} x:{this.resultAddon.X} y:{this.resultAddon.Y} s:{this.resultAddon.Scale}, w:{this.resultAddon.Width}, h:{this.resultAddon.Height}"); } if (this.findAgentInterfacePtr != IntPtr.Zero) { - ImGui.TextUnformatted( - $"Agent: 0x{this.findAgentInterfacePtr.ToInt64():x}"); + ImGui.TextUnformatted($"Agent: 0x{this.findAgentInterfacePtr.ToInt64():x}"); ImGui.SameLine(); if (ImGui.Button("C"))