mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' into multi-queueing-modes
This commit is contained in:
@ -13,6 +13,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||
using osu.Game.Online.Multiplayer.Queueing;
|
||||
@ -63,7 +64,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
return roomUser;
|
||||
}
|
||||
|
||||
public void AddNullUser() => addUser(new MultiplayerRoomUser(TestUserLookupCache.NULL_USER_ID));
|
||||
public void TestAddUnresolvedUser() => addUser(new MultiplayerRoomUser(TestUserLookupCache.UNRESOLVED_USER_ID));
|
||||
|
||||
private void addUser(MultiplayerRoomUser user)
|
||||
{
|
||||
@ -308,18 +309,24 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
return ((IMultiplayerClient)this).PlaylistItemRemoved(item);
|
||||
}
|
||||
|
||||
protected override Task<BeatmapSetInfo> GetOnlineBeatmapSet(int beatmapId, CancellationToken cancellationToken = default)
|
||||
protected override Task<APIBeatmapSet> GetOnlineBeatmapSet(int beatmapId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Debug.Assert(Room != null);
|
||||
|
||||
var apiRoom = roomManager.ServerSideRooms.Single(r => r.RoomID.Value == Room.RoomID);
|
||||
var set = apiRoom.Playlist.FirstOrDefault(p => p.BeatmapID == beatmapId)?.Beatmap.Value.BeatmapSet
|
||||
?? beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == beatmapId)?.BeatmapSet;
|
||||
IBeatmapSetInfo? set = apiRoom.Playlist.FirstOrDefault(p => p.BeatmapID == beatmapId)?.Beatmap.Value.BeatmapSet
|
||||
?? beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == beatmapId)?.BeatmapSet;
|
||||
|
||||
if (set == null)
|
||||
throw new InvalidOperationException("Beatmap not found.");
|
||||
|
||||
return Task.FromResult(set);
|
||||
var apiSet = new APIBeatmapSet
|
||||
{
|
||||
OnlineID = set.OnlineID,
|
||||
Beatmaps = set.Beatmaps.Select(b => new APIBeatmap { OnlineID = b.OnlineID }).ToArray(),
|
||||
};
|
||||
|
||||
return Task.FromResult(apiSet);
|
||||
}
|
||||
|
||||
private async Task changeMatchType(MatchType type)
|
||||
|
@ -175,27 +175,42 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
|
||||
|
||||
protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset)
|
||||
/// <summary>
|
||||
/// Returns a sample API Beatmap with BeatmapSet populated.
|
||||
/// </summary>
|
||||
/// <param name="ruleset">The ruleset to create the sample model using. osu! ruleset will be used if not specified.</param>
|
||||
protected APIBeatmap CreateAPIBeatmap(RulesetInfo ruleset = null)
|
||||
{
|
||||
var beatmap = CreateBeatmap(ruleset).BeatmapInfo;
|
||||
var beatmapSet = CreateAPIBeatmapSet(ruleset ?? Ruleset.Value);
|
||||
|
||||
// Avoid circular reference.
|
||||
var beatmap = beatmapSet.Beatmaps.First();
|
||||
beatmapSet.Beatmaps = Array.Empty<APIBeatmap>();
|
||||
|
||||
// Populate the set as that's generally what we expect from the API.
|
||||
beatmap.BeatmapSet = beatmapSet;
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a sample API BeatmapSet with beatmaps populated.
|
||||
/// </summary>
|
||||
/// <param name="ruleset">The ruleset to create the sample model using. osu! ruleset will be used if not specified.</param>
|
||||
protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset = null)
|
||||
{
|
||||
var beatmap = CreateBeatmap(ruleset ?? Ruleset.Value).BeatmapInfo;
|
||||
|
||||
return new APIBeatmapSet
|
||||
{
|
||||
Covers = beatmap.BeatmapSet.Covers,
|
||||
OnlineID = beatmap.BeatmapSet.OnlineID,
|
||||
Status = beatmap.BeatmapSet.Status,
|
||||
Preview = beatmap.BeatmapSet.Preview,
|
||||
HasFavourited = beatmap.BeatmapSet.HasFavourited,
|
||||
PlayCount = beatmap.BeatmapSet.PlayCount,
|
||||
FavouriteCount = beatmap.BeatmapSet.FavouriteCount,
|
||||
BPM = beatmap.BeatmapSet.BPM,
|
||||
HasExplicitContent = beatmap.BeatmapSet.HasExplicitContent,
|
||||
HasVideo = beatmap.BeatmapSet.HasVideo,
|
||||
HasStoryboard = beatmap.BeatmapSet.HasStoryboard,
|
||||
Submitted = beatmap.BeatmapSet.Submitted,
|
||||
Ranked = beatmap.BeatmapSet.Ranked,
|
||||
LastUpdated = beatmap.BeatmapSet.LastUpdated,
|
||||
TrackId = beatmap.BeatmapSet.TrackId,
|
||||
Status = BeatmapSetOnlineStatus.Ranked,
|
||||
Covers = new BeatmapSetOnlineCovers
|
||||
{
|
||||
Cover = "https://assets.ppy.sh/beatmaps/163112/covers/cover.jpg",
|
||||
Card = "https://assets.ppy.sh/beatmaps/163112/covers/card.jpg",
|
||||
List = "https://assets.ppy.sh/beatmaps/163112/covers/list.jpg"
|
||||
},
|
||||
Title = beatmap.BeatmapSet.Metadata.Title,
|
||||
TitleUnicode = beatmap.BeatmapSet.Metadata.TitleUnicode,
|
||||
Artist = beatmap.BeatmapSet.Metadata.Artist,
|
||||
@ -203,9 +218,6 @@ namespace osu.Game.Tests.Visual
|
||||
Author = beatmap.BeatmapSet.Metadata.Author,
|
||||
AuthorID = beatmap.BeatmapSet.Metadata.AuthorID,
|
||||
AuthorString = beatmap.BeatmapSet.Metadata.AuthorString,
|
||||
Availability = beatmap.BeatmapSet.Availability,
|
||||
Genre = beatmap.BeatmapSet.Genre,
|
||||
Language = beatmap.BeatmapSet.Language,
|
||||
Source = beatmap.BeatmapSet.Metadata.Source,
|
||||
Tags = beatmap.BeatmapSet.Metadata.Tags,
|
||||
Beatmaps = new[]
|
||||
|
@ -14,11 +14,11 @@ namespace osu.Game.Tests.Visual
|
||||
/// A special user ID which <see cref="ComputeValueAsync"/> would return a <see langword="null"/> <see cref="User"/> for.
|
||||
/// As a simulation to what a regular <see cref="UserLookupCache"/> would return in the case of failing to fetch the user.
|
||||
/// </summary>
|
||||
public const int NULL_USER_ID = -1;
|
||||
public const int UNRESOLVED_USER_ID = -1;
|
||||
|
||||
protected override Task<User> ComputeValueAsync(int lookup, CancellationToken token = default)
|
||||
{
|
||||
if (lookup == NULL_USER_ID)
|
||||
if (lookup == UNRESOLVED_USER_ID)
|
||||
return Task.FromResult((User)null);
|
||||
|
||||
return Task.FromResult(new User
|
||||
|
Reference in New Issue
Block a user