45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Diagnostics;
|
|
|
|
[Tool]
|
|
public sealed partial class BehaviorDebugGraphNode : GraphNode
|
|
{
|
|
public Label StateLabel { get; set; } = null!;
|
|
|
|
public override void _Ready()
|
|
{
|
|
StateLabel = GetNode<Label>("%StateLabel");
|
|
}
|
|
|
|
public string State
|
|
{
|
|
get;
|
|
set
|
|
{
|
|
field = value;
|
|
StateLabel.Text = value;
|
|
var themeStylebox = GetThemeStylebox("panel")!.Duplicate() as StyleBoxFlat;
|
|
themeStylebox?.BgColor = GetStateColor(value);
|
|
AddThemeStyleboxOverride("panel", themeStylebox);
|
|
}
|
|
} = "Idle";
|
|
|
|
private Color GetStateColor(string state) =>
|
|
state switch
|
|
{
|
|
"Idle" => Color.FromOkHsl(.653f, .3f, .2f),
|
|
"Running" => Color.FromOkHsl(.222f, .7f, .3f),
|
|
"Success" => Color.FromOkHsl(.375f, .3f, .2f),
|
|
"Failure" => Color.FromOkHsl(.055f, .3f, .2f),
|
|
_ => throw new UnreachableException(),
|
|
};
|
|
|
|
public void SetDescendantCount(int count)
|
|
{
|
|
for (var i = 0; i < count; i++)
|
|
{
|
|
var label = new Label { Text = (i + 1).ToString() };
|
|
AddChild(label);
|
|
SetSlot(i + 1, false, 0, Colors.Transparent, true, 0, Colors.FloralWhite);
|
|
}
|
|
}
|
|
}
|