Ensure track is stopped on player completion

This commit is contained in:
Bartłomiej Dach 2021-11-11 15:45:10 +01:00
parent 385df51b06
commit c465bcb821
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
2 changed files with 13 additions and 0 deletions

View File

@ -106,7 +106,9 @@ namespace osu.Game.Tests.Visual.Editing
EditorPlayer editorPlayer = null;
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
AddAssert("beatmap has 1 object", () => editorPlayer.Beatmap.Value.Beatmap.HitObjects.Count == 1);
AddUntilStep("wait for return to editor", () => Stack.CurrentScreen is Editor);
AddAssert("track stopped", () => !Beatmap.Value.Track.IsRunning);
}
public override void TearDownSteps()

View File

@ -1,7 +1,9 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Screens;
using osu.Game.Overlays;
using osu.Game.Screens.Play;
namespace osu.Game.Screens.Edit
@ -13,6 +15,9 @@ namespace osu.Game.Screens.Edit
{
}
[Resolved]
private MusicController musicController { get; set; }
protected override void LoadComplete()
{
base.LoadComplete();
@ -29,5 +34,11 @@ namespace osu.Game.Screens.Edit
}
protected override bool CheckModsAllowFailure() => false; // never fail.
public override bool OnExiting(IScreen next)
{
musicController.Stop();
return base.OnExiting(next);
}
}
}