Files
RobustToolbox/Robust.Client/UserInterface/CustomControls/FpsCounter.cs
T
Acruid 3203ca2ff4 Removed Control.Update from the UI system. UI Controls have no business running code in simulation updates.
Refactored the client update loop so that the GameStateManager is in full control of the simulation update.
2021-03-26 17:46:34 -07:00

32 lines
765 B
C#

using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
namespace Robust.Client.UserInterface.CustomControls
{
internal 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:N1}";
}
}
}