UIDebug2 Timeline Labelset support (#2275)

* Add LabelSet Display

* Update TimelineTree.cs
This commit is contained in:
MidoriKami 2025-05-26 12:09:50 -07:00 committed by GitHub
parent 43ab6f6f63
commit fe8efc9dde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,9 +52,10 @@ public readonly unsafe partial struct TimelineTree
return;
}
var count = this.Resource->AnimationCount;
var animationCount = this.Resource->AnimationCount;
var labelSetCount = this.Resource->LabelSetCount;
if (count > 0)
if (animationCount > 0)
{
using var tree = ImRaii.TreeNode($"Timeline##{(nint)this.node:X}timeline", SpanFullWidth);
@ -66,22 +67,35 @@ public readonly unsafe partial struct TimelineTree
ShowStruct(this.NodeTimeline);
PrintFieldValuePairs(
("Id", $"{this.NodeTimeline->Resource->Id}"),
("Parent Time", $"{this.NodeTimeline->ParentFrameTime:F2} ({this.NodeTimeline->ParentFrameTime * 30:F0})"),
("Frame Time", $"{this.NodeTimeline->FrameTime:F2} ({this.NodeTimeline->FrameTime * 30:F0})"));
PrintFieldValuePairs(("Active Label Id", $"{this.NodeTimeline->ActiveLabelId}"), ("Duration", $"{this.NodeTimeline->LabelFrameIdxDuration}"), ("End Frame", $"{this.NodeTimeline->LabelEndFrameIdx}"));
ImGui.TextColored(new(0.6f, 0.6f, 0.6f, 1), "Animation List");
for (var a = 0; a < count; a++)
if (this.Resource->Animations is not null)
{
var animation = this.Resource->Animations[a];
var isActive = this.ActiveAnimation != null && &animation == this.ActiveAnimation;
this.PrintAnimation(animation, a, isActive, (nint)(this.NodeTimeline->Resource->Animations + a));
PrintFieldValuePairs(
("Id", $"{this.NodeTimeline->Resource->Id}"),
("Parent Time", $"{this.NodeTimeline->ParentFrameTime:F2} ({this.NodeTimeline->ParentFrameTime * 30:F0})"),
("Frame Time", $"{this.NodeTimeline->FrameTime:F2} ({this.NodeTimeline->FrameTime * 30:F0})"));
PrintFieldValuePairs(("Active Label Id", $"{this.NodeTimeline->ActiveLabelId}"), ("Duration", $"{this.NodeTimeline->LabelFrameIdxDuration}"), ("End Frame", $"{this.NodeTimeline->LabelEndFrameIdx}"));
ImGui.TextColored(new(0.6f, 0.6f, 0.6f, 1), "Animation List");
for (var a = 0; a < animationCount; a++)
{
var animation = this.Resource->Animations[a];
var isActive = this.ActiveAnimation != null && &animation == this.ActiveAnimation;
this.PrintAnimation(animation, a, isActive, (nint)(this.NodeTimeline->Resource->Animations + a));
}
}
}
}
if (labelSetCount > 0 && this.Resource->LabelSets is not null)
{
using var tree = ImRaii.TreeNode($"Timeline Label Sets##{(nint)this.node:X}LabelSets", SpanFullWidth);
if (tree.Success)
{
this.DrawLabelSets();
}
}
}
private static void GetFrameColumn(Span<AtkTimelineKeyGroup> keyGroups, List<IKeyGroupColumn> columns, ushort endFrame)
@ -381,4 +395,63 @@ public readonly unsafe partial struct TimelineTree
return columns;
}
private void DrawLabelSets()
{
PrintFieldValuePair("LabelSet", $"{(nint)this.NodeTimeline->Resource->LabelSets:X}");
ImGui.SameLine();
ShowStruct(this.NodeTimeline->Resource->LabelSets);
PrintFieldValuePairs(
("StartFrameIdx", $"{this.NodeTimeline->Resource->LabelSets->StartFrameIdx}"),
("EndFrameIdx", $"{this.NodeTimeline->Resource->LabelSets->EndFrameIdx}"));
using var labelSetTable = ImRaii.TreeNode("Entries");
if (labelSetTable.Success)
{
var keyFrameGroup = this.Resource->LabelSets->LabelKeyGroup;
using var table = ImRaii.Table($"##{(nint)this.node}labelSetKeyFrameTable", 7, Borders | SizingFixedFit | RowBg | NoHostExtendX);
if (table.Success)
{
ImGui.TableSetupColumn("Frame ID", WidthFixed);
ImGui.TableSetupColumn("Speed Start", WidthFixed);
ImGui.TableSetupColumn("Speed End", WidthFixed);
ImGui.TableSetupColumn("Interpolation", WidthFixed);
ImGui.TableSetupColumn("Label ID", WidthFixed);
ImGui.TableSetupColumn("Jump Behavior", WidthFixed);
ImGui.TableSetupColumn("Target Label ID", WidthFixed);
ImGui.TableHeadersRow();
for (var l = 0; l < keyFrameGroup.KeyFrameCount; l++)
{
var keyFrame = keyFrameGroup.KeyFrames[l];
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{keyFrame.FrameIdx}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{keyFrame.SpeedCoefficient1:F2}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{keyFrame.SpeedCoefficient2:F2}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{keyFrame.Interpolation}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{keyFrame.Value.Label.LabelId}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{keyFrame.Value.Label.JumpBehavior}");
ImGui.TableNextColumn();
ImGui.TextUnformatted($"{keyFrame.Value.Label.JumpLabelId}");
}
}
}
}
}