2020-12-19 02:23:42 +09: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 16:37:17 +09:00
|
|
|
#nullable disable
|
|
|
|
|
2021-03-02 19:06:21 +09:00
|
|
|
using osu.Game.Online.Rooms;
|
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-06-25 15:00:10 +09:00
|
|
|
using osu.Game.Tests.Visual.OnlinePlay;
|
2021-06-25 17:55:16 +09:00
|
|
|
using osu.Game.Tests.Visual.Spectator;
|
2020-12-19 02:23:42 +09:00
|
|
|
|
2020-12-25 13:38:11 +09:00
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
2020-12-19 02:23:42 +09:00
|
|
|
{
|
2021-06-25 18:02:53 +09:00
|
|
|
/// <summary>
|
|
|
|
/// The base test scene for all multiplayer components and screens.
|
|
|
|
/// </summary>
|
2022-11-24 14:32:20 +09:00
|
|
|
public abstract partial class MultiplayerTestScene : OnlinePlayTestScene, IMultiplayerTestSceneDependencies
|
2020-12-19 02:23:42 +09:00
|
|
|
{
|
2021-04-26 17:22:16 +09:00
|
|
|
public const int PLAYER_1_ID = 55;
|
|
|
|
public const int PLAYER_2_ID = 56;
|
|
|
|
|
2022-02-16 09:43:28 +09:00
|
|
|
public TestMultiplayerClient MultiplayerClient => OnlinePlayDependencies.MultiplayerClient;
|
2021-10-27 16:10:22 +09:00
|
|
|
public new TestMultiplayerRoomManager RoomManager => OnlinePlayDependencies.RoomManager;
|
2024-02-02 19:48:13 +09:00
|
|
|
public TestSpectatorClient SpectatorClient => OnlinePlayDependencies.SpectatorClient;
|
2020-12-19 02:23:42 +09:00
|
|
|
|
2021-06-25 20:11:38 +09:00
|
|
|
protected new MultiplayerTestSceneDependencies OnlinePlayDependencies => (MultiplayerTestSceneDependencies)base.OnlinePlayDependencies;
|
2020-12-19 02:23:42 +09:00
|
|
|
|
2022-02-16 09:43:28 +09:00
|
|
|
public bool RoomJoined => MultiplayerClient.RoomJoined;
|
2021-11-23 16:04:11 +09:00
|
|
|
|
2020-12-19 02:23:42 +09:00
|
|
|
private readonly bool joinRoom;
|
|
|
|
|
2020-12-25 13:38:11 +09:00
|
|
|
protected MultiplayerTestScene(bool joinRoom = true)
|
2020-12-19 02:23:42 +09:00
|
|
|
{
|
|
|
|
this.joinRoom = joinRoom;
|
|
|
|
}
|
|
|
|
|
2021-08-09 16:44:50 +09:00
|
|
|
protected virtual Room CreateRoom()
|
|
|
|
{
|
|
|
|
return new Room
|
|
|
|
{
|
|
|
|
Name = { Value = "test name" },
|
2022-04-11 16:47:34 +09:00
|
|
|
Type = { Value = MatchType.HeadToHead },
|
2021-08-09 16:44:50 +09:00
|
|
|
Playlist =
|
|
|
|
{
|
2022-02-15 23:33:26 +09:00
|
|
|
new PlaylistItem(new TestBeatmap(Ruleset.Value).BeatmapInfo)
|
2021-08-09 16:44:50 +09:00
|
|
|
{
|
2022-02-15 16:01:14 +09:00
|
|
|
RulesetID = Ruleset.Value.OnlineID
|
2021-08-09 16:44:50 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-02-05 00:42:38 +09:00
|
|
|
public override void SetUpSteps()
|
|
|
|
{
|
|
|
|
base.SetUpSteps();
|
|
|
|
|
|
|
|
if (joinRoom)
|
2021-10-27 16:10:22 +09:00
|
|
|
{
|
2022-07-29 15:27:39 +09:00
|
|
|
AddStep("join room", () =>
|
|
|
|
{
|
2024-02-02 21:05:12 +09:00
|
|
|
SelectedRoom.Value = CreateRoom();
|
2022-07-29 15:27:39 +09:00
|
|
|
RoomManager.CreateRoom(SelectedRoom.Value);
|
|
|
|
});
|
|
|
|
|
2021-11-23 16:04:11 +09:00
|
|
|
AddUntilStep("wait for room join", () => RoomJoined);
|
2021-10-27 16:10:22 +09:00
|
|
|
}
|
2021-02-05 00:42:38 +09:00
|
|
|
}
|
2021-06-25 18:02:53 +09:00
|
|
|
|
2021-06-25 20:11:38 +09:00
|
|
|
protected override OnlinePlayTestSceneDependencies CreateOnlinePlayDependencies() => new MultiplayerTestSceneDependencies();
|
2020-12-19 02:23:42 +09:00
|
|
|
}
|
|
|
|
}
|