mirror of
https://github.com/ppy/osu
synced 2024-12-16 03:45:46 +00:00
Merge pull request #25253 from bdach/fix-double-adjustment-application
Fix `StopUsingBeatmapClock()` applying adjustments to track it was supposed to stop using
This commit is contained in:
commit
344bb28469
@ -108,6 +108,28 @@ namespace osu.Game.Tests.Gameplay
|
||||
AddAssert("gameplay clock time = 10000", () => gameplayClockContainer.CurrentTime, () => Is.EqualTo(10000).Within(10f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStopUsingBeatmapClock()
|
||||
{
|
||||
ClockBackedTestWorkingBeatmap working = null;
|
||||
MasterGameplayClockContainer gameplayClockContainer = null;
|
||||
BindableDouble frequencyAdjustment = new BindableDouble(2);
|
||||
|
||||
AddStep("create container", () =>
|
||||
{
|
||||
working = new ClockBackedTestWorkingBeatmap(new OsuRuleset().RulesetInfo, new FramedClock(new ManualClock()), Audio);
|
||||
Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0);
|
||||
|
||||
gameplayClockContainer.Reset(startClock: true);
|
||||
});
|
||||
|
||||
AddStep("apply frequency adjustment", () => gameplayClockContainer.AdjustmentsFromMods.AddAdjustment(AdjustableProperty.Frequency, frequencyAdjustment));
|
||||
AddAssert("track frequency changed", () => working.Track.AggregateFrequency.Value, () => Is.EqualTo(2));
|
||||
|
||||
AddStep("stop using beatmap clock", () => gameplayClockContainer.StopUsingBeatmapClock());
|
||||
AddAssert("frequency adjustment unapplied", () => working.Track.AggregateFrequency.Value, () => Is.EqualTo(1));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
localConfig?.Dispose();
|
||||
|
@ -41,7 +41,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private readonly WorkingBeatmap beatmap;
|
||||
|
||||
private readonly Track track;
|
||||
private Track track;
|
||||
|
||||
private readonly double skipTargetTime;
|
||||
|
||||
@ -145,7 +145,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected override void StartGameplayClock()
|
||||
{
|
||||
addSourceClockAdjustments();
|
||||
addAdjustmentsToTrack();
|
||||
|
||||
base.StartGameplayClock();
|
||||
|
||||
@ -186,20 +186,20 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public void StopUsingBeatmapClock()
|
||||
{
|
||||
removeSourceClockAdjustments();
|
||||
removeAdjustmentsFromTrack();
|
||||
|
||||
var virtualTrack = new TrackVirtual(beatmap.Track.Length);
|
||||
virtualTrack.Seek(CurrentTime);
|
||||
track = new TrackVirtual(beatmap.Track.Length);
|
||||
track.Seek(CurrentTime);
|
||||
if (IsRunning)
|
||||
virtualTrack.Start();
|
||||
ChangeSource(virtualTrack);
|
||||
track.Start();
|
||||
ChangeSource(track);
|
||||
|
||||
addSourceClockAdjustments();
|
||||
addAdjustmentsToTrack();
|
||||
}
|
||||
|
||||
private bool speedAdjustmentsApplied;
|
||||
|
||||
private void addSourceClockAdjustments()
|
||||
private void addAdjustmentsToTrack()
|
||||
{
|
||||
if (speedAdjustmentsApplied)
|
||||
return;
|
||||
@ -213,7 +213,7 @@ namespace osu.Game.Screens.Play
|
||||
speedAdjustmentsApplied = true;
|
||||
}
|
||||
|
||||
private void removeSourceClockAdjustments()
|
||||
private void removeAdjustmentsFromTrack()
|
||||
{
|
||||
if (!speedAdjustmentsApplied)
|
||||
return;
|
||||
@ -228,7 +228,7 @@ namespace osu.Game.Screens.Play
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
removeSourceClockAdjustments();
|
||||
removeAdjustmentsFromTrack();
|
||||
}
|
||||
|
||||
ControlPointInfo IBeatSyncProvider.ControlPoints => beatmap.Beatmap.ControlPointInfo;
|
||||
|
Loading…
Reference in New Issue
Block a user