private void SetupUI()
        {
            if (initialized)
            {
                return;
            }
            _beatmapCharacteristics = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSO>();
            _lastCharacteristic     = _beatmapCharacteristics.First(x => x.characteristicName == "Standard");

            Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSelectionViewController>().First().didSelectBeatmapCharacteristicEvent += (BeatmapCharacteristicSelectionViewController sender, BeatmapCharacteristicSO selected) => { _lastCharacteristic = selected; };
            if (SongLoader.AreSongsLoaded)
            {
                _levelCollection = SongLoader.CustomLevelCollectionSO;
            }
            else
            {
                SongLoader.SongsLoadedEvent += (SongLoader sender, List <CustomLevel> levels) =>
                {
                    _levelCollection = SongLoader.CustomLevelCollectionSO;
                };
            }

            _levelListViewController = Resources.FindObjectsOfTypeAll <LevelListViewController>().FirstOrDefault();

            RectTransform _tableViewRectTransform = _levelListViewController.GetComponentsInChildren <RectTransform>().First(x => x.name == "TableViewContainer");

            _tableViewRectTransform.sizeDelta = new Vector2(0f, -35f);
            //_tableViewRectTransform.anchoredPosition = new Vector2(0f, -2.5f);

            RectTransform _pageUp = _tableViewRectTransform.GetComponentsInChildren <RectTransform>(true).First(x => x.name == "PageUpButton");

            _pageUp.anchoredPosition = new Vector2(0f, -1f);

            RectTransform _pageDown = _tableViewRectTransform.GetComponentsInChildren <RectTransform>(true).First(x => x.name == "PageDownButton");

            _pageDown.anchoredPosition = new Vector2(0f, 1f);

            _requestButton = _levelListViewController.CreateUIButton("CreditsButton", new Vector2(0, 30.25f), new Vector2(20f, 6f), RequestsButtonPressed, "Requests");
            _requestButton.SetButtonTextSize(3f);
            _requestButton.ToggleWordWrapping(false);

            _detailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First(x => x.name == "StandardLevelDetailViewController");

            //based on https://github.com/halsafar/BeatSaberSongBrowser/blob/master/SongBrowserPlugin/UI/Browser/SongBrowserUI.cs#L192
            var statsPanel     = _detailViewController.GetComponentsInChildren <CanvasRenderer>(true).First(x => x.name == "LevelParamsPanel");
            var statTransforms = statsPanel.GetComponentsInChildren <RectTransform>();
            var valueTexts     = statsPanel.GetComponentsInChildren <TextMeshProUGUI>().Where(x => x.name == "ValueText").ToList();

            foreach (RectTransform r in statTransforms)
            {
                if (r.name == "Separator")
                {
                    continue;
                }
                r.sizeDelta = new Vector2(r.sizeDelta.x * 0.85f, r.sizeDelta.y * 0.85f);
            }

            _levelListViewController.didSelectLevelEvent += _levelListViewController_didSelectLevelEvent;
            initialized = true;
        }
Ejemplo n.º 2
0
        private void StandardLevelListViewControllerOnDidSelectLevelEvent(LevelListViewController levelListViewController, IBeatmapLevel level)
        {
            var customLevel = level as CustomLevel;

            if (customLevel == null)
            {
                return;
            }

            if (customLevel.audioClip != TemporaryAudioClip || customLevel.AudioClipLoading)
            {
                return;
            }

            var levels = levelListViewController.GetPrivateField <IBeatmapLevel[]>("_levels").ToList();

            Action callback = delegate
            {
                levelListViewController.SetPrivateField("_selectedLevel", null);
                levelListViewController.HandleLevelListTableViewDidSelectRow(null, levels.IndexOf(customLevel));
            };

            customLevel.FixBPMAndGetNoteJumpMovementSpeed();
            StartCoroutine(LoadAudio(
                               "file:///" + customLevel.customSongInfo.path + "/" + customLevel.customSongInfo.GetAudioPath(), customLevel,
                               callback));
        }
        protected void didSelectLevel(LevelListViewController controller, IBeatmapLevel level)
        {
            Logger.Debug($"level {level.levelID} selected");

            if (!_partyFlowCoordinator || !_partyFlowCoordinator.isActivated)
            {
                toggleButtons(true);
                return;
            }
            toggleButtons(false);
            SteamAPI.SetSong(level.levelID, level.songName);
        }
 private void _levelListViewController_didSelectLevelEvent(LevelListViewController levelListView, IBeatmapLevel selectedLevel)
 {
     _lvlData = selectedLevel.levelID.Substring(0, Math.Min(32, selectedLevel.levelID.Length));
 }
