예제 #1
0
        public void Start()
        {
            // The goal now is to find the clip this scene will be playing.
            // For this, we find the single root gameObject (which is the gameObject
            // to which we are attached),
            // then we get its GameSongController to find the audio clip,
            // and its FlyingTextSpawner to display the lyrics.

            textSpawner    = gameObject.GetComponentInChildren <FlyingTextSpawner>();
            songController = gameObject.GetComponentInChildren <GameSongController>();

            if (textSpawner == null || songController == null)
            {
                return;
            }


            audioClip = (AudioClip)SongFileField.GetValue(songController);

            // Clip found, now select the first song that has the same clip (using reference comparison).
            levelData = (from world in PersistentSingleton <GameDataModel> .instance.gameStaticData.worldsData
                         from levelStaticData in world.levelsData
                         from difficultyLevel in levelStaticData.difficultyLevels
                         where ReferenceEquals(difficultyLevel.audioClip, audioClip)
                         select levelStaticData).FirstOrDefault();

            if (levelData == null)
            {
                Debug.Log("Corresponding song not found.");

                return;
            }

            // We found the matching song, we can get started.
            Debug.Log($"Corresponding song data found: {levelData.songName} by {levelData.authorName}.");

            // When this coroutine ends, it will call the given callback with a list
            // of all the subtitles we found, and allow us to react.
            // If no subs are found, the callback is not called.
            StartCoroutine(LyricsFetcher.GetLyrics(levelData.songName, levelData.authorName, subs =>
            {
                SpawnText("Lyrics found", 3f);
                StartCoroutine(DisplayLyrics(subs));
            }));
        }
예제 #2
0
        public IEnumerator Start()
        {
            // The goal now is to find the clip this scene will be playing.
            // For this, we find the single root gameObject (which is the gameObject
            // to which we are attached),
            // then we get its GameSongController to find the audio clip,
            // and its FlyingTextSpawner to display the lyrics.

            if (Settings.VerboseLogging)
            {
                Debug.Log("[Beat Singer] Attached to scene.");
                Debug.Log($"[Beat Singer] Lyrics are enabled: {Settings.DisplayLyrics}.");
            }

            textSpawner    = FindObjectOfType <FlyingTextSpawner>();
            songController = FindObjectOfType <GameSongController>();

            var sceneSetup = FindObjectOfType <GameplayCoreSceneSetup>();

            if (songController == null || sceneSetup == null)
            {
                yield break;
            }

            if (textSpawner == null)
            {
                var installer = FindObjectOfType <EffectPoolsInstaller>();
                var container = (Zenject.DiContainer)ContainerField.GetValue(installer);

                textSpawner = container.InstantiateComponentOnNewGameObject <FlyingTextSpawner>();
            }

            var sceneSetupData = (GameplayCoreSceneSetupData)SceneSetupDataField.GetValue(sceneSetup);

            if (sceneSetupData == null)
            {
                yield break;
            }

            audio = (AudioTimeSyncController)AudioTimeSyncField.GetValue(songController);

            IBeatmapLevel   level     = sceneSetupData.difficultyBeatmap.level;
            List <Subtitle> subtitles = new List <Subtitle>();

            Debug.Log($"[Beat Singer] Corresponding song data found: {level.songName} by {level.songAuthorName} ({(level.songSubName != null ? level.songSubName : "No sub-name")}).");

            if (LyricsFetcher.GetLocalLyrics(sceneSetupData.difficultyBeatmap.level.levelID, subtitles))
            {
                Debug.Log("[Beat Singer] Found local lyrics.");
                Debug.Log($"[Beat Singer] These lyrics can be uploaded online using the ID: \"{level.GetLyricsHash()}\".");

                // Lyrics found locally, continue with them.
                SpawnText("Lyrics found locally", 3f);
            }
            else
            {
                Debug.Log("[Beat Singer] Did not find local lyrics, trying online lyrics...");

                // When this coroutine ends, it will call the given callback with a list
                // of all the subtitles we found, and allow us to react.
                // If no subs are found, the callback is not called.
                yield return(StartCoroutine(LyricsFetcher.GetOnlineLyrics(level, subtitles)));

                if (subtitles.Count != 0)
                {
                    goto FoundOnlineLyrics;
                }

                yield return(StartCoroutine(LyricsFetcher.GetMusixmatchLyrics(level.songName, level.songAuthorName, subtitles)));

                if (subtitles.Count != 0)
                {
                    goto FoundOnlineLyrics;
                }

                yield return(StartCoroutine(LyricsFetcher.GetMusixmatchLyrics(level.songName, level.songSubName, subtitles)));

                if (subtitles.Count != 0)
                {
                    goto FoundOnlineLyrics;
                }

                yield break;

FoundOnlineLyrics:
                SpawnText("Lyrics found online", 3f);
            }

            StartCoroutine(DisplayLyrics(subtitles));
        }
