Exemplo n.º 1
0
        public T AddIconSegmentsSetting <T>(string name, string hintText, IconSegmentedControl.DataItem[] icons) where T : SegmentedControlViewController
        {
            var        volumeSettings    = GetVolumeSettings();
            GameObject newSettingsObject = MonoBehaviour.Instantiate(volumeSettings.gameObject, transform);

            newSettingsObject.name = name;

            ListSettingsController volume       = newSettingsObject.GetComponent <ListSettingsController>();
            T newTextSegmentsSettingsController = (T)ReflectionUtil.CopyComponent(volume, typeof(ListSettingsController), typeof(T), newSettingsObject);

            MonoBehaviour.DestroyImmediate(volume);

            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("DecButton").gameObject);
            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("ValueText").gameObject);
            GameObject.Destroy(newSettingsObject.transform.Find("Value").Find("IncButton").gameObject);

            IconSegmentedControl segmentedControl = BeatSaberUI.CreateIconSegmentedControl(newSettingsObject.transform.Find("Value") as RectTransform, new Vector2(0f, 0f), new Vector2(40f, 7f));

            newTextSegmentsSettingsController.segmentedControl = segmentedControl;
            segmentedControl.SetData(icons);

            var tmpText = newSettingsObject.GetComponentInChildren <TMP_Text>();

            tmpText.text = name;
            if (hintText != String.Empty)
            {
                BeatSaberUI.AddHintText(tmpText.rectTransform, hintText);
            }

            viewController?.AddSubmenuOption(newSettingsObject);
            AddHooks(newTextSegmentsSettingsController);
            return(newTextSegmentsSettingsController);
        }
Exemplo n.º 2
0
        public void SetContent(MoreSongsFlowCoordinator sender, Song newSongInfo)
        {
            selectedCharacteristic = null;
            currentDifficulties    = null;
            _currentSong           = newSongInfo;

            songNameText.text = _currentSong.songName;
            if (_characteristicSegmentedDisplay == null)
            {
                _characteristicSegmentedDisplay = BeatSaberUI.CreateIconSegmentedControl(rectTransform, new Vector2(-40, .2f), new Vector2(70, 9f),
                                                                                         delegate(int value) { SelectedCharacteristic(_currentSong.metadata.characteristics[value]); });
                SetupCharacteristicDisplay(_characteristicSegmentedDisplay, _currentSong);
            }
            else
            {
                SetupCharacteristicDisplay(_characteristicSegmentedDisplay, _currentSong);
            }



            if (_difficultySegmentedDisplay == null)
            {
                _difficultySegmentedDisplay = BeatSaberUI.CreateTextSegmentedControl(rectTransform, new Vector2(-40, -9f), new Vector2(85, 8f),
                                                                                     delegate(int value) { SelectedDifficulty(currentDifficulties[value]); });
                _difficultySegmentedDisplay.transform.localScale = new Vector3(.8f,
                                                                               _difficultySegmentedDisplay.transform.localScale.y, _difficultySegmentedDisplay.transform.localScale.z);
                SetupDifficultyDisplay(_difficultySegmentedDisplay, _currentSong);
            }
            else
            {
                SetupDifficultyDisplay(_difficultySegmentedDisplay, _currentSong);
            }

            downloadsText.text          = _currentSong.downloads.ToString();
            _levelParams.bpm            = (float)(_currentSong.plays);
            _levelParams.notesCount     = (int)_currentSong.bpm;
            _levelParams.obstaclesCount = _currentSong.upVotes;
            _levelParams.bombsCount     = _currentSong.downVotes;

            Polyglot.LocalizedTextMeshProUGUI localizer1 = difficulty1Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>();
            if (localizer1 != null)
            {
                GameObject.Destroy(localizer1);
            }
            Polyglot.LocalizedTextMeshProUGUI localizer2 = difficulty2Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>();
            if (localizer2 != null)
            {
                GameObject.Destroy(localizer2);
            }
            Polyglot.LocalizedTextMeshProUGUI localizer3 = difficulty3Title.GetComponentInChildren <Polyglot.LocalizedTextMeshProUGUI>();
            if (localizer3 != null)
            {
                GameObject.Destroy(localizer3);
            }
            difficulty1Title.text = "";
            difficulty2Title.text = "";
            difficulty3Title.text = "";
            difficulty1Text.text  = "";
            difficulty2Text.text  = "";
            difficulty3Text.text  = "";



            //       difficulty1Text.text = (_currentSong.metadata.difficulties.expert || _currentSong.metadata.difficulties.expertPlus) ? "Yes" : "No";
            //       difficulty2Text.text = (_currentSong.metadata.difficulties.hard) ? "Yes" : "No";
            //       difficulty3Text.text = (_currentSong.metadata.difficulties.easy || _currentSong.metadata.difficulties.normal) ? "Yes" : "No";

            StartCoroutine(LoadScripts.LoadSpriteCoroutine(_currentSong.coverURL, (cover) => { coverImage.texture = cover.texture; }));

            SetFavoriteState(PluginConfig.favoriteSongs.Any(x => x.Contains(_currentSong.hash)));
            SetDownloadState((SongDownloader.Instance.IsSongDownloaded(_currentSong) ? DownloadState.Downloaded : (sender.IsDownloadingSong(_currentSong) ? DownloadState.Downloading : DownloadState.NotDownloaded)));
            SetLoadingState(false);


            SelectedCharacteristic(_currentSong.metadata.characteristics[0]);
        }