1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:02:55 +08:00

Allow continuing to automatically spectate user from results screen

This commit is contained in:
Dean Herbert 2020-10-28 18:05:15 +09:00
parent 16b0a7b33e
commit c97feb09bf
2 changed files with 59 additions and 3 deletions

View File

@ -7,19 +7,25 @@ using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Online.Spectator;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
namespace osu.Game.Screens.Play
{
public class SpectatorPlayer : ReplayPlayer
{
[Resolved]
private SpectatorStreamingClient spectatorStreaming { get; set; }
public SpectatorPlayer(Score score)
: base(score)
{
}
protected override ResultsScreen CreateResults(ScoreInfo score)
{
return new SpectatorResultsScreen(score);
}
[Resolved]
private SpectatorStreamingClient spectatorStreaming { get; set; }
[BackgroundDependencyLoader]
private void load()
{
@ -32,6 +38,14 @@ namespace osu.Game.Screens.Play
Schedule(this.Exit);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (spectatorStreaming != null)
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
}
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.

View File

@ -0,0 +1,42 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Screens;
using osu.Game.Online.Spectator;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
namespace osu.Game.Screens.Play
{
public class SpectatorResultsScreen : SoloResultsScreen
{
public SpectatorResultsScreen(ScoreInfo score)
: base(score)
{
}
[Resolved]
private SpectatorStreamingClient spectatorStreaming { get; set; }
[BackgroundDependencyLoader]
private void load()
{
spectatorStreaming.OnUserBeganPlaying += userBeganPlaying;
}
private void userBeganPlaying(int userId, SpectatorState state)
{
if (userId == Score.UserID)
Schedule(this.Exit);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (spectatorStreaming != null)
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
}
}
}