mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:32:55 +08:00
Merge branch 'new-interfaces' into beatmap-difficulty-more-interface-usage
This commit is contained in:
commit
20e3f7fec4
@ -24,7 +24,6 @@ namespace osu.Game.Beatmaps
|
||||
public int BeatmapVersion;
|
||||
|
||||
private int? onlineBeatmapID;
|
||||
private IRulesetInfo ruleset;
|
||||
|
||||
[JsonProperty("id")]
|
||||
public int? OnlineBeatmapID
|
||||
@ -158,13 +157,9 @@ namespace osu.Game.Beatmaps
|
||||
Version
|
||||
}.Concat(Metadata?.SearchableTerms ?? Enumerable.Empty<string>()).Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
||||
|
||||
public override string ToString() => $"{Metadata ?? BeatmapSet?.Metadata} {versionString}".Trim();
|
||||
public override string ToString() => ((IBeatmapInfo)this).DisplayTitle;
|
||||
|
||||
public RomanisableString ToRomanisableString()
|
||||
{
|
||||
var metadata = (Metadata ?? BeatmapSet?.Metadata)?.ToRomanisableString() ?? new RomanisableString(null, null);
|
||||
return new RomanisableString($"{metadata.GetPreferred(true)} {versionString}".Trim(), $"{metadata.GetPreferred(false)} {versionString}".Trim());
|
||||
}
|
||||
public RomanisableString ToRomanisableString() => ((IBeatmapInfo)this).DisplayTitleRomanisable;
|
||||
|
||||
public bool Equals(BeatmapInfo other)
|
||||
{
|
||||
@ -191,17 +186,18 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
#region Implementation of IHasOnlineID
|
||||
|
||||
public int? OnlineID => ID;
|
||||
public int? OnlineID => OnlineBeatmapID;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation of IBeatmapInfo
|
||||
|
||||
public string DifficultyName => Version;
|
||||
string IBeatmapInfo.DifficultyName => Version;
|
||||
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
|
||||
public IBeatmapDifficultyInfo Difficulty => BaseDifficulty;
|
||||
IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => BaseDifficulty;
|
||||
IBeatmapSetInfo IBeatmapInfo.BeatmapSet => BeatmapSet;
|
||||
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;
|
||||
public double StarRating => StarDifficulty;
|
||||
double IBeatmapInfo.StarRating => StarDifficulty;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Testing;
|
||||
@ -83,51 +82,16 @@ namespace osu.Game.Beatmaps
|
||||
public int PreviewTime { get; set; }
|
||||
|
||||
public string AudioFile { get; set; }
|
||||
|
||||
public string BackgroundFile { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string author = Author == null ? string.Empty : $"({Author})";
|
||||
return $"{Artist} - {Title} {author}".Trim();
|
||||
}
|
||||
public bool Equals(BeatmapMetadata other) => ((IBeatmapMetadataInfo)this).Equals(other);
|
||||
|
||||
public RomanisableString ToRomanisableString()
|
||||
{
|
||||
string author = Author == null ? string.Empty : $"({Author})";
|
||||
var artistUnicode = string.IsNullOrEmpty(ArtistUnicode) ? Artist : ArtistUnicode;
|
||||
var titleUnicode = string.IsNullOrEmpty(TitleUnicode) ? Title : TitleUnicode;
|
||||
public override string ToString() => ((IBeatmapMetadataInfo)this).DisplayTitle;
|
||||
|
||||
return new RomanisableString($"{artistUnicode} - {titleUnicode} {author}".Trim(), $"{Artist} - {Title} {author}".Trim());
|
||||
}
|
||||
public RomanisableString ToRomanisableString() => ((IBeatmapMetadataInfo)this).DisplayTitleRomanisable;
|
||||
|
||||
[JsonIgnore]
|
||||
public string[] SearchableTerms => new[]
|
||||
{
|
||||
Author?.Username,
|
||||
Artist,
|
||||
ArtistUnicode,
|
||||
Title,
|
||||
TitleUnicode,
|
||||
Source,
|
||||
Tags
|
||||
}.Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
||||
|
||||
public bool Equals(BeatmapMetadata other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return Title == other.Title
|
||||
&& TitleUnicode == other.TitleUnicode
|
||||
&& Artist == other.Artist
|
||||
&& ArtistUnicode == other.ArtistUnicode
|
||||
&& AuthorString == other.AuthorString
|
||||
&& Source == other.Source
|
||||
&& Tags == other.Tags
|
||||
&& PreviewTime == other.PreviewTime
|
||||
&& AudioFile == other.AudioFile
|
||||
&& BackgroundFile == other.BackgroundFile;
|
||||
}
|
||||
public IEnumerable<string> SearchableTerms => ((IBeatmapMetadataInfo)this).SearchableTerms;
|
||||
|
||||
string IBeatmapMetadataInfo.Author => AuthorString;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
|
||||
@ -61,7 +62,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public string Hash { get; set; }
|
||||
|
||||
public string StoryboardFile => Files.Find(f => f.Filename.EndsWith(".osb", StringComparison.OrdinalIgnoreCase))?.Filename;
|
||||
[JsonIgnore]
|
||||
public string StoryboardFile => ((IBeatmapSetInfo)this).StoryboardFile;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the storage path for the file in this beatmapset with the given filename, if any exists, otherwise null.
|
||||
@ -93,7 +95,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
#region Implementation of IHasOnlineID
|
||||
|
||||
public int? OnlineID => ID;
|
||||
public int? OnlineID => OnlineBeatmapSetID;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -29,6 +29,11 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
IBeatmapDifficultyInfo Difficulty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The beatmap set this beatmap is part of.
|
||||
/// </summary>
|
||||
IBeatmapSetInfo BeatmapSet { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The playable length in milliseconds of this beatmap.
|
||||
/// </summary>
|
||||
@ -59,8 +64,14 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
double StarRating { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A user-presentable display title representing this metadata.
|
||||
/// </summary>
|
||||
string DisplayTitle => $"{Metadata} {versionString}".Trim();
|
||||
|
||||
/// <summary>
|
||||
/// A user-presentable display title representing this beatmap, with localisation handling for potentially romanisable fields.
|
||||
/// </summary>
|
||||
RomanisableString DisplayTitleRomanisable
|
||||
{
|
||||
get
|
||||
|
@ -65,6 +65,9 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
string BackgroundFile { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A user-presentable display title representing this metadata.
|
||||
/// </summary>
|
||||
string DisplayTitle
|
||||
{
|
||||
get
|
||||
@ -74,6 +77,9 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A user-presentable display title representing this metadata, with localisation handling for potentially romanisable fields.
|
||||
/// </summary>
|
||||
RomanisableString DisplayTitleRomanisable
|
||||
{
|
||||
get
|
||||
@ -86,6 +92,9 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An array of all searchable terms provided in contained metadata.
|
||||
/// </summary>
|
||||
string[] SearchableTerms => new[]
|
||||
{
|
||||
Author,
|
||||
|
Loading…
Reference in New Issue
Block a user