Scale frame debug into control boundaries (#1305)

* Scale frame debug into control boundaries

* Remove unnecessary  cache
This commit is contained in:
Jan Nekvapil
2020-10-06 09:47:50 +02:00
committed by GitHub
parent c96d5933d5
commit 5bf4e9ae1a

View File

@@ -58,13 +58,22 @@ namespace Robust.Client.UserInterface.CustomControls
{
base.Draw(handle);
for (var i = 0; i < TrackedFrames; i++)
float maxHeight = 0;
for (var i = 0; i < _frameTimes.Length; i++)
{
var currentFrameIndex = MathHelper.Mod(_frameIndex - 1 - i, TrackedFrames);
var frameTime = _frameTimes[currentFrameIndex];
maxHeight = System.Math.Max(maxHeight, FrameHeight * (frameTime * TargetFrameRate));
}
float ratio = maxHeight > PixelHeight ? PixelHeight / maxHeight : 1;
for(int i = 0; i < _frameTimes.Length; i++)
{
var currentFrameIndex = MathHelper.Mod(_frameIndex - 1 - i, TrackedFrames);
var frameTime = _frameTimes[currentFrameIndex];
var frameHeight = FrameHeight * (frameTime * TargetFrameRate);
var x = FrameWidth * UserInterfaceManager.UIScale * (TrackedFrames - 1 - i);
var frameHeight = FrameHeight * (frameTime / (1f / TargetFrameRate));
var rect = new UIBox2(x, PixelHeight - frameHeight, x + FrameWidth * UserInterfaceManager.UIScale, PixelHeight);
var rect = new UIBox2(x, PixelHeight - (frameHeight * ratio), x + FrameWidth * UserInterfaceManager.UIScale, PixelHeight);
Color color;
if (frameTime > 1f / (TargetFrameRate / 2 - 1))
@@ -79,7 +88,6 @@ namespace Robust.Client.UserInterface.CustomControls
{
color = Color.Lime;
}
handle.DrawRect(rect, color);
}
}