1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 15:43:21 +08:00

Don't inherit ReplayPlayer to make results screen work correctly

This commit is contained in:
Dean Herbert 2020-10-28 18:40:06 +09:00
parent 344ff8f4bc
commit 93e3e1a4db

View File

@ -11,11 +11,16 @@ using osu.Game.Screens.Ranking;
namespace osu.Game.Screens.Play
{
public class SpectatorPlayer : ReplayPlayer
public class SpectatorPlayer : Player
{
private readonly Score score;
protected override bool CheckModsAllowFailure() => false; // todo: better support starting mid-way through beatmap
public SpectatorPlayer(Score score)
: base(score)
: base(true, true)
{
this.score = score;
}
protected override ResultsScreen CreateResults(ScoreInfo score)
@ -32,9 +37,14 @@ namespace osu.Game.Screens.Play
spectatorStreaming.OnUserBeganPlaying += userBeganPlaying;
}
protected override void PrepareReplay()
{
DrawableRuleset?.SetReplayScore(score);
}
private void userBeganPlaying(int userId, SpectatorState state)
{
if (userId == Score.ScoreInfo.UserID)
if (userId == score.ScoreInfo.UserID)
Schedule(this.Exit);
}
@ -49,7 +59,7 @@ namespace osu.Game.Screens.Play
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
{
// if we already have frames, start gameplay at the point in time they exist, should they be too far into the beatmap.
double? firstFrameTime = Score.Replay.Frames.FirstOrDefault()?.Time;
double? firstFrameTime = score.Replay.Frames.FirstOrDefault()?.Time;
if (firstFrameTime == null || firstFrameTime <= gameplayStart + 5000)
return base.CreateGameplayClockContainer(beatmap, gameplayStart);