Exemplo n.º 1
0
        public override void __Activate(ActivationType activationType)
        {
            base.__Activate(activationType);
            //
            if (!initialized && activationType == ActivationType.AddedToHierarchy)
            {
                (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0, 26);
                _pageUpButton.onClick.AddListener(delegate()
                {
                    pageUpPressed?.Invoke();
                });
                _pageDownButton.onClick.AddListener(delegate()
                {
                    pageDownPressed?.Invoke();
                });

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                _loadingIndicator.SetActive(true);

                CreateButtons();
                initialized = true;
                _customListTableView.didSelectCellWithIdxEvent += DidSelectRowEvent;
            }
            else
            {
                _customListTableView.ReloadData();
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                title = "More Playlists";

                _playlistsNavigationController = BeatSaberUI.CreateViewController <BackButtonNavigationController>();
                _playlistsNavigationController.didFinishEvent += _morePlaylistsNavigationController_didFinishEvent;

                _playlistsListViewController = BeatSaberUI.CreateViewController <PlaylistListViewController>();
                _playlistsListViewController.didSelectRow += _morePlaylistsListViewController_didSelectRow;
                _playlistsListViewController.highlightDownloadedPlaylists = true;

                GameObject _songDetailGameObject = Instantiate(Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First(), _playlistsNavigationController.rectTransform, false).gameObject;
                Destroy(_songDetailGameObject.GetComponent <StandardLevelDetailViewController>());
                _playlistDetailViewController = _songDetailGameObject.AddComponent <PlaylistDetailViewController>();
                _playlistDetailViewController.selectButtonPressed += _playlistDetailViewController_selectButtonPressed;
                _playlistDetailViewController.SetSelectButtonText("Add");
                _playlistDetailViewController.addDownloadButton = false;

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(_playlistsNavigationController.transform);
            }

            SetViewControllersToNavigationConctroller(_playlistsNavigationController, new VRUIViewController[]
            {
                _playlistsListViewController
            });
            ProvideInitialViewControllers(_playlistsNavigationController, null, null);


            StartCoroutine(GetPlaylists());
        }
Exemplo n.º 3
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                if (activationType == ActivationType.AddedToHierarchy)
                {
                    _backButton = BeatSaberUI.CreateBackButton(rectTransform);
                    _backButton.onClick.AddListener(delegate() { didFinishEvent?.Invoke(); });

                    _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                }
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                BeatSaberUI.CreateBackButton(this.rectTransform, () => BackButtonPressed?.Invoke());
                _loadingSpinner = BeatSaberUI.CreateLoadingSpinner(this.rectTransform);

                var headerRectTransform = Instantiate(Resources.FindObjectsOfTypeAll <RectTransform>()
                                                      .First(x => x.name == "HeaderPanel" && x.parent.name == "PlayerSettingsViewController"), this.rectTransform);
                _header = headerRectTransform.gameObject;

                _resultsText                    = BeatSaberUI.CreateText(this.rectTransform, _placeholderResultsText, Vector2.zero, Vector2.zero);
                _resultsText.alignment          = TextAlignmentOptions.Center;
                _resultsText.enableWordWrapping = true;
                _forceButton                    = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", new Vector2(59f, -32f), new Vector2(36f, 10f), () => ForceShowButtonPressed?.Invoke(), "Force Show Results");

                _lastSearchButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", new Vector2(59f, -32f), new Vector2(36f, 10f), () => LastSearchButtonPressed?.Invoke(), "<color=#FFFFCC>Redo Last Search</color>");
                (_lastSearchButton as HMUI.NoTransitionsButton).selectionStateDidChangeEvent += delegate(HMUI.NoTransitionsButton.SelectionState selectionState)
                {
                    var text = _lastSearchButton.GetComponentInChildren <TextMeshProUGUI>();
                    if (selectionState == HMUI.NoTransitionsButton.SelectionState.Highlighted)
                    {
                        text.text = "<color=#444400>Redo Last Search</color>";
                    }
                    else
                    {
                        text.text = "<color=#FFFFCC>Redo Last Search</color>";
                    }
                };
                _lastSearchText           = BeatSaberUI.CreateText(this.rectTransform, "", new Vector2(23f, -31.5f), new Vector2(30f, 8f));
                _lastSearchText.fontSize  = 3.5f;
                _lastSearchText.color     = new Color(1f, 1f, 1f, 0.3f);
                _lastSearchText.alignment = TextAlignmentOptions.TopRight;

                _songPreviewPlayer = Instantiate(Resources.FindObjectsOfTypeAll <SongPreviewPlayer>().First());
            }
            else
            {
                _resultsText.text     = _placeholderResultsText;
                _resultsText.fontSize = 6f;
            }

            AdjustElements();

            _loadingSpinner.SetActive(false);
            _resultsText.gameObject.SetActive(!PluginConfig.CompactSearchMode);
            _forceButton.gameObject.SetActive(false);
            _lastSearchButton.gameObject.SetActive(false);
            _lastSearchText.gameObject.SetActive(false);
            SetHeaderActive(!PluginConfig.CompactSearchMode);
        }
