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