1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Don't require a local storage variable for restoring playback speed

This commit is contained in:
Dean Herbert 2017-11-11 13:00:54 +09:00
parent 3142832693
commit 7d4e1b6f22

View File

@ -51,7 +51,6 @@ namespace osu.Game.Screens.Play
private IAdjustableClock adjustableSourceClock;
private FramedOffsetClock offsetClock;
private DecoupleableInterpolatingFramedClock decoupledClock;
private double clockRate;
private PauseContainer pauseContainer;
@ -157,10 +156,7 @@ namespace osu.Game.Screens.Play
Schedule(() =>
{
decoupledClock.ChangeSource(adjustableSourceClock);
foreach (var mod in working.Mods.Value.OfType<IApplicableToClock>())
mod.ApplyToClock(adjustableSourceClock);
clockRate = adjustableSourceClock.Rate;
applyRateFromMods();
});
});
@ -249,6 +245,13 @@ namespace osu.Game.Screens.Play
scoreProcessor.Failed += onFail;
}
private void applyRateFromMods()
{
adjustableSourceClock.Rate = 1;
foreach (var mod in Beatmap.Value.Mods.Value.OfType<IApplicableToClock>())
mod.ApplyToClock(adjustableSourceClock);
}
private void initializeStoryboard(bool asyncLoad)
{
var beatmap = Beatmap.Value.Beatmap;
@ -346,8 +349,9 @@ namespace osu.Game.Screens.Play
{
if (HasFailed || !ValidForResume || pauseContainer?.AllowExit != false || RulesetContainer?.HasReplayLoaded != false)
{
// We want to make sure we restore the clock rate
adjustableSourceClock.Rate = clockRate;
// In the case of replays, we may have changed the playback rate.
applyRateFromMods();
fadeOut();
return base.OnExiting(next);
}