// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Linq; using osu.Framework.Localisation; using osu.Game.Database; using osu.Game.Rulesets; #nullable enable namespace osu.Game.Beatmaps { /// /// A single beatmap difficulty. /// public interface IBeatmapInfo : IHasOnlineID { /// /// The user-specified name given to this beatmap. /// string DifficultyName { get; } /// /// The metadata representing this beatmap. May be shared between multiple beatmaps. /// IBeatmapMetadataInfo? Metadata { get; } /// /// The difficulty settings for this beatmap. /// IBeatmapDifficultyInfo Difficulty { get; } /// /// The beatmap set this beatmap is part of. /// IBeatmapSetInfo BeatmapSet { get; } /// /// The playable length in milliseconds of this beatmap. /// double Length { get; } /// /// The most common BPM of this beatmap. /// double BPM { get; } /// /// The SHA-256 hash representing this beatmap's contents. /// string Hash { get; } /// /// MD5 is kept for legacy support (matching against replays etc.). /// string MD5Hash { get; } /// /// The ruleset this beatmap was made for. /// IRulesetInfo Ruleset { get; } /// /// The basic star rating for this beatmap (with no mods applied). /// double StarRating { get; } /// /// A user-presentable display title representing this metadata. /// string DisplayTitle => $"{Metadata} {versionString}".Trim(); /// /// A user-presentable display title representing this beatmap, with localisation handling for potentially romanisable fields. /// RomanisableString DisplayTitleRomanisable { get { var metadata = closestMetadata.DisplayTitleRomanisable; return new RomanisableString($"{metadata.GetPreferred(true)} {versionString}".Trim(), $"{metadata.GetPreferred(false)} {versionString}".Trim()); } } string[] SearchableTerms => new[] { DifficultyName }.Concat(closestMetadata.SearchableTerms).Where(s => !string.IsNullOrEmpty(s)).ToArray(); private string versionString => string.IsNullOrEmpty(DifficultyName) ? string.Empty : $"[{DifficultyName}]"; // temporary helper methods until we figure which metadata should be where. private IBeatmapMetadataInfo closestMetadata => (Metadata ?? BeatmapSet.Metadata)!; } }