Files
sbox-public/game/editor/ActionGraph/Code/WarningFrame.cs
James King 839c60100c Fix action graph editor regressions (#3590)
* Fix scene reference gizmos not showing up
* Fix links not pulsing when viewing a graph in play mode
* Fix undo system error when action graph gizmos are selected in scene view
* Fix warning about when a graph can be saved or not
* Fix some SerializedObject.IsValid / SerializedProperty.IsValid implementations
* Fixed errors in console when opening the node creation menu
* Fix possible error when dragging links during play mode
* Fix errors when opening some graphs that reference removed component types
* Strip action graph editor code from engine projects
2026-01-05 10:34:52 +01:00

46 lines
849 B
C#

using Sandbox;
namespace Editor.ActionGraphs;
#nullable enable
public sealed class WarningFrame : Widget
{
public Color Color { get; set; } = Color.Parse( "#FA9131" )!.Value;
public string? Text
{
get;
set
{
if ( field == value ) return;
field = value;
Update();
}
}
public WarningFrame()
{
TransparentForMouseEvents = true;
}
protected override void OnPaint()
{
if ( string.IsNullOrEmpty( Text ) ) return;
Paint.SetPen( Color, 8f );
Paint.DrawRect( LocalRect );
Paint.SetDefaultFont( 10f );
var textRect = LocalRect.Contain( Paint.MeasureText( Text ) + new Vector2( 16f, 8f ), TextFlag.RightBottom );
Paint.ClearPen();
Paint.SetBrush( Color );
Paint.DrawRect( textRect.Shrink( 0f, 0f, 4f, 4f ) );
Paint.ClearBrush();
Paint.SetPen( Color.Black );
Paint.DrawText( textRect, Text );
}
}