mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:05:37 +08:00
Ensure clock is set in GCC.Start()
This commit is contained in:
parent
8dd9134e3d
commit
88ded95e75
@ -25,8 +25,34 @@ namespace osu.Game.Tests.Gameplay
|
||||
Add(gcc = new MasterGameplayClockContainer(working, 0));
|
||||
});
|
||||
|
||||
AddStep("start track", () => gcc.Start());
|
||||
AddStep("start clock", () => gcc.Start());
|
||||
AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestElapseThenReset()
|
||||
{
|
||||
GameplayClockContainer gcc = null;
|
||||
|
||||
AddStep("create container", () =>
|
||||
{
|
||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
working.LoadTrack();
|
||||
|
||||
Add(gcc = new MasterGameplayClockContainer(working, 0));
|
||||
});
|
||||
|
||||
AddStep("start clock", () => gcc.Start());
|
||||
AddUntilStep("current time greater 2000", () => gcc.GameplayClock.CurrentTime > 2000);
|
||||
|
||||
double timeAtReset = 0;
|
||||
AddStep("reset clock", () =>
|
||||
{
|
||||
timeAtReset = gcc.GameplayClock.CurrentTime;
|
||||
gcc.Reset();
|
||||
});
|
||||
|
||||
AddAssert("current time < time at reset", () => gcc.GameplayClock.CurrentTime < timeAtReset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Globalization;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Timing;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
@ -68,6 +70,9 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public virtual void Start()
|
||||
{
|
||||
// Ensure that the source clock is set.
|
||||
ChangeSource(SourceClock);
|
||||
|
||||
if (!AdjustableSource.IsRunning)
|
||||
{
|
||||
// Seeking the decoupled clock to its current time ensures that its source clock will be seeked to the same time
|
||||
@ -96,8 +101,6 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public virtual void Reset()
|
||||
{
|
||||
ChangeSource(SourceClock);
|
||||
|
||||
AdjustableSource.Seek(StartOffset);
|
||||
AdjustableSource.Stop();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user