From cd722e4abb08e81509e8b6609cbb933e71b578e7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 Oct 2017 20:25:27 +0900 Subject: [PATCH] Fix beatmap author being stored in two different places --- .../Tests/TestCaseTaikoPlayfield.cs | 2 +- osu.Game/Beatmaps/Beatmap.cs | 2 +- osu.Game/Beatmaps/BeatmapMetadata.cs | 17 ++++++++++++++-- osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs | 6 ------ osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 2 +- .../API/Requests/GetBeatmapSetsResponse.cs | 13 +++--------- osu.Game/Overlays/BeatmapSet/AuthorInfo.cs | 4 ++-- osu.Game/Overlays/Direct/DirectGridPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 2 +- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 2 +- osu.Game/Screens/Select/FilterCriteria.cs | 4 ++-- .../Tests/Visual/TestCaseBeatmapSetOverlay.cs | 20 +++++++++---------- osu.Game/Tests/Visual/TestCaseDirect.cs | 8 ++++---- .../Tests/Visual/TestCasePlaySongSelect.cs | 2 +- .../Tests/Visual/TestCaseRoomInspector.cs | 4 ++-- osu.sln.DotSettings | 1 + 18 files changed, 48 insertions(+), 47 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs index 79ee2945ad..2136d0d86a 100644 --- a/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Taiko.Tests { Artist = @"Unknown", Title = @"Sample Beatmap", - Author = @"peppy", + AuthorString = @"peppy", }, }, ControlPointInfo = controlPointInfo diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index 383a331eb4..56bb48965f 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -69,7 +69,7 @@ namespace osu.Game.Beatmaps { Artist = @"Unknown", Title = @"Unknown", - Author = @"Unknown Creator", + AuthorString = @"Unknown Creator", }, Version = @"Normal", Difficulty = new BeatmapDifficulty() diff --git a/osu.Game/Beatmaps/BeatmapMetadata.cs b/osu.Game/Beatmaps/BeatmapMetadata.cs index cc9a51b4e2..9ed70caf35 100644 --- a/osu.Game/Beatmaps/BeatmapMetadata.cs +++ b/osu.Game/Beatmaps/BeatmapMetadata.cs @@ -3,6 +3,7 @@ using System.Linq; using Newtonsoft.Json; +using osu.Game.Users; using SQLite.Net.Attributes; namespace osu.Game.Beatmaps @@ -19,8 +20,20 @@ namespace osu.Game.Beatmaps public string Artist { get; set; } public string ArtistUnicode { get; set; } + /// + /// Helper property to deserialize a username to . + /// [JsonProperty(@"creator")] - public string Author { get; set; } + [Column("Author")] + public string AuthorString + { + set { Author = new User { Username = value }; } + } + + /// + /// The author of the beatmaps in this set. + /// + public User Author; public string Source { get; set; } @@ -32,7 +45,7 @@ namespace osu.Game.Beatmaps public string[] SearchableTerms => new[] { - Author, + Author?.Username, Artist, ArtistUnicode, Title, diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs index 6b59f0f298..27d1f057ca 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs @@ -3,7 +3,6 @@ using System; using Newtonsoft.Json; -using osu.Game.Users; namespace osu.Game.Beatmaps { @@ -12,11 +11,6 @@ namespace osu.Game.Beatmaps /// public class BeatmapSetOnlineInfo { - /// - /// The author of the beatmaps in this set. - /// - public User Author; - /// /// The date this beatmap set was submitted to the online listing. /// diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index d8cd58d939..9a61762fa6 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -22,7 +22,7 @@ namespace osu.Game.Beatmaps { Artist = "please load a beatmap!", Title = "no beatmaps available!", - Author = "no one", + AuthorString = "no one", }, BeatmapSet = new BeatmapSetInfo(), Difficulty = new BeatmapDifficulty diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 2493dab08c..3c06180532 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -171,7 +171,7 @@ namespace osu.Game.Beatmaps.Formats metadata.ArtistUnicode = pair.Value; break; case @"Creator": - metadata.Author = pair.Value; + metadata.AuthorString = pair.Value; break; case @"Version": beatmap.BeatmapInfo.Version = pair.Value; diff --git a/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs b/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs index 085563845d..b3bdab2616 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapSetsResponse.cs @@ -6,7 +6,6 @@ using System.Linq; using Newtonsoft.Json; using osu.Game.Beatmaps; using osu.Game.Rulesets; -using osu.Game.Users; namespace osu.Game.Online.API.Requests { @@ -27,11 +26,10 @@ namespace osu.Game.Online.API.Requests [JsonProperty(@"id")] private int onlineId { get; set; } - [JsonProperty(@"creator")] - private string creatorUsername { get; set; } - [JsonProperty(@"user_id")] - private long creatorId = 1; + private long creatorId { + set { Author.Id = value; } + } [JsonProperty(@"beatmaps")] private IEnumerable beatmaps { get; set; } @@ -44,11 +42,6 @@ namespace osu.Game.Online.API.Requests Metadata = this, OnlineInfo = new BeatmapSetOnlineInfo { - Author = new User - { - Id = creatorId, - Username = creatorUsername, - }, Covers = covers, Preview = preview, PlayCount = playCount, diff --git a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs index fc9fd1e614..46ee5a9cdb 100644 --- a/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs +++ b/osu.Game/Overlays/BeatmapSet/AuthorInfo.cs @@ -36,12 +36,12 @@ namespace osu.Game.Overlays.BeatmapSet var i = BeatmapSet.OnlineInfo; - avatar.User = i.Author; + avatar.User = BeatmapSet.Metadata.Author; clickableArea.Action = () => profile?.ShowUser(avatar.User); fields.Children = new Drawable[] { - new Field("made by", i.Author.Username, @"Exo2.0-RegularItalic"), + new Field("made by", BeatmapSet.Metadata.Author.Username, @"Exo2.0-RegularItalic"), new Field("submitted on", i.Submitted.ToString(@"MMM d, yyyy"), @"Exo2.0-Bold") { Margin = new MarginPadding { Top = 5 }, diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 7464ee7fb8..e863f78e3f 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -130,7 +130,7 @@ namespace osu.Game.Overlays.Direct }, new OsuSpriteText { - Text = SetInfo.Metadata.Author, + Text = SetInfo.Metadata.Author.Username, TextSize = 14, Font = @"Exo2.0-SemiBoldItalic", Shadow = false, diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 5889a1bc12..3a1004fd44 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -128,7 +128,7 @@ namespace osu.Game.Overlays.Direct }, new OsuSpriteText { - Text = SetInfo.Metadata.Author, + Text = SetInfo.Metadata.Author.Username, TextSize = 14, Font = @"Exo2.0-SemiBoldItalic", }, diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 9366797f47..a5248acbe4 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -248,7 +248,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, }, - new MetadataLine("Mapper", metadata.Author) + new MetadataLine("Mapper", metadata.Author.Username) { Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 76c384b84c..3b26f7bffc 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -210,7 +210,7 @@ namespace osu.Game.Screens.Select new OsuSpriteText { Font = @"Exo2.0-Bold", - Text = metadata.Author, + Text = metadata.Author.Username, TextSize = 15, }, } diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index a1fea4a41d..6c1fb1703d 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -51,7 +51,7 @@ namespace osu.Game.Screens.Select groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase)); break; case SortMode.Author: - groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase)); + groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author.Username, y.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase)); break; case SortMode.Difficulty: groups.Sort((x, y) => x.BeatmapSet.MaxStarDifficulty.CompareTo(y.BeatmapSet.MaxStarDifficulty)); @@ -59,4 +59,4 @@ namespace osu.Game.Screens.Select } } } -} \ No newline at end of file +} diff --git a/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs b/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs index 76ed9979ca..72d97f905c 100644 --- a/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs @@ -39,6 +39,11 @@ namespace osu.Game.Tests.Visual Artist = @"Kaneko Chiharu", Source = @"SOUND VOLTEX III GRAVITY WARS", Tags = @"sdvx grace the 5th kac original song contest konami bemani", + Author = new User + { + Username = @"Fresh Chicken", + Id = 3984370, + }, }, OnlineInfo = new BeatmapSetOnlineInfo { @@ -48,11 +53,6 @@ namespace osu.Game.Tests.Visual Submitted = new DateTime(2016, 2, 10), Ranked = new DateTime(2016, 6, 19), BPM = 236, - Author = new User - { - Username = @"Fresh Chicken", - Id = 3984370, - }, Covers = new BeatmapSetOnlineCovers { Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778", @@ -213,6 +213,11 @@ namespace osu.Game.Tests.Visual Title = @"Soumatou Labyrinth", Artist = @"Yunomi with Momobako&miko", Tags = @"mmbk.com yuzu__rinrin charlotte", + Author = new User + { + Username = @"komasy", + Id = 1980256, + }, }, OnlineInfo = new BeatmapSetOnlineInfo { @@ -222,11 +227,6 @@ namespace osu.Game.Tests.Visual Submitted = new DateTime(2016, 6, 11), Ranked = new DateTime(2016, 7, 12), BPM = 160, - Author = new User - { - Username = @"komasy", - Id = 1980256, - }, Covers = new BeatmapSetOnlineCovers { Cover = @"https://assets.ppy.sh/beatmaps/625493/covers/cover.jpg?1499167472", diff --git a/osu.Game/Tests/Visual/TestCaseDirect.cs b/osu.Game/Tests/Visual/TestCaseDirect.cs index 1fb9dbea8f..2d8677c391 100644 --- a/osu.Game/Tests/Visual/TestCaseDirect.cs +++ b/osu.Game/Tests/Visual/TestCaseDirect.cs @@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual { Title = @"OrVid", Artist = @"An", - Author = @"RLC", + AuthorString = @"RLC", Source = @"", Tags = @"acuticnotes an-fillnote revid tear tearvid encrpted encryption axi axivid quad her hervid recoll", }, @@ -78,7 +78,7 @@ namespace osu.Game.Tests.Visual { Title = @"tiny lamp", Artist = @"fhana", - Author = @"Sotarks", + AuthorString = @"Sotarks", Source = @"ぎんぎつね", Tags = @"lantis junichi sato yuxuki waga kevin mitsunaga towana gingitsune opening op full ver version kalibe collab collaboration", }, @@ -110,7 +110,7 @@ namespace osu.Game.Tests.Visual { Title = @"At Gwanghwamun", Artist = @"KYUHYUN", - Author = @"Cerulean Veyron", + AuthorString = @"Cerulean Veyron", Source = @"", Tags = @"soul ballad kh super junior sj suju 슈퍼주니어 kt뮤직 sm엔터테인먼트 s.m.entertainment kt music 1st mini album ep", }, @@ -157,7 +157,7 @@ namespace osu.Game.Tests.Visual { Title = @"RHAPSODY OF BLUE SKY", Artist = @"fhana", - Author = @"[Kamiya]", + AuthorString = @"[Kamiya]", Source = @"小林さんちのメイドラゴン", Tags = @"kobayashi san chi no maidragon aozora no opening anime maid dragon oblivion karen dynamix imoutosan pata-mon gxytcgxytc", }, diff --git a/osu.Game/Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game/Tests/Visual/TestCasePlaySongSelect.cs index feff7497d8..3ea976b96f 100644 --- a/osu.Game/Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game/Tests/Visual/TestCasePlaySongSelect.cs @@ -68,7 +68,7 @@ namespace osu.Game.Tests.Visual // Create random metadata, then we can check if sorting works based on these Artist = "MONACA " + RNG.Next(0, 9), Title = "Black Song " + RNG.Next(0, 9), - Author = "Some Guy " + RNG.Next(0, 9), + AuthorString = "Some Guy " + RNG.Next(0, 9), }, Beatmaps = new List(new[] { diff --git a/osu.Game/Tests/Visual/TestCaseRoomInspector.cs b/osu.Game/Tests/Visual/TestCaseRoomInspector.cs index dd773b361a..e6b57c970b 100644 --- a/osu.Game/Tests/Visual/TestCaseRoomInspector.cs +++ b/osu.Game/Tests/Visual/TestCaseRoomInspector.cs @@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual { Title = @"Platina", Artist = @"Maaya Sakamoto", - Author = @"uwutm8", + AuthorString = @"uwutm8", }, BeatmapSet = new BeatmapSetInfo { @@ -104,7 +104,7 @@ namespace osu.Game.Tests.Visual { Title = @"FREEDOM DIVE", Artist = @"xi", - Author = @"Nakagawa-Kanon", + AuthorString = @"Nakagawa-Kanon", }, BeatmapSet = new BeatmapSetInfo { diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 4011e3991f..c236ce82b0 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -645,6 +645,7 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-frame <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + True True True True