2019-01-24 16:43:03 +08:00
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Screens.Select.Filter;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select.Carousel
|
|
|
|
{
|
|
|
|
public class CarouselBeatmapSet : CarouselGroupEagerSelect
|
|
|
|
{
|
|
|
|
public IEnumerable<CarouselBeatmap> Beatmaps => InternalChildren.OfType<CarouselBeatmap>();
|
|
|
|
|
|
|
|
public BeatmapSetInfo BeatmapSet;
|
|
|
|
|
|
|
|
public CarouselBeatmapSet(BeatmapSetInfo beatmapSet)
|
|
|
|
{
|
|
|
|
BeatmapSet = beatmapSet ?? throw new ArgumentNullException(nameof(beatmapSet));
|
|
|
|
|
|
|
|
beatmapSet.Beatmaps
|
|
|
|
.Where(b => !b.Hidden)
|
|
|
|
.Select(b => new CarouselBeatmap(b))
|
|
|
|
.ForEach(AddChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmapSet(this);
|
|
|
|
|
|
|
|
public override int CompareTo(FilterCriteria criteria, CarouselItem other)
|
|
|
|
{
|
|
|
|
if (!(other is CarouselBeatmapSet otherSet))
|
|
|
|
return base.CompareTo(criteria, other);
|
|
|
|
|
|
|
|
switch (criteria.Sort)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SortMode.Artist:
|
|
|
|
return string.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase);
|
2019-04-01 11:44:46 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
case SortMode.Title:
|
|
|
|
return string.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase);
|
2019-04-01 11:44:46 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
case SortMode.Author:
|
|
|
|
return string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase);
|
2019-04-01 11:44:46 +08:00
|
|
|
|
2019-06-05 17:17:43 +08:00
|
|
|
case SortMode.DateAdded:
|
|
|
|
return otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded);
|
|
|
|
|
2019-07-07 23:14:23 +08:00
|
|
|
case SortMode.BPM:
|
2019-07-08 14:10:41 +08:00
|
|
|
return BeatmapSet.OnlineInfo.BPM.CompareTo(otherSet.BeatmapSet.OnlineInfo.BPM);
|
2019-07-07 23:14:23 +08:00
|
|
|
|
2019-07-07 23:26:56 +08:00
|
|
|
case SortMode.Length:
|
|
|
|
return BeatmapSet.MaxLength.CompareTo(otherSet.BeatmapSet.MaxLength);
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
case SortMode.Difficulty:
|
|
|
|
return BeatmapSet.MaxStarDifficulty.CompareTo(otherSet.BeatmapSet.MaxStarDifficulty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Filter(FilterCriteria criteria)
|
|
|
|
{
|
|
|
|
base.Filter(criteria);
|
2019-02-21 17:56:34 +08:00
|
|
|
Filtered.Value = InternalChildren.All(i => i.Filtered.Value);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString() => BeatmapSet.ToString();
|
|
|
|
}
|
|
|
|
}
|