mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-20 04:10:00 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
36 lines
771 B
C#
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 );
|
|
}
|
|
}
|