Example #1
0
        public void SetSongs(IBeatmapLevelPack selectedPack, SortMode sortMode, string searchRequest)
        {
            _lastSortMode      = sortMode;
            _lastSearchRequest = searchRequest;
            _lastSelectedPack  = selectedPack;

            List <BeatmapLevelSO> levels = new List <BeatmapLevelSO>();

            if (_lastSelectedPack != null)
            {
                levels = _lastSelectedPack.beatmapLevelCollection.beatmapLevels.Where(x => x is BeatmapLevelSO).Cast <BeatmapLevelSO>().ToList();

                if (string.IsNullOrEmpty(searchRequest))
                {
                    switch (sortMode)
                    {
                    case SortMode.Newest: { levels = SortLevelsByCreationTime(levels); }; break;

                    case SortMode.Difficulty:
                    {
                        levels = levels.AsParallel().OrderBy(x => { int index = ScrappedData.Songs.FindIndex(y => x.levelID.StartsWith(y.Hash)); return(index == -1 ? (x.levelID.Length < 32 ? int.MaxValue : int.MaxValue - 1) : index); }).ToList();
                    }; break;
                    }
                }
                else
                {
                    levels = levels.Where(x => ($"{x.songName} {x.songSubName} {x.levelAuthorName} {x.songAuthorName}".ToLower().Contains(searchRequest))).ToList();
                }
            }

            _songSelectionViewController.SetSongs(levels);
        }
        public void SetSongs(SortMode sortMode, string searchRequest)
        {
            _lastSortMode      = sortMode;
            _lastSearchRequest = searchRequest;

            List <BeatmapLevelSO> levels = new List <BeatmapLevelSO>();

            levels = SongLoader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.Where(x => x.packID == "CustomMaps" || CustomExtensions.basePackIDs.Contains(x.packID)).SelectMany(x => x.beatmapLevelCollection.beatmapLevels).Cast <BeatmapLevelSO>().ToList();

            if (string.IsNullOrEmpty(searchRequest))
            {
                switch (sortMode)
                {
                case SortMode.Newest: { levels = SortLevelsByCreationTime(levels); }; break;

                case SortMode.Difficulty:
                {
                    levels = levels.AsParallel().OrderBy(x => { int index = ScrappedData.Songs.FindIndex(y => x.levelID.StartsWith(y.Hash)); return(index == -1 ? (x.levelID.Length < 32 ? int.MaxValue : int.MaxValue - 1) : index); }).ToList();
                }; break;
                }
            }
            else
            {
                levels = levels.Where(x => ($"{x.songName} {x.songSubName} {x.levelAuthorName} {x.songAuthorName}".ToLower().Contains(searchRequest))).ToList();
            }

            _songSelectionViewController.SetSongs(levels);
        }
        public void SetSongs(BeatmapCharacteristicSO characteristic, SortMode sortMode, string searchRequest)
        {
            _lastCharacteristic = characteristic;
            _lastSortMode       = sortMode;
            _lastSearchRequest  = searchRequest;

            LevelSO[] levels = null;

            levels = _levelCollection.GetLevelsWithBeatmapCharacteristic(characteristic);

            if (string.IsNullOrEmpty(searchRequest))
            {
                switch (sortMode)
                {
                case SortMode.Newest: { levels = SortLevelsByCreationTime(levels); }; break;

                case SortMode.Difficulty:
                {
                    levels = levels.AsParallel().OrderBy(x => { int index = ScrappedData.Songs.FindIndex(y => x.levelID.StartsWith(y.Hash)); return(index == -1 ? (x.levelID.Length < 32 ? int.MaxValue : int.MaxValue - 1) : index); }).ToArray();
                }; break;
                }
            }
            else
            {
                levels = levels.Where(x => ($"{x.songName} {x.songSubName} {x.levelAuthorName} {x.songAuthorName}".ToLower().Contains(searchRequest))).ToArray();
            }

            _songSelectionViewController.SetSongs(levels.ToList());
        }
Example #4
0
        public void SetSongs(IBeatmapLevelPack selectedPack, SortMode sortMode, string searchRequest)
        {
            _lastSortMode      = sortMode;
            _lastSearchRequest = searchRequest;
            _lastSelectedPack  = selectedPack;

            List <IPreviewBeatmapLevel> levels = new List <IPreviewBeatmapLevel>();

            if (_lastSelectedPack != null)
            {
                levels = _lastSelectedPack.beatmapLevelCollection.beatmapLevels.ToList();

                if (string.IsNullOrEmpty(searchRequest))
                {
                    switch (sortMode)
                    {
                    case SortMode.Newest: { levels = SortLevelsByCreationTime(levels); }; break;

                    case SortMode.Difficulty:
                    {
                        levels = levels.AsParallel().OrderByDescending(x =>
                            {
                                var diffs = ScrappedData.Songs.FirstOrDefault(y => x.levelID.Contains(y.Hash)).Diffs;
                                if (diffs != null && diffs.Count > 0)
                                {
                                    return(diffs.Max(y => y.Stars));
                                }
                                else
                                {
                                    return(-1);
                                }
                            }).ToList();
                    }; break;
                    }
                }
                else
                {
                    levels = levels.Where(x => ($"{x.songName} {x.songSubName} {x.levelAuthorName} {x.songAuthorName}".ToLower().Contains(searchRequest))).ToList();
                }
            }

            _songSelectionViewController.SetSongs(levels);
        }