Ejemplo n.º 5
0
        private void OnSceneTransitioned(Scene activeScene)
        {
            GameObject.Destroy(GameObject.Find("SongLoader Color Setter"));
            customSongColors    = IllusionPlugin.ModPrefs.GetBool("Songloader", "customSongColors", true, true);
            customSongPlatforms = IllusionPlugin.ModPrefs.GetBool("Songloader", "customSongPlatforms", true, true);
            if (AreSongsLoading)
            {
                //Scene changing while songs are loading. Since we are using a separate thread while loading, this is bad and could cause a crash.
                //So we have to stop loading.
                if (_loadingTask != null)
                {
                    _loadingTask.Cancel();
                    _loadingCancelled = true;
                    AreSongsLoading   = false;
                    LoadingProgress   = 0;
                    StopAllCoroutines();
                    _progressBar.ShowMessage("Loading cancelled\n<size=80%>Press Ctrl+R to refresh</size>");
                    Log("Loading was cancelled by player since they loaded another scene.");
                }
            }

            StartCoroutine(WaitRemoveScores());

            if (activeScene.name == MenuSceneName)
            {
                CurrentLevelPlaying = null;

                if (CustomLevelCollectionSO == null)
                {
                    var levelCollectionSO = Resources.FindObjectsOfTypeAll <LevelCollectionSO>().FirstOrDefault();
                    CustomLevelCollectionSO = CustomLevelCollectionSO.ReplaceOriginal(levelCollectionSO);
                }
                else
                {
                    CustomLevelCollectionSO.ReplaceReferences();
                }
                if (_standardLevelDetailViewController == null)
                {
                    _standardLevelDetailViewController = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().FirstOrDefault();
                    if (_standardLevelDetailViewController == null)
                    {
                        return;
                    }
                    _standardLevelDetailViewController.didPressPlayButtonEvent += StandardLevelDetailControllerOnDidPressPlayButtonEvent;
                }

                if (_LevelListViewController == null)
                {
                    _LevelListViewController = Resources.FindObjectsOfTypeAll <LevelListViewController>().FirstOrDefault();
                    if (_LevelListViewController == null)
                    {
                        return;
                    }

                    _LevelListViewController.didSelectLevelEvent += StandardLevelListViewControllerOnDidSelectLevelEvent;
                }



                if (_characteristicViewController == null)
                {
                    _characteristicViewController = Resources.FindObjectsOfTypeAll <BeatmapCharacteristicSelectionViewController>().FirstOrDefault();
                    if (_characteristicViewController == null)
                    {
                        return;
                    }

                    _characteristicViewController.didSelectBeatmapCharacteristicEvent += OnDidSelectBeatmapCharacteristicEvent;
                }

                if (CustomPlatformsPresent)
                {
                    CheckForPreviousPlatform();
                }
            }
            else if (activeScene.name == GameSceneName)
            {
                _standardLevelSceneSetupData = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>().FirstOrDefault();
                if (_standardLevelSceneSetupData == null)
                {
                    return;
                }
                var level   = _standardLevelSceneSetupData.difficultyBeatmap;
                var beatmap = level as CustomLevel.CustomDifficultyBeatmap;
                if (beatmap != null)
                {
                    CurrentLevelPlaying = beatmap;

                    //The note jump movement speed now gets set in the Start method, so we're too early here. We have to wait a bit before overriding.
                    Invoke(nameof(DelayedNoteJumpMovementSpeedFix), 0.1f);
                }

                if (NoteHitVolumeChanger.PrefabFound)
                {
                    return;
                }
                var song = CustomLevels.FirstOrDefault(x => x.levelID == level.level.levelID);
                if (song == null)
                {
                    return;
                }
                NoteHitVolumeChanger.SetVolume(song.customSongInfo.noteHitVolume, song.customSongInfo.noteMissVolume);

                //Set environment if the song has customEnvironment
                if (CustomPlatformsPresent)
                {
                    CheckCustomSongEnvironment(song);
                }
                //Set enviroment colors for the song if it has song specific colors
                if (customSongColors)
                {
                    song.SetSongColors(CurrentLevelPlaying.colorLeft, CurrentLevelPlaying.colorRight, CurrentLevelPlaying.hasCustomColors);
                }
            }
        }