Ejemplo n.º 1
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                title          = "Search For Songs";
                showBackButton = true;

                _searchResultsNavigationController   = BeatSaberUI.CreateViewController <SearchResultsNavigationController>();
                _searchResultsListViewController     = BeatSaberUI.CreateViewController <SearchResultsListViewController>();
                _songDetailsViewController           = BeatSaberUI.CreateViewController <SongDetailsViewController>();
                _searchOptionsViewController         = BeatSaberUI.CreateViewController <SearchOptionsViewController>();
                _searchKeyboardViewController        = BeatSaberUI.CreateViewController <SearchKeyboardViewController>();
                _searchCompactKeyboardViewController = BeatSaberUI.CreateViewController <SearchCompactKeyboardViewController>();
                _searchResultsNavigationController.ForceShowButtonPressed += delegate()
                {
                    ShowSearchResult(SearchBehaviour.Instance.CachedResult, true);
                };
                _searchResultsNavigationController.LastSearchButtonPressed += delegate()
                {
                    _searchResultsNavigationController.ShowLastSearchButton(false);

                    if (string.IsNullOrEmpty(_lastSearchQuery))
                    {
                        return;
                    }

                    PopAllViewControllersFromNavigationController();
                    _searchResultsNavigationController.ShowLoadingSpinner();
                    _searchResultsListViewController.UpdateSongs(new IPreviewBeatmapLevel[0]);

                    _searchQuery = _lastSearchQuery;

                    if (PluginConfig.CompactSearchMode)
                    {
                        _searchCompactKeyboardViewController.SetText(_searchQuery);
                    }
                    else
                    {
                        _searchKeyboardViewController.SetText(_searchQuery);
                    }
                    SearchBehaviour.Instance.StartNewSearch(_levelsSearchSpace, _searchQuery, levels => ShowSearchResult(levels, true));
                };
                _searchResultsListViewController.SongSelected += delegate(IPreviewBeatmapLevel level)
                {
                    if (_searchCompactKeyboardViewController.isInViewControllerHierarchy)
                    {
                        PopViewControllerFromNavigationController(_searchResultsNavigationController, null, true);
                    }
                    if (!_songDetailsViewController.isInViewControllerHierarchy)
                    {
                        PushViewControllerToNavigationController(_searchResultsNavigationController, _songDetailsViewController, null, PluginConfig.CompactSearchMode);
                    }
                    _songDetailsViewController.SetContent(level);
                    _searchResultsNavigationController.CrossfadeAudioToLevelAsync(level);
                };
                _songDetailsViewController.SelectButtonPressed += delegate(IPreviewBeatmapLevel level)
                {
                    _lastSearchQuery = _searchQuery;

                    SearchBehaviour.Instance.StopSearch();
                    _searchResultsListViewController.UpdateSongs(new IPreviewBeatmapLevel[0]);
                    PopAllViewControllersFromNavigationController(true);
                    SongSelected?.Invoke(level);
                };
                _songDetailsViewController.CompactKeyboardButtonPressed += delegate()
                {
                    if (!PluginConfig.CompactSearchMode)
                    {
                        return;
                    }

                    PopViewControllerFromNavigationController(_searchResultsNavigationController, null, true);
                    PushViewControllerToNavigationController(_searchResultsNavigationController, _searchCompactKeyboardViewController, null, true);

                    _searchCompactKeyboardViewController.SetText(_searchQuery);
                    _searchResultsListViewController.DeselectSong();
                };

                _searchOptionsViewController.SearchOptionsApplied += OptionsChanged;

                _searchKeyboardViewController.TextKeyPressed      += KeyboardTextKeyPressed;
                _searchKeyboardViewController.DeleteButtonPressed += KeyboardDeleteButtonPressed;
                _searchKeyboardViewController.ClearButtonPressed  += KeyboardClearButtonPressed;
                _searchKeyboardViewController.PredictionPressed   += KeyboardPredictionPressed;

                _searchCompactKeyboardViewController.TextKeyPressed      += KeyboardTextKeyPressed;
                _searchCompactKeyboardViewController.DeleteButtonPressed += KeyboardDeleteButtonPressed;
                _searchCompactKeyboardViewController.ClearButtonPressed  += KeyboardClearButtonPressed;
                _searchCompactKeyboardViewController.PredictionPressed   += KeyboardPredictionPressed;

                ProvideInitialViewControllers(_searchResultsNavigationController, _searchOptionsViewController, PluginConfig.CompactSearchMode ? null : _searchKeyboardViewController);
            }
            else
            {
                _searchQuery          = "";
                _readyForDeactivation = false;
            }
        }
