2021-10-05 05:41:14 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
{
|
|
|
|
public static class BeatmapInfoExtensions
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A user-presentable display title representing this beatmap.
|
|
|
|
/// </summary>
|
2021-11-09 12:51:18 +00:00
|
|
|
public static string GetDisplayTitle(this IBeatmapInfo beatmapInfo) => $"{beatmapInfo.Metadata.GetDisplayTitle()} {getVersionString(beatmapInfo)}".Trim();
|
2021-10-05 05:41:14 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A user-presentable display title representing this beatmap, with localisation handling for potentially romanisable fields.
|
|
|
|
/// </summary>
|
2021-11-01 05:33:24 +00:00
|
|
|
public static RomanisableString GetDisplayTitleRomanisable(this IBeatmapInfo beatmapInfo, bool includeDifficultyName = true, bool includeCreator = true)
|
2021-10-05 05:41:14 +00:00
|
|
|
{
|
2021-11-04 05:25:30 +00:00
|
|
|
var metadata = beatmapInfo.Metadata.GetDisplayTitleRomanisable(includeCreator);
|
2021-10-05 05:41:14 +00:00
|
|
|
|
2021-10-20 09:43:48 +00:00
|
|
|
if (includeDifficultyName)
|
|
|
|
{
|
2021-10-27 04:04:41 +00:00
|
|
|
string versionString = getVersionString(beatmapInfo);
|
2021-10-20 09:43:48 +00:00
|
|
|
return new RomanisableString($"{metadata.GetPreferred(true)} {versionString}".Trim(), $"{metadata.GetPreferred(false)} {versionString}".Trim());
|
|
|
|
}
|
|
|
|
|
|
|
|
return new RomanisableString($"{metadata.GetPreferred(true)}".Trim(), $"{metadata.GetPreferred(false)}".Trim());
|
2021-10-05 05:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static string[] GetSearchableTerms(this IBeatmapInfo beatmapInfo) => new[]
|
|
|
|
{
|
|
|
|
beatmapInfo.DifficultyName
|
2021-11-04 05:25:30 +00:00
|
|
|
}.Concat(beatmapInfo.Metadata.GetSearchableTerms()).Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
2021-10-05 05:41:14 +00:00
|
|
|
|
|
|
|
private static string getVersionString(IBeatmapInfo beatmapInfo) => string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? string.Empty : $"[{beatmapInfo.DifficultyName}]";
|
|
|
|
}
|
|
|
|
}
|