mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
Expose the loading player in PlayerLoader
This commit is contained in:
parent
e2c0e3bafd
commit
da76358ee0
@ -90,7 +90,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private bool readyForPush =>
|
private bool readyForPush =>
|
||||||
!playerConsumed
|
!playerConsumed
|
||||||
// don't push unless the player is completely loaded
|
// don't push unless the player is completely loaded
|
||||||
&& player?.LoadState == LoadState.Ready
|
&& CurrentPlayer?.LoadState == LoadState.Ready
|
||||||
// don't push if the user is hovering one of the panes, unless they are idle.
|
// don't push if the user is hovering one of the panes, unless they are idle.
|
||||||
&& (IsHovered || idleTracker.IsIdle.Value)
|
&& (IsHovered || idleTracker.IsIdle.Value)
|
||||||
// don't push if the user is dragging a slider or otherwise.
|
// don't push if the user is dragging a slider or otherwise.
|
||||||
@ -100,10 +100,14 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly Func<Player> createPlayer;
|
private readonly Func<Player> createPlayer;
|
||||||
|
|
||||||
private Player player;
|
/// <summary>
|
||||||
|
/// The <see cref="Player"/> instance being loaded by this screen.
|
||||||
|
/// </summary>
|
||||||
|
[CanBeNull]
|
||||||
|
public Player CurrentPlayer { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the curent player instance has been consumed via <see cref="consumePlayer"/>.
|
/// Whether the current player instance has been consumed via <see cref="consumePlayer"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool playerConsumed;
|
private bool playerConsumed;
|
||||||
|
|
||||||
@ -237,12 +241,12 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
|
|
||||||
var lastScore = player.Score;
|
var lastScore = CurrentPlayer.Score;
|
||||||
|
|
||||||
AudioSettings.ReferenceScore.Value = lastScore?.ScoreInfo;
|
AudioSettings.ReferenceScore.Value = lastScore?.ScoreInfo;
|
||||||
|
|
||||||
// prepare for a retry.
|
// prepare for a retry.
|
||||||
player = null;
|
CurrentPlayer = null;
|
||||||
playerConsumed = false;
|
playerConsumed = false;
|
||||||
cancelLoad();
|
cancelLoad();
|
||||||
|
|
||||||
@ -346,7 +350,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Debug.Assert(!playerConsumed);
|
Debug.Assert(!playerConsumed);
|
||||||
|
|
||||||
playerConsumed = true;
|
playerConsumed = true;
|
||||||
return player;
|
return CurrentPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareNewPlayer()
|
private void prepareNewPlayer()
|
||||||
@ -354,11 +358,11 @@ namespace osu.Game.Screens.Play
|
|||||||
if (!this.IsCurrentScreen())
|
if (!this.IsCurrentScreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player = createPlayer();
|
CurrentPlayer = createPlayer();
|
||||||
player.RestartCount = restartCount++;
|
CurrentPlayer.RestartCount = restartCount++;
|
||||||
player.RestartRequested = restartRequested;
|
CurrentPlayer.RestartRequested = restartRequested;
|
||||||
|
|
||||||
LoadTask = LoadComponentAsync(player, _ => MetadataInfo.Loading = false);
|
LoadTask = LoadComponentAsync(CurrentPlayer, _ => MetadataInfo.Loading = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restartRequested()
|
private void restartRequested()
|
||||||
@ -472,7 +476,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (isDisposing)
|
if (isDisposing)
|
||||||
{
|
{
|
||||||
// if the player never got pushed, we should explicitly dispose it.
|
// if the player never got pushed, we should explicitly dispose it.
|
||||||
DisposalTask = LoadTask?.ContinueWith(_ => player?.Dispose());
|
DisposalTask = LoadTask?.ContinueWith(_ => CurrentPlayer?.Dispose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user