mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-19 13:59:22 -04:00
36 lines
833 B
C#
36 lines
833 B
C#
using Sandbox.UI.Construct;
|
|
|
|
namespace Sandbox.UI.Dev;
|
|
|
|
public class ExceptionNotification : Panel
|
|
{
|
|
Label message;
|
|
RealTimeSince TimeSinceLastError;
|
|
|
|
public ExceptionNotification()
|
|
{
|
|
Add.Icon( "😥" );
|
|
|
|
var column = new Panel( this, "column" );
|
|
column.AddChild( new Label() { Text = "Code Error" } );
|
|
|
|
message = column.Add.Label( "Something went wrong! This is an exception notice!", "message" );
|
|
SetClass( "hidden", true );
|
|
TimeSinceLastError = 100;
|
|
}
|
|
|
|
public override void Tick()
|
|
{
|
|
base.Tick();
|
|
|
|
SetClass( "hidden", TimeSinceLastError > 8 );
|
|
SetClass( "fresh", TimeSinceLastError < 0.2f );
|
|
}
|
|
|
|
internal void OnException( LogEvent entry )
|
|
{
|
|
message.Text = entry.Message?.Split( '\n', System.StringSplitOptions.RemoveEmptyEntries ).FirstOrDefault()?.Trim() ?? "null";
|
|
TimeSinceLastError = 0;
|
|
}
|
|
}
|