feat: object dumper for data window

This commit is contained in:
goat 2021-04-13 21:45:30 +02:00
parent 6ecf095867
commit 74c311ce60
No known key found for this signature in database
GPG key ID: F18F057873895461
2 changed files with 34 additions and 0 deletions

View file

@ -5,6 +5,9 @@ using System.Runtime.InteropServices;
using System.Text;
using Dalamud.Game;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using ImGuiNET;
using Serilog;
namespace Dalamud
@ -116,5 +119,32 @@ namespace Dalamud
return sb.ToString().TrimEnd(Environment.NewLine.ToCharArray());
}
/// <summary>
/// Show all properties and fields of the provided object via ImGui.
/// </summary>
/// <param name="obj">The object to show.</param>
public static void ShowObject(object obj)
{
var type = obj.GetType();
ImGui.Text($"Object Dump({type.Name}) for {obj}({obj.GetHashCode()})");
ImGuiHelpers.ScaledDummy(5);
ImGui.TextColored(ImGuiColors.DalamudOrange, "-> Properties:");
foreach (var propertyInfo in type.GetProperties())
{
ImGui.TextColored(ImGuiColors.DalamudOrange, $" {propertyInfo.Name}: {propertyInfo.GetValue(obj)}");
}
ImGuiHelpers.ScaledDummy(5);
ImGui.TextColored(ImGuiColors.HealerGreen, "-> Fields:");
foreach (var fieldInfo in type.GetFields())
{
ImGui.TextColored(ImGuiColors.HealerGreen, $" {fieldInfo.Name}: {fieldInfo.GetValue(obj)}");
}
}
}
}