fix: also set correct item spacing for Util.ShowStruct

This commit is contained in:
goat 2021-12-08 01:47:02 +01:00
parent cb51d2f033
commit 6d22edb390
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
2 changed files with 14 additions and 10 deletions

View file

@ -118,7 +118,7 @@ namespace Dalamud.Interface.Internal
object addonObj = *atkUnitBase;
Util.ShowStruct(addonObj, (ulong)atkUnitBase, new List<string>());
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<string>()); break;
default: Util.ShowStruct(*node, (ulong)node); break;
}
this.PrintResNode(node);

View file

@ -169,10 +169,11 @@ namespace Dalamud.Utility
/// </summary>
/// <param name="obj">The structure to show.</param>
/// <param name="addr">The address to the structure.</param>
/// <param name="path">The already followed path.</param>
/// <param name="autoExpand">Whether or not this structure should start out expanded.</param>
public static void ShowStruct(object obj, ulong addr, IEnumerable<string>? path = null, bool autoExpand = false)
/// <param name="path">The already followed path.</param>
public static void ShowStruct(object obj, ulong addr, bool autoExpand = false, IEnumerable<string>? path = null)
{
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(3, 2));
path ??= new List<string>();
if (moduleEndAddr == 0 && moduleStartAddr == 0)
@ -242,24 +243,27 @@ namespace Dalamud.Utility
{
ImGui.PopStyleColor();
}
ImGui.PopStyleVar();
}
/// <summary>
/// Show a GameObject's internal data in an ImGui-context.
/// </summary>
/// <param name="go">The GameObject to show.</param>
public static unsafe void ShowGameObjectStruct(GameObject go)
/// <param name="autoExpand">Whether or not the struct should start as expanded.</param>
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<string>(path));
ShowStruct(ptrObj, (ulong)unboxed, path: new List<string>(path));
}
}
catch
@ -470,7 +474,7 @@ namespace Dalamud.Utility
{
if (!type.IsPrimitive)
{
ShowStruct(value, addr, new List<string>(path));
ShowStruct(value, addr, path: new List<string>(path));
}
else
{