Exemplo n.º 5
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                _prevChannelButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(-55f, 34f), () => { prevPressedEvent?.Invoke(); }, "<<");
                _nextChannelButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(65f, 34f), () => { nextPressedEvent?.Invoke(); }, ">>");

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(4.5f, 4.5f);

                _container = new GameObject("Container", typeof(RectTransform));
                _container.transform.SetParent(rectTransform, false);

                _joinButton = BeatSaberUI.CreateUIButton(rectTransform, "QuitButton", new Vector2(4.5f, -30f), () => { joinPressedEvent?.Invoke(currentChannel); }, "Join");
                _joinButton.ToggleWordWrapping(false);
                _joinButton.transform.SetParent(_container.transform, true);

                _channelCover = new GameObject("CustomUIImage").AddComponent <Image>();

                _channelCover.material = Sprites.NoGlowMat;
                _channelCover.rectTransform.SetParent(rectTransform, false);
                _channelCover.rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
                _channelCover.rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
                _channelCover.rectTransform.anchoredPosition = new Vector2(4.5f, 4.5f);
                _channelCover.rectTransform.sizeDelta        = new Vector2(32f, 32f);
                _channelCover.sprite = UIUtilities.BlankSprite;
                _channelCover.rectTransform.SetParent(_container.transform, true);

                _channelNameText              = BeatSaberUI.CreateText(rectTransform, "CHANNEL NAME", new Vector2(4.5f, 35.50f));
                _channelNameText.alignment    = TextAlignmentOptions.Top;
                _channelNameText.overflowMode = TextOverflowModes.Overflow;
                _channelNameText.lineSpacing  = -46f;
                _channelNameText.fontSize     = 10;
                _channelNameText.transform.SetParent(_container.transform, true);

                _playerCountText           = BeatSaberUI.CreateText(rectTransform, "Players: 0", new Vector2(4.5f, -15f));
                _playerCountText.alignment = TextAlignmentOptions.Center;
                _playerCountText.transform.SetParent(_container.transform, true);

                _nowPlayingText           = BeatSaberUI.CreateText(rectTransform, "Now playing: UNKNOWN", new Vector2(4.5f, -21f));
                _nowPlayingText.alignment = TextAlignmentOptions.Center;
                _nowPlayingText.transform.SetParent(_container.transform, true);
            }
            _container.SetActive(false);
        }
Exemplo n.º 6
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                if (activationType == ActivationType.AddedToHierarchy)
                {
                    _backButton = BeatSaberUI.CreateBackButton(rectTransform);
                    _backButton.onClick.AddListener(delegate() { if (!_isInTransition && !_parentViewController.GetPrivateField <bool>("_isInTransition"))
                                                                 {
                                                                     didFinishEvent?.Invoke();
                                                                 }
                                                    });

                    _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                    _loadingIndicator.SetActive(false);
                }
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            base.DidActivate(firstActivation, type);

            if (firstActivation && type == ActivationType.AddedToHierarchy)
            {
                _backButton = BeatSaberUI.CreateBackButton(rectTransform as RectTransform, delegate() { backButtonPressed?.Invoke(); });

                RectTransform container = new GameObject("VideoListContainer", typeof(RectTransform)).transform as RectTransform;
                container.SetParent(rectTransform, false);
                container.sizeDelta = new Vector2(105f, 0f);

                _searchButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -20), new Vector2(30, 8), () =>
                {
                    searchButtonPressed?.Invoke();
                }, "Refine");

                _downloadButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -30), new Vector2(30, 8), () =>
                {
                    downloadButtonPressed?.Invoke(resultsList[_lastSelectedRow]);
                }, "Download");
