2018-01-05 20:21:19 +09:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 13:59:30 +09:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-20 16:30:03 +09:00
|
|
|
|
|
2017-12-07 15:32:39 +09:00
|
|
|
|
using System;
|
2017-10-19 14:05:11 +09:00
|
|
|
|
using System.Collections.Generic;
|
2017-10-04 22:52:12 +03:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2017-05-02 17:54:07 +09:00
|
|
|
|
using System.Linq;
|
2017-05-28 00:37:55 -03:00
|
|
|
|
using Newtonsoft.Json;
|
2017-10-13 20:25:27 +09:00
|
|
|
|
using osu.Game.Users;
|
2016-10-04 16:29:08 -04:00
|
|
|
|
|
2017-07-26 13:22:46 +09:00
|
|
|
|
namespace osu.Game.Beatmaps
|
2016-08-31 13:52:30 +09:00
|
|
|
|
{
|
2017-12-07 15:32:39 +09:00
|
|
|
|
[Serializable]
|
2017-11-25 15:05:59 +01:00
|
|
|
|
public class BeatmapMetadata : IEquatable<BeatmapMetadata>
|
2016-08-31 13:52:30 +09:00
|
|
|
|
{
|
2017-10-06 00:23:26 +03:00
|
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
2017-12-06 00:37:37 +09:00
|
|
|
|
[JsonIgnore]
|
2017-10-14 14:28:25 +09:00
|
|
|
|
public int ID { get; set; }
|
2016-12-21 14:47:56 +08:00
|
|
|
|
|
2017-10-25 14:34:39 +09:00
|
|
|
|
private int? onlineBeatmapSetID;
|
|
|
|
|
|
2017-10-09 00:30:52 +03:00
|
|
|
|
[NotMapped]
|
2017-10-25 19:26:46 +09:00
|
|
|
|
[JsonProperty(@"id")]
|
2017-10-25 14:34:39 +09:00
|
|
|
|
public int? OnlineBeatmapSetID
|
|
|
|
|
{
|
|
|
|
|
get { return onlineBeatmapSetID; }
|
|
|
|
|
set { onlineBeatmapSetID = value > 0 ? value : null; }
|
|
|
|
|
}
|
2016-12-21 14:47:56 +08:00
|
|
|
|
|
2016-10-04 16:29:08 -04:00
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
public string TitleUnicode { get; set; }
|
|
|
|
|
public string Artist { get; set; }
|
|
|
|
|
public string ArtistUnicode { get; set; }
|
2017-05-28 00:37:55 -03:00
|
|
|
|
|
2017-12-06 00:37:37 +09:00
|
|
|
|
[JsonIgnore]
|
2017-10-19 14:05:11 +09:00
|
|
|
|
public List<BeatmapInfo> Beatmaps { get; set; }
|
2017-12-06 00:37:37 +09:00
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
2017-10-19 14:05:11 +09:00
|
|
|
|
public List<BeatmapSetInfo> BeatmapSets { get; set; }
|
|
|
|
|
|
2017-10-13 20:25:27 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Helper property to deserialize a username to <see cref="User"/>.
|
|
|
|
|
/// </summary>
|
2017-05-28 00:37:55 -03:00
|
|
|
|
[JsonProperty(@"creator")]
|
2017-10-13 20:25:27 +09:00
|
|
|
|
[Column("Author")]
|
|
|
|
|
public string AuthorString
|
|
|
|
|
{
|
2017-10-14 12:27:32 +09:00
|
|
|
|
get { return Author?.Username; }
|
2017-10-13 20:25:27 +09:00
|
|
|
|
set { Author = new User { Username = value }; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The author of the beatmaps in this set.
|
|
|
|
|
/// </summary>
|
2017-12-07 15:55:22 +09:00
|
|
|
|
[JsonIgnore]
|
2017-10-13 20:25:27 +09:00
|
|
|
|
public User Author;
|
2017-05-28 00:37:55 -03:00
|
|
|
|
|
2016-10-04 16:29:08 -04:00
|
|
|
|
public string Source { get; set; }
|
2017-06-07 11:30:52 -03:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"tags")]
|
2016-10-04 16:29:08 -04:00
|
|
|
|
public string Tags { get; set; }
|
|
|
|
|
public int PreviewTime { get; set; }
|
|
|
|
|
public string AudioFile { get; set; }
|
|
|
|
|
public string BackgroundFile { get; set; }
|
2017-05-02 10:45:55 +09:00
|
|
|
|
|
2017-12-16 16:14:01 +09:00
|
|
|
|
public override string ToString() => $"{Artist} - {Title} ({Author})";
|
|
|
|
|
|
2017-12-06 00:37:37 +09:00
|
|
|
|
[JsonIgnore]
|
2017-05-02 10:45:55 +09:00
|
|
|
|
public string[] SearchableTerms => new[]
|
|
|
|
|
{
|
2017-10-13 20:25:27 +09:00
|
|
|
|
Author?.Username,
|
2017-05-02 10:45:55 +09:00
|
|
|
|
Artist,
|
|
|
|
|
ArtistUnicode,
|
|
|
|
|
Title,
|
|
|
|
|
TitleUnicode,
|
|
|
|
|
Source,
|
|
|
|
|
Tags
|
2017-05-02 17:54:07 +09:00
|
|
|
|
}.Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
2017-11-23 19:46:58 +01:00
|
|
|
|
|
2017-11-25 15:05:59 +01:00
|
|
|
|
public bool Equals(BeatmapMetadata other)
|
2017-11-23 19:46:58 +01:00
|
|
|
|
{
|
2017-11-25 15:05:59 +01:00
|
|
|
|
if (other == null)
|
|
|
|
|
return false;
|
2017-11-23 19:46:58 +01:00
|
|
|
|
|
2017-11-25 15:05:59 +01:00
|
|
|
|
return onlineBeatmapSetID == other.onlineBeatmapSetID
|
2017-11-25 15:28:39 +01:00
|
|
|
|
&& Title == other.Title
|
|
|
|
|
&& TitleUnicode == other.TitleUnicode
|
|
|
|
|
&& Artist == other.Artist
|
|
|
|
|
&& ArtistUnicode == other.ArtistUnicode
|
|
|
|
|
&& AuthorString == other.AuthorString
|
|
|
|
|
&& Source == other.Source
|
|
|
|
|
&& Tags == other.Tags
|
2017-11-25 15:05:59 +01:00
|
|
|
|
&& PreviewTime == other.PreviewTime
|
2017-11-25 15:28:39 +01:00
|
|
|
|
&& AudioFile == other.AudioFile
|
|
|
|
|
&& BackgroundFile == other.BackgroundFile;
|
2017-11-23 19:46:58 +01:00
|
|
|
|
}
|
2016-08-31 13:52:30 +09:00
|
|
|
|
}
|
2017-05-28 00:37:55 -03:00
|
|
|
|
}
|