Simplify group filter display

This commit is contained in:
Dean Herbert 2019-08-25 11:38:26 +09:00
parent 524547adbf
commit a19a9b90ed
2 changed files with 5 additions and 35 deletions

View File

@ -19,46 +19,19 @@ namespace osu.Game.Beatmaps.Drawables
/// </remarks> /// </remarks>
public class GroupedDifficultyIcon : DifficultyIcon public class GroupedDifficultyIcon : DifficultyIcon
{ {
private readonly OsuSpriteText counter;
private List<BeatmapInfo> beatmaps;
protected List<BeatmapInfo> Beatmaps
{
get => beatmaps;
set
{
beatmaps = value;
updateDisplay();
}
}
public GroupedDifficultyIcon(List<BeatmapInfo> beatmaps, RulesetInfo ruleset, Color4 counterColour) public GroupedDifficultyIcon(List<BeatmapInfo> beatmaps, RulesetInfo ruleset, Color4 counterColour)
: base(null, ruleset, false) : base(beatmaps.OrderBy(b => b.StarDifficulty).Last(), ruleset, false)
{ {
this.beatmaps = beatmaps; AddInternal(new OsuSpriteText
AddInternal(counter = new OsuSpriteText
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Padding = new MarginPadding { Left = Size.X }, Padding = new MarginPadding { Left = Size.X },
Margin = new MarginPadding { Left = 2, Right = 5 }, Margin = new MarginPadding { Left = 2, Right = 5 },
Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold), Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold),
Text = beatmaps.Count.ToString(),
Colour = counterColour, Colour = counterColour,
}); });
updateDisplay();
}
private void updateDisplay()
{
if (beatmaps == null || beatmaps.Count == 0)
return;
Beatmap = beatmaps.OrderBy(b => b.StarDifficulty).Last();
counter.Text = beatmaps.Count.ToString();
} }
} }
} }

View File

@ -231,11 +231,8 @@ namespace osu.Game.Screens.Select.Carousel
{ {
items.ForEach(item => item.Filtered.ValueChanged += _ => items.ForEach(item => item.Filtered.ValueChanged += _ =>
{ {
var hiddenItems = items.FindAll(i => !i.Filtered.Value); // for now, fade the whole group based on the ratio of hidden items.
var hasHidden = hiddenItems.Count > 0; this.FadeTo(1 - 0.9f * ((float)items.Count(i => i.Filtered.Value) / items.Count), 100);
this.FadeTo(hasHidden ? 1 : 0.1f, 100);
Beatmaps = (hasHidden ? hiddenItems : items).Select(i => i.Beatmap).ToList();
}); });
} }
} }