Exemple #1
0
        // Token: 0x06000007 RID: 7
        public override void OnSelectedSong(Playable[] playable, ChartInfo chartInfo, PlayLog[] playLogs)
        {
            Playable p = playable[0];

            this.Lyric = null;
            this.Lyric = new LyRiCs[p.Sections.Length];
            for (int section = 0; section < this.Lyric.Length; section++)
            {
                string audioPath = chartInfo.Audio[section];
                if (audioPath != null)
                {
                    string directoryName = Path.GetDirectoryName(audioPath);
                    string lrcFile       = Path.GetFileNameWithoutExtension(audioPath) + ".lrc";
                    string lrcPath       = Path.Combine(directoryName, lrcFile);
                    if (File.Exists(lrcPath))
                    {
                        LyRiCs result = LRCDotNet.Parse(File.ReadAllText(lrcPath));
                        this.Lyric[section] = result;
                    }
                }
            }
            this.LyricAndTimings = new SyncLyrics.LyricAndTiming[this.Lyric.Length][];
            for (int section2 = 0; section2 < this.Lyric.Length; section2++)
            {
                if (this.Lyric[section2] != null)
                {
                    List <Lyric> lyric = this.Lyric[section2].Lyrics;
                    this.LyricAndTimings[section2] = new SyncLyrics.LyricAndTiming[lyric.Count <Lyric>()];
                    for (int i = 0; i < lyric.Count <Lyric>(); i++)
                    {
                        long    timing = (long)(lyric[i].Time.TotalMilliseconds * 1000.0);
                        Texture tex    = this.LyricFont.GetTexture(lyric[i].Text, null);
                        this.LyricAndTimings[section2][i] = new SyncLyrics.LyricAndTiming(tex, timing);
                    }
                }
            }
            this.Showing = null;
        }
Exemple #2
0
        public override void OnSelectedSong(Playable[] playable, ChartMetadata chartInfo, PlayLog[] playLogs)
        {
            // Use player1's Playable
            var p = playable[0];

            Lyric = null;
            Lyric = new LyRiCs[p.Sections.Length];

            // *.lrc parse phase
            for (var section = 0; section < Lyric.Length; section++)
            {
                // get path for file
                var audioPath = chartInfo.Audio[section];

                if (audioPath == null)
                {
                    continue;
                }

                var folder  = Path.GetDirectoryName(audioPath);
                var lrcFile = $"{Path.GetFileNameWithoutExtension(audioPath)}.lrc";

                var lrcPath = Path.Combine(folder, lrcFile);

                // read and parse
                if (!File.Exists(lrcPath))
                {
                    continue;
                }

                var file = File.ReadAllText(lrcPath);

                var result = LRCDotNet.Parse(file);

                Lyric[section] = result;
            }
            // phase end

            // Generation texture phase
            LyricAndTimings = new LyricAndTiming[Lyric.Length][];
            for (var section = 0; section < Lyric.Length; section++)
            {
                if (Lyric[section] == null)
                {
                    continue;
                }

                var lyric = Lyric[section].Lyrics;
                LyricAndTimings[section] = new LyricAndTiming[lyric.Count()];

                for (var l = 0; l < lyric.Count(); l++)
                {
                    // convert ms to us
                    var timing = (long)(lyric[l].Time.TotalMilliseconds * 1000.0);
                    // apply offset
                    if (Theme.Offset != 0)
                    {
                        timing += Theme.Offset;
                    }
                    var tex = LyricFont.GetTexture(lyric[l].Text);
                    LyricAndTimings[section][l] = new LyricAndTiming(tex, timing);
                }
            }
            // phase end

            Showing = null;
        }