mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Simplify group filter display
This commit is contained in:
parent
524547adbf
commit
a19a9b90ed
@ -19,46 +19,19 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
/// </remarks>
|
||||
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)
|
||||
: base(null, ruleset, false)
|
||||
: base(beatmaps.OrderBy(b => b.StarDifficulty).Last(), ruleset, false)
|
||||
{
|
||||
this.beatmaps = beatmaps;
|
||||
|
||||
AddInternal(counter = new OsuSpriteText
|
||||
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 = beatmaps.Count.ToString(),
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,11 +231,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
items.ForEach(item => item.Filtered.ValueChanged += _ =>
|
||||
{
|
||||
var hiddenItems = items.FindAll(i => !i.Filtered.Value);
|
||||
var hasHidden = hiddenItems.Count > 0;
|
||||
|
||||
this.FadeTo(hasHidden ? 1 : 0.1f, 100);
|
||||
Beatmaps = (hasHidden ? hiddenItems : items).Select(i => i.Beatmap).ToList();
|
||||
// for now, fade the whole group based on the ratio of hidden items.
|
||||
this.FadeTo(1 - 0.9f * ((float)items.Count(i => i.Filtered.Value) / items.Count), 100);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user