Exemplo n.º 1
0
 private void filterChanged()
 {
     filterTask?.Cancel();
     filterTask = Scheduler.AddDelayed(() =>
     {
         filterTask = null;
         var search = filter.Search;
         BeatmapGroup newSelection = null;
         foreach (var beatmapGroup in carousel)
         {
             var set    = beatmapGroup.BeatmapSet;
             bool match = string.IsNullOrEmpty(search) ||
                          (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                          (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                          (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                          (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;
             if (match)
             {
                 beatmapGroup.State = BeatmapGroupState.Collapsed;
                 if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
                 {
                     newSelection = beatmapGroup;
                 }
             }
             else
             {
                 beatmapGroup.State = BeatmapGroupState.Hidden;
             }
         }
         if (newSelection != null)
         {
             carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false);
         }
     }, 250);
 }
Exemplo n.º 2
0
        private void filterChanged(bool debounce = true, bool eagerSelection = true)
        {
            filterTask?.Cancel();
            filterTask = Scheduler.AddDelayed(() =>
            {
                filterTask = null;
                var search = filter.Search;
                BeatmapGroup newSelection = null;
                carousel.Sort(filter.Sort);
                foreach (var beatmapGroup in carousel)
                {
                    var set = beatmapGroup.BeatmapSet;

                    bool hasCurrentMode = set.Beatmaps.Any(bm => bm.Mode == playMode);

                    bool match = hasCurrentMode;

                    match &= string.IsNullOrEmpty(search) ||
                             (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                             (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                             (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                             (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;

                    if (match)
                    {
                        if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
                        {
                            if (newSelection != null)
                            {
                                newSelection.State = BeatmapGroupState.Collapsed;
                            }
                            newSelection = beatmapGroup;
                        }
                        else
                        {
                            beatmapGroup.State = BeatmapGroupState.Collapsed;
                        }
                    }
                    else
                    {
                        beatmapGroup.State = BeatmapGroupState.Hidden;
                    }
                }

                if (newSelection != null)
                {
                    if (newSelection.BeatmapPanels.Any(b => b.Beatmap.ID == Beatmap.BeatmapInfo.ID))
                    {
                        carousel.SelectBeatmap(Beatmap.BeatmapInfo, false);
                    }
                    else if (eagerSelection)
                    {
                        carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false);
                    }
                }
            }, debounce ? 250 : 0);
        }
Exemplo n.º 3
0
 private void selectBeatmap(BeatmapInfo beatmap)
 {
     carousel.SelectBeatmap(beatmap);
 }