示例#1
0
        protected override void DidActivate()
        {
            log.Log("Activated!");

            ui          = BeatSaverUI._instance;
            _songLoader = FindObjectOfType <SongLoader>();

            UpdateAlreadyDownloadedSongs();

            if (_songListViewController == null)
            {
                _songListViewController = ui.CreateViewController <BeatSaverSongListViewController>();
                _songListViewController.rectTransform.anchorMin = new Vector2(0.3f, 0f);
                _songListViewController.rectTransform.anchorMax = new Vector2(0.7f, 1f);

                PushViewController(_songListViewController, true);
            }
            else
            {
                if (_viewControllers.IndexOf(_songListViewController) < 0)
                {
                    PushViewController(_songListViewController, true);
                }
            }
            _songListViewController.SelectTopButtons(TopButtonsState.Select);

            if (_backButton == null)
            {
                _backButton = ui.CreateBackButton(rectTransform);

                _backButton.onClick.AddListener(delegate()
                {
                    try
                    {
                        _songLoader.RefreshSongs();
                    }
                    catch (Exception e)
                    {
                        log.Exception("Can't refresh songs! EXCEPTION: " + e);
                    }
                    DismissModalViewController(null, false);
                });
            }

            GetPage(0);

            base.DidActivate();
        }
示例#2
0
        protected override void DidActivate()
        {
            ui          = BeatSaverUI._instance;
            _songLoader = FindObjectOfType <SongLoader>();

            UpdateAlreadyDownloadedSongs();



            if (_songPreviewPlayer == null)
            {
                ObjectProvider[] providers = Resources.FindObjectsOfTypeAll <ObjectProvider>().Where(x => x.name == "SongPreviewPlayerProvider").ToArray();

                if (providers.Length > 0)
                {
                    _songPreviewPlayer = providers[0].GetProvidedObject <SongPreviewPlayer>();
                }
            }

            if (_songListViewController == null)
            {
                _songListViewController = ui.CreateViewController <BeatSaverSongListViewController>();
                _songListViewController.rectTransform.anchorMin = new Vector2(0.3f, 0f);
                _songListViewController.rectTransform.anchorMax = new Vector2(0.7f, 1f);

                PushViewController(_songListViewController, true);
            }
            else
            {
                if (_viewControllers.IndexOf(_songListViewController) < 0)
                {
                    PushViewController(_songListViewController, true);
                }
            }
            _songListViewController.SelectTopButtons(TopButtonsState.Select);

            if (_backButton == null)
            {
                _backButton = ui.CreateBackButton(rectTransform);

                _backButton.onClick.AddListener(delegate()
                {
                    if (!_loading)
                    {
                        if (_songPreviewPlayer != null)
                        {
                            _songPreviewPlayer.CrossfadeToDefault();
                        }
                        try
                        {
                            _songLoader.RefreshSongs();
                            _notUpdatedSongs.Clear();
                        }
                        catch (Exception e)
                        {
                            log.Exception("Can't refresh songs! EXCEPTION: " + e);
                        }
                        DismissModalViewController(null, false);
                    }
                });
            }

            GetPage(_songListViewController._currentPage);

            base.DidActivate();
        }
示例#3
0
        protected override void DidActivate()
        {
            Debug.Log("Activated!");

            ui          = FindObjectOfType <CustomUI>();
            _songLoader = FindObjectOfType <SongLoader>();

            UpdateAlreadyDownloadedSongs();

            try
            {
                _pageUpButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Where(x => (x.name == "PageUpButton")).First(), 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.interactable = true;
                _pageUpButton.onClick.AddListener(delegate()
                {
                    if (_currentPage > 0)
                    {
                        if (!_loading)
                        {
                            _loading          = true;
                            _loadingText.text = "Loading...";
                            _selectedRow      = -1;
                            _downloadButton.gameObject.SetActive(false);
                            StartCoroutine(GetSongs(_currentPage - 1));
                        }
                    }
                });


                _pageDownButton = Instantiate(Resources.FindObjectsOfTypeAll <Button>().Where(x => (x.name == "PageDownButton")).First(), 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.interactable = true;
                _pageDownButton.onClick.AddListener(delegate()
                {
                    if (!_loading)
                    {
                        _loading          = true;
                        _loadingText.text = "Loading...";
                        _selectedRow      = -1;
                        _downloadButton.gameObject.SetActive(false);
                        StartCoroutine(GetSongs(_currentPage + 1));
                    }
                });

                _songListTableCellInstance = Resources.FindObjectsOfTypeAll <SongListTableCell>().Where(x => (x.name == "SongListTableCell")).First();
            }
            catch (Exception e)
            {
                Debug.Log("EXCEPTION IN DidActivate: " + e);
            }

            Button _backButton = ui.CreateBackButton(rectTransform);


            _backButton.onClick.AddListener(delegate() {
                try
                {
                    _songLoader.RefreshSongs();
                }catch (Exception e)
                {
                    Debug.Log("Can't refresh songs!");
                }
                DismissModalViewController(null, false);
            });

            _downloadButton = ui.CreateUIButton(rectTransform);

            (_downloadButton.transform as RectTransform).anchorMin        = new Vector2(0.5f, 1f);
            (_downloadButton.transform as RectTransform).anchorMax        = new Vector2(0.5f, 1f);
            (_downloadButton.transform as RectTransform).anchoredPosition = new Vector2(-66f, -50f);
            (_downloadButton.transform as RectTransform).sizeDelta        = new Vector2(32f, 10f);

            ui.SetButtonText(ref _downloadButton, "Download");
            ui.SetButtonIcon(ref _downloadButton, CustomUI.icons.Where(x => x.name == "PlayIcon").First());

            _downloadButton.onClick.AddListener(delegate() {
                if (_selectedRow != -1 && !_loading)
                {
                    DownloadSong(_selectedRow);
                }
            });

            _downloadButton.gameObject.SetActive(false);


            _loadingText = ui.CreateText(rectTransform, "Loading songs from BeatSaver...", new Vector2(-34f, -32f));
            StartCoroutine(GetSongs(0));

            base.DidActivate();
        }