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:
parent
16b0a7b33e
commit
c97feb09bf
@ -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.
|
||||
|
42
osu.Game/Screens/Play/SpectatorResultsScreen.cs
Normal file
42
osu.Game/Screens/Play/SpectatorResultsScreen.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user