コード例 #1
0
        // From KFC
        public Song(Dictionary <string, string> data_,
                    Dictionary <string, Dictionary <string, string> > chartData_,
                    string kfcPath,
                    bool load)
        {
            data      = data_;
            chartData = chartData_;


            if (!load)
            {
                return;
            }
            // load:    If false, skips the entire .vox & .2dx parsing procedure.

            // Make Charts

            foreach (KeyValuePair <string, Dictionary <string, string> > chartInfo in chartData)
            {
                if (chartInfo.Value["difnum"] == "0")
                {
                    continue;
                }

                string chartPath = kfcPath + "\\data\\others\\vox\\" + BaseName() + Suffix(chartInfo.Key) + ".vox";
                if (!File.Exists(chartPath))
                {
                    chartPath = SongList.GetCachePath() + BaseName() + Suffix(chartInfo.Key) + ".vox";
                    if (!File.Exists(chartPath))
                    {
                        throw new FileNotFoundException();
                    }
                }
                FileStream cstream = new FileStream(chartPath, FileMode.Open);

                charts[chartInfo.Key] = new Chart(cstream);

                cstream.Close();

                // .2dx to wav (looking for difficulty-specific sound file)

                string soundPath    = kfcPath + "\\data\\sound\\" + BaseName() + Suffix(chartInfo.Key) + ".2dx";
                string outSoundPath = Util.cachePath + BaseName() + Suffix(chartInfo.Key) + ".wav";
                if (File.Exists(soundPath))
                {
                    FileStream sstream  = new FileStream(soundPath, FileMode.Open);
                    FileStream osstream = new FileStream(outSoundPath, FileMode.Create);

                    sstream.Position = 0x64;
                    sstream.CopyTo(osstream);

                    sstream.Close();
                    osstream.Close();

                    soundCaches.Add(soundPath, new Tuple <string, string>(outSoundPath, ""));
                }
            }

            // .2dx to wav (looking for common sound file)

            string soundPath2    = kfcPath + "\\data\\sound\\" + BaseName() + ".2dx";
            string outSoundPath2 = Util.cachePath + BaseName() + ".wav";

            if (!File.Exists(soundPath2))
            {
                throw new Exception("");
            }
            FileStream sstream2  = new FileStream(soundPath2, FileMode.Open);
            FileStream osstream2 = new FileStream(outSoundPath2, FileMode.Create);

            sstream2.Position = 0x64;
            sstream2.CopyTo(osstream2);

            sstream2.Close();
            osstream2.Close();

            soundCaches.Add(soundPath2, new Tuple <string, string>(outSoundPath2, ""));

            loaded = true;
        }