1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 18:32:56 +08:00

Fix APIBeatmapSet.Beatmaps being IEnumerable, causing stupid issues

This commit is contained in:
Dean Herbert 2021-11-04 16:44:05 +09:00
parent baabe99f78
commit 8f459e6ce8
9 changed files with 15 additions and 20 deletions

View File

@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
HasVideo = true, HasVideo = true,
HasStoryboard = true, HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
Beatmaps = new List<APIBeatmap> Beatmaps = new[]
{ {
new APIBeatmap new APIBeatmap
{ {
@ -128,7 +128,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
HasVideo = true, HasVideo = true,
HasStoryboard = true, HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
Beatmaps = beatmaps, Beatmaps = beatmaps.ToArray(),
}; };
} }

View File

@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
{ {
RulesetID = difficulty.rulesetId, RulesetID = difficulty.rulesetId,
StarRating = difficulty.stars StarRating = difficulty.stars
}).ToList() }).ToArray()
}; };
[Test] [Test]

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -37,7 +36,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
selector.BeatmapSet = new APIBeatmapSet selector.BeatmapSet = new APIBeatmapSet
{ {
Beatmaps = enabledRulesets.Select(r => new APIBeatmap { RulesetID = r.OnlineID }).ToList() Beatmaps = enabledRulesets.Select(r => new APIBeatmap { RulesetID = r.OnlineID }).ToArray()
}; };
}); });
@ -55,7 +54,7 @@ namespace osu.Game.Tests.Visual.Online
{ {
selector.BeatmapSet = new APIBeatmapSet selector.BeatmapSet = new APIBeatmapSet
{ {
Beatmaps = new List<APIBeatmap> Beatmaps = new[]
{ {
new APIBeatmap new APIBeatmap
{ {
@ -71,10 +70,7 @@ namespace osu.Game.Tests.Visual.Online
[Test] [Test]
public void TestEmptyBeatmapSet() public void TestEmptyBeatmapSet()
{ {
AddStep("load empty beatmapset", () => selector.BeatmapSet = new APIBeatmapSet AddStep("load empty beatmapset", () => selector.BeatmapSet = new APIBeatmapSet());
{
Beatmaps = new List<APIBeatmap>()
});
AddAssert("no ruleset selected", () => selector.SelectedTab == null); AddAssert("no ruleset selected", () => selector.SelectedTab == null);
AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value)); AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value));

View File

@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.Online
Ratings = Enumerable.Range(0, 11).ToArray(), Ratings = Enumerable.Range(0, 11).ToArray(),
HasStoryboard = true, HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
Beatmaps = new List<APIBeatmap> Beatmaps = new[]
{ {
new APIBeatmap new APIBeatmap
{ {
@ -145,7 +145,7 @@ namespace osu.Game.Tests.Visual.Online
var set = getBeatmapSet(); var set = getBeatmapSet();
set.Beatmaps = beatmaps; set.Beatmaps = beatmaps.ToArray();
overlay.ShowBeatmapSet(set); overlay.ShowBeatmapSet(set);
}); });
@ -211,7 +211,7 @@ namespace osu.Game.Tests.Visual.Online
}); });
} }
set.Beatmaps = beatmaps; set.Beatmaps = beatmaps.ToArray();
return set; return set;
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -46,7 +45,7 @@ namespace osu.Game.Tests.Visual.Online
static APIBeatmapSet createSet() => new APIBeatmapSet static APIBeatmapSet createSet() => new APIBeatmapSet
{ {
Beatmaps = new List<APIBeatmap> Beatmaps = new[]
{ {
new APIBeatmap new APIBeatmap
{ {

View File

@ -90,7 +90,7 @@ namespace osu.Game.Tests.Visual.Online
HasVideo = true, HasVideo = true,
HasStoryboard = true, HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
Beatmaps = new List<APIBeatmap> Beatmaps = new[]
{ {
new APIBeatmap new APIBeatmap
{ {
@ -129,7 +129,7 @@ namespace osu.Game.Tests.Visual.Online
HasVideo = true, HasVideo = true,
HasStoryboard = true, HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(), Covers = new BeatmapSetOnlineCovers(),
Beatmaps = beatmaps, Beatmaps = beatmaps.ToArray(),
}; };
} }
} }

View File

@ -119,7 +119,7 @@ namespace osu.Game.Online.API.Requests.Responses
public string Tags { get; set; } = string.Empty; public string Tags { get; set; } = string.Empty;
[JsonProperty(@"beatmaps")] [JsonProperty(@"beatmaps")]
public IEnumerable<APIBeatmap> Beatmaps { get; set; } = Array.Empty<APIBeatmap>(); public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets) public virtual BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
{ {

View File

@ -147,7 +147,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
{ {
var icons = new List<DifficultyIcon>(); var icons = new List<DifficultyIcon>();
if (SetInfo.Beatmaps.Count() > maximum_difficulty_icons) if (SetInfo.Beatmaps.Length > maximum_difficulty_icons)
{ {
foreach (var ruleset in SetInfo.Beatmaps.Select(b => b.Ruleset).Distinct()) foreach (var ruleset in SetInfo.Beatmaps.Select(b => b.Ruleset).Distinct())
icons.Add(new GroupedDifficultyIcon(SetInfo.Beatmaps.Where(b => b.RulesetID == ruleset.OnlineID).ToList(), ruleset, this is ListBeatmapPanel ? Color4.White : colours.Gray5)); icons.Add(new GroupedDifficultyIcon(SetInfo.Beatmaps.Where(b => b.RulesetID == ruleset.OnlineID).ToList(), ruleset, this is ListBeatmapPanel ? Color4.White : colours.Gray5));

View File

@ -280,7 +280,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
var apiSet = new APIBeatmapSet var apiSet = new APIBeatmapSet
{ {
OnlineID = set.OnlineID, OnlineID = set.OnlineID,
Beatmaps = set.Beatmaps.Select(b => new APIBeatmap { OnlineID = b.OnlineID }) Beatmaps = set.Beatmaps.Select(b => new APIBeatmap { OnlineID = b.OnlineID }).ToArray(),
}; };
return Task.FromResult(apiSet); return Task.FromResult(apiSet);