1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Always show counter temporarily when aim FPS changes

This commit is contained in:
Dean Herbert 2022-07-21 12:57:38 +09:00
parent 705ff06ea5
commit 311a0a3de0

View File

@ -127,6 +127,9 @@ namespace osu.Game.Graphics.UserInterface
private ScheduledDelegate? fadeOutDelegate;
private double aimDrawFPS;
private double aimUpdateFPS;
private void displayTemporarily()
{
if (!isDisplayed)
@ -155,13 +158,9 @@ namespace osu.Game.Graphics.UserInterface
{
base.Update();
double aimDrawFPS = gameHost.DrawThread.Clock.MaximumUpdateHz;
double aimUpdateFPS = gameHost.UpdateThread.Clock.MaximumUpdateHz;
if (!gameHost.UpdateThread.Clock.Throttling)
{
aimUpdateFPS = aimDrawFPS = gameHost.InputThread.Clock.MaximumUpdateHz;
}
// Handle the case where the window has become inactive or the user changed the
// frame limiter (we want to show the FPS as it's changing, even if it isn't an outlier).
bool aimRatesChanged = updateAimFPS();
// TODO: this is wrong (elapsed clock time, not actual run time).
double newUpdateFrameTime = gameHost.UpdateThread.Clock.ElapsedFrameTime;
@ -189,7 +188,8 @@ namespace osu.Game.Graphics.UserInterface
double displayedUpdateFPS = 1000 / counterUpdateFrameTime.DisplayedCount;
counterUpdateFrameTime.Colour = getColour(displayedUpdateFPS / aimUpdateFPS);
bool hasSignificantChanges = hasDrawSpike
bool hasSignificantChanges = aimRatesChanged
|| hasDrawSpike
|| hasUpdateSpike
|| counterDrawFPS.DisplayedCount < aimDrawFPS * 0.8
|| displayedUpdateFPS < aimUpdateFPS * 0.8;
@ -198,6 +198,34 @@ namespace osu.Game.Graphics.UserInterface
displayTemporarily();
}
private bool updateAimFPS()
{
if (gameHost.UpdateThread.Clock.Throttling)
{
double newAimDrawFPS = gameHost.DrawThread.Clock.MaximumUpdateHz;
double newAimUpdateFPS = gameHost.UpdateThread.Clock.MaximumUpdateHz;
if (aimDrawFPS != newAimDrawFPS || aimUpdateFPS != newAimUpdateFPS)
{
aimDrawFPS = newAimDrawFPS;
aimUpdateFPS = newAimUpdateFPS;
return true;
}
}
else
{
double newAimFPS = gameHost.InputThread.Clock.MaximumUpdateHz;
if (aimDrawFPS != newAimFPS || aimUpdateFPS != newAimFPS)
{
aimUpdateFPS = aimDrawFPS = newAimFPS;
return true;
}
}
return false;
}
private ColourInfo getColour(double performanceRatio)
{
if (performanceRatio < 0.5f)