mirror of
https://github.com/ppy/osu.git
synced 2025-01-09 00:13:01 +08:00
Merge pull request #8100 from smoogipoo/fix-testscene-rate
Fix test scene virtual track not respecting rate adjustments
This commit is contained in:
commit
8ceaa39fb4
@ -0,0 +1,35 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests.Mods
|
||||||
|
{
|
||||||
|
public class TestSceneOsuModDoubleTime : ModTestScene
|
||||||
|
{
|
||||||
|
public TestSceneOsuModDoubleTime()
|
||||||
|
: base(new OsuRuleset())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(0.5)]
|
||||||
|
[TestCase(1.01)]
|
||||||
|
[TestCase(1.5)]
|
||||||
|
[TestCase(2)]
|
||||||
|
[TestCase(5)]
|
||||||
|
public void TestSpeedChangeCustomisation(double rate)
|
||||||
|
{
|
||||||
|
var mod = new OsuModDoubleTime { SpeedChange = { Value = rate } };
|
||||||
|
|
||||||
|
CreateModTest(new ModTestData
|
||||||
|
{
|
||||||
|
Mod = mod,
|
||||||
|
PassCondition = () => Player.ScoreProcessor.JudgedHits >= 2 &&
|
||||||
|
Precision.AlmostEquals(Player.GameplayClockContainer.GameplayClock.Rate, mod.SpeedChange.Value)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -116,7 +116,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
var progress = Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime));
|
var progress = fadeOutBeginTime <= displayTime ? 1 : Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime));
|
||||||
|
|
||||||
remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
||||||
|
|
||||||
|
@ -231,15 +231,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
private readonly IFrameBasedClock referenceClock;
|
private readonly IFrameBasedClock referenceClock;
|
||||||
|
|
||||||
private readonly ManualClock clock = new ManualClock();
|
|
||||||
|
|
||||||
private bool running;
|
private bool running;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Local offset added to the reference clock to resolve correct time.
|
|
||||||
/// </summary>
|
|
||||||
private double offset;
|
|
||||||
|
|
||||||
public TrackVirtualManual(IFrameBasedClock referenceClock)
|
public TrackVirtualManual(IFrameBasedClock referenceClock)
|
||||||
{
|
{
|
||||||
this.referenceClock = referenceClock;
|
this.referenceClock = referenceClock;
|
||||||
@ -248,10 +241,10 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public override bool Seek(double seek)
|
public override bool Seek(double seek)
|
||||||
{
|
{
|
||||||
offset = Math.Clamp(seek, 0, Length);
|
accumulated = Math.Clamp(seek, 0, Length);
|
||||||
lastReferenceTime = null;
|
lastReferenceTime = null;
|
||||||
|
|
||||||
return offset == seek;
|
return accumulated == seek;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Start()
|
public override void Start()
|
||||||
@ -270,9 +263,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
if (running)
|
if (running)
|
||||||
{
|
{
|
||||||
running = false;
|
running = false;
|
||||||
// on stopping, the current value should be transferred out of the clock, as we can no longer rely on
|
|
||||||
// the referenceClock (which will still be counting time).
|
|
||||||
offset = clock.CurrentTime;
|
|
||||||
lastReferenceTime = null;
|
lastReferenceTime = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,7 +271,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private double? lastReferenceTime;
|
private double? lastReferenceTime;
|
||||||
|
|
||||||
public override double CurrentTime => clock.CurrentTime;
|
private double accumulated;
|
||||||
|
|
||||||
|
public override double CurrentTime => Math.Min(accumulated, Length);
|
||||||
|
|
||||||
protected override void UpdateState()
|
protected override void UpdateState()
|
||||||
{
|
{
|
||||||
@ -291,18 +283,12 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
double refTime = referenceClock.CurrentTime;
|
double refTime = referenceClock.CurrentTime;
|
||||||
|
|
||||||
if (!lastReferenceTime.HasValue)
|
if (lastReferenceTime.HasValue)
|
||||||
{
|
accumulated += (refTime - lastReferenceTime.Value) * Rate;
|
||||||
// if the clock just started running, the current value should be transferred to the offset
|
|
||||||
// (to zero the progression of time).
|
|
||||||
offset -= refTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastReferenceTime = refTime;
|
lastReferenceTime = refTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
clock.CurrentTime = Math.Min((lastReferenceTime ?? 0) + offset, Length);
|
|
||||||
|
|
||||||
if (CurrentTime >= Length)
|
if (CurrentTime >= Length)
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
Loading…
Reference in New Issue
Block a user