mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 12:25:04 +08:00
Add IBeatmapSetInfo
equality support
This commit is contained in:
parent
a67e156883
commit
54cd1158a4
@ -66,6 +66,17 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public bool Protected { get; set; }
|
public bool Protected { get; set; }
|
||||||
|
|
||||||
|
public bool Equals(IBeatmapSetInfo other)
|
||||||
|
{
|
||||||
|
if (other is BeatmapSetInfo b)
|
||||||
|
return Equals(b);
|
||||||
|
|
||||||
|
if (OnlineID > 0 && other?.OnlineID > 0)
|
||||||
|
return other.OnlineID == OnlineID;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Equals(BeatmapSetInfo other)
|
public bool Equals(BeatmapSetInfo other)
|
||||||
{
|
{
|
||||||
if (other == null)
|
if (other == null)
|
||||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A representation of a collection of beatmap difficulties, generally packaged as an ".osz" archive.
|
/// A representation of a collection of beatmap difficulties, generally packaged as an ".osz" archive.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBeatmapSetInfo : IHasOnlineID<int>
|
public interface IBeatmapSetInfo : IHasOnlineID<int>, IEquatable<IBeatmapSetInfo>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The date when this beatmap was imported.
|
/// The date when this beatmap was imported.
|
||||||
|
@ -53,7 +53,16 @@ namespace osu.Game.Models
|
|||||||
/// <param name="filename">The name of the file to get the storage path of.</param>
|
/// <param name="filename">The name of the file to get the storage path of.</param>
|
||||||
public string? GetPathForFile(string filename) => Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.File.StoragePath;
|
public string? GetPathForFile(string filename) => Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.File.StoragePath;
|
||||||
|
|
||||||
public override string ToString() => Metadata?.ToString() ?? base.ToString();
|
public bool Equals(IBeatmapSetInfo? other)
|
||||||
|
{
|
||||||
|
if (other is RealmBeatmap b)
|
||||||
|
return b.ID == ID;
|
||||||
|
|
||||||
|
if (OnlineID > 0 && other?.OnlineID > 0)
|
||||||
|
return other.OnlineID == OnlineID;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Equals(RealmBeatmapSet? other)
|
public bool Equals(RealmBeatmapSet? other)
|
||||||
{
|
{
|
||||||
@ -72,6 +81,8 @@ namespace osu.Game.Models
|
|||||||
return ReferenceEquals(this, other);
|
return ReferenceEquals(this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString() => Metadata?.ToString() ?? base.ToString();
|
||||||
|
|
||||||
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
|
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
|
||||||
|
|
||||||
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
|
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
|
||||||
|
@ -141,5 +141,17 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
double IBeatmapSetInfo.MaxBPM => BPM;
|
double IBeatmapSetInfo.MaxBPM => BPM;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Implementation of IEquatable<IBeatmapSetInfo>
|
||||||
|
|
||||||
|
public bool Equals(IBeatmapSetInfo? other)
|
||||||
|
{
|
||||||
|
if (OnlineID > 0 && other?.OnlineID > 0)
|
||||||
|
return other.OnlineID == OnlineID;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user