diff --git a/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs b/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs index 42a3b4cf43..9ce7e0a0e0 100644 --- a/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs +++ b/osu.Game.Tests/NonVisual/BeatmapSetInfoEqualityTest.cs @@ -39,8 +39,8 @@ namespace osu.Game.Tests.NonVisual [Test] public void TestCheckNullID() { - var ourInfo = new BeatmapSetInfo { Status = BeatmapSetOnlineStatus.Loved }; - var otherInfo = new BeatmapSetInfo { Status = BeatmapSetOnlineStatus.Approved }; + var ourInfo = new BeatmapSetInfo { Hash = "1" }; + var otherInfo = new BeatmapSetInfo { Hash = "2" }; Assert.AreNotEqual(ourInfo, otherInfo); } diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs index f44b0c9716..afd48d5191 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneDrawableRoomPlaylist.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; @@ -223,11 +224,11 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestDownloadButtonVisibleInitiallyWhenBeatmapDoesNotExist() { - var byOnlineId = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo; - byOnlineId.BeatmapSet.OnlineBeatmapSetID = 1337; // Some random ID that does not exist locally. + var byOnlineId = CreateAPIBeatmap(); + byOnlineId.OnlineID = 1337; // Some random ID that does not exist locally. - var byChecksum = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo; - byChecksum.MD5Hash = "1337"; // Some random checksum that does not exist locally. + var byChecksum = CreateAPIBeatmap(); + byChecksum.Checksum = "1337"; // Some random checksum that does not exist locally. createPlaylist(byOnlineId, byChecksum); @@ -237,8 +238,11 @@ namespace osu.Game.Tests.Visual.Multiplayer [Test] public void TestExplicitBeatmapItem() { - var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo; - beatmap.BeatmapSet.OnlineInfo.HasExplicitContent = true; + var beatmap = CreateAPIBeatmap(); + + Debug.Assert(beatmap.BeatmapSet != null); + + beatmap.BeatmapSet.HasExplicitContent = true; createPlaylist(beatmap); } @@ -310,7 +314,7 @@ namespace osu.Game.Tests.Visual.Multiplayer AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded)); } - private void createPlaylist(params BeatmapInfo[] beatmaps) + private void createPlaylist(params IBeatmapInfo[] beatmaps) { AddStep("create playlist", () => { diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs index f0cf88840a..3d828077c8 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs @@ -9,7 +9,6 @@ using osu.Game.Beatmaps; using osu.Game.Online; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapListing.Panels; -using osu.Game.Rulesets.Osu; using osu.Game.Tests.Resources; using osuTK; @@ -110,7 +109,7 @@ namespace osu.Game.Tests.Visual.Online private IBeatmapSetInfo getDownloadableBeatmapSet() { - var apiBeatmapSet = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo.OnlineInfo; + var apiBeatmapSet = CreateAPIBeatmapSet(); apiBeatmapSet.HasVideo = true; apiBeatmapSet.HasStoryboard = true; @@ -120,7 +119,7 @@ namespace osu.Game.Tests.Visual.Online private IBeatmapSetInfo getUndownloadableBeatmapSet() { - var apiBeatmapSet = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo.OnlineInfo; + var apiBeatmapSet = CreateAPIBeatmapSet(); apiBeatmapSet.Artist = "test"; apiBeatmapSet.Title = "undownloadable"; diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetails.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetails.cs index 9856b28b00..bd15c40271 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetails.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapDetails.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; -using osu.Game.Rulesets.Osu; using osu.Game.Screens.Select; namespace osu.Game.Tests.Visual.SongSelect @@ -32,159 +31,112 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestAllMetrics() { - AddStep("all metrics", () => details.BeatmapInfo = new BeatmapInfo + AddStep("all metrics", () => details.BeatmapInfo = new APIBeatmap { - BeatmapSet = new BeatmapSetInfo - { - OnlineInfo = new APIBeatmapSet - { - Ratings = Enumerable.Range(0, 11).ToArray(), - } - }, - Version = "All Metrics", - Metadata = new BeatmapMetadata + BeatmapSet = new APIBeatmapSet { Source = "osu!", Tags = "this beatmap has all the metrics", + Ratings = Enumerable.Range(0, 11).ToArray(), }, - BaseDifficulty = new BeatmapDifficulty + DifficultyName = "All Metrics", + CircleSize = 7, + DrainRate = 1, + OverallDifficulty = 5.7f, + ApproachRate = 3.5f, + StarRating = 5.3f, + FailTimes = new APIFailTimes { - CircleSize = 7, - DrainRate = 1, - OverallDifficulty = 5.7f, - ApproachRate = 3.5f, + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, - StarDifficulty = 5.3f, - Ruleset = new OsuRuleset().RulesetInfo, - OnlineInfo = new APIBeatmap - { - FailTimes = new APIFailTimes - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - } }); } [Test] public void TestAllMetricsExceptSource() { - AddStep("all except source", () => details.BeatmapInfo = new BeatmapInfo + AddStep("all except source", () => details.BeatmapInfo = new APIBeatmap { - BeatmapSet = new BeatmapSetInfo - { - OnlineInfo = new APIBeatmapSet - { - Ratings = Enumerable.Range(0, 11).ToArray(), - } - }, - Version = "All Metrics", - Metadata = new BeatmapMetadata + BeatmapSet = new APIBeatmapSet { Tags = "this beatmap has all the metrics", + Ratings = Enumerable.Range(0, 11).ToArray(), }, - BaseDifficulty = new BeatmapDifficulty + DifficultyName = "All Metrics", + CircleSize = 7, + DrainRate = 1, + OverallDifficulty = 5.7f, + ApproachRate = 3.5f, + StarRating = 5.3f, + FailTimes = new APIFailTimes { - CircleSize = 7, - DrainRate = 1, - OverallDifficulty = 5.7f, - ApproachRate = 3.5f, + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, - StarDifficulty = 5.3f, - Ruleset = new OsuRuleset().RulesetInfo, - OnlineInfo = new APIBeatmap - { - FailTimes = new APIFailTimes - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - } }); } [Test] public void TestOnlyRatings() { - AddStep("ratings", () => details.BeatmapInfo = new BeatmapInfo + AddStep("ratings", () => details.BeatmapInfo = new APIBeatmap { - BeatmapSet = new BeatmapSetInfo - { - OnlineInfo = new APIBeatmapSet - { - Ratings = Enumerable.Range(0, 11).ToArray(), - } - }, - Version = "Only Ratings", - Metadata = new BeatmapMetadata + BeatmapSet = new APIBeatmapSet { + Ratings = Enumerable.Range(0, 11).ToArray(), Source = "osu!", Tags = "this beatmap has ratings metrics but not retries or fails", }, - Ruleset = new OsuRuleset().RulesetInfo, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 6, - DrainRate = 9, - OverallDifficulty = 6, - ApproachRate = 6, - }, - StarDifficulty = 4.8f, + DifficultyName = "Only Ratings", + CircleSize = 6, + DrainRate = 9, + OverallDifficulty = 6, + ApproachRate = 6, + StarRating = 4.8f, }); } [Test] public void TestOnlyFailsAndRetries() { - AddStep("fails retries", () => details.BeatmapInfo = new BeatmapInfo + AddStep("fails retries", () => details.BeatmapInfo = new APIBeatmap { - Version = "Only Retries and Fails", - Metadata = new BeatmapMetadata + DifficultyName = "Only Retries and Fails", + BeatmapSet = new APIBeatmapSet { Source = "osu!", Tags = "this beatmap has retries and fails but no ratings", }, - BaseDifficulty = new BeatmapDifficulty + CircleSize = 3.7f, + DrainRate = 6, + OverallDifficulty = 6, + ApproachRate = 7, + StarRating = 2.91f, + FailTimes = new APIFailTimes { - CircleSize = 3.7f, - DrainRate = 6, - OverallDifficulty = 6, - ApproachRate = 7, + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, - Ruleset = new OsuRuleset().RulesetInfo, - StarDifficulty = 2.91f, - OnlineInfo = new APIBeatmap - { - FailTimes = new APIFailTimes - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - } }); } [Test] public void TestNoMetrics() { - AddStep("no metrics", () => details.BeatmapInfo = new BeatmapInfo + AddStep("no metrics", () => details.BeatmapInfo = new APIBeatmap { - Version = "No Metrics", - Metadata = new BeatmapMetadata + DifficultyName = "No Metrics", + BeatmapSet = new APIBeatmapSet { Source = "osu!", Tags = "this beatmap has no metrics", }, - Ruleset = new OsuRuleset().RulesetInfo, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 5, - DrainRate = 5, - OverallDifficulty = 5.5f, - ApproachRate = 6.5f, - }, - StarDifficulty = 1.97f, + CircleSize = 5, + DrainRate = 5, + OverallDifficulty = 5.5f, + ApproachRate = 6.5f, + StarRating = 1.97f, }); } @@ -197,10 +149,9 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestOnlineMetrics() { - AddStep("online ratings/retries/fails", () => details.BeatmapInfo = new BeatmapInfo + AddStep("online ratings/retries/fails", () => details.BeatmapInfo = new APIBeatmap { - OnlineBeatmapID = 162, - Ruleset = new OsuRuleset().RulesetInfo + OnlineID = 162, }); AddStep("set online", () => api.SetState(APIState.Online)); AddStep("set offline", () => api.SetState(APIState.Offline)); diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapSetCover.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapSetCover.cs index f67f6258cc..7b6774a6b2 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapSetCover.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapSetCover.cs @@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface { AddStep("setup cover", () => Child = new UpdateableOnlineBeatmapSetCover(coverType) { - OnlineInfo = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet.OnlineInfo, + OnlineInfo = CreateAPIBeatmapSet(), RelativeSizeAxes = Axes.Both, Masking = true, }); @@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("setup covers", () => { - BeatmapSetInfo setInfo = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet; + var beatmapSet = CreateAPIBeatmapSet(); FillFlowContainer fillFlow; @@ -68,7 +68,7 @@ namespace osu.Game.Tests.Visual.UserInterface var cover = new UpdateableOnlineBeatmapSetCover(coverType) { - OnlineInfo = setInfo.OnlineInfo, + OnlineInfo = beatmapSet, Height = 100, Masking = true, }; @@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("setup cover", () => Child = updateableCover = new TestUpdateableOnlineBeatmapSetCover { - OnlineInfo = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet.OnlineInfo, + OnlineInfo = CreateAPIBeatmapSet(), RelativeSizeAxes = Axes.Both, Masking = true, }); @@ -117,7 +117,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("setup cover", () => Child = updateableCover = new TestUpdateableOnlineBeatmapSetCover(0) { - OnlineInfo = createBeatmapWithCover("https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg").OnlineInfo, + OnlineInfo = createBeatmapWithCover("https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg"), RelativeSizeAxes = Axes.Both, Masking = true, Alpha = 0.4f @@ -128,16 +128,13 @@ namespace osu.Game.Tests.Visual.UserInterface AddUntilStep("wait for fade complete", () => initialCover.Alpha == 1); AddStep("switch beatmap", - () => updateableCover.OnlineInfo = createBeatmapWithCover("https://assets.ppy.sh/beatmaps/1079428/covers/cover.jpg").OnlineInfo); + () => updateableCover.OnlineInfo = createBeatmapWithCover("https://assets.ppy.sh/beatmaps/1079428/covers/cover.jpg")); AddUntilStep("new cover loaded", () => updateableCover.ChildrenOfType().Except(new[] { initialCover }).Any()); } - private static BeatmapSetInfo createBeatmapWithCover(string coverUrl) => new BeatmapSetInfo + private static APIBeatmapSet createBeatmapWithCover(string coverUrl) => new APIBeatmapSet { - OnlineInfo = new APIBeatmapSet - { - Covers = new BeatmapSetOnlineCovers { Cover = coverUrl } - } + Covers = new BeatmapSetOnlineCovers { Cover = coverUrl } }; private class TestUpdateableOnlineBeatmapSetCover : UpdateableOnlineBeatmapSetCover diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index 952e205aa0..01a819dead 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -17,7 +17,7 @@ namespace osu.Game.Beatmaps { [ExcludeFromDynamicCompile] [Serializable] - public class BeatmapInfo : IEquatable, IHasPrimaryKey, IBeatmapInfo, IBeatmapOnlineInfo + public class BeatmapInfo : IEquatable, IHasPrimaryKey, IBeatmapInfo { public int ID { get; set; } @@ -201,24 +201,5 @@ namespace osu.Game.Beatmaps double IBeatmapInfo.StarRating => StarDifficulty; #endregion - - #region Implementation of IBeatmapOnlineInfo - - [JsonIgnore] - public int CircleCount => OnlineInfo.CircleCount; - - [JsonIgnore] - public int SliderCount => OnlineInfo.SliderCount; - - [JsonIgnore] - public int PlayCount => OnlineInfo.PlayCount; - - [JsonIgnore] - public int PassCount => OnlineInfo.PassCount; - - [JsonIgnore] - public APIFailTimes FailTimes => OnlineInfo.FailTimes; - - #endregion } } diff --git a/osu.Game/Beatmaps/BeatmapSetInfo.cs b/osu.Game/Beatmaps/BeatmapSetInfo.cs index 79cc8b70fb..638366c580 100644 --- a/osu.Game/Beatmaps/BeatmapSetInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetInfo.cs @@ -6,10 +6,8 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using JetBrains.Annotations; -using Newtonsoft.Json; using osu.Framework.Testing; using osu.Game.Database; -using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Beatmaps { @@ -32,13 +30,11 @@ namespace osu.Game.Beatmaps public List Beatmaps { get; set; } + public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None; + [NotNull] public List Files { get; set; } = new List(); - // This field is temporary and only used by `APIBeatmapSet.ToBeatmapSet` (soon to be removed) and tests (to be updated to provide APIBeatmapSet instead). - [NotMapped] - public APIBeatmapSet OnlineInfo { get; set; } - /// /// The maximum star difficulty of all beatmaps in this set. /// @@ -100,80 +96,5 @@ namespace osu.Game.Beatmaps IEnumerable IBeatmapSetInfo.Files => Files; #endregion - - #region Delegation for IBeatmapSetOnlineInfo - - [NotMapped] - [JsonIgnore] - public DateTimeOffset Submitted => OnlineInfo.Submitted; - - [NotMapped] - [JsonIgnore] - public DateTimeOffset? Ranked => OnlineInfo.Ranked; - - [NotMapped] - [JsonIgnore] - public DateTimeOffset? LastUpdated => OnlineInfo.LastUpdated; - - [JsonIgnore] - public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None; - - [NotMapped] - [JsonIgnore] - public bool HasExplicitContent => OnlineInfo.HasExplicitContent; - - [NotMapped] - [JsonIgnore] - public bool HasVideo => OnlineInfo.HasVideo; - - [NotMapped] - [JsonIgnore] - public bool HasStoryboard => OnlineInfo.HasStoryboard; - - [NotMapped] - [JsonIgnore] - public BeatmapSetOnlineCovers Covers => OnlineInfo.Covers; - - [NotMapped] - [JsonIgnore] - public string Preview => OnlineInfo.Preview; - - [NotMapped] - [JsonIgnore] - public double BPM => OnlineInfo.BPM; - - [NotMapped] - [JsonIgnore] - public int PlayCount => OnlineInfo.PlayCount; - - [NotMapped] - [JsonIgnore] - public int FavouriteCount => OnlineInfo.FavouriteCount; - - [NotMapped] - [JsonIgnore] - public bool HasFavourited => OnlineInfo.HasFavourited; - - [NotMapped] - [JsonIgnore] - public BeatmapSetOnlineAvailability Availability => OnlineInfo.Availability; - - [NotMapped] - [JsonIgnore] - public BeatmapSetOnlineGenre Genre => OnlineInfo.Genre; - - [NotMapped] - [JsonIgnore] - public BeatmapSetOnlineLanguage Language => OnlineInfo.Language; - - [NotMapped] - [JsonIgnore] - public int? TrackId => OnlineInfo?.TrackId; - - [NotMapped] - [JsonIgnore] - public int[] Ratings => OnlineInfo?.Ratings; - - #endregion } } diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs index 4100fe9586..636c568bd0 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs @@ -57,12 +57,7 @@ namespace osu.Game.Beatmaps.Drawables return new OnlineBeatmapSetCover(online, beatmapSetCoverType); if (model is BeatmapInfo localModel) - { - if (localModel.BeatmapSet?.OnlineInfo != null) - return new OnlineBeatmapSetCover(localModel.BeatmapSet.OnlineInfo, beatmapSetCoverType); - return new BeatmapBackgroundSprite(beatmaps.GetWorkingBeatmap(localModel)); - } return new BeatmapBackgroundSprite(beatmaps.DefaultBeatmap); } diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs index 22cf6d25cd..c41271ad5c 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs @@ -128,7 +128,6 @@ namespace osu.Game.Online.API.Requests.Responses OnlineBeatmapSetID = OnlineID, Metadata = metadata, Status = Status, - OnlineInfo = this }; beatmapSet.Beatmaps = Beatmaps.Select(b => diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index ece16a8e57..6f215b9287 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -41,13 +41,13 @@ namespace osu.Game.Screens.Select [Resolved] private RulesetStore rulesets { get; set; } - private BeatmapInfo beatmapInfo; + private IBeatmapInfo beatmapInfo; private APIFailTimes failTimes; private int[] ratings; - public BeatmapInfo BeatmapInfo + public IBeatmapInfo BeatmapInfo { get => beatmapInfo; set @@ -56,8 +56,11 @@ namespace osu.Game.Screens.Select beatmapInfo = value; - failTimes = beatmapInfo?.OnlineInfo?.FailTimes; - ratings = beatmapInfo?.BeatmapSet?.OnlineInfo?.Ratings; + var onlineInfo = beatmapInfo as IBeatmapOnlineInfo; + var onlineSetInfo = beatmapInfo.BeatmapSet as IBeatmapSetOnlineInfo; + + failTimes = onlineInfo?.FailTimes; + ratings = onlineSetInfo?.Ratings; Scheduler.AddOnce(updateStatistics); } @@ -178,9 +181,9 @@ namespace osu.Game.Screens.Select private void updateStatistics() { advanced.BeatmapInfo = BeatmapInfo; - description.Text = BeatmapInfo?.Version; - source.Text = BeatmapInfo?.Metadata?.Source; - tags.Text = BeatmapInfo?.Metadata?.Tags; + description.Text = BeatmapInfo?.DifficultyName; + source.Text = BeatmapInfo?.Metadata.Source; + tags.Text = BeatmapInfo?.Metadata.Tags; // failTimes may have been previously fetched if (ratings != null && failTimes != null) @@ -190,7 +193,7 @@ namespace osu.Game.Screens.Select } // for now, let's early abort if an OnlineBeatmapID is not present (should have been populated at import time). - if (BeatmapInfo?.OnlineBeatmapID == null || api.State.Value == APIState.Offline) + if (BeatmapInfo == null || BeatmapInfo.OnlineID <= 0 || api.State.Value == APIState.Offline) { updateMetrics(); return; diff --git a/osu.Game/Tests/Beatmaps/TestBeatmap.cs b/osu.Game/Tests/Beatmaps/TestBeatmap.cs index caf83973c4..b9eda5c06e 100644 --- a/osu.Game/Tests/Beatmaps/TestBeatmap.cs +++ b/osu.Game/Tests/Beatmaps/TestBeatmap.cs @@ -39,16 +39,6 @@ namespace osu.Game.Tests.Beatmaps BeatmapInfo.Length = 75000; BeatmapInfo.OnlineInfo = new APIBeatmap(); BeatmapInfo.OnlineBeatmapID = Interlocked.Increment(ref onlineBeatmapID); - BeatmapInfo.BeatmapSet.OnlineInfo = new APIBeatmapSet - { - 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" - } - }; } protected virtual Beatmap CreateBeatmap() => createTestBeatmap(); diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index 90e85f7716..153e2c487c 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -175,27 +175,42 @@ namespace osu.Game.Tests.Visual protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset); - protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset) + /// + /// Returns a sample API Beatmap with BeatmapSet populated. + /// + /// The ruleset to create the sample model using. osu! ruleset will be used if not specified. + 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(); + + // Populate the set as that's generally what we expect from the API. + beatmap.BeatmapSet = beatmapSet; + + return beatmap; + } + + /// + /// Returns a sample API BeatmapSet with beatmaps populated. + /// + /// The ruleset to create the sample model using. osu! ruleset will be used if not specified. + 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[]