From ca52a8c9e4d51af13f66526436a3a9dfaab99ae2 Mon Sep 17 00:00:00 2001
From: goat <16760685+goaaats@users.noreply.github.com>
Date: Tue, 7 Dec 2021 22:29:51 +0100
Subject: [PATCH] feat: add Util.ShowGameObjectStruct, switch target data
viewer
---
.../ClientState/Objects/Types/BattleChara.cs | 2 +-
Dalamud/Interface/ImGuiHelpers.cs | 16 ++++++-------
.../Interface/Internal/Windows/DataWindow.cs | 5 ++--
Dalamud/Utility/Util.cs | 23 ++++++++++++++++++-
4 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs b/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs
index 8f4650b79..a3f9b9f89 100644
--- a/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs
+++ b/Dalamud/Game/ClientState/Objects/Types/BattleChara.cs
@@ -62,6 +62,6 @@ namespace Dalamud.Game.ClientState.Objects.Types
///
/// Gets the underlying structure.
///
- internal protected new FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara*)this.Address;
+ protected internal new FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara*)this.Address;
}
}
diff --git a/Dalamud/Interface/ImGuiHelpers.cs b/Dalamud/Interface/ImGuiHelpers.cs
index 395d3340b..4006f719e 100644
--- a/Dalamud/Interface/ImGuiHelpers.cs
+++ b/Dalamud/Interface/ImGuiHelpers.cs
@@ -112,14 +112,6 @@ namespace Dalamud.Interface
/// with the size of the button.
public static Vector2 GetButtonSize(string text) => ImGui.CalcTextSize(text) + (ImGui.GetStyle().FramePadding * 2);
- ///
- /// Get data needed for each new frame.
- ///
- internal static void NewFrame()
- {
- GlobalScale = ImGui.GetIO().FontGlobalScale;
- }
-
///
/// Print out text that can be copied when clicked.
///
@@ -137,5 +129,13 @@ namespace Dalamud.Interface
if (ImGui.IsItemClicked()) ImGui.SetClipboardText($"{textCopy}");
}
+
+ ///
+ /// Get data needed for each new frame.
+ ///
+ internal static void NewFrame()
+ {
+ GlobalScale = ImGui.GetIO().FontGlobalScale;
+ }
}
}
diff --git a/Dalamud/Interface/Internal/Windows/DataWindow.cs b/Dalamud/Interface/Internal/Windows/DataWindow.cs
index 724728c63..48febaa5a 100644
--- a/Dalamud/Interface/Internal/Windows/DataWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/DataWindow.cs
@@ -1019,15 +1019,16 @@ namespace Dalamud.Interface.Internal.Windows
this.PrintGameObject(targetMgr.Target, "CurrentTarget");
ImGui.Text("Target");
- Util.ShowObject(targetMgr.Target);
+ Util.ShowGameObjectStruct(targetMgr.Target);
var tot = targetMgr.Target.TargetObject;
if (tot != null)
{
ImGuiHelpers.ScaledDummy(10);
+ ImGui.Separator();
ImGui.Text("ToT");
- Util.ShowObject(tot);
+ Util.ShowGameObjectStruct(tot);
}
ImGuiHelpers.ScaledDummy(10);
diff --git a/Dalamud/Utility/Util.cs b/Dalamud/Utility/Util.cs
index 40d092d18..a89e257cf 100644
--- a/Dalamud/Utility/Util.cs
+++ b/Dalamud/Utility/Util.cs
@@ -13,6 +13,7 @@ using System.Text;
using Dalamud.Configuration.Internal;
using Dalamud.Game;
+using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using ImGuiNET;
@@ -243,6 +244,26 @@ namespace Dalamud.Utility
}
}
+ ///
+ /// Show a GameObject's internal data in an ImGui-context.
+ ///
+ /// The GameObject to show.
+ public static unsafe void ShowGameObjectStruct(GameObject go)
+ {
+ switch (go)
+ {
+ case BattleChara bchara:
+ ShowStruct(*bchara.Struct, (ulong)bchara.Address);
+ break;
+ case Character chara:
+ ShowStruct(*chara.Struct, (ulong)chara.Address);
+ break;
+ default:
+ ShowStruct(*go.Struct, (ulong)go.Address);
+ break;
+ }
+ }
+
///
/// Show all properties and fields of the provided object via ImGui.
///
@@ -402,7 +423,7 @@ namespace Dalamud.Utility
return Check1() || Check2() || Check3();
}
-
+
private static unsafe void ShowValue(ulong addr, IEnumerable path, Type type, object value)
{
if (type.IsPointer)