Files
sbox-public/game/editor/ShaderGraph/Code/PerformanceBar.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

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();
}
}