1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +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 84d36cbae7
commit 5a078da4d9
9 changed files with 15 additions and 20 deletions

View File

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

View File

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

View File

@ -1,7 +1,6 @@
// 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 NUnit.Framework;
using osu.Framework.Allocation;
@ -37,7 +36,7 @@ namespace osu.Game.Tests.Visual.Online
{
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
{
Beatmaps = new List<APIBeatmap>
Beatmaps = new[]
{
new APIBeatmap
{
@ -71,10 +70,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestEmptyBeatmapSet()
{
AddStep("load empty beatmapset", () => selector.BeatmapSet = new APIBeatmapSet
{
Beatmaps = new List<APIBeatmap>()
});
AddStep("load empty beatmapset", () => selector.BeatmapSet = new APIBeatmapSet());
AddAssert("no ruleset selected", () => selector.SelectedTab == null);
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(),
HasStoryboard = true,
Covers = new BeatmapSetOnlineCovers(),
Beatmaps = new List<APIBeatmap>
Beatmaps = new[]
{
new APIBeatmap
{
@ -145,7 +145,7 @@ namespace osu.Game.Tests.Visual.Online
var set = getBeatmapSet();
set.Beatmaps = beatmaps;
set.Beatmaps = beatmaps.ToArray();
overlay.ShowBeatmapSet(set);
});
@ -211,7 +211,7 @@ namespace osu.Game.Tests.Visual.Online
});
}
set.Beatmaps = beatmaps;
set.Beatmaps = beatmaps.ToArray();
return set;
}

View File

@ -1,7 +1,6 @@
// 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 NUnit.Framework;
using osu.Framework.Allocation;
@ -46,7 +45,7 @@ namespace osu.Game.Tests.Visual.Online
static APIBeatmapSet createSet() => new APIBeatmapSet
{
Beatmaps = new List<APIBeatmap>
Beatmaps = new[]
{
new APIBeatmap
{

View File

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

View File

@ -147,7 +147,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
{
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())
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
{
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);