Merge branch 'master' into progress-bar-show-seek

This commit is contained in:
Dean Herbert
2019-05-10 17:27:49 +09:00
committed by GitHub
7 changed files with 70 additions and 41 deletions

View File

@ -17,20 +17,29 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public class FrameStabilityContainer : Container, IHasReplayHandler
{
public FrameStabilityContainer()
private readonly double gameplayStartTime;
/// <summary>
/// The number of frames (per parent frame) which can be run in an attempt to catch-up to real-time.
/// </summary>
public int MaxCatchUpFrames { get; set; } = 5;
[Cached]
public GameplayClock GameplayClock { get; }
public FrameStabilityContainer(double gameplayStartTime = double.MinValue)
{
RelativeSizeAxes = Axes.Both;
GameplayClock = new GameplayClock(framedClock = new FramedClock(manualClock = new ManualClock()));
this.gameplayStartTime = gameplayStartTime;
}
private readonly ManualClock manualClock;
private readonly FramedClock framedClock;
[Cached]
public GameplayClock GameplayClock { get; }
private IFrameBasedClock parentGameplayClock;
[BackgroundDependencyLoader(true)]
@ -65,8 +74,6 @@ namespace osu.Game.Rulesets.UI
private bool isAttached => ReplayInputHandler != null;
private const int max_catch_up_updates_per_frame = 50;
private const double sixty_frame_time = 1000.0 / 60;
private bool firstConsumption = true;
@ -78,7 +85,7 @@ namespace osu.Game.Rulesets.UI
int loops = 0;
while (validState && requireMoreUpdateLoops && loops++ < max_catch_up_updates_per_frame)
while (validState && requireMoreUpdateLoops && loops++ < MaxCatchUpFrames)
{
updateClock();
@ -117,6 +124,8 @@ namespace osu.Game.Rulesets.UI
firstConsumption = false;
}
else if (manualClock.CurrentTime < gameplayStartTime)
manualClock.CurrentTime = newProposedTime = Math.Min(gameplayStartTime, newProposedTime);
else if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
{
newProposedTime = newProposedTime > manualClock.CurrentTime