From 6d22edb390bd3aee6052fa0b2b3139ca2f91d63d Mon Sep 17 00:00:00 2001 From: goat <16760685+goaaats@users.noreply.github.com> Date: Wed, 8 Dec 2021 01:47:02 +0100 Subject: [PATCH] fix: also set correct item spacing for Util.ShowStruct --- Dalamud/Interface/Internal/UiDebug.cs | 4 ++-- Dalamud/Utility/Util.cs | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Dalamud/Interface/Internal/UiDebug.cs b/Dalamud/Interface/Internal/UiDebug.cs index 9c847dd77..3b02a1b8d 100644 --- a/Dalamud/Interface/Internal/UiDebug.cs +++ b/Dalamud/Interface/Internal/UiDebug.cs @@ -118,7 +118,7 @@ namespace Dalamud.Interface.Internal object addonObj = *atkUnitBase; - Util.ShowStruct(addonObj, (ulong)atkUnitBase, new List()); + Util.ShowStruct(addonObj, (ulong)atkUnitBase); ImGui.Dummy(new Vector2(25 * ImGui.GetIO().FontGlobalScale)); ImGui.Separator(); @@ -200,7 +200,7 @@ namespace Dalamud.Interface.Internal case NodeType.Collision: Util.ShowStruct(*(AtkCollisionNode*)node, (ulong)node); break; case NodeType.NineGrid: Util.ShowStruct(*(AtkNineGridNode*)node, (ulong)node); break; case NodeType.Counter: Util.ShowStruct(*(AtkCounterNode*)node, (ulong)node); break; - default: Util.ShowStruct(*node, (ulong)node, new List()); break; + default: Util.ShowStruct(*node, (ulong)node); break; } this.PrintResNode(node); diff --git a/Dalamud/Utility/Util.cs b/Dalamud/Utility/Util.cs index a89e257cf..2b5440a4a 100644 --- a/Dalamud/Utility/Util.cs +++ b/Dalamud/Utility/Util.cs @@ -169,10 +169,11 @@ namespace Dalamud.Utility /// /// The structure to show. /// The address to the structure. - /// The already followed path. /// Whether or not this structure should start out expanded. - public static void ShowStruct(object obj, ulong addr, IEnumerable? path = null, bool autoExpand = false) + /// The already followed path. + public static void ShowStruct(object obj, ulong addr, bool autoExpand = false, IEnumerable? path = null) { + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(3, 2)); path ??= new List(); if (moduleEndAddr == 0 && moduleStartAddr == 0) @@ -242,24 +243,27 @@ namespace Dalamud.Utility { ImGui.PopStyleColor(); } + + ImGui.PopStyleVar(); } /// /// Show a GameObject's internal data in an ImGui-context. /// /// The GameObject to show. - public static unsafe void ShowGameObjectStruct(GameObject go) + /// Whether or not the struct should start as expanded. + public static unsafe void ShowGameObjectStruct(GameObject go, bool autoExpand = true) { switch (go) { case BattleChara bchara: - ShowStruct(*bchara.Struct, (ulong)bchara.Address); + ShowStruct(*bchara.Struct, (ulong)bchara.Address, autoExpand); break; case Character chara: - ShowStruct(*chara.Struct, (ulong)chara.Address); + ShowStruct(*chara.Struct, (ulong)chara.Address, autoExpand); break; default: - ShowStruct(*go.Struct, (ulong)go.Address); + ShowStruct(*go.Struct, (ulong)go.Address, autoExpand); break; } } @@ -453,7 +457,7 @@ namespace Dalamud.Utility } else { - ShowStruct(ptrObj, (ulong)unboxed, new List(path)); + ShowStruct(ptrObj, (ulong)unboxed, path: new List(path)); } } catch @@ -470,7 +474,7 @@ namespace Dalamud.Utility { if (!type.IsPrimitive) { - ShowStruct(value, addr, new List(path)); + ShowStruct(value, addr, path: new List(path)); } else {