Move BeatmapInfo's SearchableTerms implementation to interface

This commit is contained in:
Dean Herbert 2021-10-04 17:00:22 +09:00
parent 51b7dce16f
commit f293e008d9
3 changed files with 13 additions and 6 deletions

View File

@ -152,10 +152,7 @@ namespace osu.Game.Beatmaps
[JsonIgnore]
public DifficultyRating DifficultyRating => BeatmapDifficultyCache.GetDifficultyRating(StarDifficulty);
public string[] SearchableTerms => new[]
{
Version
}.Concat(Metadata?.SearchableTerms ?? Enumerable.Empty<string>()).Where(s => !string.IsNullOrEmpty(s)).ToArray();
public IEnumerable<string> SearchableTerms => ((IBeatmapInfo)this).SearchableTerms;
public override string ToString() => ((IBeatmapInfo)this).DisplayTitle;

View File

@ -4,6 +4,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Textures;
using osu.Framework.Logging;

View File

@ -1,6 +1,7 @@
// 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;
using osu.Game.Database;
using osu.Game.Rulesets;
@ -22,7 +23,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// The metadata representing this beatmap. May be shared between multiple beatmaps.
/// </summary>
IBeatmapMetadataInfo Metadata { get; }
IBeatmapMetadataInfo? Metadata { get; }
/// <summary>
/// The difficulty settings for this beatmap.
@ -76,12 +77,20 @@ namespace osu.Game.Beatmaps
{
get
{
var metadata = Metadata.DisplayTitleRomanisable;
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)!;
}
}