2021-04-08 21:07:00 +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;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Scoring;
|
2021-04-15 18:32:55 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync;
|
2021-04-08 21:07:00 +08:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|
|
|
{
|
|
|
|
public class PlayerInstance : CompositeDrawable
|
|
|
|
{
|
|
|
|
public bool PlayerLoaded => stack?.CurrentScreen is Player;
|
|
|
|
|
2021-04-16 11:25:29 +08:00
|
|
|
public readonly int UserId;
|
|
|
|
public readonly SpectatorCatchUpSlaveClock GameplayClock;
|
2021-04-08 21:07:00 +08:00
|
|
|
|
2021-04-16 11:25:29 +08:00
|
|
|
public Score Score { get; private set; }
|
2021-04-08 21:07:00 +08:00
|
|
|
|
2021-04-16 11:25:29 +08:00
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmapManager { get; set; }
|
2021-04-13 21:10:35 +08:00
|
|
|
|
2021-04-08 21:07:00 +08:00
|
|
|
private OsuScreenStack stack;
|
|
|
|
|
2021-04-16 11:25:29 +08:00
|
|
|
public PlayerInstance(int userId, SpectatorCatchUpSlaveClock gameplayClock)
|
2021-04-08 21:07:00 +08:00
|
|
|
{
|
2021-04-16 11:25:29 +08:00
|
|
|
UserId = userId;
|
2021-04-15 18:12:52 +08:00
|
|
|
GameplayClock = gameplayClock;
|
2021-04-08 21:13:54 +08:00
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Masking = true;
|
2021-04-08 21:07:00 +08:00
|
|
|
}
|
|
|
|
|
2021-04-16 11:25:29 +08:00
|
|
|
public void LoadPlayer(Score score)
|
2021-04-08 21:07:00 +08:00
|
|
|
{
|
2021-04-16 11:25:29 +08:00
|
|
|
Score = score;
|
2021-04-08 21:07:00 +08:00
|
|
|
|
2021-04-16 11:25:29 +08:00
|
|
|
InternalChild = new GameplayIsolationContainer(beatmapManager.GetWorkingBeatmap(Score.ScoreInfo.Beatmap, bypassCache: true), Score.ScoreInfo.Ruleset, Score.ScoreInfo.Mods)
|
2021-04-08 21:07:00 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = new DrawSizePreservingFillContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Child = stack = new OsuScreenStack()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-15 18:12:52 +08:00
|
|
|
stack.Push(new MultiplayerSpectatorPlayerLoader(Score, () => new MultiplayerSpectatorPlayer(Score, GameplayClock)));
|
2021-04-09 18:58:24 +08:00
|
|
|
}
|
2021-04-13 19:52:20 +08:00
|
|
|
|
|
|
|
// Player interferes with global input, so disable input for now.
|
|
|
|
public override bool PropagatePositionalInputSubTree => false;
|
|
|
|
public override bool PropagateNonPositionalInputSubTree => false;
|
2021-04-08 21:07:00 +08:00
|
|
|
}
|
|
|
|
}
|