Allow grouped difficulty icons to be clicked

This commit is contained in:
Dean Herbert
2020-03-12 16:30:21 +09:00
parent db5c8043db
commit 6e11c3014c
2 changed files with 54 additions and 6 deletions

View File

@ -228,12 +228,12 @@ namespace osu.Game.Screens.Select.Carousel
public class FilterableGroupedDifficultyIcon : GroupedDifficultyIcon
{
private readonly List<CarouselBeatmap> items;
public readonly List<CarouselBeatmap> Items;
public FilterableGroupedDifficultyIcon(List<CarouselBeatmap> items, RulesetInfo ruleset)
: base(items.Select(i => i.Beatmap).ToList(), ruleset, Color4.White)
{
this.items = items;
Items = items;
foreach (var item in items)
item.Filtered.BindValueChanged(_ => Scheduler.AddOnce(updateFilteredDisplay));
@ -241,10 +241,16 @@ namespace osu.Game.Screens.Select.Carousel
updateFilteredDisplay();
}
protected override bool OnClick(ClickEvent e)
{
Items.First().State.Value = CarouselItemState.Selected;
return true;
}
private void updateFilteredDisplay()
{
// 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);
this.FadeTo(1 - 0.9f * ((float)Items.Count(i => i.Filtered.Value) / Items.Count), 100);
}
}
}