From ed07ee8c611744849d921b2c7110431cc19cdad3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 4 Nov 2021 18:46:26 +0900 Subject: [PATCH] Update all existing usages of `AuthorString`/`AuthorId` Unfortunately the getters need to be left in place else EF breaks. --- .../Beatmaps/Formats/LegacyBeatmapDecoderTest.cs | 12 ++++++------ .../Beatmaps/Formats/OsuJsonDecoderTest.cs | 2 +- osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs | 2 +- .../Visual/SongSelect/TestSceneBeatmapCarousel.cs | 2 +- osu.Game/Beatmaps/BeatmapMetadata.cs | 4 ++-- osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs | 2 +- osu.Game/Screens/Edit/Setup/MetadataSection.cs | 2 +- osu.Game/Screens/Play/BeatmapMetadataDisplay.cs | 2 +- osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs | 2 +- osu.Game/Skinning/LegacyBeatmapSkin.cs | 2 +- osu.Game/Stores/BeatmapImporter.cs | 4 ++-- osu.Game/Tests/Visual/OsuTestScene.cs | 4 +--- 12 files changed, 19 insertions(+), 21 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs index 7a95856c36..0bd7c19200 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs @@ -112,7 +112,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.AreEqual("Renatus", metadata.TitleUnicode); Assert.AreEqual("Soleily", metadata.Artist); Assert.AreEqual("Soleily", metadata.ArtistUnicode); - Assert.AreEqual("Gamu", metadata.AuthorString); + Assert.AreEqual("Gamu", metadata.Author.Username); Assert.AreEqual("Insane", beatmapInfo.Version); Assert.AreEqual(string.Empty, metadata.Source); Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", metadata.Tags); @@ -547,7 +547,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); Assert.IsNotNull(beatmap); Assert.AreEqual("Beatmap with corrupted header", beatmap.Metadata.Title); - Assert.AreEqual("Evil Hacker", beatmap.Metadata.AuthorString); + Assert.AreEqual("Evil Hacker", beatmap.Metadata.Author.Username); } } @@ -565,7 +565,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); Assert.IsNotNull(beatmap); Assert.AreEqual("Beatmap with no header", beatmap.Metadata.Title); - Assert.AreEqual("Incredibly Evil Hacker", beatmap.Metadata.AuthorString); + Assert.AreEqual("Incredibly Evil Hacker", beatmap.Metadata.Author.Username); } } @@ -583,7 +583,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); Assert.IsNotNull(beatmap); Assert.AreEqual("Empty lines at start", beatmap.Metadata.Title); - Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.AuthorString); + Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username); } } @@ -601,7 +601,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); Assert.IsNotNull(beatmap); Assert.AreEqual("The dog ate the file header", beatmap.Metadata.Title); - Assert.AreEqual("Why does this keep happening", beatmap.Metadata.AuthorString); + Assert.AreEqual("Why does this keep happening", beatmap.Metadata.Author.Username); } } @@ -619,7 +619,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream)); Assert.IsNotNull(beatmap); Assert.AreEqual("No empty line delimiting header from contents", beatmap.Metadata.Title); - Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.AuthorString); + Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username); } } diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs index 9ec2f37569..37c1dfc657 100644 --- a/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs @@ -35,7 +35,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.AreEqual("Soleily", meta.Artist); Assert.AreEqual("Soleily", meta.ArtistUnicode); Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); - Assert.AreEqual("Gamu", meta.AuthorString); + Assert.AreEqual("Gamu", meta.Author.Username); Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile); Assert.AreEqual(164471, meta.PreviewTime); Assert.AreEqual(string.Empty, meta.Source); diff --git a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs index d11da5e2a3..eaf5d107ca 100644 --- a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs @@ -60,7 +60,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.AreEqual("Soleily", meta.Artist); Assert.AreEqual("Soleily", meta.ArtistUnicode); Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); - Assert.AreEqual("Deif", meta.AuthorString); + Assert.AreEqual("Deif", meta.Author.Username); Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile); Assert.AreEqual(164471, meta.PreviewTime); Assert.AreEqual(string.Empty, meta.Source); diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index 7a38d213d9..9a142f3ca8 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -400,7 +400,7 @@ namespace osu.Game.Tests.Visual.SongSelect loadBeatmaps(); AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false)); - AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.AuthorString == "zzzzz"); + AddAssert("Check zzzzz is at bottom", () => carousel.BeatmapSets.Last().Metadata.Author.Username == "zzzzz"); 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)); } diff --git a/osu.Game/Beatmaps/BeatmapMetadata.cs b/osu.Game/Beatmaps/BeatmapMetadata.cs index 4ae212c411..b395f16c24 100644 --- a/osu.Game/Beatmaps/BeatmapMetadata.cs +++ b/osu.Game/Beatmaps/BeatmapMetadata.cs @@ -49,7 +49,7 @@ namespace osu.Game.Beatmaps [Column("AuthorID")] public int AuthorID { - get => Author.Id; + get => Author.Id; // This should not be used, but is required to make EF work correctly. set => Author.Id = value; } @@ -60,7 +60,7 @@ namespace osu.Game.Beatmaps [Column("Author")] public string AuthorString { - get => Author.Username; + get => Author.Username; // This should not be used, but is required to make EF work correctly. set => Author.Username = value; } diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs index 3ed5055b7f..9117da5d32 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs @@ -129,7 +129,7 @@ namespace osu.Game.Beatmaps.Formats if (!string.IsNullOrEmpty(beatmap.Metadata.TitleUnicode)) writer.WriteLine(FormattableString.Invariant($"TitleUnicode: {beatmap.Metadata.TitleUnicode}")); writer.WriteLine(FormattableString.Invariant($"Artist: {beatmap.Metadata.Artist}")); if (!string.IsNullOrEmpty(beatmap.Metadata.ArtistUnicode)) writer.WriteLine(FormattableString.Invariant($"ArtistUnicode: {beatmap.Metadata.ArtistUnicode}")); - writer.WriteLine(FormattableString.Invariant($"Creator: {beatmap.Metadata.AuthorString}")); + writer.WriteLine(FormattableString.Invariant($"Creator: {beatmap.Metadata.Author.Username}")); writer.WriteLine(FormattableString.Invariant($"Version: {beatmap.BeatmapInfo.Version}")); if (!string.IsNullOrEmpty(beatmap.Metadata.Source)) writer.WriteLine(FormattableString.Invariant($"Source: {beatmap.Metadata.Source}")); if (!string.IsNullOrEmpty(beatmap.Metadata.Tags)) writer.WriteLine(FormattableString.Invariant($"Tags: {beatmap.Metadata.Tags}")); diff --git a/osu.Game/Screens/Edit/Setup/MetadataSection.cs b/osu.Game/Screens/Edit/Setup/MetadataSection.cs index 5bb40c09a5..34c2fa8480 100644 --- a/osu.Game/Screens/Edit/Setup/MetadataSection.cs +++ b/osu.Game/Screens/Edit/Setup/MetadataSection.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Edit.Setup Empty(), - creatorTextBox = createTextBox("Creator", metadata.AuthorString), + creatorTextBox = createTextBox("Creator", metadata.Author.Username), difficultyTextBox = createTextBox("Difficulty Name", Beatmap.BeatmapInfo.Version), sourceTextBox = createTextBox("Source", metadata.Source), tagsTextBox = createTextBox("Tags", metadata.Tags) diff --git a/osu.Game/Screens/Play/BeatmapMetadataDisplay.cs b/osu.Game/Screens/Play/BeatmapMetadataDisplay.cs index d77673580a..909f0a2b65 100644 --- a/osu.Game/Screens/Play/BeatmapMetadataDisplay.cs +++ b/osu.Game/Screens/Play/BeatmapMetadataDisplay.cs @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Play new Drawable[] { new MetadataLineLabel("Mapper"), - new MetadataLineInfo(metadata.AuthorString) + new MetadataLineInfo(metadata.Author.Username) } } }, diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index 9e057808a7..fa96e6dde7 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -49,7 +49,7 @@ namespace osu.Game.Screens.Select.Carousel match &= !criteria.BeatDivisor.HasFilter || criteria.BeatDivisor.IsInRange(BeatmapInfo.BeatDivisor); match &= !criteria.OnlineStatus.HasFilter || criteria.OnlineStatus.IsInRange(BeatmapInfo.Status); - match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(BeatmapInfo.Metadata.AuthorString); + match &= !criteria.Creator.HasFilter || criteria.Creator.Matches(BeatmapInfo.Metadata.Author.Username); match &= !criteria.Artist.HasFilter || criteria.Artist.Matches(BeatmapInfo.Metadata.Artist) || criteria.Artist.Matches(BeatmapInfo.Metadata.ArtistUnicode); diff --git a/osu.Game/Skinning/LegacyBeatmapSkin.cs b/osu.Game/Skinning/LegacyBeatmapSkin.cs index 8720a55076..8abef6800d 100644 --- a/osu.Game/Skinning/LegacyBeatmapSkin.cs +++ b/osu.Game/Skinning/LegacyBeatmapSkin.cs @@ -77,6 +77,6 @@ namespace osu.Game.Skinning } private static SkinInfo createSkinInfo(BeatmapInfo beatmapInfo) => - new SkinInfo { Name = beatmapInfo.ToString(), Creator = beatmapInfo.Metadata?.AuthorString }; + new SkinInfo { Name = beatmapInfo.ToString(), Creator = beatmapInfo.Metadata?.Author.Username }; } } diff --git a/osu.Game/Stores/BeatmapImporter.cs b/osu.Game/Stores/BeatmapImporter.cs index 5eb7b10d9b..1ac73cf781 100644 --- a/osu.Game/Stores/BeatmapImporter.cs +++ b/osu.Game/Stores/BeatmapImporter.cs @@ -240,8 +240,8 @@ namespace osu.Game.Stores ArtistUnicode = decoded.Metadata.ArtistUnicode, Author = { - OnlineID = decoded.Metadata.AuthorID, - Username = decoded.Metadata.AuthorString + OnlineID = decoded.Metadata.Author.Id, + Username = decoded.Metadata.Author.Username }, Source = decoded.Metadata.Source, Tags = decoded.Metadata.Tags, diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index 153e2c487c..83e1423504 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -216,8 +216,6 @@ namespace osu.Game.Tests.Visual Artist = beatmap.BeatmapSet.Metadata.Artist, ArtistUnicode = beatmap.BeatmapSet.Metadata.ArtistUnicode, Author = beatmap.BeatmapSet.Metadata.Author, - AuthorID = beatmap.BeatmapSet.Metadata.AuthorID, - AuthorString = beatmap.BeatmapSet.Metadata.AuthorString, Source = beatmap.BeatmapSet.Metadata.Source, Tags = beatmap.BeatmapSet.Metadata.Tags, Beatmaps = new[] @@ -228,7 +226,7 @@ namespace osu.Game.Tests.Visual OnlineBeatmapSetID = beatmap.BeatmapSet.OnlineID, Status = beatmap.Status, Checksum = beatmap.MD5Hash, - AuthorID = beatmap.Metadata.AuthorID, + AuthorID = beatmap.Metadata.Author.OnlineID, RulesetID = beatmap.RulesetID, StarRating = beatmap.StarDifficulty, DifficultyName = beatmap.Version,