|
6 | 6 | using osu.Framework.Bindables;
|
7 | 7 | using osu.Framework.Graphics;
|
8 | 8 | using osu.Framework.Utils;
|
| 9 | +using osu.Game.Beatmaps; |
9 | 10 | using osu.Game.Graphics;
|
| 11 | +using osu.Game.Online.Spectator; |
| 12 | +using osu.Game.Rulesets.Osu; |
| 13 | +using osu.Game.Rulesets.Osu.Scoring; |
10 | 14 | using osu.Game.Screens.Play;
|
11 | 15 | using osu.Game.Screens.Play.HUD;
|
| 16 | +using osu.Game.Tests.Visual.Spectator; |
12 | 17 |
|
13 | 18 | namespace osu.Game.Tests.Visual.Gameplay
|
14 | 19 | {
|
15 | 20 | [TestFixture]
|
16 | 21 | public partial class TestSceneSpectatorList : OsuTestScene
|
17 | 22 | {
|
18 |
| - private readonly BindableList<SpectatorList.Spectator> spectators = new BindableList<SpectatorList.Spectator>(); |
19 |
| - private readonly Bindable<LocalUserPlayingState> localUserPlayingState = new Bindable<LocalUserPlayingState>(); |
20 |
| - |
21 | 23 | private int counter;
|
22 | 24 |
|
23 | 25 | [Test]
|
24 | 26 | public void TestBasics()
|
25 | 27 | {
|
26 | 28 | SpectatorList list = null!;
|
27 |
| - AddStep("create spectator list", () => Child = list = new SpectatorList |
| 29 | + Bindable<LocalUserPlayingState> playingState = new Bindable<LocalUserPlayingState>(); |
| 30 | + GameplayState gameplayState = new GameplayState(new Beatmap(), new OsuRuleset(), healthProcessor: new OsuHealthProcessor(0), localUserPlayingState: playingState); |
| 31 | + TestSpectatorClient client = new TestSpectatorClient(); |
| 32 | + |
| 33 | + AddStep("create spectator list", () => |
28 | 34 | {
|
29 |
| - Anchor = Anchor.Centre, |
30 |
| - Origin = Anchor.Centre, |
31 |
| - Spectators = { BindTarget = spectators }, |
32 |
| - UserPlayingState = { BindTarget = localUserPlayingState } |
| 35 | + Children = new Drawable[] |
| 36 | + { |
| 37 | + client, |
| 38 | + new DependencyProvidingContainer |
| 39 | + { |
| 40 | + RelativeSizeAxes = Axes.Both, |
| 41 | + CachedDependencies = |
| 42 | + [ |
| 43 | + (typeof(GameplayState), gameplayState), |
| 44 | + (typeof(SpectatorClient), client) |
| 45 | + ], |
| 46 | + Child = list = new SpectatorList |
| 47 | + { |
| 48 | + Anchor = Anchor.Centre, |
| 49 | + Origin = Anchor.Centre, |
| 50 | + } |
| 51 | + } |
| 52 | + }; |
33 | 53 | });
|
34 | 54 |
|
35 |
| - AddStep("start playing", () => localUserPlayingState.Value = LocalUserPlayingState.Playing); |
| 55 | + AddStep("start playing", () => playingState.Value = LocalUserPlayingState.Playing); |
36 | 56 |
|
37 | 57 | AddRepeatStep("add a user", () =>
|
38 | 58 | {
|
39 | 59 | int id = Interlocked.Increment(ref counter);
|
40 |
| - spectators.Add(new SpectatorList.Spectator(id, $"User {id}")); |
| 60 | + ((ISpectatorClient)client).UserStartedWatching([ |
| 61 | + new SpectatorUser |
| 62 | + { |
| 63 | + OnlineID = id, |
| 64 | + Username = $"User {id}" |
| 65 | + } |
| 66 | + ]); |
41 | 67 | }, 10);
|
42 | 68 |
|
43 |
| - AddRepeatStep("remove random user", () => spectators.RemoveAt(RNG.Next(0, spectators.Count)), 5); |
| 69 | + AddRepeatStep("remove random user", () => ((ISpectatorClient)client).UserEndedWatching(client.WatchingUsers[RNG.Next(client.WatchingUsers.Count)].OnlineID), 5); |
44 | 70 |
|
45 | 71 | AddStep("change font to venera", () => list.Font.Value = Typeface.Venera);
|
46 | 72 | AddStep("change font to torus", () => list.Font.Value = Typeface.Torus);
|
47 | 73 | AddStep("change header colour", () => list.HeaderColour.Value = new Colour4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1));
|
48 | 74 |
|
49 |
| - AddStep("enter break", () => localUserPlayingState.Value = LocalUserPlayingState.Break); |
50 |
| - AddStep("stop playing", () => localUserPlayingState.Value = LocalUserPlayingState.NotPlaying); |
| 75 | + AddStep("enter break", () => playingState.Value = LocalUserPlayingState.Break); |
| 76 | + AddStep("stop playing", () => playingState.Value = LocalUserPlayingState.NotPlaying); |
51 | 77 | }
|
52 | 78 | }
|
53 | 79 | }
|
0 commit comments