mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 18:17:09 +02:00
32 lines
763 B
C#
32 lines
763 B
C#
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Robust.Client.UserInterface.CustomControls
|
|
{
|
|
public sealed class FpsCounter : Label
|
|
{
|
|
private readonly IGameTiming _gameTiming;
|
|
|
|
public FpsCounter(IGameTiming gameTiming)
|
|
{
|
|
_gameTiming = gameTiming;
|
|
|
|
FontColorShadowOverride = Color.Black;
|
|
ShadowOffsetXOverride = 1;
|
|
ShadowOffsetYOverride = 1;
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
if (!VisibleInTree)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var fps = _gameTiming.FramesPerSecondAvg;
|
|
Text = $"FPS: {fps:N0}";
|
|
}
|
|
}
|
|
}
|