diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs index 6f9744ca73..176e0592ef 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs @@ -21,15 +21,12 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestUndownloadableWithLink() { - AddStep("set undownloadable beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo + AddStep("set undownloadable beatmapset with link", () => container.BeatmapSet = new APIBeatmapSet { - OnlineInfo = new APIBeatmapSet + Availability = new BeatmapSetOnlineAvailability { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = true, - ExternalLink = @"https://osu.ppy.sh", - }, + DownloadDisabled = true, + ExternalLink = @"https://osu.ppy.sh", }, }); @@ -39,14 +36,11 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestUndownloadableNoLink() { - AddStep("set undownloadable beatmapset without link", () => container.BeatmapSet = new BeatmapSetInfo + AddStep("set undownloadable beatmapset without link", () => container.BeatmapSet = new APIBeatmapSet { - OnlineInfo = new APIBeatmapSet + Availability = new BeatmapSetOnlineAvailability { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = true, - }, + DownloadDisabled = true, }, }); @@ -56,15 +50,12 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestPartsRemovedWithLink() { - AddStep("set parts-removed beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo + AddStep("set parts-removed beatmapset with link", () => container.BeatmapSet = new APIBeatmapSet { - OnlineInfo = new APIBeatmapSet + Availability = new BeatmapSetOnlineAvailability { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = false, - ExternalLink = @"https://osu.ppy.sh", - }, + DownloadDisabled = false, + ExternalLink = @"https://osu.ppy.sh", }, }); @@ -74,14 +65,11 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestNormal() { - AddStep("set normal beatmapset", () => container.BeatmapSet = new BeatmapSetInfo + AddStep("set normal beatmapset", () => container.BeatmapSet = new APIBeatmapSet { - OnlineInfo = new APIBeatmapSet + Availability = new BeatmapSetOnlineAvailability { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = false, - }, + DownloadDisabled = false, }, }); diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs index eb34187cd6..b880633559 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs @@ -1,15 +1,15 @@ // Copyright (c) ppy Pty Ltd . 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; using osu.Framework.Graphics.UserInterface; -using osu.Game.Beatmaps; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet; using osu.Game.Rulesets; -using System.Collections.Generic; -using System.Linq; namespace osu.Game.Tests.Visual.Online { @@ -35,9 +35,9 @@ namespace osu.Game.Tests.Visual.Online AddStep("load multiple rulesets beatmapset", () => { - selector.BeatmapSet = new BeatmapSetInfo + selector.BeatmapSet = new APIBeatmapSet { - Beatmaps = enabledRulesets.Select(r => new BeatmapInfo { Ruleset = r }).ToList() + Beatmaps = enabledRulesets.Select(r => new APIBeatmap { RulesetID = r.OnlineID }).ToList() }; }); @@ -53,13 +53,13 @@ namespace osu.Game.Tests.Visual.Online AddStep("load single ruleset beatmapset", () => { - selector.BeatmapSet = new BeatmapSetInfo + selector.BeatmapSet = new APIBeatmapSet { - Beatmaps = new List + Beatmaps = new List { - new BeatmapInfo + new APIBeatmap { - Ruleset = enabledRuleset + RulesetID = enabledRuleset.OnlineID } } }; @@ -71,9 +71,9 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestEmptyBeatmapSet() { - AddStep("load empty beatmapset", () => selector.BeatmapSet = new BeatmapSetInfo + AddStep("load empty beatmapset", () => selector.BeatmapSet = new APIBeatmapSet { - Beatmaps = new List() + Beatmaps = new List() }); AddAssert("no ruleset selected", () => selector.SelectedTab == null); diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 7f9b56e873..bae9af1897 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -49,60 +49,48 @@ namespace osu.Game.Tests.Visual.Online { AddStep(@"show first", () => { - overlay.ShowBeatmapSet(new BeatmapSetInfo + overlay.ShowBeatmapSet(new APIBeatmapSet { - OnlineBeatmapSetID = 1235, - Metadata = new BeatmapMetadata + OnlineID = 1235, + Title = @"an awesome beatmap", + Artist = @"naru narusegawa", + Source = @"hinata sou", + Tags = @"test tag tag more tag", + Author = new User { - Title = @"an awesome beatmap", - Artist = @"naru narusegawa", - Source = @"hinata sou", - Tags = @"test tag tag more tag", - Author = new User - { - Username = @"BanchoBot", - Id = 3, - }, + Username = @"BanchoBot", + Id = 3, }, - OnlineInfo = new APIBeatmapSet + Preview = @"https://b.ppy.sh/preview/12345.mp3", + PlayCount = 123, + FavouriteCount = 456, + Submitted = DateTime.Now, + Ranked = DateTime.Now, + BPM = 111, + HasVideo = true, + Ratings = Enumerable.Range(0, 11).ToArray(), + HasStoryboard = true, + Covers = new BeatmapSetOnlineCovers(), + Beatmaps = new List { - Preview = @"https://b.ppy.sh/preview/12345.mp3", - PlayCount = 123, - FavouriteCount = 456, - Submitted = DateTime.Now, - Ranked = DateTime.Now, - BPM = 111, - HasVideo = true, - Ratings = Enumerable.Range(0, 11).ToArray(), - HasStoryboard = true, - Covers = new BeatmapSetOnlineCovers(), - }, - Beatmaps = new List - { - new BeatmapInfo + new APIBeatmap { - StarDifficulty = 9.99, - Version = @"TEST", + StarRating = 9.99, + DifficultyName = @"TEST", Length = 456000, - Ruleset = rulesets.GetRuleset(3), - BaseDifficulty = new BeatmapDifficulty + RulesetID = 3, + CircleSize = 1, + DrainRate = 2.3f, + OverallDifficulty = 4.5f, + ApproachRate = 6, + CircleCount = 111, + SliderCount = 12, + PlayCount = 222, + PassCount = 21, + FailTimes = new APIFailTimes { - CircleSize = 1, - DrainRate = 2.3f, - OverallDifficulty = 4.5f, - ApproachRate = 6, - }, - OnlineInfo = new APIBeatmap - { - CircleCount = 111, - SliderCount = 12, - PlayCount = 222, - PassCount = 21, - 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(), - }, + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, }, @@ -120,71 +108,15 @@ namespace osu.Game.Tests.Visual.Online { AddStep(@"show undownloadable", () => { - overlay.ShowBeatmapSet(new BeatmapSetInfo + var set = getBeatmapSet(); + + set.Availability = new BeatmapSetOnlineAvailability { - OnlineBeatmapSetID = 1234, - Metadata = new BeatmapMetadata - { - Title = @"undownloadable beatmap", - Artist = @"no one", - Source = @"some source", - Tags = @"another test tag tag more test tags", - Author = new User - { - Username = @"BanchoBot", - Id = 3, - }, - }, - OnlineInfo = new APIBeatmapSet - { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = true, - ExternalLink = "https://osu.ppy.sh", - }, - Preview = @"https://b.ppy.sh/preview/1234.mp3", - PlayCount = 123, - FavouriteCount = 456, - Submitted = DateTime.Now, - Ranked = DateTime.Now, - BPM = 111, - HasVideo = true, - HasStoryboard = true, - Covers = new BeatmapSetOnlineCovers(), - Language = new BeatmapSetOnlineLanguage { Id = 3, Name = "English" }, - Genre = new BeatmapSetOnlineGenre { Id = 4, Name = "Rock" }, - Ratings = Enumerable.Range(0, 11).ToArray(), - }, - Beatmaps = new List - { - new BeatmapInfo - { - StarDifficulty = 5.67, - Version = @"ANOTHER TEST", - Length = 123000, - Ruleset = rulesets.GetRuleset(1), - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 9, - DrainRate = 8, - OverallDifficulty = 7, - ApproachRate = 6, - }, - OnlineInfo = new APIBeatmap - { - CircleCount = 123, - SliderCount = 45, - PlayCount = 567, - PassCount = 89, - 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(), - }, - }, - }, - }, - }); + DownloadDisabled = true, + ExternalLink = "https://osu.ppy.sh", + }; + + overlay.ShowBeatmapSet(set); }); downloadAssert(false); @@ -195,48 +127,30 @@ namespace osu.Game.Tests.Visual.Online { AddStep("show multiple rulesets beatmap", () => { - var beatmaps = new List(); + var beatmaps = new List(); foreach (var ruleset in rulesets.AvailableRulesets.Skip(1)) { - beatmaps.Add(new BeatmapInfo + beatmaps.Add(new APIBeatmap { - Version = ruleset.Name, - Ruleset = ruleset, - BaseDifficulty = new BeatmapDifficulty(), - OnlineInfo = new APIBeatmap + DifficultyName = ruleset.Name, + RulesetID = ruleset.OnlineID, + FailTimes = new APIFailTimes { - 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(), - }, - } + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), + }, }); } - overlay.ShowBeatmapSet(new BeatmapSetInfo - { - Metadata = new BeatmapMetadata - { - Title = @"multiple rulesets beatmap", - Artist = @"none", - Author = new User - { - Username = "BanchoBot", - Id = 3, - } - }, - OnlineInfo = new APIBeatmapSet - { - Covers = new BeatmapSetOnlineCovers(), - Ratings = Enumerable.Range(0, 11).ToArray(), - }, - Beatmaps = beatmaps - }); + var set = getBeatmapSet(); + + set.Beatmaps = beatmaps; + + overlay.ShowBeatmapSet(set); }); - AddAssert("shown beatmaps of current ruleset", () => overlay.Header.HeaderContent.Picker.Difficulties.All(b => b.BeatmapInfo.Ruleset.Equals(overlay.Header.RulesetSelector.Current.Value))); + AddAssert("shown beatmaps of current ruleset", () => overlay.Header.HeaderContent.Picker.Difficulties.All(b => b.Beatmap.Ruleset.OnlineID == overlay.Header.RulesetSelector.Current.Value.OnlineID)); AddAssert("left-most beatmap selected", () => overlay.Header.HeaderContent.Picker.Difficulties.First().State == BeatmapPicker.DifficultySelectorState.Selected); } @@ -246,7 +160,7 @@ namespace osu.Game.Tests.Visual.Online AddStep("show explicit map", () => { var beatmapSet = getBeatmapSet(); - beatmapSet.OnlineInfo.HasExplicitContent = true; + beatmapSet.HasExplicitContent = true; overlay.ShowBeatmapSet(beatmapSet); }); } @@ -257,7 +171,7 @@ namespace osu.Game.Tests.Visual.Online AddStep("show featured map", () => { var beatmapSet = getBeatmapSet(); - beatmapSet.OnlineInfo.TrackId = 1; + beatmapSet.TrackId = 1; overlay.ShowBeatmapSet(beatmapSet); }); } @@ -274,63 +188,41 @@ namespace osu.Game.Tests.Visual.Online AddStep(@"show without reload", overlay.Show); } - private BeatmapSetInfo createManyDifficultiesBeatmapSet() + private APIBeatmapSet createManyDifficultiesBeatmapSet() { - var beatmaps = new List(); + var set = getBeatmapSet(); + + var beatmaps = new List(); for (int i = 1; i < 41; i++) { - beatmaps.Add(new BeatmapInfo + beatmaps.Add(new APIBeatmap { - OnlineBeatmapID = i * 10, - Version = $"Test #{i}", - Ruleset = Ruleset.Value, - StarDifficulty = 2 + i * 0.1, - BaseDifficulty = new BeatmapDifficulty + OnlineID = i * 10, + DifficultyName = $"Test #{i}", + RulesetID = Ruleset.Value.ID ?? -1, + StarRating = 2 + i * 0.1, + OverallDifficulty = 3.5f, + FailTimes = new APIFailTimes { - OverallDifficulty = 3.5f, + Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(), }, - OnlineInfo = new APIBeatmap - { - FailTimes = new APIFailTimes - { - Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(), - }, - } }); } - return new BeatmapSetInfo - { - OnlineBeatmapSetID = 123, - Metadata = new BeatmapMetadata - { - Title = @"many difficulties beatmap", - Artist = @"none", - Author = new User - { - Username = @"BanchoBot", - Id = 3, - }, - }, - OnlineInfo = new APIBeatmapSet - { - Preview = @"https://b.ppy.sh/preview/123.mp3", - HasVideo = true, - HasStoryboard = true, - Covers = new BeatmapSetOnlineCovers(), - Ratings = Enumerable.Range(0, 11).ToArray(), - }, - Beatmaps = beatmaps, - }; + set.Beatmaps = beatmaps; + + return set; } - private BeatmapSetInfo getBeatmapSet() + private APIBeatmapSet getBeatmapSet() { - var beatmapSet = CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet; + var beatmapSet = CreateAPIBeatmapSet(Ruleset.Value); + // Make sure the overlay is reloaded (see `BeatmapSetInfo.Equals`). - beatmapSet.OnlineBeatmapSetID = nextBeatmapSetId++; + beatmapSet.OnlineID = nextBeatmapSetId++; + return beatmapSet; } diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs index d14f9f47d1..491a2d5d90 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs @@ -44,27 +44,21 @@ namespace osu.Game.Tests.Visual.Online AddStep("set second set", () => details.BeatmapSet = secondSet); AddAssert("ratings set", () => details.Ratings.Ratings == secondSet.Ratings); - static BeatmapSetInfo createSet() => new BeatmapSetInfo + static APIBeatmapSet createSet() => new APIBeatmapSet { - Beatmaps = new List + Beatmaps = new List { - new BeatmapInfo + new APIBeatmap { - OnlineInfo = new APIBeatmap + FailTimes = new APIFailTimes { - FailTimes = new APIFailTimes - { - Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(), - }, - } + Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(), + }, } }, - OnlineInfo = new APIBeatmapSet - { - Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray(), - Status = BeatmapSetOnlineStatus.Ranked - } + Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray(), + Status = BeatmapSetOnlineStatus.Ranked }; } diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs index b3b67fcbca..be3fc7aff9 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlaySuccessRate.cs @@ -59,21 +59,18 @@ namespace osu.Game.Tests.Visual.Online var firstBeatmap = createBeatmap(); var secondBeatmap = createBeatmap(); - AddStep("set first set", () => successRate.BeatmapInfo = firstBeatmap); + AddStep("set first set", () => successRate.Beatmap = firstBeatmap); AddAssert("ratings set", () => successRate.Graph.FailTimes == firstBeatmap.FailTimes); - AddStep("set second set", () => successRate.BeatmapInfo = secondBeatmap); + AddStep("set second set", () => successRate.Beatmap = secondBeatmap); AddAssert("ratings set", () => successRate.Graph.FailTimes == secondBeatmap.FailTimes); - static BeatmapInfo createBeatmap() => new BeatmapInfo + static APIBeatmap createBeatmap() => new APIBeatmap { - OnlineInfo = new APIBeatmap + FailTimes = new APIFailTimes { - FailTimes = new APIFailTimes - { - Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(), - } + Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(), } }; } @@ -81,14 +78,11 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestOnlyFailMetrics() { - AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo + AddStep("set beatmap", () => successRate.Beatmap = new APIBeatmap { - OnlineInfo = new APIBeatmap + FailTimes = new APIFailTimes { - FailTimes = new APIFailTimes - { - Fails = Enumerable.Range(1, 100).ToArray(), - } + Fails = Enumerable.Range(1, 100).ToArray(), } }); @@ -98,12 +92,9 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestEmptyMetrics() { - AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo + AddStep("set beatmap", () => successRate.Beatmap = new APIBeatmap { - OnlineInfo = new APIBeatmap - { - FailTimes = new APIFailTimes(), - } + FailTimes = new APIFailTimes() }); AddAssert("graph max values correct", () => successRate.ChildrenOfType().All(graph => graph.MaxValue == 0)); diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs index bb7fcc2fce..f0cf88840a 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs @@ -69,24 +69,7 @@ namespace osu.Game.Tests.Visual.Online AddAssert($"button {(enabled ? "enabled" : "disabled")}", () => downloadButton.DownloadEnabled == enabled); } - private BeatmapSetInfo createSoleily() - { - return new BeatmapSetInfo - { - ID = 1, - OnlineBeatmapSetID = 241526, - OnlineInfo = new APIBeatmapSet - { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = false, - ExternalLink = string.Empty, - }, - }, - }; - } - - private void createButtonWithBeatmap(BeatmapSetInfo beatmap) + private void createButtonWithBeatmap(IBeatmapSetInfo beatmap) { AddStep("create button", () => { @@ -112,32 +95,47 @@ namespace osu.Game.Tests.Visual.Online }); } - private BeatmapSetInfo getDownloadableBeatmapSet() + private IBeatmapSetInfo createSoleily() { - var normal = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo; - normal.OnlineInfo.HasVideo = true; - normal.OnlineInfo.HasStoryboard = true; - - return normal; + return new APIBeatmapSet + { + OnlineID = 241526, + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = false, + ExternalLink = string.Empty, + }, + }; } - private BeatmapSetInfo getUndownloadableBeatmapSet() + private IBeatmapSetInfo getDownloadableBeatmapSet() { - var beatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo; - beatmap.Metadata.Artist = "test"; - beatmap.Metadata.Title = "undownloadable"; - beatmap.Metadata.AuthorString = "test"; + var apiBeatmapSet = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo.OnlineInfo; - beatmap.OnlineInfo.HasVideo = true; - beatmap.OnlineInfo.HasStoryboard = true; + apiBeatmapSet.HasVideo = true; + apiBeatmapSet.HasStoryboard = true; - beatmap.OnlineInfo.Availability = new BeatmapSetOnlineAvailability + return apiBeatmapSet; + } + + private IBeatmapSetInfo getUndownloadableBeatmapSet() + { + var apiBeatmapSet = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo.OnlineInfo; + + apiBeatmapSet.Artist = "test"; + apiBeatmapSet.Title = "undownloadable"; + apiBeatmapSet.AuthorString = "test"; + + apiBeatmapSet.HasVideo = true; + apiBeatmapSet.HasStoryboard = true; + + apiBeatmapSet.Availability = new BeatmapSetOnlineAvailability { DownloadDisabled = true, ExternalLink = "http://osu.ppy.sh", }; - return beatmap; + return apiBeatmapSet; } private class TestDownloadButton : BeatmapPanelDownloadButton @@ -146,7 +144,7 @@ namespace osu.Game.Tests.Visual.Online public DownloadState DownloadState => State.Value; - public TestDownloadButton(BeatmapSetInfo beatmapSet) + public TestDownloadButton(IBeatmapSetInfo beatmapSet) : base(beatmapSet) { } diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs index 6caca2a67c..9a3d998966 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs @@ -18,104 +18,25 @@ namespace osu.Game.Tests.Visual.Online [Cached(typeof(IPreviewTrackOwner))] public class TestSceneDirectPanel : OsuTestScene, IPreviewTrackOwner { - private BeatmapSetInfo getUndownloadableBeatmapSet() => new BeatmapSetInfo - { - OnlineBeatmapSetID = 123, - Metadata = new BeatmapMetadata - { - Title = "undownloadable beatmap", - Artist = "test", - Source = "more tests", - Author = new User - { - Username = "BanchoBot", - Id = 3, - }, - }, - OnlineInfo = new APIBeatmapSet - { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = true, - }, - Preview = @"https://b.ppy.sh/preview/12345.mp3", - PlayCount = 123, - FavouriteCount = 456, - BPM = 111, - HasVideo = true, - HasStoryboard = true, - Covers = new BeatmapSetOnlineCovers(), - }, - Beatmaps = new List - { - new BeatmapInfo - { - Ruleset = Ruleset.Value, - Version = "Test", - StarDifficulty = 6.42, - } - } - }; - - private BeatmapSetInfo getManyDifficultiesBeatmapSet(RulesetStore rulesets) - { - var beatmaps = new List(); - - for (int i = 0; i < 100; i++) - { - beatmaps.Add(new BeatmapInfo - { - Ruleset = rulesets.GetRuleset(i % 4), - StarDifficulty = 2 + i % 4 * 2, - BaseDifficulty = new BeatmapDifficulty - { - OverallDifficulty = 3.5f, - } - }); - } - - return new BeatmapSetInfo - { - OnlineBeatmapSetID = 1, - Metadata = new BeatmapMetadata - { - Title = "many difficulties beatmap", - Artist = "test", - Author = new User - { - Username = "BanchoBot", - Id = 3, - } - }, - OnlineInfo = new APIBeatmapSet - { - HasVideo = true, - HasStoryboard = true, - Covers = new BeatmapSetOnlineCovers(), - }, - Beatmaps = beatmaps, - }; - } - [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { var normal = getBeatmapSet(); - normal.OnlineInfo.HasVideo = true; - normal.OnlineInfo.HasStoryboard = true; + normal.HasVideo = true; + normal.HasStoryboard = true; var undownloadable = getUndownloadableBeatmapSet(); - var manyDifficulties = getManyDifficultiesBeatmapSet(rulesets); + var manyDifficulties = getManyDifficultiesBeatmapSet(); var explicitMap = getBeatmapSet(); - explicitMap.OnlineInfo.HasExplicitContent = true; + explicitMap.HasExplicitContent = true; var featuredMap = getBeatmapSet(); - featuredMap.OnlineInfo.TrackId = 1; + featuredMap.TrackId = 1; var explicitFeaturedMap = getBeatmapSet(); - explicitFeaturedMap.OnlineInfo.HasExplicitContent = true; - explicitFeaturedMap.OnlineInfo.TrackId = 2; + explicitFeaturedMap.HasExplicitContent = true; + explicitFeaturedMap.TrackId = 2; Child = new BasicScrollContainer { @@ -145,7 +66,72 @@ namespace osu.Game.Tests.Visual.Online }, }; - BeatmapSetInfo getBeatmapSet() => CreateBeatmap(Ruleset.Value).BeatmapInfo.BeatmapSet; + APIBeatmapSet getBeatmapSet() => CreateAPIBeatmapSet(Ruleset.Value); + + APIBeatmapSet getUndownloadableBeatmapSet() => new APIBeatmapSet + { + OnlineID = 123, + Title = "undownloadable beatmap", + Artist = "test", + Source = "more tests", + Author = new User + { + Username = "BanchoBot", + Id = 3, + }, + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = true, + }, + Preview = @"https://b.ppy.sh/preview/12345.mp3", + PlayCount = 123, + FavouriteCount = 456, + BPM = 111, + HasVideo = true, + HasStoryboard = true, + Covers = new BeatmapSetOnlineCovers(), + Beatmaps = new List + { + new APIBeatmap + { + RulesetID = Ruleset.Value.ID ?? 0, + DifficultyName = "Test", + StarRating = 6.42, + } + } + }; + + APIBeatmapSet getManyDifficultiesBeatmapSet() + { + var beatmaps = new List(); + + for (int i = 0; i < 100; i++) + { + beatmaps.Add(new APIBeatmap + { + RulesetID = i % 4, + StarRating = 2 + i % 4 * 2, + OverallDifficulty = 3.5f, + }); + } + + return new APIBeatmapSet + { + OnlineID = 1, + Title = "undownloadable beatmap", + Artist = "test", + Source = "more tests", + Author = new User + { + Username = "BanchoBot", + Id = 3, + }, + HasVideo = true, + HasStoryboard = true, + Covers = new BeatmapSetOnlineCovers(), + Beatmaps = beatmaps, + }; + } } } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs b/osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs index 8e2ee4e28d..87458da578 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneFavouriteButton.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Testing; -using osu.Game.Beatmaps; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapSet.Buttons; using osuTK; @@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestLoggedOutIn() { - AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo { OnlineBeatmapSetID = 88 }); + AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet { OnlineID = 88 }); AddStep("log out", () => API.Logout()); checkEnabled(false); AddStep("log in", () => API.Login("test", "test")); @@ -40,9 +40,9 @@ namespace osu.Game.Tests.Visual.Online public void TestBeatmapChange() { AddStep("log in", () => API.Login("test", "test")); - AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo { OnlineBeatmapSetID = 88 }); + AddStep("set valid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet { OnlineID = 88 }); checkEnabled(true); - AddStep("set invalid beatmap", () => favourite.BeatmapSet.Value = new BeatmapSetInfo()); + AddStep("set invalid beatmap", () => favourite.BeatmapSet.Value = new APIBeatmapSet()); checkEnabled(false); } diff --git a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs index fc438ce6dd..aa442ded02 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs @@ -26,7 +26,8 @@ namespace osu.Game.Tests.Visual.Online { LeaderboardModSelector modSelector; FillFlowContainer selectedMods; - var ruleset = new Bindable(); + + var ruleset = new Bindable(); Add(selectedMods = new FillFlowContainer { diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs index 4538e36c5e..6a2b577fd3 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs @@ -124,7 +124,7 @@ namespace osu.Game.Tests.Visual.SongSelect { var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance(); var difficultyAdjustMod = ruleset.CreateMod(); - difficultyAdjustMod.ReadFromDifficulty(advancedStats.BeatmapInfo.BaseDifficulty); + difficultyAdjustMod.ReadFromDifficulty(advancedStats.BeatmapInfo.Difficulty); SelectedMods.Value = new[] { difficultyAdjustMod }; }); @@ -143,7 +143,7 @@ namespace osu.Game.Tests.Visual.SongSelect { var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance(); var difficultyAdjustMod = ruleset.CreateMod(); - var originalDifficulty = advancedStats.BeatmapInfo.BaseDifficulty; + var originalDifficulty = advancedStats.BeatmapInfo.Difficulty; difficultyAdjustMod.ReadFromDifficulty(originalDifficulty); difficultyAdjustMod.DrainRate.Value = originalDifficulty.DrainRate - 0.5f; diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs index a9fe7ed7d8..f17de75f5c 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSearchControl.cs @@ -110,25 +110,19 @@ namespace osu.Game.Tests.Visual.UserInterface base.Dispose(isDisposing); } - private static readonly BeatmapSetInfo beatmap_set = new BeatmapSetInfo + private static readonly APIBeatmapSet beatmap_set = new APIBeatmapSet { - OnlineInfo = new APIBeatmapSet + Covers = new BeatmapSetOnlineCovers { - Covers = new BeatmapSetOnlineCovers - { - Cover = "https://assets.ppy.sh/beatmaps/1094296/covers/cover@2x.jpg?1581416305" - } + Cover = "https://assets.ppy.sh/beatmaps/1094296/covers/cover@2x.jpg?1581416305" } }; - private static readonly BeatmapSetInfo no_cover_beatmap_set = new BeatmapSetInfo + private static readonly APIBeatmapSet no_cover_beatmap_set = new APIBeatmapSet { - OnlineInfo = new APIBeatmapSet + Covers = new BeatmapSetOnlineCovers { - Covers = new BeatmapSetOnlineCovers - { - Cover = string.Empty - } + Cover = string.Empty } }; } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs index 74cd675a05..d30f1e8889 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneUpdateableBeatmapBackgroundSprite.cs @@ -12,6 +12,7 @@ using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics.Containers; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets; using osu.Game.Tests.Beatmaps.IO; using osuTK; @@ -24,7 +25,6 @@ namespace osu.Game.Tests.Visual.UserInterface private BeatmapSetInfo testBeatmap; private IAPIProvider api; - private RulesetStore rulesets; [Resolved] private BeatmapManager beatmaps { get; set; } @@ -33,7 +33,6 @@ namespace osu.Game.Tests.Visual.UserInterface private void load(OsuGameBase osu, IAPIProvider api, RulesetStore rulesets) { this.api = api; - this.rulesets = rulesets; testBeatmap = ImportBeatmapTest.LoadOszIntoOsu(osu).Result; } @@ -81,7 +80,7 @@ namespace osu.Game.Tests.Visual.UserInterface Child = background = new TestUpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both, - Beatmap = { Value = new BeatmapInfo { BeatmapSet = req.Response?.ToBeatmapSet(rulesets) } } + Beatmap = { Value = new APIBeatmap { BeatmapSet = req.Response } } }; }); diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs index 061e034648..653b011f73 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs @@ -100,10 +100,10 @@ namespace osu.Game.Online.API.Requests.Responses MaxCombo = MaxCombo, BaseDifficulty = new BeatmapDifficulty { - DrainRate = drainRate, - CircleSize = circleSize, - ApproachRate = approachRate, - OverallDifficulty = overallDifficulty, + DrainRate = DrainRate, + CircleSize = CircleSize, + ApproachRate = ApproachRate, + OverallDifficulty = OverallDifficulty, }, OnlineInfo = this, }; diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs index 03d36ff5df..fa57191ef3 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs @@ -12,9 +12,9 @@ using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Framework.Localisation; using osu.Framework.Threading; -using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets; using osu.Game.Resources.Localisation.Web; using osuTK; @@ -206,7 +206,7 @@ namespace osu.Game.Overlays.BeatmapListing getSetsRequest.Success += response => { - var sets = response.BeatmapSets.Select(responseJson => responseJson.ToBeatmapSet(rulesets)).ToList(); + var sets = response.BeatmapSets.ToList(); // If the previous request returned a null cursor, the API is indicating we can't paginate further (maybe there are no more beatmaps left). if (sets.Count == 0 || response.Cursor == null) @@ -289,7 +289,7 @@ namespace osu.Game.Overlays.BeatmapListing /// Contains the beatmap sets returned from API. /// Valid for read if and only if is . /// - public List Results { get; private set; } + public List Results { get; private set; } /// /// Contains the names of supporter-only filters requested by the user. @@ -297,7 +297,7 @@ namespace osu.Game.Overlays.BeatmapListing /// public List SupporterOnlyFiltersUsed { get; private set; } - public static SearchResult ResultsReturned(List results) => new SearchResult + public static SearchResult ResultsReturned(List results) => new SearchResult { Type = SearchResultType.ResultsReturned, Results = results diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs index 776a8e73b0..2474515802 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs @@ -8,12 +8,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; -using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Configuration; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Input.Bindings; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets; using osu.Game.Scoring; @@ -49,17 +49,17 @@ namespace osu.Game.Overlays.BeatmapListing public Bindable ExplicitContent => explicitContentFilter.Current; - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { set { - if (value == null || string.IsNullOrEmpty(value.OnlineInfo.Covers.Cover)) + if (value == null || string.IsNullOrEmpty(value.Covers.Cover)) { beatmapCover.FadeOut(600, Easing.OutQuint); return; } - beatmapCover.OnlineInfo = value.OnlineInfo; + beatmapCover.OnlineInfo = value; beatmapCover.FadeTo(0.1f, 200, Easing.OutQuint); } } diff --git a/osu.Game/Overlays/BeatmapListing/Panels/BeatmapPanel.cs b/osu.Game/Overlays/BeatmapListing/Panels/BeatmapPanel.cs index c7fa98f159..2fd05f6742 100644 --- a/osu.Game/Overlays/BeatmapListing/Panels/BeatmapPanel.cs +++ b/osu.Game/Overlays/BeatmapListing/Panels/BeatmapPanel.cs @@ -23,6 +23,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API.Requests.Responses; using osuTK; using osuTK.Graphics; @@ -30,7 +31,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { public abstract class BeatmapPanel : OsuClickableContainer, IHasContextMenu { - public readonly BeatmapSetInfo SetInfo; + public readonly APIBeatmapSet SetInfo; private const double hover_transition_time = 400; private const int maximum_difficulty_icons = 10; @@ -49,10 +50,10 @@ namespace osu.Game.Overlays.BeatmapListing.Panels protected Action ViewBeatmap; - protected BeatmapPanel(BeatmapSetInfo setInfo) + protected BeatmapPanel(APIBeatmapSet setInfo) : base(HoverSampleSet.Submit) { - Debug.Assert(setInfo.OnlineBeatmapSetID != null); + Debug.Assert(setInfo.OnlineID > 0); SetInfo = setInfo; } @@ -95,8 +96,8 @@ namespace osu.Game.Overlays.BeatmapListing.Panels Action = ViewBeatmap = () => { - Debug.Assert(SetInfo.OnlineBeatmapSetID != null); - beatmapSetOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value); + Debug.Assert(SetInfo.OnlineID > 0); + beatmapSetOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineID); }; } @@ -146,14 +147,14 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { var icons = new List(); - if (SetInfo.Beatmaps.Count > maximum_difficulty_icons) + if (SetInfo.Beatmaps.Count() > maximum_difficulty_icons) { foreach (var ruleset in SetInfo.Beatmaps.Select(b => b.Ruleset).Distinct()) - icons.Add(new GroupedDifficultyIcon(SetInfo.Beatmaps.FindAll(b => b.Ruleset.Equals(ruleset)), 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)); } else { - foreach (var b in SetInfo.Beatmaps.OrderBy(beatmap => beatmap.Ruleset.ID).ThenBy(beatmap => beatmap.StarDifficulty)) + foreach (var b in SetInfo.Beatmaps.OrderBy(beatmap => beatmap.RulesetID).ThenBy(beatmap => beatmap.StarRating)) icons.Add(new DifficultyIcon(b)); } @@ -163,7 +164,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels protected Drawable CreateBackground() => new UpdateableOnlineBeatmapSetCover { RelativeSizeAxes = Axes.Both, - OnlineInfo = SetInfo.OnlineInfo, + OnlineInfo = SetInfo, }; public class Statistic : FillFlowContainer diff --git a/osu.Game/Overlays/BeatmapListing/Panels/BeatmapPanelDownloadButton.cs b/osu.Game/Overlays/BeatmapListing/Panels/BeatmapPanelDownloadButton.cs index dd12e8e467..d7c2837f4d 100644 --- a/osu.Game/Overlays/BeatmapListing/Panels/BeatmapPanelDownloadButton.cs +++ b/osu.Game/Overlays/BeatmapListing/Panels/BeatmapPanelDownloadButton.cs @@ -11,6 +11,7 @@ using osu.Game.Configuration; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.BeatmapListing.Panels { @@ -21,7 +22,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels /// /// Currently selected beatmap. Used to present the correct difficulty after completing a download. /// - public readonly IBindable SelectedBeatmap = new Bindable(); + public readonly IBindable SelectedBeatmap = new Bindable(); private readonly ShakeContainer shakeContainer; private readonly DownloadButton button; @@ -31,9 +32,9 @@ namespace osu.Game.Overlays.BeatmapListing.Panels protected readonly Bindable State = new Bindable(); - private readonly BeatmapSetInfo beatmapSet; + private readonly IBeatmapSetInfo beatmapSet; - public BeatmapPanelDownloadButton(BeatmapSetInfo beatmapSet) + public BeatmapPanelDownloadButton(IBeatmapSetInfo beatmapSet) { this.beatmapSet = beatmapSet; @@ -79,13 +80,13 @@ namespace osu.Game.Overlays.BeatmapListing.Panels case DownloadState.LocallyAvailable: Predicate findPredicate = null; if (SelectedBeatmap.Value != null) - findPredicate = b => b.OnlineBeatmapID == SelectedBeatmap.Value.OnlineBeatmapID; + findPredicate = b => b.OnlineBeatmapID == SelectedBeatmap.Value.OnlineID; game?.PresentBeatmap(beatmapSet, findPredicate); break; default: - beatmaps.Download(beatmapSet, noVideoSetting.Value); + beatmaps.Download(new BeatmapSetInfo { OnlineBeatmapSetID = beatmapSet.OnlineID }, noVideoSetting.Value); break; } }; @@ -100,7 +101,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels break; default: - if (beatmapSet.OnlineInfo?.Availability.DownloadDisabled ?? false) + if ((beatmapSet as IBeatmapSetOnlineInfo)?.Availability.DownloadDisabled == true) { button.Enabled.Value = false; button.TooltipText = "this beatmap is currently not available for download."; diff --git a/osu.Game/Overlays/BeatmapListing/Panels/DownloadProgressBar.cs b/osu.Game/Overlays/BeatmapListing/Panels/DownloadProgressBar.cs index 24f929f55e..93eaf775e0 100644 --- a/osu.Game/Overlays/BeatmapListing/Panels/DownloadProgressBar.cs +++ b/osu.Game/Overlays/BeatmapListing/Panels/DownloadProgressBar.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels private readonly ProgressBar progressBar; private readonly BeatmapDownloadTracker downloadTracker; - public DownloadProgressBar(BeatmapSetInfo beatmapSet) + public DownloadProgressBar(IBeatmapSetInfo beatmapSet) { InternalChildren = new Drawable[] { diff --git a/osu.Game/Overlays/BeatmapListing/Panels/GridBeatmapPanel.cs b/osu.Game/Overlays/BeatmapListing/Panels/GridBeatmapPanel.cs index 4a0fa59c31..770e5af7bd 100644 --- a/osu.Game/Overlays/BeatmapListing/Panels/GridBeatmapPanel.cs +++ b/osu.Game/Overlays/BeatmapListing/Panels/GridBeatmapPanel.cs @@ -9,11 +9,11 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Framework.Localisation; -using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapSet; using osuTK; using osuTK.Graphics; @@ -32,7 +32,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; - public GridBeatmapPanel(BeatmapSetInfo beatmap) + public GridBeatmapPanel(APIBeatmapSet beatmap) : base(beatmap) { Width = 380; @@ -84,7 +84,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { new OsuSpriteText { - Text = new RomanisableString(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title), + Text = new RomanisableString(SetInfo.TitleUnicode, SetInfo.Title), Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true) }, } @@ -97,7 +97,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { new OsuSpriteText { - Text = new RomanisableString(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist), + Text = new RomanisableString(SetInfo.ArtistUnicode, SetInfo.Artist), Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true) } } @@ -145,7 +145,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { d.AutoSizeAxes = Axes.Both; d.AddText("mapped by ", t => t.Colour = colours.Gray5); - d.AddUserLink(SetInfo.Metadata.Author); + d.AddUserLink(SetInfo.Author); }), new Container { @@ -155,11 +155,11 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { new OsuSpriteText { - Text = SetInfo.Metadata.Source, + Text = SetInfo.Source, Font = OsuFont.GetFont(size: 14), Shadow = false, Colour = colours.Gray5, - Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f, + Alpha = string.IsNullOrEmpty(SetInfo.Source) ? 0f : 1f, }, }, }, @@ -193,8 +193,8 @@ namespace osu.Game.Overlays.BeatmapListing.Panels Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding }, Children = new[] { - new Statistic(FontAwesome.Solid.PlayCircle, SetInfo.OnlineInfo?.PlayCount ?? 0), - new Statistic(FontAwesome.Solid.Heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), + new Statistic(FontAwesome.Solid.PlayCircle, SetInfo.PlayCount), + new Statistic(FontAwesome.Solid.Heart, SetInfo.FavouriteCount), }, }, statusContainer = new FillFlowContainer @@ -211,7 +211,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels }, }); - if (SetInfo.OnlineInfo?.HasExplicitContent ?? false) + if (SetInfo.HasExplicitContent) { titleContainer.Add(new ExplicitContentBeatmapPill { @@ -221,7 +221,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels }); } - if (SetInfo.OnlineInfo?.TrackId != null) + if (SetInfo.TrackId != null) { artistContainer.Add(new FeaturedArtistBeatmapPill { @@ -231,12 +231,12 @@ namespace osu.Game.Overlays.BeatmapListing.Panels }); } - if (SetInfo.OnlineInfo?.HasVideo ?? false) + if (SetInfo.HasVideo) { statusContainer.Add(new IconPill(FontAwesome.Solid.Film)); } - if (SetInfo.OnlineInfo?.HasStoryboard ?? false) + if (SetInfo.HasStoryboard) { statusContainer.Add(new IconPill(FontAwesome.Solid.Image)); } @@ -246,7 +246,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels AutoSizeAxes = Axes.Both, TextSize = 12, TextPadding = new MarginPadding { Horizontal = 10, Vertical = 5 }, - Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, + Status = SetInfo.Status, }); PreviewPlaying.ValueChanged += _ => updateStatusContainer(); diff --git a/osu.Game/Overlays/BeatmapListing/Panels/ListBeatmapPanel.cs b/osu.Game/Overlays/BeatmapListing/Panels/ListBeatmapPanel.cs index 63d651f9de..dcd676724a 100644 --- a/osu.Game/Overlays/BeatmapListing/Panels/ListBeatmapPanel.cs +++ b/osu.Game/Overlays/BeatmapListing/Panels/ListBeatmapPanel.cs @@ -9,11 +9,11 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; -using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapSet; using osuTK; using osuTK.Graphics; @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; - public ListBeatmapPanel(BeatmapSetInfo beatmap) + public ListBeatmapPanel(APIBeatmapSet beatmap) : base(beatmap) { RelativeSizeAxes = Axes.X; @@ -107,7 +107,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { new OsuSpriteText { - Text = new RomanisableString(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title), + Text = new RomanisableString(SetInfo.TitleUnicode, SetInfo.Title), Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true) }, } @@ -120,7 +120,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { new OsuSpriteText { - Text = new RomanisableString(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist), + Text = new RomanisableString(SetInfo.ArtistUnicode, SetInfo.Artist), Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true) }, }, @@ -182,8 +182,8 @@ namespace osu.Game.Overlays.BeatmapListing.Panels Direction = FillDirection.Vertical, Children = new Drawable[] { - new Statistic(FontAwesome.Solid.PlayCircle, SetInfo.OnlineInfo?.PlayCount ?? 0), - new Statistic(FontAwesome.Solid.Heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0), + new Statistic(FontAwesome.Solid.PlayCircle, SetInfo.PlayCount), + new Statistic(FontAwesome.Solid.Heart, SetInfo.FavouriteCount), new LinkFlowContainer(s => { s.Shadow = false; @@ -197,15 +197,15 @@ namespace osu.Game.Overlays.BeatmapListing.Panels { d.AutoSizeAxes = Axes.Both; d.AddText("mapped by "); - d.AddUserLink(SetInfo.Metadata.Author); + d.AddUserLink(SetInfo.Author); }), new OsuSpriteText { - Text = SetInfo.Metadata.Source, + Text = SetInfo.Source, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Font = OsuFont.GetFont(size: 14), - Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f, + Alpha = string.IsNullOrEmpty(SetInfo.Source) ? 0f : 1f, }, }, }, @@ -225,7 +225,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels }, }); - if (SetInfo.OnlineInfo?.HasExplicitContent ?? false) + if (SetInfo.HasExplicitContent) { titleContainer.Add(new ExplicitContentBeatmapPill { @@ -235,7 +235,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels }); } - if (SetInfo.OnlineInfo?.TrackId != null) + if (SetInfo.TrackId != null) { artistContainer.Add(new FeaturedArtistBeatmapPill { @@ -245,12 +245,12 @@ namespace osu.Game.Overlays.BeatmapListing.Panels }); } - if (SetInfo.OnlineInfo?.HasVideo ?? false) + if (SetInfo.HasVideo) { statusContainer.Add(new IconPill(FontAwesome.Solid.Film) { IconSize = new Vector2(20) }); } - if (SetInfo.OnlineInfo?.HasStoryboard ?? false) + if (SetInfo.HasStoryboard) { statusContainer.Add(new IconPill(FontAwesome.Solid.Image) { IconSize = new Vector2(20) }); } @@ -260,7 +260,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels AutoSizeAxes = Axes.Both, TextSize = 12, TextPadding = new MarginPadding { Horizontal = 10, Vertical = 4 }, - Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None, + Status = SetInfo.Status, }); } } diff --git a/osu.Game/Overlays/BeatmapListing/Panels/PlayButton.cs b/osu.Game/Overlays/BeatmapListing/Panels/PlayButton.cs index 3aa9aa5ca5..c352fe0223 100644 --- a/osu.Game/Overlays/BeatmapListing/Panels/PlayButton.cs +++ b/osu.Game/Overlays/BeatmapListing/Panels/PlayButton.cs @@ -8,9 +8,9 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Game.Audio; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API.Requests.Responses; using osuTK; using osuTK.Graphics; @@ -24,9 +24,9 @@ namespace osu.Game.Overlays.BeatmapListing.Panels public PreviewTrack Preview { get; private set; } - private BeatmapSetInfo beatmapSet; + private APIBeatmapSet beatmapSet; - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { get => beatmapSet; set @@ -66,7 +66,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels } } - public PlayButton(BeatmapSetInfo setInfo = null) + public PlayButton(APIBeatmapSet setInfo = null) { BeatmapSet = setInfo; AddRange(new Drawable[] diff --git a/osu.Game/Overlays/BeatmapListingOverlay.cs b/osu.Game/Overlays/BeatmapListingOverlay.cs index 935a89b99b..e08af52a72 100644 --- a/osu.Game/Overlays/BeatmapListingOverlay.cs +++ b/osu.Game/Overlays/BeatmapListingOverlay.cs @@ -15,10 +15,10 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input.Events; using osu.Game.Audio; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Containers; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapListing; using osu.Game.Overlays.BeatmapListing.Panels; using osu.Game.Resources.Localisation.Web; @@ -136,7 +136,7 @@ namespace osu.Game.Overlays return; } - var newPanels = searchResult.Results.Select(b => new GridBeatmapPanel(b) + var newPanels = searchResult.Results.Select(b => new GridBeatmapPanel(b) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, diff --git a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs index 265d9bf125..c90e2e2085 100644 --- a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs @@ -6,7 +6,6 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; using osu.Game.Users.Drawables; using osuTK; @@ -16,6 +15,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Users; using osu.Game.Graphics.Containers; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.BeatmapSet { @@ -26,9 +26,9 @@ namespace osu.Game.Overlays.BeatmapSet private UpdateableAvatar avatar; private FillFlowContainer fields; - private BeatmapSetInfo beatmapSet; + private APIBeatmapSet beatmapSet; - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { get => beatmapSet; set @@ -78,30 +78,28 @@ namespace osu.Game.Overlays.BeatmapSet private void updateDisplay() { - avatar.User = BeatmapSet?.Metadata.Author; + avatar.User = BeatmapSet?.Author; fields.Clear(); if (BeatmapSet == null) return; - var online = BeatmapSet.OnlineInfo; - fields.Children = new Drawable[] { - new Field("mapped by", BeatmapSet.Metadata.Author, OsuFont.GetFont(weight: FontWeight.Regular, italics: true)), - new Field("submitted", online.Submitted, OsuFont.GetFont(weight: FontWeight.Bold)) + new Field("mapped by", BeatmapSet.Author, OsuFont.GetFont(weight: FontWeight.Regular, italics: true)), + new Field("submitted", BeatmapSet.Submitted, OsuFont.GetFont(weight: FontWeight.Bold)) { Margin = new MarginPadding { Top = 5 }, }, }; - if (online.Ranked.HasValue) + if (BeatmapSet.Ranked.HasValue) { - fields.Add(new Field(online.Status.ToString().ToLowerInvariant(), online.Ranked.Value, OsuFont.GetFont(weight: FontWeight.Bold))); + fields.Add(new Field(BeatmapSet.Status.ToString().ToLowerInvariant(), BeatmapSet.Ranked.Value, OsuFont.GetFont(weight: FontWeight.Bold))); } - else if (online.LastUpdated.HasValue) + else if (BeatmapSet.LastUpdated.HasValue) { - fields.Add(new Field("last updated", online.LastUpdated.Value, OsuFont.GetFont(weight: FontWeight.Bold))); + fields.Add(new Field("last updated", BeatmapSet.LastUpdated.Value, OsuFont.GetFont(weight: FontWeight.Bold))); } } diff --git a/osu.Game/Overlays/BeatmapSet/BasicStats.cs b/osu.Game/Overlays/BeatmapSet/BasicStats.cs index 683f4f0c49..8f848edf24 100644 --- a/osu.Game/Overlays/BeatmapSet/BasicStats.cs +++ b/osu.Game/Overlays/BeatmapSet/BasicStats.cs @@ -14,6 +14,7 @@ using osu.Game.Beatmaps; using osu.Game.Extensions; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; using osuTK; @@ -23,9 +24,9 @@ namespace osu.Game.Overlays.BeatmapSet { private readonly Statistic length, bpm, circleCount, sliderCount; - private BeatmapSetInfo beatmapSet; + private APIBeatmapSet beatmapSet; - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { get => beatmapSet; set @@ -38,9 +39,9 @@ namespace osu.Game.Overlays.BeatmapSet } } - private BeatmapInfo beatmapInfo; + private IBeatmapInfo beatmapInfo; - public BeatmapInfo BeatmapInfo + public IBeatmapInfo BeatmapInfo { get => beatmapInfo; set @@ -55,7 +56,7 @@ namespace osu.Game.Overlays.BeatmapSet private void updateDisplay() { - bpm.Value = BeatmapSet?.OnlineInfo?.BPM.ToLocalisableString(@"0.##") ?? (LocalisableString)"-"; + bpm.Value = BeatmapSet?.BPM.ToLocalisableString(@"0.##") ?? (LocalisableString)"-"; if (beatmapInfo == null) { @@ -68,8 +69,10 @@ namespace osu.Game.Overlays.BeatmapSet length.TooltipText = BeatmapsetsStrings.ShowStatsTotalLength(TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration()); length.Value = TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration(); - circleCount.Value = beatmapInfo.OnlineInfo.CircleCount.ToLocalisableString(@"N0"); - sliderCount.Value = beatmapInfo.OnlineInfo.SliderCount.ToLocalisableString(@"N0"); + var onlineInfo = beatmapInfo as IBeatmapOnlineInfo; + + circleCount.Value = (onlineInfo?.CircleCount ?? 0).ToLocalisableString(@"N0"); + sliderCount.Value = (onlineInfo?.SliderCount ?? 0).ToLocalisableString(@"N0"); } } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs b/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs index f005a37eaa..dc46452dcb 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs @@ -5,19 +5,19 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Online.API.Requests.Responses; using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet { public class BeatmapAvailability : Container { - private BeatmapSetInfo beatmapSet; + private APIBeatmapSet beatmapSet; - private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability.DownloadDisabled ?? false; - private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability.ExternalLink); + private bool downloadDisabled => BeatmapSet?.Availability.DownloadDisabled ?? false; + private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.Availability.ExternalLink); private readonly LinkFlowContainer textContainer; @@ -44,7 +44,7 @@ namespace osu.Game.Overlays.BeatmapSet }; } - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { get => beatmapSet; @@ -76,7 +76,7 @@ namespace osu.Game.Overlays.BeatmapSet { textContainer.NewParagraph(); textContainer.NewParagraph(); - textContainer.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink, creationParameters: t => t.Font = OsuFont.GetFont(size: 10)); + textContainer.AddLink("Check here for more information.", BeatmapSet.Availability.ExternalLink, creationParameters: t => t.Font = OsuFont.GetFont(size: 10)); } } } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs index 3df275c6d3..c43ac74714 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs @@ -17,6 +17,7 @@ using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets; using osuTK; @@ -34,10 +35,10 @@ namespace osu.Game.Overlays.BeatmapSet public readonly DifficultiesContainer Difficulties; - public readonly Bindable Beatmap = new Bindable(); - private BeatmapSetInfo beatmapSet; + public readonly Bindable Beatmap = new Bindable(); + private APIBeatmapSet beatmapSet; - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { get => beatmapSet; set @@ -164,35 +165,38 @@ namespace osu.Game.Overlays.BeatmapSet if (BeatmapSet != null) { - Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.Where(b => b.Ruleset.Equals(ruleset.Value)).OrderBy(b => b.StarDifficulty).Select(b => new DifficultySelectorButton(b) - { - State = DifficultySelectorState.NotSelected, - OnHovered = beatmap => - { - showBeatmap(beatmap); - starRating.Text = beatmap.StarDifficulty.ToLocalisableString(@"0.##"); - starRatingContainer.FadeIn(100); - }, - OnClicked = beatmap => { Beatmap.Value = beatmap; }, - }); + Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps + .Where(b => b.Ruleset?.OnlineID == ruleset.Value?.OnlineID) + .OrderBy(b => b.StarRating) + .Select(b => new DifficultySelectorButton(b) + { + State = DifficultySelectorState.NotSelected, + OnHovered = beatmap => + { + showBeatmap(beatmap); + starRating.Text = beatmap.StarRating.ToLocalisableString(@"0.##"); + starRatingContainer.FadeIn(100); + }, + OnClicked = beatmap => { Beatmap.Value = beatmap; }, + }); } starRatingContainer.FadeOut(100); - Beatmap.Value = Difficulties.FirstOrDefault()?.BeatmapInfo; - plays.Value = BeatmapSet?.OnlineInfo.PlayCount ?? 0; - favourites.Value = BeatmapSet?.OnlineInfo.FavouriteCount ?? 0; + Beatmap.Value = Difficulties.FirstOrDefault()?.Beatmap; + plays.Value = BeatmapSet?.PlayCount ?? 0; + favourites.Value = BeatmapSet?.FavouriteCount ?? 0; updateDifficultyButtons(); } - private void showBeatmap(BeatmapInfo beatmapInfo) + private void showBeatmap(IBeatmapInfo beatmapInfo) { - version.Text = beatmapInfo?.Version; + version.Text = beatmapInfo?.DifficultyName; } private void updateDifficultyButtons() { - Difficulties.Children.ToList().ForEach(diff => diff.State = diff.BeatmapInfo == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected); + Difficulties.Children.ToList().ForEach(diff => diff.State = diff.Beatmap == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected); } public class DifficultiesContainer : FillFlowContainer @@ -216,10 +220,10 @@ namespace osu.Game.Overlays.BeatmapSet private readonly Box backgroundBox; private readonly DifficultyIcon icon; - public readonly BeatmapInfo BeatmapInfo; + public readonly APIBeatmap Beatmap; - public Action OnHovered; - public Action OnClicked; + public Action OnHovered; + public Action OnClicked; public event Action StateChanged; private DifficultySelectorState state; @@ -241,9 +245,9 @@ namespace osu.Game.Overlays.BeatmapSet } } - public DifficultySelectorButton(BeatmapInfo beatmapInfo) + public DifficultySelectorButton(APIBeatmap beatmapInfo) { - BeatmapInfo = beatmapInfo; + Beatmap = beatmapInfo; Size = new Vector2(size); Margin = new MarginPadding { Horizontal = tile_spacing / 2 }; @@ -273,7 +277,7 @@ namespace osu.Game.Overlays.BeatmapSet protected override bool OnHover(HoverEvent e) { fadeIn(); - OnHovered?.Invoke(BeatmapInfo); + OnHovered?.Invoke(Beatmap); return base.OnHover(e); } @@ -286,7 +290,7 @@ namespace osu.Game.Overlays.BeatmapSet protected override bool OnClick(ClickEvent e) { - OnClicked?.Invoke(BeatmapInfo); + OnClicked?.Invoke(Beatmap); return base.OnClick(e); } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs index 005d21726b..6564ca3d41 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs @@ -3,17 +3,17 @@ using osu.Framework.Bindables; using osu.Framework.Graphics.UserInterface; -using osu.Game.Beatmaps; using osu.Game.Rulesets; using System.Linq; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.BeatmapSet { public class BeatmapRulesetSelector : OverlayRulesetSelector { - private readonly Bindable beatmapSet = new Bindable(); + private readonly Bindable beatmapSet = new Bindable(); - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { get => beatmapSet.Value; set diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs index 79c95d6646..b3b3d1980b 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs @@ -1,22 +1,22 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets; -using System.Linq; namespace osu.Game.Overlays.BeatmapSet { public class BeatmapRulesetTabItem : OverlayRulesetTabItem { - public readonly Bindable BeatmapSet = new Bindable(); + public readonly Bindable BeatmapSet = new Bindable(); [Resolved] private OverlayColourProvider colourProvider { get; set; } @@ -64,7 +64,7 @@ namespace osu.Game.Overlays.BeatmapSet BeatmapSet.BindValueChanged(setInfo => { - int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.Equals(Value)) ?? 0; + int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.OnlineID == Value.OnlineID) ?? 0; count.Text = beatmapsCount.ToString(); countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0); diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs index 4a0c0e9f75..102cddfa92 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs @@ -6,7 +6,7 @@ using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Effects; -using osu.Game.Beatmaps; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets; using osuTK; @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.BeatmapSet { public class BeatmapSetHeader : OverlayHeader { - public readonly Bindable BeatmapSet = new Bindable(); + public readonly Bindable BeatmapSet = new Bindable(); public BeatmapSetHeaderContent HeaderContent { get; private set; } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs index 97cd17313e..f94fee7a8b 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeaderContent.cs @@ -10,13 +10,13 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Localisation; -using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online; using osu.Game.Online.API; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapListing.Panels; using osu.Game.Overlays.BeatmapSet.Buttons; using osuTK; @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet { public class BeatmapSetHeaderContent : CompositeDrawable { - public readonly Bindable BeatmapSet = new Bindable(); + public readonly Bindable BeatmapSet = new Bindable(); private const float transition_duration = 200; private const float buttons_height = 45; @@ -219,7 +219,7 @@ namespace osu.Game.Overlays.BeatmapSet Picker.Beatmap.ValueChanged += b => { Details.BeatmapInfo = b.NewValue; - externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineBeatmapSetID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineBeatmapID}"; + externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineID}"; }; } @@ -231,7 +231,7 @@ namespace osu.Game.Overlays.BeatmapSet BeatmapSet.BindValueChanged(setInfo => { Picker.BeatmapSet = rulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue; - cover.OnlineInfo = setInfo.NewValue?.OnlineInfo; + cover.OnlineInfo = setInfo.NewValue; downloadTracker?.RemoveAndDisposeImmediately(); @@ -254,14 +254,14 @@ namespace osu.Game.Overlays.BeatmapSet loading.Hide(); - title.Text = new RomanisableString(setInfo.NewValue.Metadata.TitleUnicode, setInfo.NewValue.Metadata.Title); - artist.Text = new RomanisableString(setInfo.NewValue.Metadata.ArtistUnicode, setInfo.NewValue.Metadata.Artist); + title.Text = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title); + artist.Text = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist); - explicitContentPill.Alpha = setInfo.NewValue.OnlineInfo.HasExplicitContent ? 1 : 0; - featuredArtistPill.Alpha = setInfo.NewValue.OnlineInfo.TrackId != null ? 1 : 0; + explicitContentPill.Alpha = setInfo.NewValue.HasExplicitContent ? 1 : 0; + featuredArtistPill.Alpha = setInfo.NewValue.TrackId != null ? 1 : 0; onlineStatusPill.FadeIn(500, Easing.OutQuint); - onlineStatusPill.Status = setInfo.NewValue.OnlineInfo.Status; + onlineStatusPill.Status = setInfo.NewValue.Status; downloadButtonsContainer.FadeIn(transition_duration); favouriteButton.FadeIn(transition_duration); @@ -275,7 +275,7 @@ namespace osu.Game.Overlays.BeatmapSet { if (BeatmapSet.Value == null) return; - if (BeatmapSet.Value.OnlineInfo.Availability.DownloadDisabled && downloadTracker.State.Value != DownloadState.LocallyAvailable) + if (BeatmapSet.Value.Availability.DownloadDisabled && downloadTracker.State.Value != DownloadState.LocallyAvailable) { downloadButtonsContainer.Clear(); return; @@ -301,7 +301,7 @@ namespace osu.Game.Overlays.BeatmapSet default: downloadButtonsContainer.Child = new HeaderDownloadButton(BeatmapSet.Value); - if (BeatmapSet.Value.OnlineInfo.HasVideo) + if (BeatmapSet.Value.HasVideo) downloadButtonsContainer.Add(new HeaderDownloadButton(BeatmapSet.Value, true)); break; } diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs index 43dd1438f1..d4873f241c 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/FavouriteButton.cs @@ -8,10 +8,10 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; -using osu.Game.Beatmaps; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Notifications; using osu.Game.Resources.Localisation.Web; using osu.Game.Users; @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons { public class FavouriteButton : HeaderButton, IHasTooltip { - public readonly Bindable BeatmapSet = new Bindable(); + public readonly Bindable BeatmapSet = new Bindable(); private readonly BindableBool favourited = new BindableBool(); @@ -61,13 +61,13 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons Action = () => { // guaranteed by disabled state above. - Debug.Assert(BeatmapSet.Value.OnlineBeatmapSetID != null); + Debug.Assert(BeatmapSet.Value.OnlineID > 0); loading.Show(); request?.Cancel(); - request = new PostBeatmapFavouriteRequest(BeatmapSet.Value.OnlineBeatmapSetID.Value, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite); + request = new PostBeatmapFavouriteRequest(BeatmapSet.Value.OnlineID, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite); request.Success += () => { @@ -98,11 +98,11 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons BeatmapSet.BindValueChanged(setInfo => { updateEnabled(); - favourited.Value = setInfo.NewValue?.OnlineInfo?.HasFavourited ?? false; + favourited.Value = setInfo.NewValue?.HasFavourited ?? false; }, true); } - private void updateEnabled() => Enabled.Value = !(localUser.Value is GuestUser) && BeatmapSet.Value?.OnlineBeatmapSetID > 0; + private void updateEnabled() => Enabled.Value = !(localUser.Value is GuestUser) && BeatmapSet.Value?.OnlineID > 0; protected override void UpdateAfterChildren() { diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs index 88d0778ae4..6862864c55 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/HeaderDownloadButton.cs @@ -14,11 +14,13 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Online; using osu.Game.Online.API; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapListing.Panels; using osu.Game.Resources.Localisation.Web; using osu.Game.Users; using osuTK; using osuTK.Graphics; +using CommonStrings = osu.Game.Localisation.CommonStrings; namespace osu.Game.Overlays.BeatmapSet.Buttons { @@ -36,9 +38,10 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons private HeaderButton button; private BeatmapDownloadTracker downloadTracker; - private readonly BeatmapSetInfo beatmapSet; - public HeaderDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) + private readonly APIBeatmapSet beatmapSet; + + public HeaderDownloadButton(APIBeatmapSet beatmapSet, bool noVideo = false) { this.beatmapSet = beatmapSet; this.noVideo = noVideo; @@ -105,7 +108,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons return; } - beatmaps.Download(beatmapSet, noVideo); + beatmaps.Download(new BeatmapSetInfo { OnlineBeatmapSetID = beatmapSet.OnlineID }, noVideo); }; localUser.BindTo(api.LocalUser); @@ -121,7 +124,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons { new OsuSpriteText { - Text = Localisation.CommonStrings.Downloading, + Text = CommonStrings.Downloading, Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold) }, }; @@ -132,7 +135,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons { new OsuSpriteText { - Text = Localisation.CommonStrings.Importing, + Text = CommonStrings.Importing, Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold) }, }; @@ -168,7 +171,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons private LocalisableString getVideoSuffixText() { - if (!beatmapSet.OnlineInfo.HasVideo) + if (!beatmapSet.HasVideo) return string.Empty; return noVideo ? BeatmapsetsStrings.ShowDetailsDownloadNoVideo : BeatmapsetsStrings.ShowDetailsDownloadVideo; diff --git a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs index 5b3c142a66..6bcdb7bdc5 100644 --- a/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs +++ b/osu.Game/Overlays/BeatmapSet/Buttons/PreviewButton.cs @@ -8,9 +8,9 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Game.Audio; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapListing.Panels; using osuTK; @@ -25,7 +25,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons public IBindable Playing => playButton.Playing; - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { get => playButton.BeatmapSet; set => playButton.BeatmapSet = value; diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index d6720e5f35..dfc8d5e680 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapSet.Buttons; using osu.Game.Screens.Select.Details; using osuTK; @@ -21,9 +22,9 @@ namespace osu.Game.Overlays.BeatmapSet private readonly AdvancedStats advanced; private readonly DetailBox ratingBox; - private BeatmapSetInfo beatmapSet; + private APIBeatmapSet beatmapSet; - public BeatmapSetInfo BeatmapSet + public APIBeatmapSet BeatmapSet { get => beatmapSet; set @@ -37,9 +38,9 @@ namespace osu.Game.Overlays.BeatmapSet } } - private BeatmapInfo beatmapInfo; + private IBeatmapInfo beatmapInfo; - public BeatmapInfo BeatmapInfo + public IBeatmapInfo BeatmapInfo { get => beatmapInfo; set @@ -53,7 +54,7 @@ namespace osu.Game.Overlays.BeatmapSet private void updateDisplay() { Ratings.Ratings = BeatmapSet?.Ratings; - ratingBox.Alpha = BeatmapSet?.OnlineInfo?.Status > 0 ? 1 : 0; + ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0; } public Details() diff --git a/osu.Game/Overlays/BeatmapSet/Info.cs b/osu.Game/Overlays/BeatmapSet/Info.cs index 970e9bbf42..3ef52d718d 100644 --- a/osu.Game/Overlays/BeatmapSet/Info.cs +++ b/osu.Game/Overlays/BeatmapSet/Info.cs @@ -6,9 +6,9 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Overlays.BeatmapSet { @@ -22,12 +22,12 @@ namespace osu.Game.Overlays.BeatmapSet private readonly Box background; private readonly SuccessRate successRate; - public readonly Bindable BeatmapSet = new Bindable(); + public readonly Bindable BeatmapSet = new Bindable(); - public BeatmapInfo BeatmapInfo + public APIBeatmap BeatmapInfo { - get => successRate.BeatmapInfo; - set => successRate.BeatmapInfo = value; + get => successRate.Beatmap; + set => successRate.Beatmap = value; } public Info() @@ -115,11 +115,11 @@ namespace osu.Game.Overlays.BeatmapSet BeatmapSet.ValueChanged += b => { - source.Text = b.NewValue?.Metadata.Source ?? string.Empty; - tags.Text = b.NewValue?.Metadata.Tags ?? string.Empty; - genre.Text = b.NewValue?.OnlineInfo?.Genre.Name ?? string.Empty; - language.Text = b.NewValue?.OnlineInfo?.Language.Name ?? string.Empty; - bool setHasLeaderboard = b.NewValue?.OnlineInfo?.Status > 0; + source.Text = b.NewValue?.Source ?? string.Empty; + tags.Text = b.NewValue?.Tags ?? string.Empty; + genre.Text = b.NewValue?.Genre.Name ?? string.Empty; + language.Text = b.NewValue?.Language.Name ?? string.Empty; + bool setHasLeaderboard = b.NewValue?.Status > 0; successRate.Alpha = setHasLeaderboard ? 1 : 0; notRankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1; Height = setHasLeaderboard ? 270 : base_height; diff --git a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs index 6349f115cb..a9723c9c62 100644 --- a/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/LeaderboardModSelector.cs @@ -13,6 +13,7 @@ using osu.Game.Graphics.UserInterface; using osuTK.Graphics; using System; using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Overlays.BeatmapSet @@ -20,7 +21,7 @@ namespace osu.Game.Overlays.BeatmapSet public class LeaderboardModSelector : CompositeDrawable { public readonly BindableList SelectedMods = new BindableList(); - public readonly Bindable Ruleset = new Bindable(); + public readonly Bindable Ruleset = new Bindable(); private readonly FillFlowContainer modsContainer; @@ -45,7 +46,10 @@ namespace osu.Game.Overlays.BeatmapSet Ruleset.BindValueChanged(onRulesetChanged, true); } - private void onRulesetChanged(ValueChangedEvent ruleset) + [Resolved] + private RulesetStore rulesets { get; set; } + + private void onRulesetChanged(ValueChangedEvent ruleset) { SelectedMods.Clear(); modsContainer.Clear(); @@ -54,7 +58,7 @@ namespace osu.Game.Overlays.BeatmapSet return; modsContainer.Add(new ModButton(new ModNoMod())); - modsContainer.AddRange(ruleset.NewValue.CreateInstance().AllMods.Where(m => m.UserPlayable).Select(m => new ModButton(m))); + modsContainer.AddRange(rulesets.GetRuleset(ruleset.NewValue.OnlineID).CreateInstance().AllMods.Where(m => m.UserPlayable).Select(m => new ModButton(m))); modsContainer.ForEach(button => { diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index c6eb516c7c..4a00c8b4a0 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -1,24 +1,24 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osuTK; using System.Linq; using System.Threading; using System.Threading.Tasks; -using osu.Game.Online.API.Requests.Responses; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; -using osu.Framework.Bindables; -using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets; using osu.Game.Scoring; using osu.Game.Screens.Select.Leaderboards; using osu.Game.Users; +using osuTK; namespace osu.Game.Overlays.BeatmapSet.Scores { @@ -26,8 +26,8 @@ namespace osu.Game.Overlays.BeatmapSet.Scores { private const int spacing = 15; - public readonly Bindable Beatmap = new Bindable(); - private readonly Bindable ruleset = new Bindable(); + public readonly Bindable Beatmap = new Bindable(); + private readonly Bindable ruleset = new Bindable(); private readonly Bindable scope = new Bindable(BeatmapLeaderboardScope.Global); private readonly IBindable user = new Bindable(); @@ -66,7 +66,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores if (value?.Scores.Any() != true) return; - scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, Beatmap.Value)).ToArray(), loadCancellationSource.Token) + scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, Beatmap.Value.ToBeatmapInfo(rulesets))).ToArray(), loadCancellationSource.Token) .ContinueWith(ordered => Schedule(() => { if (loadCancellationSource.IsCancellationRequested) @@ -78,7 +78,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores scoreTable.Show(); var userScore = value.UserScore; - var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, Beatmap.Value); + var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets, Beatmap.Value.ToBeatmapInfo(rulesets)); topScoresContainer.Add(new DrawableTopScore(topScore)); @@ -200,11 +200,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores user.BindValueChanged(onUserChanged, true); } - private void onBeatmapChanged(ValueChangedEvent beatmap) + private void onBeatmapChanged(ValueChangedEvent beatmap) { var beatmapRuleset = beatmap.NewValue?.Ruleset; - if (ruleset.Value?.Equals(beatmapRuleset) ?? false) + if (ruleset.Value?.OnlineID == beatmapRuleset?.OnlineID) { modSelector.DeselectAll(); ruleset.TriggerChange(); @@ -232,7 +232,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores noScoresPlaceholder.Hide(); - if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) + if (Beatmap.Value == null || Beatmap.Value.OnlineID <= 0 || (Beatmap.Value?.BeatmapSet as IBeatmapSetOnlineInfo)?.Status <= BeatmapSetOnlineStatus.Pending) { Scores = null; Hide(); diff --git a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs index 40a3c9fe8b..e08f099226 100644 --- a/osu.Game/Overlays/BeatmapSet/SuccessRate.cs +++ b/osu.Game/Overlays/BeatmapSet/SuccessRate.cs @@ -5,10 +5,10 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; using osu.Game.Screens.Select.Details; @@ -23,16 +23,16 @@ namespace osu.Game.Overlays.BeatmapSet private readonly Bar successRate; private readonly Container percentContainer; - private BeatmapInfo beatmapInfo; + private APIBeatmap beatmap; - public BeatmapInfo BeatmapInfo + public APIBeatmap Beatmap { - get => beatmapInfo; + get => beatmap; set { - if (value == beatmapInfo) return; + if (value == beatmap) return; - beatmapInfo = value; + beatmap = value; updateDisplay(); } @@ -40,15 +40,15 @@ namespace osu.Game.Overlays.BeatmapSet private void updateDisplay() { - int passCount = beatmapInfo?.OnlineInfo?.PassCount ?? 0; - int playCount = beatmapInfo?.OnlineInfo?.PlayCount ?? 0; + int passCount = beatmap?.PassCount ?? 0; + int playCount = beatmap?.PlayCount ?? 0; float rate = playCount != 0 ? (float)passCount / playCount : 0; successPercent.Text = rate.ToLocalisableString(@"0.#%"); successRate.Length = rate; percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic); - Graph.FailTimes = beatmapInfo?.FailTimes; + Graph.FailTimes = beatmap?.FailTimes; } public SuccessRate() diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index f987b57d6e..fa5a7c66d0 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -7,8 +7,8 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; -using osu.Game.Beatmaps; using osu.Game.Online.API.Requests; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapSet; using osu.Game.Overlays.BeatmapSet.Scores; using osu.Game.Overlays.Comments; @@ -27,7 +27,7 @@ namespace osu.Game.Overlays [Resolved] private RulesetStore rulesets { get; set; } - private readonly Bindable beatmapSet = new Bindable(); + private readonly Bindable beatmapSet = new Bindable(); // receive input outside our bounds so we can trigger a close event on ourselves. public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; @@ -89,8 +89,8 @@ namespace osu.Game.Overlays var req = new GetBeatmapSetRequest(beatmapId, BeatmapSetLookupType.BeatmapId); req.Success += res => { - beatmapSet.Value = res.ToBeatmapSet(rulesets); - Header.HeaderContent.Picker.Beatmap.Value = Header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId); + beatmapSet.Value = res; + Header.HeaderContent.Picker.Beatmap.Value = Header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineID == beatmapId); }; API.Queue(req); @@ -102,7 +102,7 @@ namespace osu.Game.Overlays beatmapSet.Value = null; var req = new GetBeatmapSetRequest(beatmapSetId); - req.Success += res => beatmapSet.Value = res.ToBeatmapSet(rulesets); + req.Success += res => beatmapSet.Value = res; API.Queue(req); Show(); @@ -112,7 +112,7 @@ namespace osu.Game.Overlays /// Show an already fully-populated beatmap set. /// /// The set to show. - public void ShowBeatmapSet(BeatmapSetInfo set) + public void ShowBeatmapSet(APIBeatmapSet set) { beatmapSet.Value = set; Show(); @@ -120,7 +120,7 @@ namespace osu.Game.Overlays private class CommentsSection : BeatmapSetLayoutSection { - public readonly Bindable BeatmapSet = new Bindable(); + public readonly Bindable BeatmapSet = new Bindable(); public CommentsSection() { @@ -130,10 +130,10 @@ namespace osu.Game.Overlays BeatmapSet.BindValueChanged(beatmapSet => { - if (beatmapSet.NewValue?.OnlineBeatmapSetID is int onlineBeatmapSetID) + if (beatmapSet.NewValue?.OnlineID > 0) { Show(); - comments.ShowComments(CommentableType.Beatmapset, onlineBeatmapSetID); + comments.ShowComments(CommentableType.Beatmapset, beatmapSet.NewValue.OnlineID); } else { diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index c1e56facd9..fffa20dc11 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -61,7 +61,7 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage); protected override Drawable CreateDrawableItem(APIBeatmapSet model) => model.OnlineID > 0 - ? new GridBeatmapPanel(model.ToBeatmapSet(Rulesets)) + ? new GridBeatmapPanel(model) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, diff --git a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs index ac4299ae49..3ed4bd9e50 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/DrawableMostPlayedBeatmap.cs @@ -5,15 +5,15 @@ using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osuTK; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Localisation; using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; diff --git a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs index b16e0a4908..b95b0a1afc 100644 --- a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs +++ b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs @@ -143,7 +143,7 @@ namespace osu.Game.Overlays.Rankings AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Spacing = new Vector2(10), - Children = response.BeatmapSets.Select(b => new GridBeatmapPanel(b.ToBeatmapSet(rulesets)) + Children = response.BeatmapSets.Select(b => new GridBeatmapPanel(b) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, diff --git a/osu.Game/Screens/Play/SoloSpectator.cs b/osu.Game/Screens/Play/SoloSpectator.cs index 9d4dad8bdc..83ea660092 100644 --- a/osu.Game/Screens/Play/SoloSpectator.cs +++ b/osu.Game/Screens/Play/SoloSpectator.cs @@ -223,7 +223,7 @@ namespace osu.Game.Screens.Play onlineBeatmapRequest.Success += res => Schedule(() => { onlineBeatmap = res.ToBeatmapSet(rulesets); - beatmapPanelContainer.Child = new GridBeatmapPanel(onlineBeatmap); + beatmapPanelContainer.Child = new GridBeatmapPanel(res); checkForAutomaticDownload(); }); diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index dfbaa9c6a5..ece16a8e57 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -57,7 +57,7 @@ namespace osu.Game.Screens.Select beatmapInfo = value; failTimes = beatmapInfo?.OnlineInfo?.FailTimes; - ratings = beatmapInfo?.BeatmapSet?.Ratings; + ratings = beatmapInfo?.BeatmapSet?.OnlineInfo?.Ratings; Scheduler.AddOnce(updateStatistics); } @@ -182,7 +182,7 @@ namespace osu.Game.Screens.Select source.Text = BeatmapInfo?.Metadata?.Source; tags.Text = BeatmapInfo?.Metadata?.Tags; - // metrics may have been previously fetched + // failTimes may have been previously fetched if (ratings != null && failTimes != null) { updateMetrics(); diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index 562ebad9fe..e129e75ec2 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -38,9 +38,9 @@ namespace osu.Game.Screens.Select.Details protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate; private readonly StatisticRow starDifficulty; - private BeatmapInfo beatmapInfo; + private IBeatmapInfo beatmapInfo; - public BeatmapInfo BeatmapInfo + public IBeatmapInfo BeatmapInfo { get => beatmapInfo; set @@ -106,7 +106,7 @@ namespace osu.Game.Screens.Select.Details private void updateStatistics() { - IBeatmapDifficultyInfo baseDifficulty = BeatmapInfo?.BaseDifficulty; + IBeatmapDifficultyInfo baseDifficulty = BeatmapInfo?.Difficulty; BeatmapDifficulty adjustedDifficulty = null; if (baseDifficulty != null && mods.Value.Any(m => m is IApplicableToDifficulty)) @@ -117,7 +117,7 @@ namespace osu.Game.Screens.Select.Details mod.ApplyToDifficulty(adjustedDifficulty); } - switch (BeatmapInfo?.Ruleset?.ID ?? 0) + switch (BeatmapInfo?.Ruleset.OnlineID) { case 3: // Account for mania differences locally for now