Exemplo n.º 1
0
 public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
 {
     if (scene.buildIndex == 1)
     {
         BeatSaverUI.OnLoad();
     }
 }
Exemplo n.º 2
0
        private void Awake()
        {
            _instance = this;
            foreach (Sprite sprite in Resources.FindObjectsOfTypeAll <Sprite>())
            {
                icons.Add(sprite);
            }
            log.Log("Trying to find buttons...");
            try
            {
                _buttonInstance           = Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "QuitButton"));
                _backButtonInstance       = Resources.FindObjectsOfTypeAll <Button>().First(x => (x.name == "BackArrowButton"));
                _mainMenuViewController   = Resources.FindObjectsOfTypeAll <MainMenuViewController>().First();
                _mainMenuRectTransform    = _buttonInstance.transform.parent as RectTransform;
                _loadingIndicatorInstance = Resources.FindObjectsOfTypeAll <GameObject>().Where(x => x.name == "LoadingIndicator").First();

                log.Log("Buttons and main menu found!");
            }
            catch (Exception e)
            {
                log.Exception("EXCEPTION ON AWAKE(TRY FIND BUTTONS): " + e);
            }

            try
            {
                CreateBeatSaverButton();

                log.Log("BeatSaver button created!");
            }
            catch (Exception e)
            {
                log.Exception("EXCEPTION ON AWAKE(TRY CREATE BUTTON): " + e);
            }
        }
