Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// 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 System.Collections.Generic;
using System.Linq;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Matchmaking.Events;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Matchmaking.Match.BeatmapSelect;
using osu.Game.Tests.Visual.Multiplayer;

namespace osu.Game.Tests.Visual.Matchmaking
{
public partial class TestSceneMatchmakingCursorContainer : MultiplayerTestScene
{
private readonly IReadOnlyList<APIUser> users = new[]
{
new APIUser
{
Id = 2,
Username = "peppy",
},
new APIUser
{
Id = 1040328,
Username = "smoogipoo",
},
new APIUser
{
Id = 6573093,
Username = "OliBomby",
},
new APIUser
{
Id = 7782553,
Username = "aesth",
},
new APIUser
{
Id = 6411631,
Username = "Maarvin",
}
};

private readonly PlaylistItem[] items = Enumerable.Range(1, 50).Select(i => new PlaylistItem(new MultiplayerPlaylistItem
{
ID = i,
BeatmapID = i,
StarRating = i / 10.0,
})).ToArray();

private MatchmakingCursorContainer? cursorContainer;

public override void SetUpSteps()
{
base.SetUpSteps();

AddStep("join room", () =>
{
var room = CreateDefaultRoom(MatchType.Matchmaking);
room.Playlist = items;

JoinRoom(room);
});

WaitForJoined();

AddStep("add users", () =>
{
foreach (var user in users)
MultiplayerClient.AddUser(user);
});

AddStep("add screen", () =>
{
Child = new ScreenStack(new SubScreenBeatmapSelect());
});
}

protected override void LoadComplete()
{
base.LoadComplete();

var inputManager = GetContainingInputManager()!;

Scheduler.AddDelayed(() =>
{
cursorContainer ??= this.ChildrenOfType<MatchmakingCursorContainer>().FirstOrDefault();

if (cursorContainer == null)
return;

var position = cursorContainer.ToLocalSpace(inputManager.CurrentState.Mouse.Position);

var request = new MatchmakingCursorPositionRequest
{
X = position.X,
Y = position.Y,
};

Scheduler.AddDelayed(() =>
{
MultiplayerClient.SendUserMatchRequest(users[0].Id, request).FireAndForget();
}, 500);

Scheduler.AddDelayed(() =>
{
MultiplayerClient.SendUserMatchRequest(users[1].Id, request).FireAndForget();
}, 1000);

Scheduler.AddDelayed(() =>
{
MultiplayerClient.SendUserMatchRequest(users[2].Id, request).FireAndForget();
}, 1500);
}, 50, true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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 System;
using MessagePack;
using osu.Game.Online.Multiplayer;

namespace osu.Game.Online.Matchmaking.Events
{
/// <summary>
/// Requests to perform update a user's cursor position in a matchmaking room.
/// </summary>
[Serializable]
[MessagePackObject]
public class MatchmakingCursorPositionEvent : MatchServerEvent
{
/// <summary>
/// The user performing the action.
/// </summary>
[Key(0)]
public int UserId { get; set; }

/// <summary>
/// The cursor's x position.
/// </summary>
[Key(1)]
public float X { get; set; }

/// <summary>
/// The cursor's x position.
/// </summary>
[Key(2)]
public float Y { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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 System;
using MessagePack;
using osu.Game.Online.Multiplayer;

namespace osu.Game.Online.Matchmaking.Events
{
/// <summary>
/// Requests to perform update a user's cursor position in a matchmaking room.
/// </summary>
[Serializable]
[MessagePackObject]
public class MatchmakingCursorPositionRequest : MatchUserRequest
{
/// <summary>
/// The cursor's x position.
/// </summary>
[Key(0)]
public float X { get; set; }

/// <summary>
/// The cursor's x position.
/// </summary>
[Key(1)]
public float Y { get; set; }
}
}
1 change: 1 addition & 0 deletions osu.Game/Online/Multiplayer/MatchServerEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace osu.Game.Online.Multiplayer
[Union(0, typeof(CountdownStartedEvent))]
[Union(1, typeof(CountdownStoppedEvent))]
[Union(2, typeof(MatchmakingAvatarActionEvent))]
[Union(3, typeof(MatchmakingCursorPositionEvent))]
public abstract class MatchServerEvent
{
}
Expand Down
1 change: 1 addition & 0 deletions osu.Game/Online/Multiplayer/MatchUserRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace osu.Game.Online.Multiplayer
[Union(1, typeof(StartMatchCountdownRequest))]
[Union(2, typeof(StopCountdownRequest))]
[Union(3, typeof(MatchmakingAvatarActionRequest))]
[Union(4, typeof(MatchmakingCursorPositionRequest))]
public abstract class MatchUserRequest
{
}
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Online/SignalRWorkaroundTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ internal static class SignalRWorkaroundTypes
(typeof(MatchmakingStageCountdown), typeof(MultiplayerCountdown)),
(typeof(MatchmakingAvatarActionRequest), typeof(MatchUserRequest)),
(typeof(MatchmakingAvatarActionEvent), typeof(MatchServerEvent)),
(typeof(MatchmakingCursorPositionRequest), typeof(MatchUserRequest)),
(typeof(MatchmakingCursorPositionEvent), typeof(MatchServerEvent)),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ public BeatmapSelectGrid()
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
Child = panelGridContainer = new PanelGridContainer
Children = new Drawable[]
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(20),
Spacing = new Vector2(panel_spacing)
panelGridContainer = new PanelGridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(20),
Spacing = new Vector2(panel_spacing)
},
new MatchmakingCursorContainer
{
RelativeSizeAxes = Axes.Both,
},
},
},
rollContainer = new Container<BeatmapSelectPanel>
Expand Down
Loading
Loading