diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index d48c9e9661..7b60bc03e4 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -103,7 +103,10 @@ namespace osu.Desktop.Updater } else { + // In the case of an error, a separate notification will be displayed. notification.State = ProgressNotificationState.Cancelled; + notification.Close(); + Logger.Error(e, @"update failed!"); } } diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index a404a54ee4..cac1bf05a6 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -596,7 +596,7 @@ namespace osu.Game.Tests.Beatmaps.IO { OnlineID = 2, Metadata = metadata, - Status = BeatmapSetOnlineStatus.Loved, + Status = BeatmapOnlineStatus.Loved, BaseDifficulty = difficulty } } diff --git a/osu.Game.Tests/Database/BeatmapImporterTests.cs b/osu.Game.Tests/Database/BeatmapImporterTests.cs index 71e5e9081c..9ee237cfd9 100644 --- a/osu.Game.Tests/Database/BeatmapImporterTests.cs +++ b/osu.Game.Tests/Database/BeatmapImporterTests.cs @@ -550,7 +550,7 @@ namespace osu.Game.Tests.Database new RealmBeatmap(ruleset, new RealmBeatmapDifficulty(), metadata) { OnlineID = 2, - Status = BeatmapSetOnlineStatus.Loved, + Status = BeatmapOnlineStatus.Loved, } } }; diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs index e49b0d3a67..55378043e6 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs @@ -38,7 +38,7 @@ namespace osu.Game.Tests.NonVisual.Filtering Length = 2500, BPM = 160, BeatDivisor = 12, - Status = BeatmapSetOnlineStatus.Loved + Status = BeatmapOnlineStatus.Loved }; [Test] diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs index df42c70c87..460f89528b 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs @@ -162,9 +162,9 @@ namespace osu.Game.Tests.NonVisual.Filtering FilterQueryParser.ApplyQueries(filterCriteria, query); Assert.AreEqual("I want the pp", filterCriteria.SearchText.Trim()); Assert.AreEqual(4, filterCriteria.SearchTerms.Length); - Assert.AreEqual(BeatmapSetOnlineStatus.Ranked, filterCriteria.OnlineStatus.Min); + Assert.AreEqual(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Min); Assert.IsTrue(filterCriteria.OnlineStatus.IsLowerInclusive); - Assert.AreEqual(BeatmapSetOnlineStatus.Ranked, filterCriteria.OnlineStatus.Max); + Assert.AreEqual(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Max); Assert.IsTrue(filterCriteria.OnlineStatus.IsUpperInclusive); } diff --git a/osu.Game.Tests/Resources/TestResources.cs b/osu.Game.Tests/Resources/TestResources.cs index dff9478852..440d5e701f 100644 --- a/osu.Game.Tests/Resources/TestResources.cs +++ b/osu.Game.Tests/Resources/TestResources.cs @@ -2,10 +2,18 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.IO; +using System.Text; +using System.Threading; using NUnit.Framework; +using osu.Framework.Extensions; using osu.Framework.IO.Stores; using osu.Framework.Testing; +using osu.Framework.Utils; +using osu.Game.Beatmaps; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Osu; namespace osu.Game.Tests.Resources { @@ -56,5 +64,78 @@ namespace osu.Game.Tests.Resources } private static string getTempFilename() => temp_storage.GetFullPath(Guid.NewGuid() + ".osz"); + + private static int importId; + + /// + /// Create a test beatmap set model. + /// + /// Number of difficulties. If null, a random number between 1 and 20 will be used. + /// Rulesets to cycle through when creating difficulties. If null, osu! ruleset will be used. + public static BeatmapSetInfo CreateTestBeatmapSetInfo(int? difficultyCount = null, RulesetInfo[] rulesets = null) + { + int j = 0; + RulesetInfo getRuleset() => rulesets?[j++ % rulesets.Length] ?? new OsuRuleset().RulesetInfo; + + int setId = Interlocked.Increment(ref importId); + + var metadata = new BeatmapMetadata + { + // Create random metadata, then we can check if sorting works based on these + Artist = "Some Artist " + RNG.Next(0, 9), + Title = $"Some Song (set id {setId}) {Guid.NewGuid()}", + AuthorString = "Some Guy " + RNG.Next(0, 9), + }; + + var beatmapSet = new BeatmapSetInfo + { + OnlineID = setId, + Hash = new MemoryStream(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())).ComputeMD5Hash(), + DateAdded = DateTimeOffset.UtcNow, + Metadata = metadata + }; + + foreach (var b in getBeatmaps(difficultyCount ?? RNG.Next(1, 20))) + beatmapSet.Beatmaps.Add(b); + + return beatmapSet; + + IEnumerable getBeatmaps(int count) + { + for (int i = 0; i < count; i++) + { + int beatmapId = setId * 1000 + i; + + int length = RNG.Next(30000, 200000); + double bpm = RNG.NextSingle(80, 200); + + float diff = (float)i / count * 10; + + string version = "Normal"; + if (diff > 6.6) + version = "Insane"; + else if (diff > 3.3) + version = "Hard"; + + var rulesetInfo = getRuleset(); + + yield return new BeatmapInfo + { + OnlineID = beatmapId, + DifficultyName = $"{version} {beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss}, bpm {bpm:0.#})", + StarRating = diff, + Length = length, + BPM = bpm, + Ruleset = rulesetInfo, + RulesetID = rulesetInfo.ID ?? -1, + Metadata = metadata, + BaseDifficulty = new BeatmapDifficulty + { + OverallDifficulty = diff, + } + }; + } + } + } } } diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCard.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCard.cs index addec15881..cae7781db7 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCard.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapCard.cs @@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.Beatmaps var withStatistics = CreateAPIBeatmapSet(Ruleset.Value); withStatistics.Title = withStatistics.TitleUnicode = "play favourite stats"; - withStatistics.Status = BeatmapSetOnlineStatus.Approved; + withStatistics.Status = BeatmapOnlineStatus.Approved; withStatistics.FavouriteCount = 284_239; withStatistics.PlayCount = 999_001; withStatistics.Ranked = DateTimeOffset.Now.AddDays(-45); @@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.Beatmaps var someDifficulties = getManyDifficultiesBeatmapSet(11); someDifficulties.Title = someDifficulties.TitleUnicode = "favourited"; someDifficulties.Title = someDifficulties.TitleUnicode = "some difficulties"; - someDifficulties.Status = BeatmapSetOnlineStatus.Qualified; + someDifficulties.Status = BeatmapOnlineStatus.Qualified; someDifficulties.HasFavourited = true; someDifficulties.FavouriteCount = 1; someDifficulties.NominationStatus = new BeatmapSetNominationStatus @@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.Beatmaps }; var manyDifficulties = getManyDifficultiesBeatmapSet(100); - manyDifficulties.Status = BeatmapSetOnlineStatus.Pending; + manyDifficulties.Status = BeatmapOnlineStatus.Pending; var explicitMap = CreateAPIBeatmapSet(Ruleset.Value); explicitMap.Title = someDifficulties.TitleUnicode = "explicit beatmap"; diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs index c48b63ac89..8132fe6ab8 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneBeatmapSetOnlineStatusPill.cs @@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Beatmaps Origin = Anchor.Centre, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), - ChildrenEnumerable = Enum.GetValues(typeof(BeatmapSetOnlineStatus)).Cast().Select(status => new BeatmapSetOnlineStatusPill + ChildrenEnumerable = Enum.GetValues(typeof(BeatmapOnlineStatus)).Cast().Select(status => new BeatmapSetOnlineStatusPill { AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs b/osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs index f429b5b2a8..55e453c3d3 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneMusicActionHandling.cs @@ -30,25 +30,10 @@ namespace osu.Game.Tests.Visual.Menus [Test] public void TestMusicNavigationActions() { - int importId = 0; Queue<(IWorkingBeatmap working, TrackChangeDirection changeDirection)> trackChangeQueue = null; // ensure we have at least two beatmaps available to identify the direction the music controller navigated to. - AddRepeatStep("import beatmap", () => Game.BeatmapManager.Import(new BeatmapSetInfo - { - Beatmaps = - { - new BeatmapInfo - { - BaseDifficulty = new BeatmapDifficulty(), - } - }, - Metadata = new BeatmapMetadata - { - Artist = $"a test map {importId++}", - Title = "title", - } - }).Wait(), 5); + AddRepeatStep("import beatmap", () => Game.BeatmapManager.Import(TestResources.CreateTestBeatmapSetInfo()).Wait(), 5); AddStep("import beatmap with track", () => { diff --git a/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsSongSelect.cs b/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsSongSelect.cs index 3e24b7a1d0..6d761105c1 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsSongSelect.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestScenePlaylistsSongSelect.cs @@ -2,13 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.IO; using System.Linq; -using System.Text; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Extensions; using osu.Framework.Platform; using osu.Framework.Screens; using osu.Framework.Utils; @@ -20,6 +17,7 @@ using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Screens.OnlinePlay.Components; using osu.Game.Screens.OnlinePlay.Playlists; +using osu.Game.Tests.Resources; using osu.Game.Tests.Visual.OnlinePlay; namespace osu.Game.Tests.Visual.Multiplayer @@ -41,43 +39,7 @@ namespace osu.Game.Tests.Visual.Multiplayer Dependencies.Cache(rulesets = new RulesetStore(ContextFactory)); Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, Resources, host, Beatmap.Default)); - var metadata = new BeatmapMetadata - { - // Create random metadata, then we can check if sorting works based on these - Artist = "Some Artist " + RNG.Next(0, 9), - Title = "Some Song (set id 10)", - AuthorString = "Some Guy " + RNG.Next(0, 9), - }; - - var beatmapSet = new BeatmapSetInfo - { - OnlineID = 10, - Hash = new MemoryStream(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())).ComputeMD5Hash(), - Metadata = metadata, - DateAdded = DateTimeOffset.UtcNow, - }; - - for (int i = 0; i < 6; i++) - { - int beatmapId = 10 * 10 + i; - - int length = RNG.Next(30000, 200000); - double bpm = RNG.NextSingle(80, 200); - - beatmapSet.Beatmaps.Add(new BeatmapInfo - { - Ruleset = new OsuRuleset().RulesetInfo, - OnlineID = beatmapId, - DifficultyName = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss}, bpm {bpm:0.#})", - Length = length, - Metadata = metadata, - BPM = bpm, - BaseDifficulty = new BeatmapDifficulty - { - OverallDifficulty = 3.5f, - }, - }); - } + var beatmapSet = TestResources.CreateTestBeatmapSetInfo(); manager.Import(beatmapSet).Wait(); } diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs index 9c0c67b1d8..629c413d85 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlayDetails.cs @@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Online } }, Ratings = Enumerable.Range(0, 11).Select(_ => RNG.Next(10)).ToArray(), - Status = BeatmapSetOnlineStatus.Ranked + Status = BeatmapOnlineStatus.Ranked }; } diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs index 423c0a048c..94700bac6a 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs @@ -338,7 +338,7 @@ namespace osu.Game.Tests.Visual.Ranking : base(score, true) { Score.BeatmapInfo.OnlineID = 0; - Score.BeatmapInfo.Status = BeatmapSetOnlineStatus.Pending; + Score.BeatmapInfo.Status = BeatmapOnlineStatus.Pending; } protected override void LoadComplete() diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 1808f98c23..5906979bc4 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -3,15 +3,11 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Text; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Rulesets; @@ -19,6 +15,7 @@ using osu.Game.Rulesets.Osu; using osu.Game.Screens.Select; using osu.Game.Screens.Select.Carousel; using osu.Game.Screens.Select.Filter; +using osu.Game.Tests.Resources; using osuTK.Input; namespace osu.Game.Tests.Visual.SongSelect @@ -152,7 +149,7 @@ namespace osu.Game.Tests.Visual.SongSelect const int total_set_count = 200; for (int i = 0; i < total_set_count; i++) - sets.Add(createTestBeatmapSet(i + 1)); + sets.Add(TestResources.CreateTestBeatmapSetInfo()); loadBeatmaps(sets); @@ -183,7 +180,7 @@ namespace osu.Game.Tests.Visual.SongSelect const int total_set_count = 20; for (int i = 0; i < total_set_count; i++) - sets.Add(createTestBeatmapSet(i + 1)); + sets.Add(TestResources.CreateTestBeatmapSetInfo(3)); loadBeatmaps(sets); @@ -228,10 +225,9 @@ namespace osu.Game.Tests.Visual.SongSelect loadBeatmaps(); // basic filtering - setSelected(1, 1); - AddStep("Filter", () => carousel.Filter(new FilterCriteria { SearchText = "set #3!" }, false)); + AddStep("Filter", () => carousel.Filter(new FilterCriteria { SearchText = carousel.BeatmapSets.ElementAt(2).Metadata.Title }, false)); checkVisibleItemCount(diff: false, count: 1); checkVisibleItemCount(diff: true, count: 3); waitForSelection(3, 1); @@ -275,16 +271,20 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestFilterRange() { + string searchText = null; + loadBeatmaps(); // buffer the selection setSelected(3, 2); + AddStep("get search text", () => searchText = carousel.SelectedBeatmapSet.Metadata.Title); + setSelected(1, 3); AddStep("Apply a range filter", () => carousel.Filter(new FilterCriteria { - SearchText = "#3", + SearchText = searchText, StarDifficulty = new FilterCriteria.OptionalRange { Min = 2, @@ -327,7 +327,7 @@ namespace osu.Game.Tests.Visual.SongSelect nextRandom(); AddAssert("ensure repeat", () => selectedSets.Contains(carousel.SelectedBeatmapSet)); - AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(createTestBeatmapSetWithManyDifficulties(set_count + 1))); + AddStep("Add set with 100 difficulties", () => carousel.UpdateBeatmapSet(TestResources.CreateTestBeatmapSetInfo(100, rulesets.AvailableRulesets.ToArray()))); AddStep("Filter Extra", () => carousel.Filter(new FilterCriteria { SearchText = "Extra 10" }, false)); checkInvisibleDifficultiesUnselectable(); checkInvisibleDifficultiesUnselectable(); @@ -345,18 +345,21 @@ namespace osu.Game.Tests.Visual.SongSelect { loadBeatmaps(); - AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 1))); - AddStep("Add new set", () => carousel.UpdateBeatmapSet(createTestBeatmapSet(set_count + 2))); + var firstAdded = TestResources.CreateTestBeatmapSetInfo(); + var secondAdded = TestResources.CreateTestBeatmapSetInfo(); + + AddStep("Add new set", () => carousel.UpdateBeatmapSet(firstAdded)); + AddStep("Add new set", () => carousel.UpdateBeatmapSet(secondAdded)); checkVisibleItemCount(false, set_count + 2); - AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 2))); + AddStep("Remove set", () => carousel.RemoveBeatmapSet(firstAdded)); checkVisibleItemCount(false, set_count + 1); setSelected(set_count + 1, 1); - AddStep("Remove set", () => carousel.RemoveBeatmapSet(createTestBeatmapSet(set_count + 1))); + AddStep("Remove set", () => carousel.RemoveBeatmapSet(secondAdded)); checkVisibleItemCount(false, set_count); @@ -372,7 +375,7 @@ namespace osu.Game.Tests.Visual.SongSelect { sets.Clear(); - var rulesetBeatmapSet = createTestBeatmapSet(1); + var rulesetBeatmapSet = TestResources.CreateTestBeatmapSetInfo(1); var taikoRuleset = rulesets.AvailableRulesets.ElementAt(1); rulesetBeatmapSet.Beatmaps.ForEach(b => { @@ -397,12 +400,29 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestSorting() { - loadBeatmaps(); + var sets = new List(); + + const string zzz_string = "zzzzz"; + + for (int i = 0; i < 20; i++) + { + var set = TestResources.CreateTestBeatmapSetInfo(); + + if (i == 4) + set.Metadata.Artist = zzz_string; + + if (i == 16) + set.Metadata.AuthorString = zzz_string; + + sets.Add(set); + } + + loadBeatmaps(sets); AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false)); - AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.Author.Username == "zzzzz"); + AddAssert($"Check {zzz_string} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Author.Username == zzz_string); AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false)); - AddAssert($"Check #{set_count} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Title.EndsWith($"#{set_count}!", StringComparison.Ordinal)); + AddAssert($"Check {zzz_string} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Artist == zzz_string); } [Test] @@ -412,20 +432,21 @@ namespace osu.Game.Tests.Visual.SongSelect for (int i = 0; i < 20; i++) { - // index + 1 because we are using OnlineID which should never be zero. - var set = createTestBeatmapSet(i + 1); + var set = TestResources.CreateTestBeatmapSetInfo(); set.Metadata.Artist = "same artist"; set.Metadata.Title = "same title"; sets.Add(set); } + int idOffset = sets.First().OnlineID ?? 0; + loadBeatmaps(sets); AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false)); - AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.OnlineID == index + 1).All(b => b)); + AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.OnlineID == index + idOffset).All(b => b)); AddStep("Sort by title", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Title }, false)); - AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.OnlineID == index + 1).All(b => b)); + AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.OnlineID == index + idOffset).All(b => b)); } [Test] @@ -435,7 +456,7 @@ namespace osu.Game.Tests.Visual.SongSelect for (int i = 0; i < 3; i++) { - var set = createTestBeatmapSet(i); + var set = TestResources.CreateTestBeatmapSetInfo(3); set.Beatmaps[0].StarRating = 3 - i; set.Beatmaps[2].StarRating = 6 + i; sets.Add(set); @@ -504,7 +525,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("create hidden set", () => { - hidingSet = createTestBeatmapSet(1); + hidingSet = TestResources.CreateTestBeatmapSetInfo(3); hidingSet.Beatmaps[1].Hidden = true; hiddenList.Clear(); @@ -551,7 +572,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("add mixed ruleset beatmapset", () => { - testMixed = createTestBeatmapSet(set_count + 1); + testMixed = TestResources.CreateTestBeatmapSetInfo(); for (int i = 0; i <= 2; i++) { @@ -574,7 +595,7 @@ namespace osu.Game.Tests.Visual.SongSelect BeatmapSetInfo testSingle = null; AddStep("add single ruleset beatmapset", () => { - testSingle = createTestBeatmapSet(set_count + 2); + testSingle = TestResources.CreateTestBeatmapSetInfo(); testSingle.Beatmaps.ForEach(b => { b.Ruleset = rulesets.AvailableRulesets.ElementAt(1); @@ -594,7 +615,7 @@ namespace osu.Game.Tests.Visual.SongSelect List manySets = new List(); for (int i = 1; i <= 50; i++) - manySets.Add(createTestBeatmapSet(i)); + manySets.Add(TestResources.CreateTestBeatmapSetInfo(i)); loadBeatmaps(manySets); @@ -627,18 +648,11 @@ namespace osu.Game.Tests.Visual.SongSelect { for (int i = 0; i < 10; i++) { - var set = createTestBeatmapSet(i); - - foreach (var b in set.Beatmaps) + manySets.Add(TestResources.CreateTestBeatmapSetInfo(3, new[] { // all taiko except for first - int ruleset = i > 0 ? 1 : 0; - - b.Ruleset = rulesets.GetRuleset(ruleset); - b.RulesetID = ruleset; - } - - manySets.Add(set); + rulesets.GetRuleset(i > 0 ? 1 : 0) + })); } }); @@ -660,7 +674,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("Restore different ruleset filter", () => { carousel.Filter(new FilterCriteria { Ruleset = rulesets.GetRuleset(1) }, false); - eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); + eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.OnlineID ?? -1); }); AddAssert("selection changed", () => !carousel.SelectedBeatmapInfo.Equals(manySets.First().Beatmaps.First())); @@ -678,7 +692,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("add mixed difficulty set", () => { - set = createTestBeatmapSet(1); + set = TestResources.CreateTestBeatmapSetInfo(1); set.Beatmaps.Clear(); for (int i = 1; i <= 15; i++) @@ -730,7 +744,11 @@ namespace osu.Game.Tests.Visual.SongSelect beatmapSets = new List(); for (int i = 1; i <= (count ?? set_count); i++) - beatmapSets.Add(createTestBeatmapSet(i, randomDifficulties)); + { + beatmapSets.Add(randomDifficulties + ? TestResources.CreateTestBeatmapSetInfo() + : TestResources.CreateTestBeatmapSetInfo(3)); + } } carousel.Filter(initialCriteria?.Invoke() ?? new FilterCriteria()); @@ -766,7 +784,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddUntilStep($"selected is set{set}{(diff.HasValue ? $" diff{diff.Value}" : "")}", () => { if (diff != null) - return carousel.SelectedBeatmapInfo.Equals(carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First()); + return carousel.SelectedBeatmapInfo?.Equals(carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First()) == true; return carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Contains(carousel.SelectedBeatmapInfo); }); @@ -834,95 +852,6 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert("Selection is visible", selectedBeatmapVisible); } - private BeatmapSetInfo createTestBeatmapSet(int id, bool randomDifficultyCount = false) - { - var metadata = new BeatmapMetadata - { - // Create random metadata, then we can check if sorting works based on these - Artist = $"peppy{id.ToString().PadLeft(6, '0')}", - Title = $"test set #{id}!", - AuthorString = string.Concat(Enumerable.Repeat((char)('z' - Math.Min(25, id - 1)), 5)) - }; - - var beatmapSet = new BeatmapSetInfo - { - ID = id, - OnlineID = id, - Hash = new MemoryStream(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())).ComputeMD5Hash(), - Metadata = metadata, - }; - - foreach (var b in getBeatmaps(randomDifficultyCount ? RNG.Next(1, 20) : 3, metadata)) - beatmapSet.Beatmaps.Add(b); - - return beatmapSet; - } - - private IEnumerable getBeatmaps(int count, BeatmapMetadata metadata) - { - int id = 0; - - for (int i = 0; i < count; i++) - { - float diff = (float)i / count * 10; - - string version = "Normal"; - if (diff > 6.6) - version = "Insane"; - else if (diff > 3.3) - version = "Hard"; - - yield return new BeatmapInfo - { - OnlineID = id++ * 10, - DifficultyName = version, - StarRating = diff, - Ruleset = new OsuRuleset().RulesetInfo, - Metadata = metadata, - BaseDifficulty = new BeatmapDifficulty - { - OverallDifficulty = diff, - } - }; - } - } - - private BeatmapSetInfo createTestBeatmapSetWithManyDifficulties(int id) - { - var metadata = new BeatmapMetadata - { - // Create random metadata, then we can check if sorting works based on these - Artist = $"peppy{id.ToString().PadLeft(6, '0')}", - Title = $"test set #{id}!", - AuthorString = string.Concat(Enumerable.Repeat((char)('z' - Math.Min(25, id - 1)), 5)) - }; - - var toReturn = new BeatmapSetInfo - { - OnlineID = id, - Hash = new MemoryStream(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())).ComputeMD5Hash(), - Metadata = metadata, - }; - - for (int b = 1; b < 101; b++) - { - toReturn.Beatmaps.Add(new BeatmapInfo - { - OnlineID = b * 10, - DifficultyName = $"Extra {b}", - Ruleset = rulesets.GetRuleset((b - 1) % 4), - StarRating = 2, - Metadata = metadata, - BaseDifficulty = new BeatmapDifficulty - { - OverallDifficulty = 3.5f, - } - }); - } - - return toReturn; - } - private class TestBeatmapCarousel : BeatmapCarousel { public bool PendingFilterTask => PendingFilter != null; diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs index 1b070c00bf..e7c54efa8c 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs @@ -220,7 +220,7 @@ namespace osu.Game.Tests.Visual.SongSelect Title = "Verrrrry long Title" }, DifficultyName = "Verrrrrrrrrrrrrrrrrrrrrrrrrrrrry long Version", - Status = BeatmapSetOnlineStatus.Graveyard, + Status = BeatmapOnlineStatus.Graveyard, }, }; } diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs index a8a7a5d350..2a2df777f7 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs @@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual.SongSelect [Test] public void TestBeatmapStates() { - foreach (BeatmapSetOnlineStatus status in Enum.GetValues(typeof(BeatmapSetOnlineStatus))) + foreach (BeatmapOnlineStatus status in Enum.GetValues(typeof(BeatmapOnlineStatus))) AddStep($"{status} beatmap", () => showBeatmapWithStatus(status)); } @@ -384,7 +384,7 @@ namespace osu.Game.Tests.Visual.SongSelect }; } - private void showBeatmapWithStatus(BeatmapSetOnlineStatus status) + private void showBeatmapWithStatus(BeatmapOnlineStatus status) { leaderboard.BeatmapInfo = new BeatmapInfo { diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs index 60b6fd81a2..ef11ad4153 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs @@ -16,6 +16,7 @@ using osu.Game.Rulesets.Catch; using osu.Game.Rulesets.Mania; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Taiko; +using osu.Game.Tests.Resources; using osu.Game.Users; namespace osu.Game.Tests.Visual.SongSelect @@ -89,7 +90,7 @@ namespace osu.Game.Tests.Visual.SongSelect for (int i = 0; i < import_count; ++i) { - beatmapSets.Add(importBeatmapSet(i, Enumerable.Repeat(new OsuRuleset().RulesetInfo, 5))); + beatmapSets.Add(importBeatmapSet(Enumerable.Repeat(new OsuRuleset().RulesetInfo, 5))); } }); @@ -103,9 +104,8 @@ namespace osu.Game.Tests.Visual.SongSelect { BeatmapSetInfo catchSet = null, mixedSet = null; - AddStep("create catch beatmapset", () => catchSet = importBeatmapSet(1, new[] { new CatchRuleset().RulesetInfo })); - AddStep("create mixed beatmapset", () => mixedSet = importBeatmapSet(2, - new[] { new TaikoRuleset().RulesetInfo, new CatchRuleset().RulesetInfo, new ManiaRuleset().RulesetInfo })); + AddStep("create catch beatmapset", () => catchSet = importBeatmapSet(new[] { new CatchRuleset().RulesetInfo })); + AddStep("create mixed beatmapset", () => mixedSet = importBeatmapSet(new[] { new TaikoRuleset().RulesetInfo, new CatchRuleset().RulesetInfo, new ManiaRuleset().RulesetInfo })); AddAssert("all sets imported", () => ensureAllBeatmapSetsImported(new[] { catchSet, mixedSet })); @@ -121,9 +121,8 @@ namespace osu.Game.Tests.Visual.SongSelect { BeatmapSetInfo osuSet = null, mixedSet = null; - AddStep("create osu! beatmapset", () => osuSet = importBeatmapSet(1, new[] { new OsuRuleset().RulesetInfo })); - AddStep("create mixed beatmapset", () => mixedSet = importBeatmapSet(2, - new[] { new TaikoRuleset().RulesetInfo, new CatchRuleset().RulesetInfo, new ManiaRuleset().RulesetInfo })); + AddStep("create osu! beatmapset", () => osuSet = importBeatmapSet(new[] { new OsuRuleset().RulesetInfo })); + AddStep("create mixed beatmapset", () => mixedSet = importBeatmapSet(new[] { new TaikoRuleset().RulesetInfo, new CatchRuleset().RulesetInfo, new ManiaRuleset().RulesetInfo })); AddAssert("all sets imported", () => ensureAllBeatmapSetsImported(new[] { osuSet, mixedSet })); @@ -139,9 +138,8 @@ namespace osu.Game.Tests.Visual.SongSelect { BeatmapSetInfo osuSet = null, mixedSet = null; - AddStep("create osu! beatmapset", () => osuSet = importBeatmapSet(1, new[] { new OsuRuleset().RulesetInfo })); - AddStep("create mixed beatmapset", () => mixedSet = importBeatmapSet(2, - new[] { new TaikoRuleset().RulesetInfo, new CatchRuleset().RulesetInfo, new TaikoRuleset().RulesetInfo })); + AddStep("create osu! beatmapset", () => osuSet = importBeatmapSet(new[] { new OsuRuleset().RulesetInfo })); + AddStep("create mixed beatmapset", () => mixedSet = importBeatmapSet(new[] { new TaikoRuleset().RulesetInfo, new CatchRuleset().RulesetInfo, new TaikoRuleset().RulesetInfo })); AddAssert("all sets imported", () => ensureAllBeatmapSetsImported(new[] { osuSet, mixedSet })); @@ -157,8 +155,8 @@ namespace osu.Game.Tests.Visual.SongSelect { BeatmapSetInfo osuSet = null, maniaSet = null; - AddStep("create osu! beatmapset", () => osuSet = importBeatmapSet(1, new[] { new OsuRuleset().RulesetInfo })); - AddStep("create mania beatmapset", () => maniaSet = importBeatmapSet(2, Enumerable.Repeat(new ManiaRuleset().RulesetInfo, 10))); + AddStep("create osu! beatmapset", () => osuSet = importBeatmapSet(new[] { new OsuRuleset().RulesetInfo })); + AddStep("create mania beatmapset", () => maniaSet = importBeatmapSet(Enumerable.Repeat(new ManiaRuleset().RulesetInfo, 10))); AddAssert("all sets imported", () => ensureAllBeatmapSetsImported(new[] { osuSet, maniaSet })); @@ -169,31 +167,19 @@ namespace osu.Game.Tests.Visual.SongSelect presentAndConfirm(() => maniaSet, 5); } - private BeatmapSetInfo importBeatmapSet(int importID, IEnumerable difficultyRulesets) + private BeatmapSetInfo importBeatmapSet(IEnumerable difficultyRulesets) { - var metadata = new BeatmapMetadata - { - Artist = "SomeArtist", - AuthorString = "SomeAuthor", - Title = $"import {importID}" - }; + var rulesets = difficultyRulesets.ToArray(); - var beatmapSet = new BeatmapSetInfo - { - Hash = Guid.NewGuid().ToString(), - OnlineID = importID, - Metadata = metadata, - }; + var beatmapSet = TestResources.CreateTestBeatmapSetInfo(rulesets.Length, rulesets); - beatmapSet.Beatmaps.AddRange(difficultyRulesets.Select((ruleset, difficultyIndex) => new BeatmapInfo + for (int i = 0; i < rulesets.Length; i++) { - OnlineID = importID * 1024 + difficultyIndex, - Metadata = metadata, - BaseDifficulty = new BeatmapDifficulty(), - Ruleset = ruleset, - StarRating = difficultyIndex + 1, - DifficultyName = $"SR{difficultyIndex + 1}" - })); + var beatmap = beatmapSet.Beatmaps[i]; + + beatmap.StarRating = i + 1; + beatmap.DifficultyName = $"SR{i + 1}"; + } return Game.BeatmapManager.Import(beatmapSet).Result.Value; } diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index 5a9a377605..0494d1de3c 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -3,15 +3,11 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Text; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; -using osu.Framework.Extensions; -using osu.Framework.Utils; using osu.Framework.Platform; using osu.Framework.Screens; using osu.Framework.Testing; @@ -31,6 +27,7 @@ using osu.Game.Screens.Play; using osu.Game.Screens.Select; using osu.Game.Screens.Select.Carousel; using osu.Game.Screens.Select.Filter; +using osu.Game.Tests.Resources; using osuTK.Input; namespace osu.Game.Tests.Visual.SongSelect @@ -259,7 +256,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("import multi-ruleset map", () => { var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray(); - manager.Import(createTestBeatmapSet(usableRulesets)).Wait(); + manager.Import(TestResources.CreateTestBeatmapSetInfo(rulesets: usableRulesets)).Wait(); }); } else @@ -666,7 +663,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("import multi-ruleset map", () => { var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray(); - manager.Import(createTestBeatmapSet(usableRulesets)).Wait(); + manager.Import(TestResources.CreateTestBeatmapSetInfo(3, usableRulesets)).Wait(); }); int previousSetID = 0; @@ -706,7 +703,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("import multi-ruleset map", () => { var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray(); - manager.Import(createTestBeatmapSet(usableRulesets)).Wait(); + manager.Import(TestResources.CreateTestBeatmapSetInfo(3, usableRulesets)).Wait(); }); DrawableCarouselBeatmapSet set = null; @@ -755,7 +752,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddStep("import huge difficulty count map", () => { var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray(); - imported = manager.Import(createTestBeatmapSet(usableRulesets, 50)).Result.Value; + imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets)).Result.Value; }); AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported.Beatmaps.First())); @@ -869,11 +866,7 @@ namespace osu.Game.Tests.Visual.SongSelect private void addRulesetImportStep(int id) => AddStep($"import test map for ruleset {id}", () => importForRuleset(id)); - private void importForRuleset(int id) => manager.Import(createTestBeatmapSet(rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray())).Wait(); - - private static int importId; - - private int getImportId() => ++importId; + private void importForRuleset(int id) => manager.Import(TestResources.CreateTestBeatmapSetInfo(3, rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray())).Wait(); private void checkMusicPlaying(bool playing) => AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing); @@ -896,58 +889,10 @@ namespace osu.Game.Tests.Visual.SongSelect var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray(); for (int i = 0; i < 100; i += 10) - manager.Import(createTestBeatmapSet(usableRulesets)).Wait(); + manager.Import(TestResources.CreateTestBeatmapSetInfo(rulesets: usableRulesets)).Wait(); }); } - private BeatmapSetInfo createTestBeatmapSet(RulesetInfo[] rulesets, int countPerRuleset = 6) - { - int j = 0; - RulesetInfo getRuleset() => rulesets[j++ % rulesets.Length]; - - int setId = getImportId(); - - var metadata = new BeatmapMetadata - { - // Create random metadata, then we can check if sorting works based on these - Artist = "Some Artist " + RNG.Next(0, 9), - Title = $"Some Song (set id {setId})", - AuthorString = "Some Guy " + RNG.Next(0, 9), - }; - - var beatmapSet = new BeatmapSetInfo - { - OnlineID = setId, - Hash = new MemoryStream(Encoding.UTF8.GetBytes(Guid.NewGuid().ToString())).ComputeMD5Hash(), - DateAdded = DateTimeOffset.UtcNow, - Metadata = metadata - }; - - for (int i = 0; i < countPerRuleset; i++) - { - int beatmapId = setId * 1000 + i; - - int length = RNG.Next(30000, 200000); - double bpm = RNG.NextSingle(80, 200); - - beatmapSet.Beatmaps.Add(new BeatmapInfo - { - Ruleset = getRuleset(), - OnlineID = beatmapId, - DifficultyName = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss}, bpm {bpm:0.#})", - Length = length, - Metadata = metadata, - BPM = bpm, - BaseDifficulty = new BeatmapDifficulty - { - OverallDifficulty = 3.5f, - }, - }); - } - - return beatmapSet; - } - protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDropdown.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDropdown.cs index 4b74e37ec4..a9aaefdf6c 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDropdown.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneLabelledDropdown.cs @@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] public void TestLabelledEnumDropdown() - => AddStep(@"create dropdown", () => Child = new LabelledEnumDropdown + => AddStep(@"create dropdown", () => Child = new LabelledEnumDropdown { Label = @"Beatmap status", Description = @"This is a description" diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs index 9e77fcf675..cce0295413 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuDropdown.cs @@ -10,7 +10,7 @@ namespace osu.Game.Tests.Visual.UserInterface public class TestSceneOsuDropdown : ThemeComparisonTestScene { protected override Drawable CreateContent() => - new OsuEnumDropdown + new OsuEnumDropdown { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Tests/Visual/UserInterface/TestScenePlaylistOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestScenePlaylistOverlay.cs index 52141dea1a..39146d584c 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestScenePlaylistOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestScenePlaylistOverlay.cs @@ -1,16 +1,16 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Linq; using NUnit.Framework; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Testing; -using osu.Framework.Utils; using osu.Game.Beatmaps; +using osu.Game.Graphics.Containers; using osu.Game.Overlays.Music; +using osu.Game.Tests.Resources; using osuTK; using osuTK.Input; @@ -22,6 +22,8 @@ namespace osu.Game.Tests.Visual.UserInterface private PlaylistOverlay playlistOverlay; + private BeatmapSetInfo first; + [SetUp] public void Setup() => Schedule(() => { @@ -43,19 +45,11 @@ namespace osu.Game.Tests.Visual.UserInterface for (int i = 0; i < 100; i++) { - beatmapSets.Add(new BeatmapSetInfo - { - Metadata = new BeatmapMetadata - { - // Create random metadata, then we can check if sorting works based on these - Artist = "Some Artist " + RNG.Next(0, 9), - Title = $"Some Song {i + 1}", - AuthorString = "Some Guy " + RNG.Next(0, 9), - }, - DateAdded = DateTimeOffset.UtcNow, - }); + beatmapSets.Add(TestResources.CreateTestBeatmapSetInfo()); } + first = beatmapSets.First(); + playlistOverlay.BeatmapSets.BindTo(beatmapSets); }); @@ -66,7 +60,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddStep("hold 1st item handle", () => { - var handle = this.ChildrenOfType().First(); + var handle = this.ChildrenOfType.PlaylistItemHandle>().First(); InputManager.MoveMouseTo(handle.ScreenSpaceDrawQuad.Centre); InputManager.PressButton(MouseButton.Left); }); @@ -77,7 +71,7 @@ namespace osu.Game.Tests.Visual.UserInterface InputManager.MoveMouseTo(item.ScreenSpaceDrawQuad.Centre); }); - AddAssert("song 1 is 5th", () => beatmapSets[4].Metadata.Title == "Some Song 1"); + AddAssert("song 1 is 5th", () => beatmapSets[4] == first); AddStep("release handle", () => InputManager.ReleaseButton(MouseButton.Left)); } diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index 782944c28e..36f82ac56c 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -35,7 +35,7 @@ namespace osu.Game.Beatmaps [JsonIgnore] public int BeatmapSetInfoID { get; set; } - public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None; + public BeatmapOnlineStatus Status { get; set; } = BeatmapOnlineStatus.None; [Required] public BeatmapSetInfo BeatmapSet { get; set; } diff --git a/osu.Game/Beatmaps/BeatmapOnlineLookupQueue.cs b/osu.Game/Beatmaps/BeatmapOnlineLookupQueue.cs index 7c80d8ad56..76232c2932 100644 --- a/osu.Game/Beatmaps/BeatmapOnlineLookupQueue.cs +++ b/osu.Game/Beatmaps/BeatmapOnlineLookupQueue.cs @@ -83,7 +83,7 @@ namespace osu.Game.Beatmaps if (res != null) { beatmapInfo.Status = res.Status; - beatmapInfo.BeatmapSet.Status = res.BeatmapSet?.Status ?? BeatmapSetOnlineStatus.None; + beatmapInfo.BeatmapSet.Status = res.BeatmapSet?.Status ?? BeatmapOnlineStatus.None; beatmapInfo.BeatmapSet.OnlineID = res.OnlineBeatmapSetID; beatmapInfo.OnlineID = res.OnlineID; @@ -182,7 +182,7 @@ namespace osu.Game.Beatmaps { if (reader.Read()) { - var status = (BeatmapSetOnlineStatus)reader.GetByte(2); + var status = (BeatmapOnlineStatus)reader.GetByte(2); beatmapInfo.Status = status; beatmapInfo.BeatmapSet.Status = status; diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineStatus.cs b/osu.Game/Beatmaps/BeatmapOnlineStatus.cs similarity index 84% rename from osu.Game/Beatmaps/BeatmapSetOnlineStatus.cs rename to osu.Game/Beatmaps/BeatmapOnlineStatus.cs index edaf044466..7ac25b7b75 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineStatus.cs +++ b/osu.Game/Beatmaps/BeatmapOnlineStatus.cs @@ -6,7 +6,7 @@ using osu.Game.Resources.Localisation.Web; namespace osu.Game.Beatmaps { - public enum BeatmapSetOnlineStatus + public enum BeatmapOnlineStatus { None = -3, @@ -34,7 +34,7 @@ namespace osu.Game.Beatmaps public static class BeatmapSetOnlineStatusExtensions { - public static bool GrantsPerformancePoints(this BeatmapSetOnlineStatus status) - => status == BeatmapSetOnlineStatus.Ranked || status == BeatmapSetOnlineStatus.Approved; + public static bool GrantsPerformancePoints(this BeatmapOnlineStatus status) + => status == BeatmapOnlineStatus.Ranked || status == BeatmapOnlineStatus.Approved; } } diff --git a/osu.Game/Beatmaps/BeatmapSetInfo.cs b/osu.Game/Beatmaps/BeatmapSetInfo.cs index 9a954f94cd..a4d60d7ea0 100644 --- a/osu.Game/Beatmaps/BeatmapSetInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetInfo.cs @@ -34,7 +34,7 @@ namespace osu.Game.Beatmaps [NotNull] public List Beatmaps { get; } = new List(); - public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None; + public BeatmapOnlineStatus Status { get; set; } = BeatmapOnlineStatus.None; public List Files { get; } = new List(); diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs index ec098f4ca2..6345085069 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetOnlineStatusPill.cs @@ -18,9 +18,9 @@ namespace osu.Game.Beatmaps.Drawables { public class BeatmapSetOnlineStatusPill : CircularContainer { - private BeatmapSetOnlineStatus status; + private BeatmapOnlineStatus status; - public BeatmapSetOnlineStatus Status + public BeatmapOnlineStatus Status { get => status; set @@ -75,7 +75,7 @@ namespace osu.Game.Beatmaps.Drawables }, }; - Status = BeatmapSetOnlineStatus.None; + Status = BeatmapOnlineStatus.None; TextPadding = new MarginPadding { Horizontal = 5, Bottom = 1 }; } @@ -87,14 +87,14 @@ namespace osu.Game.Beatmaps.Drawables private void updateState() { - Alpha = Status == BeatmapSetOnlineStatus.None ? 0 : 1; + Alpha = Status == BeatmapOnlineStatus.None ? 0 : 1; statusText.Text = Status.GetLocalisableDescription().ToUpper(); if (colourProvider != null) - statusText.Colour = status == BeatmapSetOnlineStatus.Graveyard ? colourProvider.Background1 : colourProvider.Background3; + statusText.Colour = status == BeatmapOnlineStatus.Graveyard ? colourProvider.Background1 : colourProvider.Background3; else - statusText.Colour = status == BeatmapSetOnlineStatus.Graveyard ? colours.GreySeafoamLight : Color4.Black; + statusText.Colour = status == BeatmapOnlineStatus.Graveyard ? colours.GreySeafoamLight : Color4.Black; background.Colour = OsuColour.ForBeatmapSetOnlineStatus(Status) ?? colourProvider?.Light1 ?? colours.GreySeafoamLighter; } diff --git a/osu.Game/Beatmaps/Drawables/Cards/Statistics/BeatmapCardDateStatistic.cs b/osu.Game/Beatmaps/Drawables/Cards/Statistics/BeatmapCardDateStatistic.cs index 8f2c4b538c..9dbe5a9114 100644 --- a/osu.Game/Beatmaps/Drawables/Cards/Statistics/BeatmapCardDateStatistic.cs +++ b/osu.Game/Beatmaps/Drawables/Cards/Statistics/BeatmapCardDateStatistic.cs @@ -41,10 +41,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Statistics // reference: https://github.com/ppy/osu-web/blob/ef432c11719fd1207bec5f9194b04f0033bdf02c/resources/assets/lib/beatmapset-panel.tsx#L36-L44 switch (beatmapSetInfo.Status) { - case BeatmapSetOnlineStatus.Ranked: - case BeatmapSetOnlineStatus.Approved: - case BeatmapSetOnlineStatus.Loved: - case BeatmapSetOnlineStatus.Qualified: + case BeatmapOnlineStatus.Ranked: + case BeatmapOnlineStatus.Approved: + case BeatmapOnlineStatus.Loved: + case BeatmapOnlineStatus.Qualified: return beatmapSetInfo.Ranked; default: diff --git a/osu.Game/Beatmaps/IBeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/IBeatmapSetOnlineInfo.cs index 2982cf9c3a..0510770d5b 100644 --- a/osu.Game/Beatmaps/IBeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/IBeatmapSetOnlineInfo.cs @@ -30,7 +30,7 @@ namespace osu.Game.Beatmaps /// /// The status of this beatmap set. /// - BeatmapSetOnlineStatus Status { get; } + BeatmapOnlineStatus Status { get; } /// /// Whether or not this beatmap set has explicit content. @@ -105,7 +105,7 @@ namespace osu.Game.Beatmaps /// /// Contains the current hype status of the beatmap set. - /// Non-null only for , , and sets. + /// Non-null only for , , and sets. /// /// /// See: https://github.com/ppy/osu-web/blob/93930cd02cfbd49724929912597c727c9fbadcd1/app/Models/Beatmapset.php#L155 diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index d3afb21933..69dfd3a7a1 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -122,34 +122,34 @@ namespace osu.Game.Graphics } /// - /// Retrieves a colour for the given . + /// Retrieves a colour for the given . /// A value indicates that a "background" shade from the local /// (or another fallback colour) should be used. /// /// /// Sourced from web: https://github.com/ppy/osu-web/blob/007eebb1916ed5cb6a7866d82d8011b1060a945e/resources/assets/less/layout.less#L36-L50 /// - public static Color4? ForBeatmapSetOnlineStatus(BeatmapSetOnlineStatus status) + public static Color4? ForBeatmapSetOnlineStatus(BeatmapOnlineStatus status) { switch (status) { - case BeatmapSetOnlineStatus.Ranked: - case BeatmapSetOnlineStatus.Approved: + case BeatmapOnlineStatus.Ranked: + case BeatmapOnlineStatus.Approved: return Color4Extensions.FromHex(@"b3ff66"); - case BeatmapSetOnlineStatus.Loved: + case BeatmapOnlineStatus.Loved: return Color4Extensions.FromHex(@"ff66ab"); - case BeatmapSetOnlineStatus.Qualified: + case BeatmapOnlineStatus.Qualified: return Color4Extensions.FromHex(@"66ccff"); - case BeatmapSetOnlineStatus.Pending: + case BeatmapOnlineStatus.Pending: return Color4Extensions.FromHex(@"ffd966"); - case BeatmapSetOnlineStatus.WIP: + case BeatmapOnlineStatus.WIP: return Color4Extensions.FromHex(@"ff9966"); - case BeatmapSetOnlineStatus.Graveyard: + case BeatmapOnlineStatus.Graveyard: return Color4.Black; default: diff --git a/osu.Game/Models/RealmBeatmap.cs b/osu.Game/Models/RealmBeatmap.cs index 4e3f96ee5f..005a7ac2a8 100644 --- a/osu.Game/Models/RealmBeatmap.cs +++ b/osu.Game/Models/RealmBeatmap.cs @@ -39,9 +39,9 @@ namespace osu.Game.Models [Ignored] public RealmNamedFileUsage? File => BeatmapSet?.Files.First(f => f.File.Hash == Hash); - public BeatmapSetOnlineStatus Status + public BeatmapOnlineStatus Status { - get => (BeatmapSetOnlineStatus)StatusInt; + get => (BeatmapOnlineStatus)StatusInt; set => StatusInt = (int)value; } diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs index 243c39ab53..ebbac0dcab 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs @@ -20,7 +20,7 @@ namespace osu.Game.Online.API.Requests.Responses public int OnlineBeatmapSetID { get; set; } [JsonProperty(@"status")] - public BeatmapSetOnlineStatus Status { get; set; } + public BeatmapOnlineStatus Status { get; set; } [JsonProperty("checksum")] public string Checksum { get; set; } = string.Empty; diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs index 8d50f3d7dd..9005fa8eb7 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs @@ -21,7 +21,7 @@ namespace osu.Game.Online.API.Requests.Responses public int OnlineID { get; set; } [JsonProperty(@"status")] - public BeatmapSetOnlineStatus Status { get; set; } + public BeatmapOnlineStatus Status { get; set; } [JsonProperty(@"preview_url")] public string Preview { get; set; } = string.Empty; diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index 15e700fc91..2fcdc9402d 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -244,7 +244,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores noScoresPlaceholder.Hide(); - if (Beatmap.Value == null || Beatmap.Value.OnlineID <= 0 || (Beatmap.Value?.BeatmapSet as IBeatmapSetOnlineInfo)?.Status <= BeatmapSetOnlineStatus.Pending) + if (Beatmap.Value == null || Beatmap.Value.OnlineID <= 0 || (Beatmap.Value?.BeatmapSet as IBeatmapSetOnlineInfo)?.Status <= BeatmapOnlineStatus.Pending) { Scores = null; Hide(); diff --git a/osu.Game/Screens/Ranking/SoloResultsScreen.cs b/osu.Game/Screens/Ranking/SoloResultsScreen.cs index 425e6f983b..929bda6508 100644 --- a/osu.Game/Screens/Ranking/SoloResultsScreen.cs +++ b/osu.Game/Screens/Ranking/SoloResultsScreen.cs @@ -27,7 +27,7 @@ namespace osu.Game.Screens.Ranking protected override APIRequest FetchScores(Action> scoresCallback) { - if (Score.BeatmapInfo.OnlineID == null || Score.BeatmapInfo.Status <= BeatmapSetOnlineStatus.Pending) + if (Score.BeatmapInfo.OnlineID == null || Score.BeatmapInfo.Status <= BeatmapOnlineStatus.Pending) return null; getScoreRequest = new GetScoresRequest(Score.BeatmapInfo, Score.Ruleset); diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index f47bc5f466..1f6e99f0c6 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Select public OptionalRange Length; public OptionalRange BPM; public OptionalRange BeatDivisor; - public OptionalRange OnlineStatus; + public OptionalRange OnlineStatus; public OptionalTextFilter Creator; public OptionalTextFilter Artist; diff --git a/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs b/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs index 03da930c5c..1fd6d8c921 100644 --- a/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs +++ b/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs @@ -154,7 +154,7 @@ namespace osu.Game.Screens.Select.Leaderboards return null; } - if (BeatmapInfo.OnlineID == null || BeatmapInfo?.Status <= BeatmapSetOnlineStatus.Pending) + if (BeatmapInfo.OnlineID == null || BeatmapInfo?.Status <= BeatmapOnlineStatus.Pending) { PlaceholderState = PlaceholderState.Unavailable; return null; diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index d774514dda..7bc63a8c26 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -226,7 +226,7 @@ namespace osu.Game.Tests.Visual return new APIBeatmapSet { OnlineID = ((IBeatmapSetInfo)beatmap.BeatmapSet).OnlineID, - Status = BeatmapSetOnlineStatus.Ranked, + Status = BeatmapOnlineStatus.Ranked, Covers = new BeatmapSetOnlineCovers { Cover = "https://assets.ppy.sh/beatmaps/163112/covers/cover.jpg",