diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index c94f4fdc57..d8ba1e9195 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -61,7 +62,7 @@ namespace osu.Game.Beatmaps.Drawables return base.OnClick(state); } - public bool Filtered { get; set; } + public BindableBool Filtered = new BindableBool(); protected override void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden) { diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 85daefea57..9bb7b5c737 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -7,6 +7,7 @@ using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -157,8 +158,7 @@ namespace osu.Game.Beatmaps.Drawables if (panels == null) throw new ArgumentNullException(nameof(panels)); - foreach (var p in panels) - difficultyIcons.Add(new DifficultyIcon(p.Beatmap)); + difficultyIcons.AddRange(panels.Select(p => new FilterableDifficultyIcon(p))); } public MenuItem[] ContextMenuItems @@ -178,5 +178,18 @@ namespace osu.Game.Beatmaps.Drawables return items.ToArray(); } } + + public class FilterableDifficultyIcon : DifficultyIcon + { + private readonly BindableBool filtered = new BindableBool(); + + public FilterableDifficultyIcon(BeatmapPanel panel) + : base(panel.Beatmap) + { + filtered.BindTo(panel.Filtered); + filtered.ValueChanged += v => this.FadeTo(v ? 0.1f : 1, 100); + filtered.TriggerChange(); + } + } } } diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index 96778291a1..f410c69212 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -37,7 +37,7 @@ namespace osu.Game.Screens.Select match &= set.Metadata.SearchableTerms.Any(term => term.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0); foreach (var panel in g.BeatmapPanels) - panel.Filtered = !canConvert(panel.Beatmap); + panel.Filtered.Value = !canConvert(panel.Beatmap); switch (g.State) {