Esempio n. 1
0
        public void SearchButtonPressed()
        {
            if (_searchFlowCoordinator == null)
            {
                _searchFlowCoordinator      = BeatSaberUI.CreateFlowCoordinator <SearchFlowCoordinator>();
                _searchFlowCoordinator.name = "EnhancedSearchFlowCoordinator";

                _searchFlowCoordinator.BackButtonPressed         += DismissSearchFlowCoordinator;
                _searchFlowCoordinator.SongSelected              += SelectSongFromSearchResult;
                _searchFlowCoordinator.SearchFilterButtonPressed += ApplySearchFilter;
            }

            IAnnotatedBeatmapLevelCollection levelPack;

            if (SongBrowserTweaks.Initialized)
            {
                if (SongBrowserTweaks.IsFilterApplied())
                {
                    levelPack = LevelSelectionNavigationController.GetPrivateField <IBeatmapLevelPack>("_levelPack", typeof(LevelSelectionNavigationController));
                }
                // technically, the _lastPack doesn't actually contain the pack being shown
                // (since SongBrowser always overrides the selected pack with its own pack to handle sorting/filtering)
                // but any non-filtered level pack is going to contain the same levels anyways
                // and i'll need the true level pack ID for word storage caching
                else
                {
                    levelPack = _lastPack;
                }
            }
            else if (FilterList.AnyApplied)
            {
                levelPack = _filteredLevelPack;
            }
            else
            {
                levelPack = _lastPack;
            }

            _searchFlowCoordinator.Activate(_freePlayFlowCoordinator, levelPack);

            if (!ButtonPanel.IsSingletonAvailable || !ButtonPanel.instance.Initialized)
            {
                Logger.log.Debug("'Search' button pressed.");
            }
        }
Esempio n. 2
0
        public void SetActiveWordStorageFromLevelPack(IAnnotatedBeatmapLevelCollection levelCollection)
        {
            WordCountStorage  storage;
            IBeatmapLevelPack levelPack      = levelCollection as IBeatmapLevelPack;
            string            collectionName = levelCollection.collectionName;
            bool storageWasCached;

            if (levelPack != null)
            {
                storageWasCached = _cache.TryGetValue(levelPack.packID, out storage);
            }
            else
            {
                storageWasCached = _cache.TryGetValue(collectionName.Replace(SortedLevelsLevelPack.PackIDSuffix, ""), out storage);
            }

            if (!storageWasCached)
            {
                storage = new WordCountStorage(levelCollection);

                // never cache filtered/built-in favorites level packs
                // NOTE: ESAF filtered level pack should already be sorted (will never have sorted level pack suffix)
                if (levelPack != null &&
                    levelPack.packID != FilteredLevelsLevelPack.PackID &&
                    !SongBrowserTweaks.IsFilterApplied())
                {
                    _cache[levelPack.packID] = storage;
                }
                else if (collectionName != FilteredLevelsLevelPack.CollectionName &&
                         collectionName != BuiltInFavouritesPackCollectionName &&
                         collectionName != BuiltInFavouritesPackCollectionName + SortedLevelsLevelPack.PackIDSuffix &&
                         collectionName != SortedLevelsLevelPack.PackIDSuffix)
                {
                    _cache[collectionName.Replace(SortedLevelsLevelPack.PackIDSuffix, "")] = storage;
                }
            }

            _activeWordStorage = storage;
        }