Dalamud/Dalamud/Interface/Internal/UiDebug2/Browsing/Events.cs
ItsBexy c950b15a22
Minor interface adjustments (#2121)
- Further ImRaii safety in UiDebug2
- Set some mistakenly internal methods in ImGuiComponents to public
- Added SpanFullWidth flag to trees in Util.ShowStruct
2024-11-24 21:37:39 +01:00

71 lines
2.5 KiB
C#

using System.Numerics;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using static ImGuiNET.ImGuiTableColumnFlags;
using static ImGuiNET.ImGuiTableFlags;
namespace Dalamud.Interface.Internal.UiDebug2.Browsing;
/// <summary>
/// Class that prints the events table for a node, where applicable.
/// </summary>
public static class Events
{
/// <summary>
/// Prints out each <see cref="AtkEventManager.Event"/> for a given node.
/// </summary>
/// <param name="node">The node to print events for.</param>
internal static unsafe void PrintEvents(AtkResNode* node)
{
var evt = node->AtkEventManager.Event;
if (evt == null)
{
return;
}
using var tree = ImRaii.TreeNode($"Events##{(nint)node:X}eventTree");
if (tree.Success)
{
using var tbl = ImRaii.Table($"##{(nint)node:X}eventTable", 7, Resizable | SizingFixedFit | Borders | RowBg);
if (tbl.Success)
{
ImGui.TableSetupColumn("#", WidthFixed);
ImGui.TableSetupColumn("Type", WidthFixed);
ImGui.TableSetupColumn("Param", WidthFixed);
ImGui.TableSetupColumn("Flags", WidthFixed);
ImGui.TableSetupColumn("StateFlags1", WidthFixed);
ImGui.TableSetupColumn("Target", WidthFixed);
ImGui.TableSetupColumn("Listener", WidthFixed);
ImGui.TableHeadersRow();
var i = 0;
while (evt != null)
{
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{i++}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{evt->State.EventType}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{evt->Param}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{evt->State.StateFlags}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{evt->State.UnkFlags1}");
ImGui.TableNextColumn();
ImGuiHelpers.ClickToCopyText($"{(nint)evt->Target:X}", null, new Vector4(0.6f, 0.6f, 0.6f, 1));
ImGui.TableNextColumn();
ImGuiHelpers.ClickToCopyText($"{(nint)evt->Listener:X}", null, new Vector4(0.6f, 0.6f, 0.6f, 1));
evt = evt->NextEvent;
}
}
}
}
}