mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:32: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 dragContainer;
|
||||||
private Container playerContainer;
|
private Container playerContainer;
|
||||||
|
|
||||||
|
public bool IsUserPaused { get; private set; }
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
||||||
|
|
||||||
@ -157,7 +159,7 @@ namespace osu.Game.Overlays
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Scale = new Vector2(1.4f),
|
Scale = new Vector2(1.4f),
|
||||||
IconScale = new Vector2(1.4f),
|
IconScale = new Vector2(1.4f),
|
||||||
Action = play,
|
Action = togglePause,
|
||||||
Icon = FontAwesome.Regular.PlayCircle,
|
Icon = FontAwesome.Regular.PlayCircle,
|
||||||
},
|
},
|
||||||
nextButton = new MusicIconButton
|
nextButton = new MusicIconButton
|
||||||
@ -276,7 +278,7 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void play()
|
private void togglePause()
|
||||||
{
|
{
|
||||||
var track = current?.Track;
|
var track = current?.Track;
|
||||||
|
|
||||||
@ -288,9 +290,15 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (track.IsRunning)
|
if (track.IsRunning)
|
||||||
|
{
|
||||||
|
IsUserPaused = true;
|
||||||
track.Stop();
|
track.Stop();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
track.Start();
|
track.Start();
|
||||||
|
IsUserPaused = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prev()
|
private void prev()
|
||||||
|
@ -224,30 +224,32 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public override void OnResuming(IScreen last)
|
public override void OnResuming(IScreen last)
|
||||||
{
|
{
|
||||||
Beatmap.Value.Track?.Stop();
|
|
||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
|
Beatmap.Value.Track?.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
{
|
{
|
||||||
base.OnEntering(last);
|
base.OnEntering(last);
|
||||||
|
|
||||||
Background.FadeColour(Color4.DarkGray, 500);
|
Background.FadeColour(Color4.DarkGray, 500);
|
||||||
Beatmap.Value.Track?.Stop();
|
resetTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
Background.FadeColour(Color4.White, 500);
|
Background.FadeColour(Color4.White, 500);
|
||||||
|
resetTrack();
|
||||||
if (Beatmap.Value.Track != null)
|
|
||||||
{
|
|
||||||
Beatmap.Value.Track.Tempo.Value = 1;
|
|
||||||
Beatmap.Value.Track.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.OnExiting(next);
|
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 exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save());
|
||||||
|
|
||||||
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)
|
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)
|
||||||
|
@ -42,6 +42,9 @@ namespace osu.Game.Screens.Menu
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private MusicController music { get; set; }
|
||||||
|
|
||||||
private BackgroundScreenDefault background;
|
private BackgroundScreenDefault background;
|
||||||
|
|
||||||
protected override BackgroundScreen CreateBackground() => 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.
|
//we may have consumed our preloaded instance, so let's make another.
|
||||||
preloadSongSelect();
|
preloadSongSelect();
|
||||||
|
|
||||||
|
if (Beatmap.Value.Track != null && music?.IsUserPaused != true)
|
||||||
|
Beatmap.Value.Track.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
|
@ -87,6 +87,9 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private MusicController music { get; set; }
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
[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
|
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;
|
Track track = Beatmap.Value.Track;
|
||||||
|
|
||||||
if (!track.IsRunning || restart)
|
if ((!track.IsRunning || restart) && music?.IsUserPaused != true)
|
||||||
{
|
{
|
||||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||||
track.Restart();
|
track.Restart();
|
||||||
|
Loading…
Reference in New Issue
Block a user