mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 13:23:05 +08:00
Merge branch 'master' into i-working-beatmap/difficulty-calculator
This commit is contained in:
commit
f5c52755c9
@ -163,6 +163,8 @@ namespace osu.Game.Beatmaps
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Equals(IBeatmapInfo other) => other is BeatmapInfo b && Equals(b);
|
||||||
|
|
||||||
public bool AudioEquals(BeatmapInfo other) => other != null && BeatmapSet != null && other.BeatmapSet != null &&
|
public bool AudioEquals(BeatmapInfo other) => other != null && BeatmapSet != null && other.BeatmapSet != null &&
|
||||||
BeatmapSet.Hash == other.BeatmapSet.Hash &&
|
BeatmapSet.Hash == other.BeatmapSet.Hash &&
|
||||||
(Metadata ?? BeatmapSet.Metadata).AudioFile == (other.Metadata ?? other.BeatmapSet.Metadata).AudioFile;
|
(Metadata ?? BeatmapSet.Metadata).AudioFile == (other.Metadata ?? other.BeatmapSet.Metadata).AudioFile;
|
||||||
|
@ -78,6 +78,8 @@ namespace osu.Game.Beatmaps
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Equals(IBeatmapSetInfo other) => other is BeatmapSetInfo b && Equals(b);
|
||||||
|
|
||||||
#region Implementation of IHasOnlineID
|
#region Implementation of IHasOnlineID
|
||||||
|
|
||||||
int IHasOnlineID<int>.OnlineID => OnlineID ?? -1;
|
int IHasOnlineID<int>.OnlineID => OnlineID ?? -1;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A single beatmap difficulty.
|
/// A single beatmap difficulty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBeatmapInfo : IHasOnlineID<int>
|
public interface IBeatmapInfo : IHasOnlineID<int>, IEquatable<IBeatmapInfo>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The user-specified name given to this beatmap.
|
/// The user-specified name given to this beatmap.
|
||||||
|
@ -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.
|
||||||
|
@ -19,9 +19,9 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
IBeatmapInfo BeatmapInfo { get; }
|
IBeatmapInfo BeatmapInfo { get; }
|
||||||
|
|
||||||
IBeatmapSetInfo BeatmapSetInfo => BeatmapInfo.BeatmapSet;
|
IBeatmapSetInfo BeatmapSetInfo { get; }
|
||||||
|
|
||||||
IBeatmapMetadataInfo Metadata => BeatmapInfo.Metadata;
|
IBeatmapMetadataInfo Metadata { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the Beatmap has finished loading.
|
/// Whether the Beatmap has finished loading.
|
||||||
|
@ -27,11 +27,7 @@ namespace osu.Game.Beatmaps
|
|||||||
public abstract class WorkingBeatmap : IWorkingBeatmap
|
public abstract class WorkingBeatmap : IWorkingBeatmap
|
||||||
{
|
{
|
||||||
public readonly BeatmapInfo BeatmapInfo;
|
public readonly BeatmapInfo BeatmapInfo;
|
||||||
|
|
||||||
// ReSharper disable once FieldHidesInterfacePropertyWithDefaultImplementation
|
|
||||||
public readonly BeatmapSetInfo BeatmapSetInfo;
|
public readonly BeatmapSetInfo BeatmapSetInfo;
|
||||||
|
|
||||||
// ReSharper disable once FieldHidesInterfacePropertyWithDefaultImplementation
|
|
||||||
public readonly BeatmapMetadata Metadata;
|
public readonly BeatmapMetadata Metadata;
|
||||||
|
|
||||||
protected AudioManager AudioManager { get; }
|
protected AudioManager AudioManager { get; }
|
||||||
@ -231,6 +227,8 @@ namespace osu.Game.Beatmaps
|
|||||||
public virtual bool BeatmapLoaded => beatmapLoadTask?.IsCompleted ?? false;
|
public virtual bool BeatmapLoaded => beatmapLoadTask?.IsCompleted ?? false;
|
||||||
|
|
||||||
IBeatmapInfo IWorkingBeatmap.BeatmapInfo => BeatmapInfo;
|
IBeatmapInfo IWorkingBeatmap.BeatmapInfo => BeatmapInfo;
|
||||||
|
IBeatmapMetadataInfo IWorkingBeatmap.Metadata => Metadata;
|
||||||
|
IBeatmapSetInfo IWorkingBeatmap.BeatmapSetInfo => BeatmapSetInfo;
|
||||||
|
|
||||||
public IBeatmap Beatmap
|
public IBeatmap Beatmap
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -62,12 +63,38 @@ namespace osu.Game.Extensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether the online ID of two instances match.
|
/// Check whether the online ID of two <see cref="IBeatmapSetInfo"/>s match.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="instance">The instance to compare.</param>
|
/// <param name="instance">The instance to compare.</param>
|
||||||
/// <param name="other">The other instance to compare against.</param>
|
/// <param name="other">The other instance to compare against.</param>
|
||||||
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
||||||
public static bool MatchesOnlineID(this IHasOnlineID<long>? instance, IHasOnlineID<long>? other)
|
public static bool MatchesOnlineID(this IBeatmapSetInfo? instance, IBeatmapSetInfo? other) => matchesOnlineID(instance, other);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether the online ID of two <see cref="IBeatmapInfo"/>s match.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">The instance to compare.</param>
|
||||||
|
/// <param name="other">The other instance to compare against.</param>
|
||||||
|
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
||||||
|
public static bool MatchesOnlineID(this IBeatmapInfo? instance, IBeatmapInfo? other) => matchesOnlineID(instance, other);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether the online ID of two <see cref="IRulesetInfo"/>s match.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">The instance to compare.</param>
|
||||||
|
/// <param name="other">The other instance to compare against.</param>
|
||||||
|
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
||||||
|
public static bool MatchesOnlineID(this IRulesetInfo? instance, IRulesetInfo? other) => matchesOnlineID(instance, other);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether the online ID of two <see cref="APIUser"/>s match.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instance">The instance to compare.</param>
|
||||||
|
/// <param name="other">The other instance to compare against.</param>
|
||||||
|
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
||||||
|
public static bool MatchesOnlineID(this APIUser? instance, APIUser? other) => matchesOnlineID(instance, other);
|
||||||
|
|
||||||
|
private static bool matchesOnlineID(this IHasOnlineID<long>? instance, IHasOnlineID<long>? other)
|
||||||
{
|
{
|
||||||
if (instance == null || other == null)
|
if (instance == null || other == null)
|
||||||
return false;
|
return false;
|
||||||
@ -78,13 +105,7 @@ namespace osu.Game.Extensions
|
|||||||
return instance.OnlineID.Equals(other.OnlineID);
|
return instance.OnlineID.Equals(other.OnlineID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private static bool matchesOnlineID(this IHasOnlineID<int>? instance, IHasOnlineID<int>? other)
|
||||||
/// Check whether the online ID of two instances match.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="instance">The instance to compare.</param>
|
|
||||||
/// <param name="other">The other instance to compare against.</param>
|
|
||||||
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
|
|
||||||
public static bool MatchesOnlineID(this IHasOnlineID<int>? instance, IHasOnlineID<int>? other)
|
|
||||||
{
|
{
|
||||||
if (instance == null || other == null)
|
if (instance == null || other == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -106,6 +106,8 @@ namespace osu.Game.Models
|
|||||||
return ID == other.ID;
|
return ID == other.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Equals(IBeatmapInfo? other) => other is RealmBeatmap b && Equals(b);
|
||||||
|
|
||||||
public bool AudioEquals(RealmBeatmap? other) => other != null
|
public bool AudioEquals(RealmBeatmap? other) => other != null
|
||||||
&& BeatmapSet != null
|
&& BeatmapSet != null
|
||||||
&& other.BeatmapSet != null
|
&& other.BeatmapSet != null
|
||||||
|
@ -64,6 +64,8 @@ namespace osu.Game.Models
|
|||||||
|
|
||||||
public override string ToString() => Metadata?.GetDisplayString() ?? base.ToString();
|
public override string ToString() => Metadata?.GetDisplayString() ?? base.ToString();
|
||||||
|
|
||||||
|
public bool Equals(IBeatmapSetInfo? other) => other is RealmBeatmapSet b && Equals(b);
|
||||||
|
|
||||||
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
|
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
|
||||||
|
|
||||||
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
|
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
@ -103,5 +104,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
public string Hash => throw new NotImplementedException();
|
public string Hash => throw new NotImplementedException();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public bool Equals(IBeatmapInfo? other) => other is APIBeatmap b && this.MatchesOnlineID(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Extensions;
|
||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
@ -141,5 +142,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
double IBeatmapSetInfo.MaxBPM => BPM;
|
double IBeatmapSetInfo.MaxBPM => BPM;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public bool Equals(IBeatmapSetInfo? other) => other is APIBeatmapSet b && this.MatchesOnlineID(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Extensions;
|
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
var items = (SearchContainer<RearrangeableListItem<BeatmapSetInfo>>)ListContainer;
|
var items = (SearchContainer<RearrangeableListItem<BeatmapSetInfo>>)ListContainer;
|
||||||
|
|
||||||
foreach (var item in items.OfType<PlaylistItem>())
|
foreach (var item in items.OfType<PlaylistItem>())
|
||||||
item.InSelectedCollection = criteria.Collection?.Beatmaps.Any(b => b.MatchesOnlineID(item.Model)) ?? true;
|
item.InSelectedCollection = criteria.Collection?.Beatmaps.Any(b => item.Model.Equals(b.BeatmapSet)) ?? true;
|
||||||
|
|
||||||
items.SearchTerm = criteria.SearchText;
|
items.SearchTerm = criteria.SearchText;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user