mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 06:43:21 +08:00
Merge pull request #15224 from peppy/no-more-beatmap-metadata-base
Remove `BeatmapMetadata` base class from API classes
This commit is contained in:
commit
28d8820976
@ -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
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
/// <summary>
|
||||
/// Helper property to deserialize a username to <see cref="User"/>.
|
||||
/// </summary>
|
||||
[JsonProperty(@"user_id")]
|
||||
private int creatorId
|
||||
public int AuthorID
|
||||
{
|
||||
set => Author.Id = value;
|
||||
get => Author?.Id ?? 1;
|
||||
set
|
||||
{
|
||||
Author ??= new User();
|
||||
Author.Id = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper property to deserialize a username to <see cref="User"/>.
|
||||
/// </summary>
|
||||
[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<APIBeatmap> beatmaps { get; set; } = Array.Empty<APIBeatmap>();
|
||||
|
||||
@ -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<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => beatmaps;
|
||||
|
||||
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => this;
|
||||
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => metadata;
|
||||
|
||||
DateTimeOffset IBeatmapSetInfo.DateAdded => throw new NotImplementedException();
|
||||
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => throw new NotImplementedException();
|
||||
|
Loading…
Reference in New Issue
Block a user