mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-10 18:14:36 +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
|
|
@ -12,6 +12,7 @@ using Dalamud.Game.Internal;
|
|||
using Dalamud.Game.Internal.Gui.Addon;
|
||||
using Dalamud.Game.Internal.Gui.Toast;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin;
|
||||
using ImGuiNET;
|
||||
|
|
@ -541,7 +542,10 @@ namespace Dalamud.Interface
|
|||
var targetMgr = this.dalamud.ClientState.Targets;
|
||||
|
||||
if (targetMgr.CurrentTarget != null)
|
||||
{
|
||||
this.PrintActor(targetMgr.CurrentTarget, "CurrentTarget");
|
||||
Util.ShowObject(targetMgr.CurrentTarget);
|
||||
}
|
||||
|
||||
if (targetMgr.FocusTarget != null)
|
||||
this.PrintActor(targetMgr.FocusTarget, "FocusTarget");
|
||||
|
|
|
|||
|
|
@ -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