コード例 #1
0
        public void ShowSongsList(string lastLevelId = "")
        {
            if (_songSelectionViewController == null)
            {
                _songSelectionViewController = BeatSaberUI.CreateViewController <SongSelectionViewController>();
                _songSelectionViewController.SongSelected  += SongSelected;
                _songSelectionViewController.SortPressed   += (sortMode) => { SetSongs(_lastSelectedPack, sortMode, _lastSearchRequest); };
                _songSelectionViewController.SearchPressed += () => { _searchKeyboard.inputString = ""; PresentViewController(_searchKeyboard, null); };
            }

            if (_packsViewController == null)
            {
                _packsViewController      = Instantiate(Resources.FindObjectsOfTypeAll <LevelPacksViewController>().First(x => x.name != "CustomLevelPacksViewController"));
                _packsViewController.name = "CustomLevelPacksViewController";

                TableView table = _packsViewController.GetComponentInChildren <TableView>();
                table.Init();
                _packsViewController.GetComponentInChildren <TableViewScroller>().Init(table);


                if (_lastSelectedPack == null)
                {
                    _lastSelectedPack = SongCore.Loader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks[0];
                }

                _packsViewController.didSelectPackEvent += (sender, selectedPack) => { SetSongs(selectedPack, _lastSortMode, _lastSearchRequest); };
            }

            _packsViewController.SetData(SongCore.Loader.CustomBeatmapLevelPackCollectionSO, SongCore.Loader.CustomBeatmapLevelPackCollectionSO.beatmapLevelPacks.FindIndexInArray(_lastSelectedPack));

            if (_roomNavigationController.viewControllers.IndexOf(_songSelectionViewController) < 0)
            {
                PushViewControllerToNavigationController(_roomNavigationController, _songSelectionViewController, null, true);
                SetSongs(_lastSelectedPack, _lastSortMode, _lastSearchRequest);

                if (!string.IsNullOrEmpty(lastLevelId))
                {
                    _songSelectionViewController.ScrollToLevel(lastLevelId);
                }
            }

            if (Client.Instance.isHost)
            {
                _packsViewController.gameObject.SetActive(true);
                SetBottomScreenViewController(_packsViewController);
            }
            else
            {
                _packsViewController.gameObject.SetActive(false);
                SetBottomScreenViewController(null);
            }

            _songSelectionViewController.UpdateViewController(Client.Instance.isHost);
        }
コード例 #2
0
        public void ShowSongsList(string lastLevelId = "")
        {
            if (_songSelectionViewController == null)
            {
                _songSelectionViewController = BeatSaberUI.CreateViewController <SongSelectionViewController>();
                _songSelectionViewController.SongSelected  += SongSelected;
                _songSelectionViewController.SortPressed   += (sortMode) => { SetSongs(sortMode, _lastSearchRequest); };
                _songSelectionViewController.SearchPressed += () => { _searchKeyboard.inputString = ""; PresentViewController(_searchKeyboard, null); };
            }
            if (_roomNavigationController.viewControllers.IndexOf(_songSelectionViewController) < 0)
            {
                PushViewControllerToNavigationController(_roomNavigationController, _songSelectionViewController, null, true);
                SetSongs(_lastSortMode, _lastSearchRequest);

                if (!string.IsNullOrEmpty(lastLevelId))
                {
                    _songSelectionViewController.ScrollToLevel(lastLevelId);
                }
            }

            _songSelectionViewController.UpdateViewController(Client.Instance.isHost);
        }