mirror of
https://github.com/ppy/osu.git
synced 2026-06-03 02:31:25 +08:00
Revert unnecessary changes
This commit is contained in:
@@ -368,7 +368,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2
|
||||
var groupingFilter = new BeatmapCarouselFilterGrouping(
|
||||
() => new FilterCriteria { Group = group },
|
||||
() => new List<BeatmapCollection>(),
|
||||
(_, _) => new Dictionary<Guid, ScoreRank>());
|
||||
_ => new Dictionary<Guid, ScoreRank>());
|
||||
|
||||
return await groupingFilter.Run(beatmapSets.SelectMany(s => s.Beatmaps.Select(b => new CarouselItem(b))).ToList(), CancellationToken.None);
|
||||
}
|
||||
|
||||
@@ -157,12 +157,6 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public bool Equals(IBeatmapInfo? other) => other is BeatmapInfo b && Equals(b);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
||||
return ID.GetHashCode();
|
||||
}
|
||||
|
||||
public bool AudioEquals(BeatmapInfo? other) => other != null
|
||||
&& BeatmapSet != null
|
||||
&& other.BeatmapSet != null
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
{
|
||||
new BeatmapCarouselFilterMatching(() => Criteria!),
|
||||
new BeatmapCarouselFilterSorting(() => Criteria!),
|
||||
grouping = new BeatmapCarouselFilterGrouping(() => Criteria!, getDetachedCollections, buildTopRankMapping)
|
||||
grouping = new BeatmapCarouselFilterGrouping(() => Criteria!, getDetachedCollections, getTopRanksMapping)
|
||||
};
|
||||
|
||||
AddInternal(loading = new LoadingLayer());
|
||||
@@ -625,14 +625,14 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
#endregion
|
||||
|
||||
#region Grouping
|
||||
#region Database fetches for grouping support
|
||||
|
||||
[Resolved]
|
||||
private RealmAccess realm { get; set; } = null!;
|
||||
|
||||
private List<BeatmapCollection> getDetachedCollections() => realm.Run(r => r.All<BeatmapCollection>().Detach());
|
||||
private List<BeatmapCollection> getDetachedCollections() => realm.Run(r => r.All<BeatmapCollection>().AsEnumerable().Detach());
|
||||
|
||||
private Dictionary<Guid, ScoreRank> buildTopRankMapping(int? localUserId, string? ruleset) => realm.Run(r =>
|
||||
private Dictionary<Guid, ScoreRank> getTopRanksMapping(FilterCriteria criteria) => realm.Run(r =>
|
||||
{
|
||||
var topRankMapping = new Dictionary<Guid, ScoreRank>();
|
||||
|
||||
@@ -640,7 +640,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
.Filter($"{nameof(ScoreInfo.User)}.{nameof(RealmUser.OnlineID)} == $0"
|
||||
+ $" && {nameof(ScoreInfo.BeatmapInfo)}.{nameof(BeatmapInfo.Hash)} == {nameof(ScoreInfo.BeatmapHash)}"
|
||||
+ $" && {nameof(ScoreInfo.Ruleset)}.{nameof(RulesetInfo.ShortName)} == $1"
|
||||
+ $" && {nameof(ScoreInfo.DeletePending)} == false", localUserId, ruleset)
|
||||
+ $" && {nameof(ScoreInfo.DeletePending)} == false", criteria.LocalUserId, criteria.Ruleset?.ShortName)
|
||||
.OrderByDescending(s => s.TotalScore)
|
||||
.ThenBy(s => s.Date);
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@ namespace osu.Game.Screens.SelectV2
|
||||
private Dictionary<GroupDefinition, HashSet<CarouselItem>> groupMap = new Dictionary<GroupDefinition, HashSet<CarouselItem>>();
|
||||
|
||||
private readonly Func<FilterCriteria> getCriteria;
|
||||
private readonly GetDetachedCollectionsDelegate getDetachedCollections;
|
||||
private readonly BuildTopRankMappingDelegate buildTopRankMapping;
|
||||
private readonly Func<List<BeatmapCollection>> getCollections;
|
||||
private readonly Func<FilterCriteria, IReadOnlyDictionary<Guid, ScoreRank>> getLocalUserTopRanks;
|
||||
|
||||
public BeatmapCarouselFilterGrouping(Func<FilterCriteria> getCriteria, GetDetachedCollectionsDelegate getDetachedCollections, BuildTopRankMappingDelegate buildTopRankMapping)
|
||||
public BeatmapCarouselFilterGrouping(Func<FilterCriteria> getCriteria, Func<List<BeatmapCollection>> getCollections, Func<FilterCriteria, IReadOnlyDictionary<Guid, ScoreRank>> getLocalUserTopRanks)
|
||||
{
|
||||
this.getCriteria = getCriteria;
|
||||
this.getDetachedCollections = getDetachedCollections;
|
||||
this.buildTopRankMapping = buildTopRankMapping;
|
||||
this.getCollections = getCollections;
|
||||
this.getLocalUserTopRanks = getLocalUserTopRanks;
|
||||
}
|
||||
|
||||
public async Task<List<CarouselItem>> Run(IEnumerable<CarouselItem> items, CancellationToken cancellationToken)
|
||||
@@ -190,7 +190,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
var date = b.LastPlayed;
|
||||
|
||||
if (BeatmapSetsGroupedTogether)
|
||||
date = aggregateMax(b, static b => (b.LastPlayed ?? DateTimeOffset.MinValue));
|
||||
date = aggregateMax(b, static b => b.LastPlayed ?? DateTimeOffset.MinValue);
|
||||
|
||||
if (date == null || date == DateTimeOffset.MinValue)
|
||||
return new GroupDefinition(int.MaxValue, "Never");
|
||||
@@ -231,7 +231,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
case GroupMode.Collections:
|
||||
{
|
||||
var collections = getDetachedCollections();
|
||||
var collections = getCollections();
|
||||
return getGroupsBy(b => defineGroupByCollection(b, collections), items);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
case GroupMode.RankAchieved:
|
||||
{
|
||||
var topRankMapping = buildTopRankMapping(criteria.LocalUserId, criteria.Ruleset?.ShortName);
|
||||
var topRankMapping = getLocalUserTopRanks(criteria);
|
||||
return getGroupsBy(b => defineGroupByRankAchieved(b, topRankMapping), items);
|
||||
}
|
||||
|
||||
@@ -440,9 +440,5 @@ namespace osu.Game.Screens.SelectV2
|
||||
}
|
||||
|
||||
private record GroupMapping(GroupDefinition? Group, List<CarouselItem> ItemsInGroup);
|
||||
|
||||
public delegate List<BeatmapCollection> GetDetachedCollectionsDelegate();
|
||||
|
||||
public delegate IReadOnlyDictionary<Guid, ScoreRank> BuildTopRankMappingDelegate(int? localUserId, string? ruleset);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user