Merge pull request #2568 from Infiziert90/ImRaii-UIDebug2

Improve UIDebug2
This commit is contained in:
goat 2026-01-09 21:39:41 +01:00 committed by GitHub
commit 47f60eb391
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 103 additions and 122 deletions

View file

@ -27,7 +27,6 @@ public unsafe partial class AddonTree
if (tree.Success)
{
using var tbl = ImRaii.Table("atkUnitBase_atkValueTable"u8, 3, ImGuiTableFlags.Borders | ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg);
if (tbl.Success)
{
ImGui.TableSetupColumn("Index"u8);

View file

@ -29,11 +29,9 @@ public static class Events
}
using var tree = ImRaii.TreeNode($"Events##{(nint)node:X}eventTree");
if (tree.Success)
{
using var tbl = ImRaii.Table($"##{(nint)node:X}eventTable", 7, Resizable | SizingFixedFit | Borders | RowBg);
if (tbl.Success)
{
ImGui.TableSetupColumn("#"u8, WidthFixed);
@ -51,18 +49,25 @@ public static class Events
{
ImGui.TableNextColumn();
ImGui.Text($"{i++}");
ImGui.TableNextColumn();
ImGui.Text($"{evt->State.EventType}");
ImGui.TableNextColumn();
ImGui.Text($"{evt->Param}");
ImGui.TableNextColumn();
ImGui.Text($"{evt->State.StateFlags}");
ImGui.TableNextColumn();
ImGui.Text($"{evt->State.ReturnFlags}");
ImGui.TableNextColumn();
ImGuiHelpers.ClickToCopyText($"{(nint)evt->Target:X}", default, new Vector4(0.6f, 0.6f, 0.6f, 1));
ImGui.TableNextColumn();
ImGuiHelpers.ClickToCopyText($"{(nint)evt->Listener:X}", default, new Vector4(0.6f, 0.6f, 0.6f, 1));
evt = evt->NextEvent;
}
}

View file

@ -4,6 +4,8 @@ using Dalamud.Bindings.ImGui;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Text.ReadOnly;
using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;
using static Dalamud.Utility.Util;
using static FFXIVClientStructs.FFXIV.Component.GUI.ComponentType;
@ -90,14 +92,14 @@ internal unsafe class ComponentNodeTree : ResNodeTree
{
case TextInput:
var textInputComponent = (AtkComponentTextInput*)this.Component;
ImGui.Text($"InputBase Text1: {Marshal.PtrToStringAnsi(new(textInputComponent->AtkComponentInputBase.EvaluatedString.StringPtr))}");
ImGui.Text($"InputBase Text2: {Marshal.PtrToStringAnsi(new(textInputComponent->AtkComponentInputBase.RawString.StringPtr))}");
ImGui.Text($"InputBase Text1 (Lumina): {new ReadOnlySeStringSpan(textInputComponent->AtkComponentInputBase.EvaluatedString.AsSpan()).ToMacroString()}");
ImGui.Text($"InputBase Text2 (Lumina): {new ReadOnlySeStringSpan(textInputComponent->AtkComponentInputBase.RawString.AsSpan()).ToMacroString()}");
// TODO: Reenable when unknowns have been unprivated / named
// ImGui.Text($"Text1: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText01.StringPtr))}");
// ImGui.Text($"Text2: {Marshal.PtrToStringAnsi(new(textInputComponent->UnkText02.StringPtr))}");
ImGui.Text($"AvailableLines: {Marshal.PtrToStringAnsi(new(textInputComponent->AvailableLines.StringPtr))}");
ImGui.Text($"HighlightedAutoTranslateOptionColorPrefix: {Marshal.PtrToStringAnsi(new(textInputComponent->HighlightedAutoTranslateOptionColorPrefix.StringPtr))}");
ImGui.Text($"HighlightedAutoTranslateOptionColorSuffix: {Marshal.PtrToStringAnsi(new(textInputComponent->HighlightedAutoTranslateOptionColorSuffix.StringPtr))}");
// ImGui.Text($"Text1: {new ReadOnlySeStringSpan(textInputComponent->UnkText01.AsSpan()).ToMacroString()}");
// ImGui.Text($"Text2: {new ReadOnlySeStringSpan(textInputComponent->UnkText02.AsSpan()).ToMacroString()}");
ImGui.Text($"AvailableLines: {new ReadOnlySeStringSpan(textInputComponent->AvailableLines.AsSpan()).ToMacroString()}");
ImGui.Text($"HighlightedAutoTranslateOptionColorPrefix: {new ReadOnlySeStringSpan(textInputComponent->HighlightedAutoTranslateOptionColorPrefix.AsSpan()).ToMacroString()}");
ImGui.Text($"HighlightedAutoTranslateOptionColorSuffix: {new ReadOnlySeStringSpan(textInputComponent->HighlightedAutoTranslateOptionColorSuffix.AsSpan()).ToMacroString()}");
break;
case List:
case TreeList:

View file

@ -1,5 +1,7 @@
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Text.ReadOnly;
using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;
using static Dalamud.Utility.Util;
@ -30,7 +32,7 @@ internal unsafe partial class CounterNodeTree : ResNodeTree
{
if (!isEditorOpen)
{
PrintFieldValuePairs(("Text", ((AtkCounterNode*)this.Node)->NodeText.ToString()));
PrintFieldValuePairs(("Text", new ReadOnlySeStringSpan(((AtkCounterNode*)this.Node)->NodeText.AsSpan()).ToMacroString()));
}
}
}

View file

@ -8,6 +8,8 @@ using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Text.ReadOnly;
using static Dalamud.Bindings.ImGui.ImGuiColorEditFlags;
using static Dalamud.Bindings.ImGui.ImGuiInputTextFlags;
using static Dalamud.Bindings.ImGui.ImGuiTableColumnFlags;
@ -28,10 +30,10 @@ internal unsafe partial class ResNodeTree
private protected void DrawNodeEditorTable()
{
using var tbl = ImRaii.Table($"###Editor{(nint)this.Node}", 2, SizingStretchProp | NoHostExtendX);
if (tbl.Success)
{
this.DrawEditorRows();
}
if (!tbl.Success)
return;
this.DrawEditorRows();
}
/// <summary>
@ -60,7 +62,7 @@ internal unsafe partial class ResNodeTree
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(150);
if (ImGui.DragFloat2($"##{(nint)this.Node:X}position", ref pos, 1, default, default, "%.0f"))
if (ImGui.DragFloat2($"##{(nint)this.Node:X}position", ref pos, 1, 0, 0, "%.0f"))
{
this.Node->X = pos.X;
this.Node->Y = pos.Y;
@ -74,7 +76,7 @@ internal unsafe partial class ResNodeTree
ImGui.Text("Size:"u8);
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(150);
if (ImGui.DragFloat2($"##{(nint)this.Node:X}size", ref size, 1, 0, default, "%.0f"))
if (ImGui.DragFloat2($"##{(nint)this.Node:X}size", ref size, 1, 0, 0, "%.0f"))
{
this.Node->Width = (ushort)Math.Max(size.X, 0);
this.Node->Height = (ushort)Math.Max(size.Y, 0);
@ -102,7 +104,7 @@ internal unsafe partial class ResNodeTree
ImGui.Text("Origin:"u8);
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(150);
if (ImGui.DragFloat2($"##{(nint)this.Node:X}origin", ref origin, 1, default, default, "%.0f"))
if (ImGui.DragFloat2($"##{(nint)this.Node:X}origin", ref origin, 1, 0, 0, "%.0f"))
{
this.Node->OriginX = origin.X;
this.Node->OriginY = origin.Y;
@ -121,7 +123,7 @@ internal unsafe partial class ResNodeTree
angle -= 360;
}
if (ImGui.DragFloat($"##{(nint)this.Node:X}rotation", ref angle, 0.05f, default, default, "%.2f°"))
if (ImGui.DragFloat($"##{(nint)this.Node:X}rotation", ref angle, 0.05f, 0, 0, "%.2f°"))
{
this.Node->Rotation = (float)(angle / (180 / Math.PI));
this.Node->DrawFlags |= 0xD;
@ -169,7 +171,6 @@ internal unsafe partial class ResNodeTree
ImGui.Text("Add:"u8);
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(124);
if (ImGui.DragFloat3($"##{(nint)this.Node:X}addRGB", ref add, 1, -255, 255, "%.0f"))
{
this.Node->AddRed = (short)add.X;
@ -200,7 +201,7 @@ internal unsafe partial class CounterNodeTree
{
base.DrawEditorRows();
var str = this.CntNode->NodeText.ToString();
var str = new ReadOnlySeStringSpan(this.CntNode->NodeText.AsSpan()).ToMacroString();
ImGui.TableNextRow();
ImGui.TableNextColumn();
@ -300,7 +301,7 @@ internal unsafe partial class TextNodeTree
{
base.DrawEditorRows();
var text = this.TxtNode->NodeText.ToString();
var text = new ReadOnlySeStringSpan(this.TxtNode->NodeText.AsSpan()).ToMacroString();
var fontIndex = FontList.IndexOf(this.TxtNode->FontType);
int fontSize = this.TxtNode->FontSize;
var alignment = this.TxtNode->AlignmentType;

View file

@ -64,7 +64,6 @@ internal unsafe partial class ImageNodeTree : ResNodeTree
}
using var tree = ImRaii.TreeNode($"Texture##texture{(nint)this.TexData.Texture->D3D11ShaderResourceView:X}", SpanFullWidth);
if (tree.Success)
{
PrintFieldValuePairs(

View file

@ -60,10 +60,10 @@ internal unsafe partial class NineGridNodeTree : ImageNodeTree
var ngCol = RgbaVector4ToUint(col with { W = 0.75f * col.W });
ImGui.GetWindowDrawList()
.AddRect(partBegin, partEnd, RgbaVector4ToUint(col));
ImGui.GetWindowDrawList().AddRect(ngBegin1, ngEnd1, ngCol);
ImGui.GetWindowDrawList().AddRect(ngBegin2, ngEnd2, ngCol);
var windowDrawList = ImGui.GetWindowDrawList();
windowDrawList.AddRect(partBegin, partEnd, RgbaVector4ToUint(col));
windowDrawList.AddRect(ngBegin1, ngEnd1, ngCol);
windowDrawList.AddRect(ngBegin2, ngEnd2, ngCol);
ImGui.SetCursorPos(cursorLocalPos + uv + new Vector2(0, -20));
ImGui.TextColored(col, $"[#{partId}]\t{part.U}, {part.V}\t{part.Width}x{part.Height}");

View file

@ -138,7 +138,6 @@ internal unsafe partial class ResNodeTree : IDisposable
PrintNodeList(nodeList, count, addonTree);
var lineEnd = lineStart with { Y = ImGui.GetCursorScreenPos().Y - 7 };
if (lineStart.Y < lineEnd.Y)
{
ImGui.GetWindowDrawList().AddLine(lineStart, lineEnd, RgbaVector4ToUint(color), 1);

View file

@ -2,16 +2,15 @@ using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.ImGuiSeStringRenderer;
using Dalamud.Interface.Internal.UiDebug2.Utility;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Client.System.String;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Text.ReadOnly;
using static Dalamud.Interface.ColorHelpers;
using static Dalamud.Interface.Internal.UiDebug2.Utility.Gui;
using static Dalamud.Utility.Util;
@ -65,7 +64,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
}
catch
{
ImGui.Text(Marshal.PtrToStringAnsi(new(this.NodeText.StringPtr)) ?? string.Empty);
ImGui.Text(new ReadOnlySeStringSpan(this.NodeText.AsSpan()).ToMacroString());
}
PrintFieldValuePairs(
@ -83,36 +82,24 @@ internal unsafe partial class TextNodeTree : ResNodeTree
private void PrintPayloads()
{
using var tree = ImRaii.TreeNode($"Text Payloads##{(nint)this.Node:X}");
if (tree.Success)
{
var utf8String = this.NodeText;
var seStringBytes = new byte[utf8String.BufUsed];
for (var i = 0L; i < utf8String.BufUsed; i++)
var idx = 0;
foreach (var payload in new ReadOnlySeString(this.NodeText.AsSpan()))
{
seStringBytes[i] = utf8String.StringPtr.Value[i];
}
var seString = SeString.Parse(seStringBytes);
for (var i = 0; i < seString.Payloads.Count; i++)
{
var payload = seString.Payloads[i];
ImGui.Text($"[{i}]");
ImGui.Text($"[{idx}]");
ImGui.SameLine();
switch (payload.Type)
{
case PayloadType.RawText when payload is TextPayload tp:
{
Gui.PrintFieldValuePair("Raw Text", tp.Text ?? string.Empty);
case ReadOnlySePayloadType.Text:
PrintFieldValuePair("Raw Text", payload.ToString());
break;
}
default:
{
ImGui.Text(payload.ToString());
break;
}
}
idx++;
}
}
}

View file

@ -58,7 +58,6 @@ public readonly unsafe partial struct TimelineTree
if (animationCount > 0)
{
using var tree = ImRaii.TreeNode($"Timeline##{(nint)this.node:X}timeline", SpanFullWidth);
if (tree.Success)
{
PrintFieldValuePair("Timeline", $"{(nint)this.NodeTimeline:X}");
@ -90,7 +89,6 @@ public readonly unsafe partial struct TimelineTree
if (labelSetCount > 0 && this.Resource->LabelSets is not null)
{
using var tree = ImRaii.TreeNode($"Timeline Label Sets##{(nint)this.node:X}LabelSets", SpanFullWidth);
if (tree.Success)
{
this.DrawLabelSets();
@ -325,7 +323,6 @@ public readonly unsafe partial struct TimelineTree
using (ImRaii.PushColor(ImGuiCol.Text, new Vector4(1, 0.65F, 0.4F, 1), isActive))
{
using var tree = ImRaii.TreeNode($"[#{a}] [Frames {animation.StartFrameIdx}-{animation.EndFrameIdx}] {(isActive ? " (Active)" : string.Empty)}###{(nint)this.node}animTree{a}");
if (tree.Success)
{
PrintFieldValuePair("Animation", $"{address:X}");
@ -335,7 +332,6 @@ public readonly unsafe partial struct TimelineTree
if (columns.Count > 0)
{
using var tbl = ImRaii.Table($"##{(nint)this.node}animTable{a}", columns.Count, Borders | SizingFixedFit | RowBg | NoHostExtendX);
if (tbl.Success)
{
foreach (var c in columns)

View file

@ -160,65 +160,61 @@ internal unsafe class ElementSelector : IDisposable
if (ch.Success)
{
using var gr = ImRaii.Group();
if (gr.Success)
Gui.PrintFieldValuePair("Mouse Position", $"{mousePos.X}, {mousePos.Y}");
ImGui.Spacing();
ImGui.Text("RESULTS:\n"u8);
var i = 0;
foreach (var a in addonResults)
{
Gui.PrintFieldValuePair("Mouse Position", $"{mousePos.X}, {mousePos.Y}");
ImGui.Spacing();
ImGui.Text("RESULTS:\n"u8);
var name = a.Addon->NameString;
ImGui.Text($"[Addon] {name}");
var i = 0;
foreach (var a in addonResults)
using var indent = ImRaii.PushIndent(15.0f);
foreach (var n in a.Nodes)
{
var name = a.Addon->NameString;
ImGui.Text($"[Addon] {name}");
ImGui.Indent(15);
foreach (var n in a.Nodes)
var nSelected = i++ == this.index;
PrintNodeHeaderOnly(n.Node, nSelected, a.Addon);
if (nSelected && ImGui.IsMouseClicked(ImGuiMouseButton.Left))
{
var nSelected = i++ == this.index;
this.Active = false;
PrintNodeHeaderOnly(n.Node, nSelected, a.Addon);
this.uiDebug2.SelectedAddonName = a.Addon->NameString;
if (nSelected && ImGui.IsMouseClicked(ImGuiMouseButton.Left))
var ptrList = new List<nint> { (nint)n.Node };
var nextNode = n.Node->ParentNode;
while (nextNode != null)
{
this.Active = false;
this.uiDebug2.SelectedAddonName = a.Addon->NameString;
var ptrList = new List<nint> { (nint)n.Node };
var nextNode = n.Node->ParentNode;
while (nextNode != null)
{
ptrList.Add((nint)nextNode);
nextNode = nextNode->ParentNode;
}
SearchResults = [.. ptrList];
Countdown = 100;
Scrolled = false;
ptrList.Add((nint)nextNode);
nextNode = nextNode->ParentNode;
}
if (nSelected)
{
n.NodeBounds.DrawFilled(new(1, 1, 0.2f, 1));
}
SearchResults = [.. ptrList];
Countdown = 100;
Scrolled = false;
}
ImGui.Indent(-15);
if (nSelected)
{
n.NodeBounds.DrawFilled(new(1, 1, 0.2f, 1));
}
}
}
if (i != 0)
{
this.index -= (int)ImGui.GetIO().MouseWheel;
while (this.index < 0)
{
this.index += i;
}
if (i != 0)
while (this.index >= i)
{
this.index -= (int)ImGui.GetIO().MouseWheel;
while (this.index < 0)
{
this.index += i;
}
while (this.index >= i)
{
this.index -= i;
}
this.index -= i;
}
}
}

View file

@ -39,7 +39,7 @@ internal class AddonPopoutWindow : Window, IDisposable
/// <inheritdoc/>
public override void Draw()
{
using var ch = ImRaii.Child($"{this.WindowName}child", new(-1, -1), true);
using var ch = ImRaii.Child($"{this.WindowName}child", Vector2.Zero, true);
if (ch.Success)
{
this.addonTree.Draw();

View file

@ -39,7 +39,7 @@ internal unsafe class NodePopoutWindow : Window, IDisposable
this.PositionCondition = ImGuiCond.Once;
this.SizeCondition = ImGuiCond.Once;
this.Size = new(700, 200);
this.SizeConstraints = new() { MinimumSize = new(100, 100) };
this.SizeConstraints = new() { MinimumSize = new Vector2(100, 100) };
}
private AddonTree AddonTree => this.resNodeTree.AddonTree;
@ -51,7 +51,7 @@ internal unsafe class NodePopoutWindow : Window, IDisposable
{
if (this.Node != null && this.AddonTree.ContainsNode(this.Node))
{
using var ch = ImRaii.Child($"{(nint)this.Node:X}popoutChild", new(-1, -1), true);
using var ch = ImRaii.Child($"{(nint)this.Node:X}popoutChild", Vector2.Zero, true);
if (ch.Success)
{
ResNodeTree.GetOrCreate(this.Node, this.AddonTree).Print(null, this.firstDraw);

View file

@ -105,12 +105,8 @@ internal static class Gui
var index = (int)Math.Floor(prog * tooltips.Length);
using var tt = ImRaii.Tooltip();
if (tt.Success)
{
ImGui.Text(tooltips[index]);
}
using var tooltip = ImRaii.Tooltip();
ImGui.Text(tooltips[index]);
return true;
}
@ -124,13 +120,14 @@ internal static class Gui
{
if ((mask & 0b10) > 0)
{
ImGui.Dummy(new(padding * ImGui.GetIO().FontGlobalScale));
ImGuiHelpers.ScaledDummy(padding);
}
ImGui.Separator();
if ((mask & 0b01) > 0)
{
ImGui.Dummy(new(padding * ImGui.GetIO().FontGlobalScale));
ImGuiHelpers.ScaledDummy(padding);
}
}
}

View file

@ -62,10 +62,11 @@ public unsafe struct NodeBounds
return;
}
var backgroundDrawList = ImGui.GetBackgroundDrawList();
if (this.Points.Count == 1)
{
ImGui.GetBackgroundDrawList().AddCircle(this.Points[0], 10, RgbaVector4ToUint(col with { W = col.W / 2 }), 12, thickness);
ImGui.GetBackgroundDrawList().AddCircle(this.Points[0], thickness, RgbaVector4ToUint(col), 12, thickness + 1);
backgroundDrawList.AddCircle(this.Points[0], 10, RgbaVector4ToUint(col with { W = col.W / 2 }), 12, thickness);
backgroundDrawList.AddCircle(this.Points[0], thickness, RgbaVector4ToUint(col), 12, thickness + 1);
}
else
{
@ -75,8 +76,7 @@ public unsafe struct NodeBounds
path.Add(p);
}
ImGui.GetBackgroundDrawList()
.AddPolyline(ref path[0], path.Length, RgbaVector4ToUint(col), ImDrawFlags.Closed, thickness);
backgroundDrawList.AddPolyline(ref path[0], path.Length, RgbaVector4ToUint(col), ImDrawFlags.Closed, thickness);
path.Dispose();
}
@ -94,11 +94,11 @@ public unsafe struct NodeBounds
return;
}
var backgroundDrawList = ImGui.GetBackgroundDrawList();
if (this.Points.Count == 1)
{
ImGui.GetBackgroundDrawList()
.AddCircleFilled(this.Points[0], 10, RgbaVector4ToUint(col with { W = col.W / 2 }), 12);
ImGui.GetBackgroundDrawList().AddCircle(this.Points[0], 10, RgbaVector4ToUint(col), 12, thickness);
backgroundDrawList.AddCircleFilled(this.Points[0], 10, RgbaVector4ToUint(col with { W = col.W / 2 }), 12);
backgroundDrawList.AddCircle(this.Points[0], 10, RgbaVector4ToUint(col), 12, thickness);
}
else
{
@ -108,10 +108,8 @@ public unsafe struct NodeBounds
path.Add(p);
}
ImGui.GetBackgroundDrawList()
.AddConvexPolyFilled(ref path[0], path.Length, RgbaVector4ToUint(col with { W = col.W / 2 }));
ImGui.GetBackgroundDrawList()
.AddPolyline(ref path[0], path.Length, RgbaVector4ToUint(col), ImDrawFlags.Closed, thickness);
backgroundDrawList.AddConvexPolyFilled(ref path[0], path.Length, RgbaVector4ToUint(col with { W = col.W / 2 }));
backgroundDrawList.AddPolyline(ref path[0], path.Length, RgbaVector4ToUint(col), ImDrawFlags.Closed, thickness);
path.Dispose();
}