1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 23:05:37 +08:00

Completely change the way we fix the bug

This commit is contained in:
Desconocidosmh 2019-07-09 11:32:49 +02:00
parent 8f7476e9cc
commit 2546f647be
5 changed files with 18 additions and 28 deletions

View File

@ -306,7 +306,7 @@ namespace osu.Game
private void currentTrackCompleted()
{
if (!Beatmap.Value.Track.Looping && !Beatmap.Disabled)
MusicController.NextTrack();
musicController.NextTrack();
}
#endregion
@ -484,7 +484,7 @@ namespace osu.Game
Origin = Anchor.TopRight,
}, rightFloatingOverlayContent.Add, true);
loadComponentSingleFile(MusicController = new MusicController
loadComponentSingleFile(musicController = new MusicController
{
GetToolbarHeight = () => ToolbarOffset,
Anchor = Anchor.TopRight,
@ -752,7 +752,7 @@ namespace osu.Game
private ScalingContainer screenContainer;
public MusicController MusicController { get; private set; }
private MusicController musicController;
protected override bool OnExiting()
{

View File

@ -55,6 +55,8 @@ namespace osu.Game.Overlays
private Container dragContainer;
private Container playerContainer;
public bool UserRequestedPause { get; private set; }
[Resolved]
private Bindable<WorkingBeatmap> beatmap { get; set; }
@ -66,8 +68,6 @@ namespace osu.Game.Overlays
/// </summary>
public Func<float> GetToolbarHeight;
public bool UserRequestedPause { get; private set; }
public MusicController()
{
Width = 400;

View File

@ -42,6 +42,9 @@ namespace osu.Game.Screens.Menu
[Resolved]
private GameHost host { get; set; }
[Resolved]
private MusicController musicController { get; set; }
private BackgroundScreenDefault background;
protected override BackgroundScreen CreateBackground() => background;
@ -120,15 +123,6 @@ namespace osu.Game.Screens.Menu
var track = Beatmap.Value.Track;
var metadata = Beatmap.Value.Metadata;
if (last is Intro && track != null && !Game.MusicController.UserRequestedPause)
{
if (!track.IsRunning)
{
track.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * track.Length);
track.Start();
}
}
Beatmap.ValueChanged += beatmap_ValueChanged;
}
@ -190,7 +184,11 @@ namespace osu.Game.Screens.Menu
//we may have consumed our preloaded instance, so let's make another.
preloadSongSelect();
ResumeIfNoUserPauseRequested();
if (Beatmap.Value.Track != null && !musicController.UserRequestedPause)
{
Beatmap.Value.Track.Tempo.Value = 1;
Beatmap.Value.Track.Start();
}
}
public override bool OnExiting(IScreen next)

View File

@ -50,7 +50,7 @@ namespace osu.Game.Screens
public virtual bool CursorVisible => true;
protected new OsuGame Game => base.Game as OsuGame;
protected new OsuGameBase Game => base.Game as OsuGameBase;
/// <summary>
/// The <see cref="UserActivity"/> to set the user's activity automatically to when this screen is entered
@ -179,15 +179,6 @@ namespace osu.Game.Screens
api.Activity.Value = activity;
}
protected void ResumeIfNoUserPauseRequested()
{
if (Beatmap.Value.Track != null && !Game.MusicController.UserRequestedPause)
{
Beatmap.Value.Track.Tempo.Value = 1;
Beatmap.Value.Track.Start();
}
}
/// <summary>
/// Fired when this screen was entered or resumed and the logo state is required to be adjusted.
/// </summary>

View File

@ -87,6 +87,9 @@ namespace osu.Game.Screens.Select
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
[Resolved]
private MusicController musicController { 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
@ -426,8 +429,6 @@ namespace osu.Game.Screens.Select
{
base.OnEntering(last);
ResumeIfNoUserPauseRequested();
this.FadeInFromZero(250);
FilterControl.Activate();
}
@ -572,7 +573,7 @@ namespace osu.Game.Screens.Select
{
Track track = Beatmap.Value.Track;
if (!track.IsRunning || restart)
if ((!track.IsRunning || restart) && !musicController.UserRequestedPause)
{
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
track.Restart();