mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 08:52:55 +08:00
Remember user's selected pause state when changing game screens (#5289)
Remember user's selected pause state when changing game screens Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
c76b340a28
@ -55,6 +55,8 @@ namespace osu.Game.Overlays
|
||||
private Container dragContainer;
|
||||
private Container playerContainer;
|
||||
|
||||
public bool IsUserPaused { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
@ -157,7 +159,7 @@ namespace osu.Game.Overlays
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(1.4f),
|
||||
IconScale = new Vector2(1.4f),
|
||||
Action = play,
|
||||
Action = togglePause,
|
||||
Icon = FontAwesome.Regular.PlayCircle,
|
||||
},
|
||||
nextButton = new MusicIconButton
|
||||
@ -276,7 +278,7 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
|
||||
private void play()
|
||||
private void togglePause()
|
||||
{
|
||||
var track = current?.Track;
|
||||
|
||||
@ -288,9 +290,15 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
|
||||
if (track.IsRunning)
|
||||
{
|
||||
IsUserPaused = true;
|
||||
track.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
track.Start();
|
||||
IsUserPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void prev()
|
||||
|
@ -224,30 +224,32 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
public override void OnResuming(IScreen last)
|
||||
{
|
||||
Beatmap.Value.Track?.Stop();
|
||||
base.OnResuming(last);
|
||||
Beatmap.Value.Track?.Stop();
|
||||
}
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
Background.FadeColour(Color4.DarkGray, 500);
|
||||
Beatmap.Value.Track?.Stop();
|
||||
resetTrack();
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
{
|
||||
Background.FadeColour(Color4.White, 500);
|
||||
|
||||
if (Beatmap.Value.Track != null)
|
||||
{
|
||||
Beatmap.Value.Track.Tempo.Value = 1;
|
||||
Beatmap.Value.Track.Start();
|
||||
}
|
||||
resetTrack();
|
||||
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
private void resetTrack()
|
||||
{
|
||||
Beatmap.Value.Track?.ResetSpeedAdjustments();
|
||||
Beatmap.Value.Track?.Stop();
|
||||
}
|
||||
|
||||
private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save());
|
||||
|
||||
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)
|
||||
|
@ -42,6 +42,9 @@ namespace osu.Game.Screens.Menu
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private MusicController music { get; set; }
|
||||
|
||||
private BackgroundScreenDefault background;
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => background;
|
||||
@ -189,6 +192,9 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
//we may have consumed our preloaded instance, so let's make another.
|
||||
preloadSongSelect();
|
||||
|
||||
if (Beatmap.Value.Track != null && music?.IsUserPaused != true)
|
||||
Beatmap.Value.Track.Start();
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
|
@ -87,6 +87,9 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private MusicController music { get; set; }
|
||||
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
private readonly Bindable<IReadOnlyList<Mod>> mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>()); // Bound to the game's mods, but is not reset on exiting
|
||||
@ -570,7 +573,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
Track track = Beatmap.Value.Track;
|
||||
|
||||
if (!track.IsRunning || restart)
|
||||
if ((!track.IsRunning || restart) && music?.IsUserPaused != true)
|
||||
{
|
||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||
track.Restart();
|
||||
|
Loading…
Reference in New Issue
Block a user