2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2020-10-28 17:05:15 +08:00
|
|
|
|
// 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
|
|
|
|
|
{
|
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]
|
2023-06-23 00:37:25 +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)
|
|
|
|
|
{
|
2024-01-29 15:13:30 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|