2020-10-28 17:05:15 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-10-28 17:05:15 +08:00
|
|
|
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
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class SpectatorResultsScreen : SoloResultsScreen
|
2020-10-28 17:05:15 +08:00
|
|
|
{
|
|
|
|
public SpectatorResultsScreen(ScoreInfo score)
|
2020-11-20 13:35:44 +08:00
|
|
|
: base(score, false)
|
2020-10-28 17:05:15 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[Resolved]
|
2021-05-20 14:55:07 +08:00
|
|
|
private SpectatorClient spectatorClient { get; set; }
|
2020-10-28 17:05:15 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2021-05-20 14:55:07 +08:00
|
|
|
spectatorClient.OnUserBeganPlaying += userBeganPlaying;
|
2020-10-28 17:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void userBeganPlaying(int userId, SpectatorState state)
|
|
|
|
{
|
|
|
|
if (userId == Score.UserID)
|
2020-10-28 17:47:15 +08:00
|
|
|
{
|
|
|
|
Schedule(() =>
|
|
|
|
{
|
|
|
|
if (this.IsCurrentScreen()) this.Exit();
|
|
|
|
});
|
|
|
|
}
|
2020-10-28 17:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
2021-05-20 14:55:07 +08:00
|
|
|
if (spectatorClient != null)
|
|
|
|
spectatorClient.OnUserBeganPlaying -= userBeganPlaying;
|
2020-10-28 17:05:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|