예제 #3
0
        public IEnumerator Start()
        {
            // The goal now is to find the clip this scene will be playing.
            // For this, we find the single root gameObject (which is the gameObject
            // to which we are attached),
            // then we get its GameSongController to find the audio clip,
            // and its FlyingTextSpawner to display the lyrics.


            textSpawner    = FindObjectOfType <FlyingTextSpawner>();
            songController = FindObjectOfType <GameSongController>();

            if (textSpawner == null || songController == null)
            {
                yield break;
            }

            MainGameSceneSetup sceneSetup = FindObjectOfType <MainGameSceneSetup>();

            if (sceneSetup == null)
            {
                yield break;
            }

            MainGameSceneSetupData sceneSetupData = SetupDataField.GetValue(sceneSetup) as MainGameSceneSetupData;

            if (sceneSetupData == null)
            {
                yield break;
            }

            List <Subtitle> subtitles = new List <Subtitle>();

            if (LyricsFetcher.GetLocalLyrics(sceneSetupData.difficultyLevel.level.levelID, subtitles))
            {
                // Lyrics found locally, continue with them.
                SpawnText("Lyrics found locally", 3f);
            }
            else
            {
                // Clip found, now select the first song that has the same clip (using reference comparison).
                IStandardLevel level = sceneSetupData.difficultyLevel.level;

                // We found the matching song, we can get started.
                Debug.Log($"Corresponding song data found: {level.songName} by {level.songAuthorName}.");

                // When this coroutine ends, it will call the given callback with a list
                // of all the subtitles we found, and allow us to react.
                // If no subs are found, the callback is not called.
                yield return(StartCoroutine(LyricsFetcher.GetOnlineLyrics(level.songName, level.songAuthorName, subtitles)));

                if (subtitles.Count == 0)
                {
                    yield break;
                }

                SpawnText("Lyrics found online", 3f);
            }

            StartCoroutine(DisplayLyrics(subtitles));
        }
예제 #4
0
        public IEnumerator Start()
        {
            // The goal now is to find the clip this scene will be playing.
            // For this, we find the single root gameObject (which is the gameObject
            // to which we are attached),
            // then we get its GameSongController to find the audio clip,
            // and its FlyingTextSpawner to display the lyrics.

            if (Settings.VerboseLogging)
            {
                Debug.Log("[Beat Singer] Attached to scene.");
                Debug.Log($"[Beat Singer] Lyrics are enabled: {Settings.DisplayLyrics}.");
            }
            if (!Settings.DisplayLyrics)
            {
                yield break;
            }

            //Create a FlyingTextSpawner (Based on Custom Miss Text)
            var installer = Resources.FindObjectsOfTypeAll <EffectPoolsInstaller>().FirstOrDefault();

            if (installer != null)
            {
                var containers = Resources.FindObjectsOfTypeAll <MonoInstallerBase>();
                foreach (MonoInstallerBase a in containers)
                {
                    if (textSpawner == null)
                    {
                        try
                        {
                            var container = a.GetProperty <DiContainer>("Container");
                            textSpawner = container.InstantiateComponentOnNewGameObject <FlyingTextSpawner>("CustomMissTextSpawner");
                        }
                        catch (Exception ex)
                        {
                            Debug.Log("Exception creating TextSpawner");
                        }
                    }
                }

                //      .First().GetProperty<DiContainer>("Container");
                //     textSpawner = container.InstantiateComponentOnNewGameObject<FlyingTextSpawner>("CustomMissTextSpawner");
                Debug.Log("Text Spawner Attempted");
            }

            //    songController = FindObjectOfType<GameSongController>();

            var sceneSetup = BS_Utils.Plugin.LevelData;

            if (textSpawner == null)
            {
                Debug.Log("Null TextSpawner, breaking");
                yield break;
            }
            //Set Text Spawner Properties (fontSize, Color, Shake)
            textSpawner.SetField("_fontSize", Settings.FontSize);
            textSpawner.SetField("_shake", Settings.Shake);
            textSpawner.SetField("_color", Settings.TextColor);



            audio = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();

            if (BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.practiceSettings != null)
            {
                SpawnText("Practice Mode. \n" +
                          "Ignoring Lyrics", 2f);
                yield break;
            }
            if (BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul != 1f)
            {
                SpawnText("NonStandard Speed. \n" +
                          "Ignoring Lyrics", 2f);
                yield break;
            }


            IBeatmapLevel   level     = sceneSetup.GameplayCoreSceneSetupData.difficultyBeatmap.level;
            List <Subtitle> subtitles = new List <Subtitle>();

            Debug.Log($"[Beat Singer] Corresponding song data found: {level.songName} by {level.songAuthorName} / {level.songSubName}.");

            if (LyricsFetcher.GetLocalLyrics(sceneSetup.GameplayCoreSceneSetupData.difficultyBeatmap.level, subtitles))
            {
                Debug.Log("[Beat Singer] Found local lyrics.");
                Debug.Log($"[Beat Singer] These lyrics can be uploaded online using the ID: \"{level.GetLyricsHash()}\".");

                // Lyrics found locally, continue with them.
                SpawnText("Lyrics found locally", 3f);
            }
            else
            {
                Debug.Log("[Beat Singer] Did not find local lyrics, trying online lyrics...");

                // When this coroutine ends, it will call the given callback with a list
                // of all the subtitles we found, and allow us to react.
                // If no subs are found, the callback is not called.
                yield return(StartCoroutine(LyricsFetcher.GetOnlineLyrics(level, subtitles)));

                if (subtitles.Count != 0)
                {
                    goto FoundOnlineLyrics;
                }

                yield return(StartCoroutine(LyricsFetcher.GetMusixmatchLyrics(level.songName, level.songAuthorName, subtitles)));

                if (subtitles.Count != 0)
                {
                    goto FoundOnlineLyrics;
                }

                yield return(StartCoroutine(LyricsFetcher.GetMusixmatchLyrics(level.songName, level.songSubName, subtitles)));

                if (subtitles.Count != 0)
                {
                    goto FoundOnlineLyrics;
                }

                yield break;

FoundOnlineLyrics:
                SpawnText("Lyrics found online", 3f);
            }

            StartCoroutine(DisplayLyrics(subtitles));
        }