mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Merge pull request #15048 from bdach/frame-stability-container-direction-flip
Fix key counter overlay not rewinding count fully
This commit is contained in:
commit
d3c3aa620f
@ -103,6 +103,30 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
checkFrameCount(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRatePreservedWhenTimeNotProgressing()
|
||||
{
|
||||
AddStep("set manual clock rate", () => manualClock.Rate = 1);
|
||||
seekManualTo(5000);
|
||||
createStabilityContainer();
|
||||
checkRate(1);
|
||||
|
||||
seekManualTo(10000);
|
||||
checkRate(1);
|
||||
|
||||
AddWaitStep("wait some", 3);
|
||||
checkRate(1);
|
||||
|
||||
seekManualTo(5000);
|
||||
checkRate(-1);
|
||||
|
||||
AddWaitStep("wait some", 3);
|
||||
checkRate(-1);
|
||||
|
||||
seekManualTo(10000);
|
||||
checkRate(1);
|
||||
}
|
||||
|
||||
private const int max_frames_catchup = 50;
|
||||
|
||||
private void createStabilityContainer(double gameplayStartTime = double.MinValue) => AddStep("create container", () =>
|
||||
@ -116,6 +140,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private void checkFrameCount(int frames) =>
|
||||
AddAssert($"elapsed frames is {frames}", () => consumer.ElapsedFrames == frames);
|
||||
|
||||
private void checkRate(double rate) =>
|
||||
AddAssert($"clock rate is {rate}", () => consumer.Clock.Rate == rate);
|
||||
|
||||
public class ClockConsumingChild : CompositeDrawable
|
||||
{
|
||||
private readonly OsuSpriteText text;
|
||||
|
@ -55,7 +55,10 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <summary>
|
||||
/// The current direction of playback to be exposed to frame stable children.
|
||||
/// </summary>
|
||||
private int direction;
|
||||
/// <remarks>
|
||||
/// Initially it is presumed that playback will proceed in the forward direction.
|
||||
/// </remarks>
|
||||
private int direction = 1;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(GameplayClock clock, ISamplePlaybackDisabler sampleDisabler)
|
||||
@ -139,7 +142,9 @@ namespace osu.Game.Rulesets.UI
|
||||
state = PlaybackState.NotValid;
|
||||
}
|
||||
|
||||
if (state == PlaybackState.Valid)
|
||||
// if the proposed time is the same as the current time, assume that the clock will continue progressing in the same direction as previously.
|
||||
// this avoids spurious flips in direction from -1 to 1 during rewinds.
|
||||
if (state == PlaybackState.Valid && proposedTime != manualClock.CurrentTime)
|
||||
direction = proposedTime >= manualClock.CurrentTime ? 1 : -1;
|
||||
|
||||
double timeBehind = Math.Abs(proposedTime - parentGameplayClock.CurrentTime);
|
||||
|
Loading…
Reference in New Issue
Block a user