Exemplo n.º 3
0
 public void OnLevelWasLoaded(int level)
 {
     if (level == 1)
     {
         BeatSaverUI.OnLoad();
     }
 }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        protected override void DidActivate()
        {
            _parentMasterViewController = transform.parent.GetComponent <BeatSaverMasterViewController>();
            ui = BeatSaverUI._instance;

            if (_searchKeyboard == null)
            {
                _searchKeyboard = Instantiate(Resources.FindObjectsOfTypeAll <UIKeyboard>().First(), rectTransform, false);
                _searchKeyboard.uiKeyboardKeyEvent    = delegate(char input) { _inputString += input; UpdateInputText(); };
                _searchKeyboard.uiKeyboardDeleteEvent = delegate() { _inputString = _inputString.Substring(0, _inputString.Length - 1); UpdateInputText(); };
            }

            if (_inputText == null)
            {
                _inputText           = ui.CreateText(rectTransform, "Search...", new Vector2(0f, -17.5f));
                _inputText.alignment = TextAlignmentOptions.Center;
                _inputText.fontSize  = 6f;
            }
            else
            {
                _inputString = "";
                UpdateInputText();
            }

            if (_searchButton == null)
            {
                _searchButton = ui.CreateUIButton(rectTransform, "ApplyButton");
                ui.SetButtonText(ref _searchButton, "Submit");
                (_searchButton.transform as RectTransform).sizeDelta        = new Vector2(30f, 10f);
                (_searchButton.transform as RectTransform).anchoredPosition = new Vector2(-15f, 5f);
                _searchButton.onClick.RemoveAllListeners();
                _searchButton.onClick.AddListener(delegate() {
                    DismissModalViewController(null, false);
                });
            }


            base.DidActivate();
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
        protected override void DidActivate()
        {
            ui = BeatSaverUI._instance;
            _parentMasterViewController = transform.parent.GetComponent <BeatSaverMasterViewController>();

            try
            {
                if (_pageUpButton == null)
                {
                    _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.interactable = true;
                    _pageUpButton.onClick.AddListener(delegate()
                    {
                        if (_currentPage > 0)
                        {
                            if (!_parentMasterViewController._loading)
                            {
                                _parentMasterViewController._loading = true;
                                _currentPage -= 1;
                                _parentMasterViewController.GetPage(_currentPage);
                            }
                        }
                    });
                }

                if (_pageDownButton == null)
                {
                    _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.interactable = true;
                    _pageDownButton.onClick.AddListener(delegate()
                    {
                        if (!_parentMasterViewController._loading)
                        {
                            _parentMasterViewController._loading = true;
                            _currentPage += 1;
                            _parentMasterViewController.GetPage(_currentPage);
                        }
                    });
                }

                if (_sortByButton == null)
                {
                    _sortByButton = ui.CreateUIButton(rectTransform, "ApplyButton");
                    ui.SetButtonText(ref _sortByButton, "Sort by");
                    ui.SetButtonTextSize(ref _sortByButton, 3f);
                    (_sortByButton.transform as RectTransform).sizeDelta        = new Vector2(30f, 6f);
                    (_sortByButton.transform as RectTransform).anchoredPosition = new Vector2(0f, 73f);
                    _sortByButton.onClick.RemoveAllListeners();
                    _sortByButton.onClick.AddListener(delegate() {
                        SelectTopButtons(TopButtonsState.SortBy);
                    });
                }

                if (_sortByText == null)
                {
                    _sortByText          = ui.CreateText(rectTransform, "SORT BY", new Vector2(-36f, -4.75f));
                    _sortByText.fontSize = 3.5f;
                    _sortByText.rectTransform.sizeDelta = new Vector2(10f, 6f);
                    _sortByText.gameObject.SetActive(false);
                }

                if (_topButton == null)
                {
                    _topButton = ui.CreateUIButton(rectTransform, "ApplyButton");
                    ui.SetButtonText(ref _topButton, "Downloads");
                    ui.SetButtonTextSize(ref _topButton, 3f);
                    (_topButton.transform as RectTransform).sizeDelta        = new Vector2(20f, 6f);
                    (_topButton.transform as RectTransform).anchoredPosition = new Vector2(-30f, 73f);
                    _topButton.onClick.RemoveAllListeners();
                    _topButton.onClick.AddListener(delegate() {
                        if (!_parentMasterViewController._loading)
                        {
                            _parentMasterViewController._loading = true;
                            _parentMasterViewController._sortBy  = "top";
                            _currentPage = 0;
                            _parentMasterViewController.ClearSearchInput();
                            _parentMasterViewController.GetPage(_currentPage);
                            SelectTopButtons(TopButtonsState.Select);
                        }
                    });
                    _topButton.gameObject.SetActive(false);
                }

                if (_newButton == null)
                {
                    _newButton = ui.CreateUIButton(rectTransform, "ApplyButton");
                    ui.SetButtonText(ref _newButton, "Upload Time");
                    ui.SetButtonTextSize(ref _newButton, 3f);
                    (_newButton.transform as RectTransform).sizeDelta        = new Vector2(20f, 6f);
                    (_newButton.transform as RectTransform).anchoredPosition = new Vector2(-10f, 73f);
                    _newButton.onClick.RemoveAllListeners();
                    _newButton.onClick.AddListener(delegate() {
                        if (!_parentMasterViewController._loading)
                        {
                            _parentMasterViewController._loading = true;
                            _parentMasterViewController._sortBy  = "new";
                            _currentPage = 0;
                            _parentMasterViewController.ClearSearchInput();
                            _parentMasterViewController.GetPage(_currentPage);
                            SelectTopButtons(TopButtonsState.Select);
                        }
                    });
                    _newButton.gameObject.SetActive(false);
                }

                if (_starButton == null)
                {
                    _starButton = ui.CreateUIButton(rectTransform, "ApplyButton");
                    ui.SetButtonText(ref _starButton, "Plays");
                    ui.SetButtonTextSize(ref _starButton, 3f);
                    (_starButton.transform as RectTransform).sizeDelta        = new Vector2(20f, 6f);
                    (_starButton.transform as RectTransform).anchoredPosition = new Vector2(10f, 73f);
                    _starButton.onClick.RemoveAllListeners();
                    _starButton.onClick.AddListener(delegate() {
                        if (!_parentMasterViewController._loading)
                        {
                            _parentMasterViewController._sortBy = "plays";
                            _currentPage = 0;
                            _parentMasterViewController.ClearSearchInput();
                            _parentMasterViewController.GetPage(_currentPage);
                            SelectTopButtons(TopButtonsState.Select);
                        }
                    });
                    _starButton.gameObject.SetActive(false);
                }

                if (_searchButton == null)
                {
                    _searchButton = ui.CreateUIButton(rectTransform, "ApplyButton");
                    ui.SetButtonText(ref _searchButton, "Search");
                    ui.SetButtonTextSize(ref _searchButton, 3f);
                    (_searchButton.transform as RectTransform).sizeDelta        = new Vector2(30f, 6f);
                    (_searchButton.transform as RectTransform).anchoredPosition = new Vector2(-30f, 73f);
                    _searchButton.onClick.RemoveAllListeners();
                    _searchButton.onClick.AddListener(delegate() {
                        _parentMasterViewController.ShowSearchKeyboard();
                        SelectTopButtons(TopButtonsState.Search);
                        _currentPage = 0;
                    });
                }


                if (_loadingIndicator == null)
                {
                    try
                    {
                        _loadingIndicator = ui.CreateLoadingIndicator(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);
                    }catch (Exception e)
                    {
                        log.Exception("EXCEPTION: " + e);
                    }
                }


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

                if (_songsTableView == null)
                {
                    _songsTableView = new GameObject().AddComponent <TableView>();

                    _songsTableView.transform.SetParent(rectTransform, false);

                    _songsTableView.dataSource = this;

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

                    _songsTableView.DidSelectRowEvent += _songsTableView_DidSelectRowEvent;
                }
                else
                {
                    _songsTableView.ReloadData();
                }
            }
            catch (Exception e)
            {
                log.Exception("EXCEPTION IN DidActivate: " + e);
            }
        }