mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Allow continuing to automatically spectate user from results screen
This commit is contained in:
@ -7,19 +7,25 @@ using osu.Framework.Screens;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using osu.Game.Screens.Ranking;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class SpectatorPlayer : ReplayPlayer
|
public class SpectatorPlayer : ReplayPlayer
|
||||||
{
|
{
|
||||||
[Resolved]
|
|
||||||
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
|
||||||
|
|
||||||
public SpectatorPlayer(Score score)
|
public SpectatorPlayer(Score score)
|
||||||
: base(score)
|
: base(score)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override ResultsScreen CreateResults(ScoreInfo score)
|
||||||
|
{
|
||||||
|
return new SpectatorResultsScreen(score);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -32,6 +38,14 @@ namespace osu.Game.Screens.Play
|
|||||||
Schedule(this.Exit);
|
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)
|
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.
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user