//                _downloadButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0);

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                _loadingIndicator.SetActive(true);

                _customListTableView.didSelectCellWithIdxEvent -= DidSelectRowEvent;
                _customListTableView.didSelectCellWithIdxEvent += _songsTableView_DidSelectRowEvent;

                (_customListTableView.transform.parent as RectTransform).sizeDelta = new Vector2(105, 0);
                (_customListTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0.5f);
                (_customListTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 0.5f);
                (_customListTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_customListTableView.transform as RectTransform).anchoredPosition = new Vector3(-10f, 0f);
            }
            else
            {
                _customListTableView.ReloadData();
            }
            _downloadButton.interactable = false;
        }
Exemplo n.º 8
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                title = "More Playlists";

                _playlistsListViewController = BeatSaberUI.CreateViewController <PlaylistListViewController>();
                _playlistsListViewController.didSelectRow += _morePlaylistsListViewController_didSelectRow;
                _playlistsListViewController.highlightDownloadedPlaylists = true;

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(_playlistsNavigationController.transform);
            }

            SetViewControllersToNavigationConctroller(_playlistsNavigationController, new VRUIViewController[]
            {
                _playlistsListViewController
            });
            ProvideInitialViewControllers(_playlistsNavigationController, null, null);


            StartCoroutine(GetPlaylists());
        }
Exemplo n.º 9
0
        public override void __Activate(ActivationType activationType)
        {
            base.__Activate(activationType);

            if (activationType == ActivationType.AddedToHierarchy)
            {
                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                _loadingIndicator.SetActive(true);

                RectTransform viewControllersContainer = FindObjectsOfType <RectTransform>().First(x => x.name == "ViewControllers");
                var           headerPanelRectTransform = Instantiate(viewControllersContainer.GetComponentsInChildren <RectTransform>(true).First(x => x.name == "HeaderPanel" && x.parent.name == "PlayerSettingsViewController"), rectTransform);
                headerPanelRectTransform.name = "BeatBoards: Header";
                headerPanelRectTransform.gameObject.SetActive(true);
                _titleText      = headerPanelRectTransform.GetComponentInChildren <TextMeshProUGUI>();
                _titleText.text = "";

                GET.Instance.GetUserFromPlatformID(this);
                CreateText();
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            if (firstActivation && type == ActivationType.AddedToHierarchy)
            {
                rectTransform.anchorMin = new Vector2(0.5f, 0f);
                rectTransform.anchorMax = new Vector2(0.5f, 1f);
                rectTransform.sizeDelta = new Vector2(74f, 0f);
                rectTransform.pivot     = new Vector2(0.4f, 0.5f);

                _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), rectTransform, false);
                (_pageUpButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -14f);
                (_pageUpButton.transform as RectTransform).sizeDelta        = new Vector2(40f, 10f);
                _pageUpButton.interactable = true;
                _pageUpButton.onClick.AddListener(delegate()
                {
                    pageUpPressed?.Invoke();
                });
                _pageUpButton.interactable = false;

                _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), rectTransform, false);
                (_pageDownButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 8f);
                (_pageDownButton.transform as RectTransform).sizeDelta        = new Vector2(40f, 10f);
                _pageDownButton.interactable = true;
                _pageDownButton.onClick.AddListener(delegate()
                {
                    pageDownPressed?.Invoke();
                });

                _sortByButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(15f, 36.25f), new Vector2(30f, 6f), () => { SelectTopButtons(TopButtonsState.SortBy); }, "Sort by");
                _sortByButton.SetButtonTextSize(3f);

                _topButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(-20f, 36.25f), new Vector2(20f, 6f), () =>
                {
                    sortByTop?.Invoke();
                    SelectTopButtons(TopButtonsState.Select);
                },
                                                        "Downloads");

                _topButton.SetButtonTextSize(3f);
                _topButton.ToggleWordWrapping(false);
                _topButton.gameObject.SetActive(false);

                _newButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(0f, 36.25f), new Vector2(20f, 6f), () =>
                {
                    sortByNew?.Invoke();
                    SelectTopButtons(TopButtonsState.Select);
                }, "Newest");

                _newButton.SetButtonTextSize(3f);
                _newButton.ToggleWordWrapping(false);
                _newButton.gameObject.SetActive(false);


                _starButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(20f, 36.25f), new Vector2(20f, 6f), () =>
                {
                    sortByPlays?.Invoke();
                    SelectTopButtons(TopButtonsState.Select);
                }, "Plays");

                _starButton.SetButtonTextSize(3f);
                _starButton.ToggleWordWrapping(false);
                _starButton.gameObject.SetActive(false);

                _searchButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(-15, 36.25f), new Vector2(30f, 6f), () =>
                {
                    searchButtonPressed?.Invoke();
                    SelectTopButtons(TopButtonsState.Search);
                }, "Search");
                _searchButton.SetButtonTextSize(3f);

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                _loadingIndicator.SetActive(true);

                _songListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell"));

                RectTransform container = new GameObject("CustomListContainer", typeof(RectTransform)).transform as RectTransform;
                container.SetParent(rectTransform, false);
                container.sizeDelta = new Vector2(60f, 0f);

                _songsTableView = new GameObject("CustomTableView", typeof(RectTransform)).AddComponent <TableView>();
                _songsTableView.gameObject.AddComponent <RectMask2D>();
                _songsTableView.transform.SetParent(container, false);

                _songsTableView.SetPrivateField("_isInitialized", false);
                _songsTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]);
                _songsTableView.Init();

                (_songsTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0f);
                (_songsTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 1f);
                (_songsTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_songsTableView.transform as RectTransform).anchoredPosition = new Vector2(0f, -3f);

                _songsTableView.dataSource = this;
                _songsTableView.didSelectCellWithIdxEvent += _songsTableView_DidSelectRowEvent;
            }
            else
            {
                _songsTableView.ReloadData();
            }
        }
