mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:43:22 +08:00
Merge pull request #15776 from peppy/non-null-beatmapset-metadata
Make `BeatmapSet.Metadata` non-null
This commit is contained in:
commit
834bdd8e5c
@ -29,9 +29,9 @@ namespace osu.Game.Tests.Models
|
||||
{
|
||||
var mock = new Mock<IBeatmapSetInfo>();
|
||||
|
||||
mock.Setup(m => m.Metadata!.Artist).Returns("artist");
|
||||
mock.Setup(m => m.Metadata!.Title).Returns("title");
|
||||
mock.Setup(m => m.Metadata!.Author.Username).Returns("author");
|
||||
mock.Setup(m => m.Metadata.Artist).Returns("artist");
|
||||
mock.Setup(m => m.Metadata.Title).Returns("title");
|
||||
mock.Setup(m => m.Metadata.Author.Username).Returns("author");
|
||||
|
||||
Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title (author)"));
|
||||
}
|
||||
@ -41,9 +41,9 @@ namespace osu.Game.Tests.Models
|
||||
{
|
||||
var mock = new Mock<IBeatmapSetInfo>();
|
||||
|
||||
mock.Setup(m => m.Metadata!.Artist).Returns("artist");
|
||||
mock.Setup(m => m.Metadata!.Title).Returns("title");
|
||||
mock.Setup(m => m.Metadata!.Author.Username).Returns(string.Empty);
|
||||
mock.Setup(m => m.Metadata.Artist).Returns("artist");
|
||||
mock.Setup(m => m.Metadata.Title).Returns("title");
|
||||
mock.Setup(m => m.Metadata.Author.Username).Returns(string.Empty);
|
||||
|
||||
Assert.That(mock.Object.GetDisplayString(), Is.EqualTo("artist - title"));
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
#region Implementation of IBeatmapSetInfo
|
||||
|
||||
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => Metadata;
|
||||
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => Metadata ?? Beatmaps.FirstOrDefault()?.Metadata ?? new BeatmapMetadata();
|
||||
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
|
||||
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// The best-effort metadata representing this set. In the case metadata differs between contained beatmaps, one is arbitrarily chosen.
|
||||
/// </summary>
|
||||
IBeatmapMetadataInfo? Metadata { get; }
|
||||
IBeatmapMetadataInfo Metadata { get; }
|
||||
|
||||
/// <summary>
|
||||
/// All beatmaps contained in this set.
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Extensions
|
||||
switch (model)
|
||||
{
|
||||
case IBeatmapSetInfo beatmapSetInfo:
|
||||
result = beatmapSetInfo.Metadata?.GetDisplayTitle();
|
||||
result = beatmapSetInfo.Metadata.GetDisplayTitle();
|
||||
break;
|
||||
|
||||
case IBeatmapInfo beatmapInfo:
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Models
|
||||
|
||||
public DateTimeOffset DateAdded { get; set; }
|
||||
|
||||
public IBeatmapMetadataInfo? Metadata => Beatmaps.FirstOrDefault()?.Metadata;
|
||||
public IBeatmapMetadataInfo Metadata => Beatmaps.FirstOrDefault()?.Metadata ?? new RealmBeatmapMetadata();
|
||||
|
||||
public IList<RealmBeatmap> Beatmaps { get; } = null!;
|
||||
|
||||
@ -62,7 +62,7 @@ namespace osu.Game.Models
|
||||
return ID == other.ID;
|
||||
}
|
||||
|
||||
public override string ToString() => Metadata?.GetDisplayString() ?? base.ToString();
|
||||
public override string ToString() => Metadata.GetDisplayString();
|
||||
|
||||
public bool Equals(IBeatmapSetInfo? other) => other is RealmBeatmapSet b && Equals(b);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user