-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14917 from peppy/new-interfaces
Add new read-only interfaces for all remaining model types
- Loading branch information
Showing
34 changed files
with
553 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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> | ||
public static string GetDisplayTitle(this IBeatmapInfo beatmapInfo) => $"{getClosestMetadata(beatmapInfo)} {getVersionString(beatmapInfo)}".Trim(); | ||
|
||
/// <summary> | ||
/// A user-presentable display title representing this beatmap, with localisation handling for potentially romanisable fields. | ||
/// </summary> | ||
public static RomanisableString GetDisplayTitleRomanisable(this IBeatmapInfo beatmapInfo) | ||
{ | ||
var metadata = getClosestMetadata(beatmapInfo).GetDisplayTitleRomanisable(); | ||
var versionString = getVersionString(beatmapInfo); | ||
|
||
return new RomanisableString($"{metadata.GetPreferred(true)} {versionString}".Trim(), $"{metadata.GetPreferred(false)} {versionString}".Trim()); | ||
} | ||
|
||
public static string[] GetSearchableTerms(this IBeatmapInfo beatmapInfo) => new[] | ||
{ | ||
beatmapInfo.DifficultyName | ||
}.Concat(getClosestMetadata(beatmapInfo).GetSearchableTerms()).Where(s => !string.IsNullOrEmpty(s)).ToArray(); | ||
|
||
private static string getVersionString(IBeatmapInfo beatmapInfo) => string.IsNullOrEmpty(beatmapInfo.DifficultyName) ? string.Empty : $"[{beatmapInfo.DifficultyName}]"; | ||
|
||
// temporary helper methods until we figure which metadata should be where. | ||
private static IBeatmapMetadataInfo getClosestMetadata(IBeatmapInfo beatmapInfo) => | ||
beatmapInfo.Metadata ?? beatmapInfo.BeatmapSet?.Metadata ?? new BeatmapMetadata(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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 BeatmapMetadataInfoExtensions | ||
{ | ||
/// <summary> | ||
/// An array of all searchable terms provided in contained metadata. | ||
/// </summary> | ||
public static string[] GetSearchableTerms(this IBeatmapMetadataInfo metadataInfo) => new[] | ||
{ | ||
metadataInfo.Author, | ||
metadataInfo.Artist, | ||
metadataInfo.ArtistUnicode, | ||
metadataInfo.Title, | ||
metadataInfo.TitleUnicode, | ||
metadataInfo.Source, | ||
metadataInfo.Tags | ||
}.Where(s => !string.IsNullOrEmpty(s)).ToArray(); | ||
|
||
/// <summary> | ||
/// A user-presentable display title representing this metadata. | ||
/// </summary> | ||
public static string GetDisplayTitle(this IBeatmapMetadataInfo metadataInfo) | ||
{ | ||
string author = string.IsNullOrEmpty(metadataInfo.Author) ? string.Empty : $"({metadataInfo.Author})"; | ||
return $"{metadataInfo.Artist} - {metadataInfo.Title} {author}".Trim(); | ||
} | ||
|
||
/// <summary> | ||
/// A user-presentable display title representing this beatmap, with localisation handling for potentially romanisable fields. | ||
/// </summary> | ||
public static RomanisableString GetDisplayTitleRomanisable(this IBeatmapMetadataInfo metadataInfo) | ||
{ | ||
string author = string.IsNullOrEmpty(metadataInfo.Author) ? string.Empty : $"({metadataInfo.Author})"; | ||
var artistUnicode = string.IsNullOrEmpty(metadataInfo.ArtistUnicode) ? metadataInfo.Artist : metadataInfo.ArtistUnicode; | ||
var titleUnicode = string.IsNullOrEmpty(metadataInfo.TitleUnicode) ? metadataInfo.Title : metadataInfo.TitleUnicode; | ||
|
||
return new RomanisableString($"{artistUnicode} - {titleUnicode} {author}".Trim(), $"{metadataInfo.Artist} - {metadataInfo.Title} {author}".Trim()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.