Exemplo n.º 11
0
        //Time      - Downloads
        //BPM       - Plays
        //Notes     - BPM
        //Obstacles - Upvotes
        //Bombs     - Downvotes

        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            if (firstActivation)
            {
                gameObject.SetActive(true);
                _levelDetails = GetComponentsInChildren <StandardLevelDetailView>(true).First(x => x.name == "LevelDetail");
                _levelDetails.gameObject.SetActive(true);
                (_levelDetails.transform as RectTransform).anchoredPosition = new Vector2(-40, 0);
                BeatmapDifficultySegmentedControlController beatmapDifficultySegmentedControl = GetComponentsInChildren <BeatmapDifficultySegmentedControlController>(true).First(x => x.name == "BeatmapDifficultySegmentedControl");
                beatmapDifficultySegmentedControl.gameObject.SetActive(false);
                BeatmapCharacteristicSegmentedControlController beatmapCharacteristicSegmentedControl = GetComponentsInChildren <BeatmapCharacteristicSegmentedControlController>(true).First(x => x.name == "BeatmapCharacteristicSegmentedControl");
                beatmapCharacteristicSegmentedControl.gameObject.SetActive(false);

                RemoveCustomUIElements(rectTransform);

                _levelParams = GetComponentsInChildren <LevelParamsPanel>().First(x => x.name == "LevelParamsPanel");

                foreach (HoverHint hint in _levelParams.transform.GetComponentsInChildren <HoverHint>())
                {
                    switch (hint.name)
                    {
                    case "Time":
                    {
                        hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Sprites.DownloadIcon;
                    }; break;

                    case "BPM":
                    {
                        hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Sprites.PlayIcon;
                    }; break;

                    case "NotesCount":
                    {
                        hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Resources.FindObjectsOfTypeAll <Sprite>().First(x => x.name == "MetronomeIcon");
                    }; break;

                    case "ObstaclesCount":
                    {
                        hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Sprites.ThumbUp;
                    }; break;

                    case "BombsCount":
                    {
                        hint.GetComponentInChildren <UnityEngine.UI.Image>().sprite = Sprites.ThumbDown;
                    }; break;
                    }

                    Destroy(hint);
                }

                RectTransform yourStats = GetComponentsInChildren <RectTransform>().First(x => x.name == "Stats");
                yourStats.gameObject.SetActive(true);

                TextMeshProUGUI[] _textComponents = GetComponentsInChildren <TextMeshProUGUI>();

                try
                {
                    songNameText = _textComponents.First(x => x.name == "SongNameText");

                    downloadsText          = _textComponents.First(x => x.name == "ValueText" && x.transform.parent.name == "Time");
                    downloadsText.fontSize = 3f;

                    playsText          = _textComponents.First(x => x.name == "ValueText" && x.transform.parent.name == "BPM");
                    playsText.fontSize = 3f;
                    //        foreach (var x in _textComponents)
                    //        {
                    //            Console.WriteLine(x.name);
                    //            Console.WriteLine(x.transform.parent.name);
                    //        }
                    difficulty1Title = _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "MaxRank"); //.text = "Expert/+";
                    difficulty1Text  = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "MaxRank");

                    difficulty2Title = _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "Highscore");//.text = "Hard";
                    difficulty2Text  = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "Highscore");

                    difficulty3Title = _textComponents.First(x => x.name == "Title" && x.transform.parent.name == "MaxCombo");//.text = "Easy/Normal";
                    difficulty3Text  = _textComponents.First(x => x.name == "Value" && x.transform.parent.name == "MaxCombo");
                }
                catch (Exception e)
                {
                    Plugin.log.Critical("Unable to convert detail view controller! Exception:  " + e);
                }

                _downloadButton = _levelDetails.playButton;
                _downloadButton.SetButtonText("DOWNLOAD");
                _downloadButton.ToggleWordWrapping(false);
                _downloadButton.onClick.RemoveAllListeners();
                _downloadButton.onClick.AddListener(() => { downloadButtonPressed?.Invoke(_currentSong); });
                (_downloadButton.transform as RectTransform).sizeDelta = new Vector2(26f, 8.8f);

                _favoriteButton = _levelDetails.practiceButton;
                _favoriteButton.SetButtonIcon(Sprites.AddToFavorites);
                _favoriteButton.onClick.RemoveAllListeners();
                _favoriteButton.onClick.AddListener(() => { favoriteButtonPressed?.Invoke(_currentSong); });

                coverImage = _levelDetails.GetPrivateField <RawImage>("_coverImage");

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(-40f, 0f);
            }
        }
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            if (firstActivation)
            {
                // the rect transform initially is not the size of the entire window, so set that manually
                RectTransform rt = this.rectTransform;
                rt.sizeDelta = new Vector2(160f, 80f);

                _backButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", HandleBackButtonPressed, "Back");
                _backButton.ToggleWordWrapping(false);
                _backButton.SetButtonTextSize(4f);
                rt                  = _backButton.transform as RectTransform;
                rt.anchorMax        = Vector2.zero;
                rt.anchorMin        = Vector2.zero;
                rt.pivot            = Vector2.zero;
                rt.sizeDelta        = new Vector2(20f, 7.5f);
                rt.anchoredPosition = new Vector2(5f, 2f);

                _clearButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", HandleClearButtonPressed, "Clear All");
                _clearButton.ToggleWordWrapping(false);
                _clearButton.SetButtonTextSize(3f);
                rt                  = _clearButton.transform as RectTransform;
                rt.anchorMax        = new Vector2(1f, 0f);
                rt.anchorMin        = new Vector2(1f, 0f);
                rt.pivot            = new Vector2(1f, 0f);
                rt.sizeDelta        = new Vector2(24f, 6.5f);
                rt.anchoredPosition = new Vector2(-60f, 2f);
                BeatSaberUI.AddHintText(rt, "Puts all settings back to the default");

                _resetButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", HandleResetButtonPressed, "Reset");
                _resetButton.ToggleWordWrapping(false);
                _resetButton.SetButtonTextSize(3f);
                rt                  = _resetButton.transform as RectTransform;
                rt.anchorMax        = new Vector2(1f, 0f);
                rt.anchorMin        = new Vector2(1f, 0f);
                rt.pivot            = new Vector2(1f, 0f);
                rt.sizeDelta        = new Vector2(20f, 6.5f);
                rt.anchoredPosition = new Vector2(-35f, 2f);
                BeatSaberUI.AddHintText(rt, "Revert to previously applied settings");

                _applyButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", HandleApplyButtonPressed, "Apply");
                _applyButton.ToggleWordWrapping(false);
                _applyButton.SetButtonTextSize(4f);
                rt                  = _applyButton.transform as RectTransform;
                rt.anchorMax        = new Vector2(1f, 0f);
                rt.anchorMin        = new Vector2(1f, 0f);
                rt.pivot            = new Vector2(1f, 0f);
                rt.sizeDelta        = new Vector2(20f, 7.5f);
                rt.anchoredPosition = new Vector2(-5f, 2f);
                BeatSaberUI.AddHintText(rt, "Applies the current settings to the filter");

                _unapplyButton = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", HandleUnapplyButtonPressed, "Unapply");
                _unapplyButton.ToggleWordWrapping(false);
                _unapplyButton.SetButtonTextSize(4f);
                rt                  = _unapplyButton.transform as RectTransform;
                rt.anchorMax        = new Vector2(1f, 0f);
                rt.anchorMin        = new Vector2(1f, 0f);
                rt.pivot            = new Vector2(1f, 0f);
                rt.sizeDelta        = new Vector2(20f, 7.5f);
                rt.anchoredPosition = new Vector2(-5f, 2f);
                BeatSaberUI.AddHintText(rt, "Unapplies the filter (Keeps all settings as-is for re-application)");
                _unapplyButton.gameObject.SetActive(false);

                _colorHint = BeatSaberUI.CreateUIButton(this.rectTransform, "CancelButton", null, "?");
                _colorHint.GetComponentsInChildren <HorizontalLayoutGroup>().First(x => x.name == "Content").padding = new RectOffset(1, 1, 0, 0);
                _colorHint.SetButtonTextSize(4f);
                _colorHint.interactable = false;
                rt                  = _colorHint.transform as RectTransform;
                rt.anchorMin        = new Vector2(0f, 1f);
                rt.anchorMax        = new Vector2(0f, 1f);
                rt.pivot            = new Vector2(0f, 1f);
                rt.sizeDelta        = new Vector2(6f, 6f);
                rt.anchoredPosition = new Vector2(3f, -2.5f);
                BeatSaberUI.AddHintText(rt, "Filter Color Legend\n" +
                                        "<color=#FF5555>Red</color> - Not applied\n" +
                                        "<color=#FFFF55>Yellow</color> - Not applied, but has changes\n" +
                                        "<color=#55FF55>Green</color> - Applied\n" +
                                        "<color=#55AAFF>Blue</color> - Applied, but has changes");
                _colorHint.gameObject.SetActive(false);

                _listViewController = new GameObject("FilterListViewController").AddComponent <FilterListViewController>();
                rt = _listViewController.rectTransform;
                rt.SetParent(this.transform, false);
                rt.anchorMin        = new Vector2(0f, 1f);
                rt.anchorMax        = new Vector2(0f, 1f);
                rt.pivot            = new Vector2(0f, 1f);
                rt.sizeDelta        = new Vector2(50f, 60f);
                rt.anchoredPosition = new Vector2(5f, -5f);

                _listViewController.FilterSelected += PresentFilterMenu;

                // container RectTransform that all controls will be placed in
                // 90f wide, 60f tall
                var containerImage = new GameObject("FilterSettingsContainer").AddComponent <Image>();
                containerImage.sprite   = Sprite.Create(Texture2D.blackTexture, new Rect(0f, 0f, 1f, 1f), Vector2.zero);
                containerImage.color    = new Color(0f, 0f, 0f, 0f);
                containerImage.material = Utilities.NoGlowMaterial;
                _settingsRectTransform  = containerImage.gameObject.transform as RectTransform;
                _settingsRectTransform.SetParent(this.transform, false);
                _settingsRectTransform.anchorMin        = Vector2.one;
                _settingsRectTransform.anchorMax        = Vector2.one;
                _settingsRectTransform.pivot            = Vector2.one;
                _settingsRectTransform.sizeDelta        = new Vector2(90f, 60f);
                _settingsRectTransform.anchoredPosition = new Vector2(-5f, -5f);

                // add filters to the filter list here
                _listViewController.FilterList.Add(new DifficultyFilter());
                _listViewController.FilterList.Add(new DurationFilter());
                _listViewController.FilterList.Add(new NJSFilter());
                _listViewController.FilterList.Add(new PPFilter());
                _listViewController.FilterList.Add(new StarDifficultyFilter());
                _listViewController.FilterList.Add(new VotedFilter());
                _listViewController.FilterList.Add(new OtherFilter());

                foreach (var filter in _listViewController.FilterList)
                {
                    filter.SettingChanged += FilterSettingChanged;
                }

                _listViewController.FilterList[0].Init();
                foreach (var control in _listViewController.FilterList[0].Controls)
                {
                    control.Init(_settingsRectTransform);
                }

                // divider sprite
                Image divider = new GameObject("WhiteDivider").AddComponent <Image>();
                divider.sprite   = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), Vector2.zero);
                divider.color    = Color.white;
                divider.material = Utilities.NoGlowMaterial;
                rt = divider.rectTransform;
                rt.SetParent(_settingsRectTransform, false);
                rt.anchorMin        = Vector2.zero;
                rt.anchorMax        = new Vector2(0f, 1f);
                rt.pivot            = new Vector2(1f, 0.5f);
                rt.sizeDelta        = new Vector2(1f, 0f);
                rt.anchoredPosition = new Vector2(-8f, 0f);

                // loading screen
                _loadingSpinner = BeatSaberUI.CreateLoadingSpinner(this.transform);

                _loadingText           = BeatSaberUI.CreateText(this.rectTransform, "", new Vector2(0f, 12f), new Vector2(80f, 50f));
                _loadingText.alignment = TextAlignmentOptions.Center;
                _loadingText.fontSize  = 5f;

                // info text
                _infoText = BeatSaberUI.CreateText(this.rectTransform, "", new Vector2(28f, 2f), new Vector2(36f, 8f));
                _infoText.rectTransform.anchorMin = Vector2.zero;
                _infoText.rectTransform.anchorMax = Vector2.zero;
                _infoText.rectTransform.pivot     = Vector2.zero;
                _infoText.alignment = TextAlignmentOptions.Left;
                _infoText.fontSize  = 3.5f;
            }

            // all buttons (except back) should not be interactable when loading beatmap details
            _clearButton.interactable   = false;
            _resetButton.interactable   = false;
            _applyButton.interactable   = false;
            _unapplyButton.interactable = false;

            var originalLevels = _levels;

            _loadingSpinner.gameObject.SetActive(true);
            if (PluginConfig.ShowFirstTimeLoadingText)
            {
                _loadingText.text = "<color=#FF5555>Loading custom song details for the first time...</color>\n\n" +
                                    "This first load may take several minutes, depending on the number of custom songs you have\n(it usually takes about 10 to 15 seconds for every 100 songs).\n\n" +
                                    "<color=#CCFFCC>You may back out of this screen and have the loading occur in the background</color>,\nhowever, loading will pause when playing a level.";
                (_loadingSpinner.transform as RectTransform).anchoredPosition = new Vector2(0f, -20f);

                // force the player to load all custom beatmaps on first load, rather than just the selected levels
                // this is done instead of the old behaviour because SongBrowser will be able to apply filters outside of this view controller
                _levels = _levels.Union(SongCore.Loader.CustomLevels.Values).ToArray();
            }
            else
            {
                _loadingText.text = "Loading song details...";
                (_loadingSpinner.transform as RectTransform).anchoredPosition = Vector2.zero;
            }

            _loadingText.gameObject.SetActive(true);
            _infoText.text = GetLoadingProgressString(0, _levels.Length);
            _infoText.gameObject.SetActive(true);
            _settingsRectTransform.gameObject.SetActive(false);
            // _listViewController deactivated by DidDeactivate

            // load all songs so we have access to all the song details we need to filter
            BeatmapDetailsLoader.Instance.LoadBeatmaps(_levels,
                                                       delegate(int songsLoaded)
            {
                // on update, show updated progress text
                _infoText.text = GetLoadingProgressString(songsLoaded, _levels.Length);
            },
                                                       delegate(BeatmapDetails[] levels)
            {
                // on finish
                _loadingSpinner.SetActive(false);
                _loadingText.gameObject.SetActive(false);
                _infoText.gameObject.SetActive(false);

                _clearButton.interactable = true;
                bool anyChanges           = _listViewController.FilterList.Any(x => x.Status == FilterStatus.AppliedAndChanged || x.Status == FilterStatus.NotAppliedAndChanged);
                if (_listViewController.FilterList.Any(x => x.Status == FilterStatus.Applied) && !anyChanges)
                {
                    _resetButton.interactable   = false;
                    _applyButton.interactable   = false;
                    _unapplyButton.interactable = true;

                    _applyButton.gameObject.SetActive(false);
                    _unapplyButton.gameObject.SetActive(true);
                }
                else
                {
                    _resetButton.interactable   = anyChanges;
                    _applyButton.interactable   = anyChanges;
                    _unapplyButton.interactable = false;

                    _applyButton.gameObject.SetActive(true);
                    _unapplyButton.gameObject.SetActive(false);
                }

                _listViewController.__Activate(ActivationType.NotAddedToHierarchy);
                _listViewController.SetUserInteraction(true);
                _listViewController.RefreshTable(true);
                _colorHint.gameObject.SetActive(true);

                _settingsRectTransform.gameObject.SetActive(true);
                foreach (var control in _listViewController.CurrentFilter.Controls)
                {
                    control.EnableControl();
                }

                // if this was the first load, only take the beatmap details objects that correspond to the requested list of levels
                IPreviewBeatmapLevel[] requestedLevels;
                if (PluginConfig.ShowFirstTimeLoadingText)
                {
                    requestedLevels = originalLevels;
                }
                else
                {
                    requestedLevels = _levels;
                }

                _beatmapDetails = new Dictionary <BeatmapDetails, IPreviewBeatmapLevel>(requestedLevels.Length);
                foreach (var level in requestedLevels)
                {
                    // remove the directory part of a custom level ID
                    // see BeatmapDetailsLoader:GetLevelID() for more detail on why we do this
                    var levelID = level.levelID.StartsWith("custom_level") ? level.levelID.Substring(0, 53) : level.levelID;
                    var details = levels.FirstOrDefault(x => x?.LevelID == levelID);
                    if (details == null)
                    {
                        continue;
                    }

                    _beatmapDetails[details] = level;
                }

                PluginConfig.ShowFirstTimeLoadingText = false;
            });
        }
