diff --git a/Dalamud/Game/Internal/Gui/GameGui.cs b/Dalamud/Game/Internal/Gui/GameGui.cs index adbd592ed..702f49ec3 100644 --- a/Dalamud/Game/Internal/Gui/GameGui.cs +++ b/Dalamud/Game/Internal/Gui/GameGui.cs @@ -48,9 +48,10 @@ namespace Dalamud.Game.Internal.Gui { private delegate IntPtr ToggleUiHideDelegate(IntPtr thisPtr, byte unknownByte); private readonly Hook toggleUiHideHook; + // Return a Client::UI::UIModule [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate IntPtr GetBaseUIObjectDelegate(); - private readonly GetBaseUIObjectDelegate getBaseUIObject; + public delegate IntPtr GetBaseUIObjectDelegate(); + public readonly GetBaseUIObjectDelegate GetBaseUIObject; [UnmanagedFunctionPointer(CallingConvention.ThisCall, CharSet = CharSet.Ansi)] private delegate IntPtr GetUIObjectByNameDelegate(IntPtr thisPtr, string uiName, int index); @@ -112,7 +113,7 @@ namespace Dalamud.Game.Internal.Gui { this.toggleUiHideHook = new Hook(Address.ToggleUiHide, new ToggleUiHideDelegate(ToggleUiHideDetour), this); - this.getBaseUIObject = Marshal.GetDelegateForFunctionPointer(Address.GetBaseUIObject); + this.GetBaseUIObject = Marshal.GetDelegateForFunctionPointer(Address.GetBaseUIObject); this.getUIObjectByName = Marshal.GetDelegateForFunctionPointer(Address.GetUIObjectByName); } @@ -324,7 +325,7 @@ namespace Dalamud.Game.Internal.Gui { /// Index of UI to find (1-indexed) /// IntPtr.Zero if unable to find UI, otherwise IntPtr pointing to the start of the UI Object public IntPtr GetUiObjectByName(string name, int index) { - var baseUi = this.getBaseUIObject(); + var baseUi = this.GetBaseUIObject(); if (baseUi == IntPtr.Zero) return IntPtr.Zero; var baseUiProperties = Marshal.ReadIntPtr(baseUi, 0x20); if (baseUiProperties == IntPtr.Zero) return IntPtr.Zero; diff --git a/Dalamud/Interface/DalamudDataWindow.cs b/Dalamud/Interface/DalamudDataWindow.cs index a489e5d52..c8f0768c9 100644 --- a/Dalamud/Interface/DalamudDataWindow.cs +++ b/Dalamud/Interface/DalamudDataWindow.cs @@ -9,6 +9,7 @@ using Dalamud.Game.ClientState.Actors.Types; using Dalamud.Game.ClientState.Actors.Types.NonPlayer; using Dalamud.Game.ClientState.Structs.JobGauge; using Dalamud.Game.Internal; +using Dalamud.Game.Internal.Gui.Addon; using Dalamud.Plugin; using ImGuiNET; using JetBrains.Annotations; @@ -29,6 +30,10 @@ namespace Dalamud.Interface private bool drawActors = false; private float maxActorDrawDistance = 20; + private string inputAddonName = string.Empty; + private int inputAddonIndex; + private Addon resultAddon; + public DalamudDataWindow(Dalamud dalamud) { this.dalamud = dalamud; @@ -59,8 +64,8 @@ namespace Dalamud.Interface ImGui.SameLine(); var copy = ImGui.Button("Copy all"); ImGui.SameLine(); - ImGui.Combo("Data kind", ref this.currentKind, new[] {"ServerOpCode", "Address", "Actor Table", "Font Test", "Party List", "Plugin IPC", "Condition", "Gauge", "Command"}, - 9); + ImGui.Combo("Data kind", ref this.currentKind, new[] {"ServerOpCode", "Address", "Actor Table", "Font Test", "Party List", "Plugin IPC", "Condition", "Gauge", "Command", "Client UI"}, + 10); ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar); @@ -284,6 +289,27 @@ namespace Dalamud.Interface ImGui.Text($"{command.Key}\n -> {command.Value.HelpMessage}\n -> In help: {command.Value.ShowInHelp}\n\n"); } + break; + + case 9: + ImGui.InputText("Addon name", ref this.inputAddonName, 256); + ImGui.InputInt("Addon Index", ref this.inputAddonIndex); + + if (ImGui.Button("Get Addon")) { + this.resultAddon = + this.dalamud.Framework.Gui.GetAddonByName(this.inputAddonName, this.inputAddonIndex); + } + + 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}"); + } + + if (ImGui.Button("Get Base UI object")) { + var addr = this.dalamud.Framework.Gui.GetBaseUIObject().ToInt64().ToString("x"); + Log.Information("{0}", addr); + ImGui.SetClipboardText(addr); + } + break; } else