Tidy up all remaining usages

This commit is contained in:
Dean Herbert
2022-06-23 18:53:21 +09:00
parent 7dec530ca5
commit 01da6f20b3
9 changed files with 46 additions and 86 deletions

View File

@ -113,8 +113,9 @@ namespace osu.Game.Screens.Select.Carousel
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new CalculatingDifficultyIcon(beatmapInfo, shouldShowTooltip: false)
new CalculatingDifficultyIcon(beatmapInfo)
{
ShowTooltip = false,
Scale = new Vector2(1.8f),
},
new FillFlowContainer

View File

@ -10,7 +10,7 @@ using osu.Game.Beatmaps.Drawables;
namespace osu.Game.Screens.Select.Carousel
{
public class FilterableDifficultyIcon : CalculatingDifficultyIcon
public class FilterableDifficultyIcon : DifficultyIcon
{
private readonly BindableBool filtered = new BindableBool();

View File

@ -8,23 +8,42 @@ using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets;
using osuTK.Graphics;
namespace osu.Game.Screens.Select.Carousel
{
public class FilterableGroupedDifficultyIcon : GroupedDifficultyIcon
/// <summary>
/// A difficulty icon that contains a counter on the right-side of it.
/// </summary>
/// <remarks>
/// Used in cases when there are too many difficulty icons to show.
/// </remarks>
public class GroupedDifficultyIcon : DifficultyIcon
{
public readonly List<CarouselBeatmap> Items;
public FilterableGroupedDifficultyIcon(List<CarouselBeatmap> items, RulesetInfo ruleset)
: base(items.Select(i => i.BeatmapInfo).ToList(), ruleset, Color4.White)
public GroupedDifficultyIcon(List<CarouselBeatmap> items, RulesetInfo ruleset)
: base(items.OrderBy(b => b.BeatmapInfo.StarRating).Last().BeatmapInfo, ruleset)
{
Items = items;
foreach (var item in items)
item.Filtered.BindValueChanged(_ => Scheduler.AddOnce(updateFilteredDisplay));
AddInternal(new OsuSpriteText
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Padding = new MarginPadding { Left = Size.X },
Margin = new MarginPadding { Left = 2, Right = 5 },
Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold),
Text = items.Count.ToString(),
Colour = Color4.White,
});
updateFilteredDisplay();
}

View File

@ -73,7 +73,7 @@ namespace osu.Game.Screens.Select.Carousel
TextPadding = new MarginPadding { Horizontal = 8, Vertical = 2 },
Status = beatmapSet.Status
},
new FillFlowContainer<CalculatingDifficultyIcon>
new FillFlowContainer<DifficultyIcon>
{
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(3),
@ -87,13 +87,13 @@ namespace osu.Game.Screens.Select.Carousel
private const int maximum_difficulty_icons = 18;
private IEnumerable<CalculatingDifficultyIcon> getDifficultyIcons()
private IEnumerable<DifficultyIcon> getDifficultyIcons()
{
var beatmaps = carouselSet.Beatmaps.ToList();
return beatmaps.Count > maximum_difficulty_icons
? (IEnumerable<CalculatingDifficultyIcon>)beatmaps.GroupBy(b => b.BeatmapInfo.Ruleset)
.Select(group => new FilterableGroupedDifficultyIcon(group.ToList(), group.Last().BeatmapInfo.Ruleset))
? (IEnumerable<DifficultyIcon>)beatmaps.GroupBy(b => b.BeatmapInfo.Ruleset)
.Select(group => new GroupedDifficultyIcon(group.ToList(), group.Last().BeatmapInfo.Ruleset))
: beatmaps.Select(b => new FilterableDifficultyIcon(b));
}
}