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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2023-06-23 23:59:36 +08:00
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2020-10-28 17:05:15 +08:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Online.Spectator;
|
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
using osu.Game.Screens.Ranking;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
|
{
|
|
|
|
|
public partial class SpectatorResultsScreen : SoloResultsScreen
|
|
|
|
|
{
|
|
|
|
|
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; } = null!;
|
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);
|
|
|
|
|
|
2023-06-23 23:59:36 +08:00
|
|
|
|
if (spectatorClient.IsNotNull())
|
2021-05-20 14:55:07 +08:00
|
|
|
|
spectatorClient.OnUserBeganPlaying -= userBeganPlaying;
|
2020-10-28 17:05:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|