Exemplo n.º 13
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            if (firstActivation && type == ActivationType.AddedToHierarchy)
            {
                _backButton = BeatSaberUI.CreateBackButton(rectTransform as RectTransform, delegate() { backButtonPressed?.Invoke(); });

                RectTransform container = new GameObject("VideoListContainer", typeof(RectTransform)).transform as RectTransform;
                container.SetParent(rectTransform, false);
                container.sizeDelta = new Vector2(105f, 0f);

                _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageUpButton")), rectTransform, false);
                (_pageUpButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 1f);
                (_pageUpButton.transform as RectTransform).anchoredPosition = new Vector2(0f, -10f);
                (_pageUpButton.transform as RectTransform).sizeDelta        = new Vector2(40f, 10f);
                _pageUpButton.interactable = true;
                _pageUpButton.onClick.AddListener(delegate()
                {
                    _videosTableView.PageScrollUp();
                });

                _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "PageDownButton")), rectTransform, false);
                (_pageDownButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0f);
                (_pageDownButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 10f);
                (_pageDownButton.transform as RectTransform).sizeDelta        = new Vector2(40f, 10f);
                _pageDownButton.interactable = true;
                _pageDownButton.onClick.AddListener(delegate()
                {
                    _videosTableView.PageScrollDown();
                });

                _searchButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -20), new Vector2(30, 8), () =>
                {
                    searchButtonPressed?.Invoke();
                }, "Refine");

                _downloadButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(60, -30), new Vector2(30, 8), () =>
                {
                    downloadButtonPressed?.Invoke(resultsList[_lastSelectedRow]);
                }, "Download");
                _downloadButton.GetComponentInChildren <HorizontalLayoutGroup>().padding = new RectOffset(0, 0, 0, 0);

                _loadingIndicator = BeatSaberUI.CreateLoadingSpinner(rectTransform);
                (_loadingIndicator.transform as RectTransform).anchorMin        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchorMax        = new Vector2(0.5f, 0.5f);
                (_loadingIndicator.transform as RectTransform).anchoredPosition = new Vector2(0f, 0f);
                _loadingIndicator.SetActive(true);

                _videoListTableCellInstance = Resources.FindObjectsOfTypeAll <LevelListTableCell>().First(x => (x.name == "LevelListTableCell"));
                _videosTableView            = new GameObject().AddComponent <TableView>();
                _videosTableView.transform.SetParent(container, false);

                _videosTableView.SetPrivateField("_isInitialized", false);
                _videosTableView.SetPrivateField("_preallocatedCells", new TableView.CellsGroup[0]);
                _videosTableView.Init();

                RectMask2D viewportMask = Instantiate(Resources.FindObjectsOfTypeAll <RectMask2D>().First(), _videosTableView.transform, false);
                viewportMask.transform.DetachChildren();
                _videosTableView.GetComponentsInChildren <RectTransform>().First(x => x.name == "Content").transform.SetParent(viewportMask.rectTransform, false);

                (_videosTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0.5f);
                (_videosTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 0.5f);
                (_videosTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_videosTableView.transform as RectTransform).anchoredPosition = new Vector3(-10f, 0f);

                _videosTableView.dataSource         = this;
                _videosTableView.didSelectRowEvent += _songsTableView_DidSelectRowEvent;
            }
            else
            {
                _videosTableView.ReloadData();
            }
            _downloadButton.interactable = false;
        }