Files
sbox-public/game/editor/ActionGraph/Code/WarningFrame.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

36 lines
771 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; }
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 );
}
}