-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new read-only interfaces for all remaining model types #14917
Merged
Merged
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
619dfe0
Add new interface base types for models
peppy d309636
Update all EF based models to implement new read only interfaces
peppy 8595eb2
Switch `BeatmapDifficulty` usages to use interface type
peppy 05996cc
Add changes that got forgotted in branch surgery
peppy 00e33a1
Fix incorrect `OnlineID` mappings
peppy 9dae92e
Add missing backlink to `BeatmapSet` from `Beatmap` and fix non-expli…
peppy d6618a9
Redirect more methods to interface implementations
peppy 0daf893
Add missing xmldoc
peppy dcd7d7a
Add `JsonIgnore` rule for `StoryboardFile`
peppy 8bfdfe3
Add literal string marker
peppy 4df5f93
Inline single usage of `StoryboardFile` to avoid interface default me…
peppy fd6b106
Add TODO reminder about ruleset reference transfer quirk
peppy 51b7dce
Remove reference to `osu-web-10`
peppy f293e00
Move `BeatmapInfo`'s `SearchableTerms` implementation to interface
peppy 1d99bc2
Merge branch 'master' into new-interfaces
peppy d3b9660
Move common interface implementations to extension methods
peppy a5aa328
Remove null check suppression and add non-null fallback
peppy 4d56969
Remove unnecessary access modifier in interface
peppy 4f59fc1
Mark `BeatmapSet` as nullable for the time being
peppy 4bbff2e
Merge branch 'master' into new-interfaces
smoogipoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure whether this should be a
as the inspection suggests, or if
BeatmapSet
should be marked nullable on the interface. There are several other places that nullcheck the property so probably safest to go with the latter for now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think nullable is the safest option for now, yep. Will require revisiting once things are locked in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth, I made this change due to an actual null ref, so it can happen.