feat: some tools for UI stuff

This commit is contained in:
goat 2020-10-16 12:15:11 +02:00
parent d41da727a1
commit 258419a1b8
2 changed files with 33 additions and 6 deletions

View file

@ -48,9 +48,10 @@ namespace Dalamud.Game.Internal.Gui {
private delegate IntPtr ToggleUiHideDelegate(IntPtr thisPtr, byte unknownByte);
private readonly Hook<ToggleUiHideDelegate> 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<ToggleUiHideDelegate>(Address.ToggleUiHide, new ToggleUiHideDelegate(ToggleUiHideDetour), this);
this.getBaseUIObject = Marshal.GetDelegateForFunctionPointer<GetBaseUIObjectDelegate>(Address.GetBaseUIObject);
this.GetBaseUIObject = Marshal.GetDelegateForFunctionPointer<GetBaseUIObjectDelegate>(Address.GetBaseUIObject);
this.getUIObjectByName = Marshal.GetDelegateForFunctionPointer<GetUIObjectByNameDelegate>(Address.GetUIObjectByName);
}
@ -324,7 +325,7 @@ namespace Dalamud.Game.Internal.Gui {
/// <param name="index">Index of UI to find (1-indexed)</param>
/// <returns>IntPtr.Zero if unable to find UI, otherwise IntPtr pointing to the start of the UI Object</returns>
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;

View file

@ -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