Ejemplo n.º 2
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                title          = "Search For Songs";
                showBackButton = true;

                if (PluginConfig.TwoHandedTyping)
                {
                    CreateLaserPointerManager();
                }

                _searchResultsNavigationController = BeatSaberUI.CreateViewController <SearchResultsNavigationController>();
                _searchResultsListViewController   = BeatSaberUI.CreateViewController <SearchResultsListViewController>();
                _songDetailsViewController         = BeatSaberUI.CreateViewController <SongDetailsViewController>();
                _searchOptionsViewController       = BeatSaberUI.CreateViewController <SearchOptionsViewController>();

                CreateKeyboardManager();

                _searchResultsNavigationController.ForceShowButtonPressed += delegate()
                {
                    ShowSearchResult(SearchBehaviour.Instance.CachedResult, true);
                };
                _searchResultsNavigationController.LastSearchButtonPressed += delegate()
                {
                    _searchResultsNavigationController.ShowLastSearchButton(false);

                    if (string.IsNullOrEmpty(_lastSearchQuery))
                    {
                        return;
                    }

                    PopAllViewControllersFromNavigationController();
                    _searchResultsNavigationController.ShowLoadingSpinner();
                    _searchResultsListViewController.UpdateSongs(new IPreviewBeatmapLevel[0]);

                    _searchQuery = _lastSearchQuery;
                    _keyboardManager.SetText(_searchQuery);

                    SearchBehaviour.Instance.StartNewSearch(_levelsSearchSpace, _searchQuery, levels => ShowSearchResult(levels, true));
                };
                _searchResultsNavigationController.ResetKeyboardPositionButtonPressed += delegate()
                {
                    if (PluginConfig.SearchKeyboard == SearchKeyboardType.Floating && _keyboardManager is FloatingSearchKeyboardManager keyboardManager)
                    {
                        keyboardManager.ResetPosition();
                    }
                };

                _searchResultsListViewController.SongSelected += delegate(IPreviewBeatmapLevel level)
                {
                    if (PluginConfig.SearchKeyboard == SearchKeyboardType.Compact && _keyboardViewController.isInViewControllerHierarchy)
                    {
                        PopViewControllerFromNavigationController(_searchResultsNavigationController, null, true);
                    }
                    if (!_songDetailsViewController.isInViewControllerHierarchy)
                    {
                        PushViewControllerToNavigationController(_searchResultsNavigationController, _songDetailsViewController, null, PluginConfig.SearchKeyboard == SearchKeyboardType.Compact);
                    }
                    _songDetailsViewController.SetContent(level);
                    _searchResultsNavigationController.CrossfadeAudioToLevelAsync(level);
                };
                _songDetailsViewController.SelectButtonPressed += delegate(IPreviewBeatmapLevel level)
                {
                    _lastSearchQuery = _searchQuery;

                    SearchBehaviour.Instance.StopSearch();
                    _searchResultsListViewController.UpdateSongs(new IPreviewBeatmapLevel[0]);
                    PopAllViewControllersFromNavigationController(true);
                    SongSelected?.Invoke(level);
                };
                _songDetailsViewController.CompactKeyboardButtonPressed += delegate()
                {
                    if (PluginConfig.SearchKeyboard != SearchKeyboardType.Compact)
                    {
                        return;
                    }

                    PopViewControllerFromNavigationController(_searchResultsNavigationController, null, true);
                    PushViewControllerToNavigationController(_searchResultsNavigationController, _keyboardViewController, null, true);

                    _keyboardManager.SetText(_searchQuery);
                    _searchResultsListViewController.DeselectSong();
                };

                _searchOptionsViewController.SearchOptionsApplied += OptionsChanged;

                ProvideInitialViewControllers(_searchResultsNavigationController, _searchOptionsViewController, PluginConfig.SearchKeyboard == SearchKeyboardType.RightScreen ? _keyboardViewController : null);
            }
            else
            {
                _searchQuery          = "";
                _readyForDeactivation = false;

                if (_laserPointerInputManager != null)
                {
                    _laserPointerInputManager.gameObject.SetActive(true);
                }

                _keyboardManager.Activate();
            }
        }