diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs index 6ab1630604..6e43ac5504 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs @@ -10,7 +10,7 @@ using osu.Game.Rulesets; namespace osu.Game.Online.API.Requests.Responses { - public class APIBeatmap : BeatmapMetadata, IBeatmapInfo + public class APIBeatmap : IBeatmapInfo { [JsonProperty(@"id")] public int OnlineID { get; set; } @@ -24,6 +24,9 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty("checksum")] public string Checksum { get; set; } = string.Empty; + [JsonProperty(@"user_id")] + public int AuthorID { get; set; } + [JsonProperty(@"beatmapset")] public APIBeatmapSet? BeatmapSet { get; set; } @@ -77,7 +80,7 @@ namespace osu.Game.Online.API.Requests.Responses return new BeatmapInfo { - Metadata = set?.Metadata ?? this, + Metadata = set?.Metadata ?? new BeatmapMetadata(), Ruleset = rulesets.GetRuleset(RulesetID), StarDifficulty = StarRating, OnlineBeatmapID = OnlineID, @@ -108,7 +111,7 @@ namespace osu.Game.Online.API.Requests.Responses #region Implementation of IBeatmapInfo - public IBeatmapMetadataInfo Metadata => this; + public IBeatmapMetadataInfo Metadata => (BeatmapSet as IBeatmapSetInfo)?.Metadata ?? new BeatmapMetadata(); public IBeatmapDifficultyInfo Difficulty => new BeatmapDifficulty { diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs index 47f880cf54..24d0e09649 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs @@ -8,12 +8,13 @@ using Newtonsoft.Json; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Rulesets; +using osu.Game.Users; #nullable enable namespace osu.Game.Online.API.Requests.Responses { - public class APIBeatmapSet : BeatmapMetadata, IBeatmapSetOnlineInfo, IBeatmapSetInfo + public class APIBeatmapSet : IBeatmapSetOnlineInfo, IBeatmapSetInfo { [JsonProperty(@"covers")] public BeatmapSetOnlineCovers Covers { get; set; } @@ -63,10 +64,44 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty(@"track_id")] public int? TrackId { get; set; } + public string Title { get; set; } = string.Empty; + + [JsonProperty("title_unicode")] + public string TitleUnicode { get; set; } = string.Empty; + + public string Artist { get; set; } = string.Empty; + + [JsonProperty("artist_unicode")] + public string ArtistUnicode { get; set; } = string.Empty; + + public User? Author = new User(); + + /// + /// Helper property to deserialize a username to . + /// [JsonProperty(@"user_id")] - private int creatorId + public int AuthorID { - set => Author.Id = value; + get => Author?.Id ?? 1; + set + { + Author ??= new User(); + Author.Id = value; + } + } + + /// + /// Helper property to deserialize a username to . + /// + [JsonProperty(@"creator")] + public string AuthorString + { + get => Author?.Username ?? string.Empty; + set + { + Author ??= new User(); + Author.Username = value; + } } [JsonProperty(@"availability")] @@ -78,6 +113,11 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty(@"language")] public BeatmapSetOnlineLanguage Language { get; set; } + public string Source { get; set; } = string.Empty; + + [JsonProperty(@"tags")] + public string Tags { get; set; } = string.Empty; + [JsonProperty(@"beatmaps")] private IEnumerable beatmaps { get; set; } = Array.Empty(); @@ -86,7 +126,7 @@ namespace osu.Game.Online.API.Requests.Responses var beatmapSet = new BeatmapSetInfo { OnlineBeatmapSetID = OnlineID, - Metadata = this, + Metadata = metadata, Status = Status, Metrics = new BeatmapSetMetrics { Ratings = ratings }, OnlineInfo = this @@ -103,11 +143,23 @@ namespace osu.Game.Online.API.Requests.Responses return beatmapSet; } + private BeatmapMetadata metadata => new BeatmapMetadata + { + Title = Title, + TitleUnicode = TitleUnicode, + Artist = Artist, + ArtistUnicode = ArtistUnicode, + AuthorID = AuthorID, + Author = Author, + Source = Source, + Tags = Tags, + }; + #region Implementation of IBeatmapSetInfo IEnumerable IBeatmapSetInfo.Beatmaps => beatmaps; - IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => this; + IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => metadata; DateTimeOffset IBeatmapSetInfo.DateAdded => throw new NotImplementedException(); IEnumerable IBeatmapSetInfo.Files => throw new NotImplementedException();