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]
45 lines
838 B
C#
45 lines
838 B
C#
|
|
namespace Editor.ShaderGraph;
|
|
|
|
internal class GamePerformanceBar : Widget
|
|
{
|
|
private readonly Func<string> _getValue;
|
|
private RealTimeSince _timeSinceUpdate;
|
|
|
|
public GamePerformanceBar( Func<string> val ) : base( null )
|
|
{
|
|
_getValue = val;
|
|
|
|
MinimumHeight = Theme.RowHeight;
|
|
MinimumWidth = 60;
|
|
}
|
|
|
|
protected override void DoLayout()
|
|
{
|
|
base.DoLayout();
|
|
}
|
|
|
|
protected override void OnPaint()
|
|
{
|
|
base.OnPaint();
|
|
|
|
Paint.ClearPen();
|
|
Paint.SetBrush( Theme.ControlBackground );
|
|
Paint.DrawRect( LocalRect, Theme.ControlRadius );
|
|
|
|
Paint.SetPen( Theme.Green.WithAlpha( 0.4f ) );
|
|
Paint.DrawText( LocalRect.Shrink( 8, 0 ), _getValue(), TextFlag.RightCenter );
|
|
}
|
|
|
|
[EditorEvent.Frame]
|
|
public void Frame()
|
|
{
|
|
if ( _timeSinceUpdate < 0.6f )
|
|
return;
|
|
|
|
_timeSinceUpdate = Random.Shared.Float( 0, 0.1f );
|
|
|
|
Update();
|
|
}
|
|
}
|