mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 06:13:40 +01:00
feat: object dumper for data window
This commit is contained in:
parent
6ecf095867
commit
74c311ce60
2 changed files with 34 additions and 0 deletions
|
|
@ -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)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue