mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 01:22:59 +08:00
Tidy up and comment PlayerLoader logic.
This commit is contained in:
parent
2ccb8b154f
commit
edd71c0560
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
|
||||
public Action OnRestart;
|
||||
public Action RestartRequested;
|
||||
|
||||
public bool IsPaused => !interpolatedSourceClock.IsRunning;
|
||||
|
||||
@ -249,7 +249,7 @@ namespace osu.Game.Screens.Play
|
||||
public void Restart()
|
||||
{
|
||||
ValidForResume = false;
|
||||
OnRestart?.Invoke();
|
||||
RestartRequested?.Invoke();
|
||||
Exit();
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,16 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public PlayerLoader(Player player)
|
||||
{
|
||||
this.player = player;
|
||||
|
||||
//By default, we want to load the player and never be returned to.
|
||||
//Note that this may change if the player we load requested a re-run.
|
||||
ValidForResume = false;
|
||||
|
||||
player.OnRestart = restart;
|
||||
|
||||
this.player = player;
|
||||
player.RestartRequested = () => {
|
||||
showOverlays = false;
|
||||
ValidForResume = true;
|
||||
};
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -45,7 +50,6 @@ namespace osu.Game.Screens.Play
|
||||
Interactive = false,
|
||||
},
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -64,13 +68,14 @@ namespace osu.Game.Screens.Play
|
||||
protected override void OnResuming(Screen last)
|
||||
{
|
||||
base.OnResuming(last);
|
||||
if (last != player) return;
|
||||
player = new Player
|
||||
|
||||
//we will only be resumed if the player has requested a re-run (see ValidForResume setting above)
|
||||
LoadComponentAsync(player = new Player
|
||||
{
|
||||
RestartCount = player.RestartCount + 1,
|
||||
OnRestart = restart
|
||||
};
|
||||
LoadComponentAsync(player, delegate
|
||||
RestartRequested = player.RestartRequested,
|
||||
Beatmap = player.Beatmap,
|
||||
}, p =>
|
||||
{
|
||||
if (!Push(player))
|
||||
Exit();
|
||||
@ -78,12 +83,6 @@ namespace osu.Game.Screens.Play
|
||||
});
|
||||
}
|
||||
|
||||
private void restart()
|
||||
{
|
||||
showOverlays = false;
|
||||
ValidForResume = true;
|
||||
}
|
||||
|
||||
protected override void OnEntering(Screen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
Loading…
Reference in New Issue
Block a user