コード例 #1
0
            public static void Init()
            {
                // Check if kfc dll exists.
                if (!File.Exists(Util.kfcPath + "soundvoltex.dll"))
                {
                    throw new Exception();
                }


                // Check if folders exist.
                if (!Directory.Exists(Util.GetKshSongFolderPath()))
                {
                    Directory.CreateDirectory(Util.GetKshSongFolderPath());
                    DirectoryInfo di = new DirectoryInfo(Util.GetKshSongFolderPath());
                    di.Attributes = FileAttributes.Hidden;
                }

                if (!Directory.Exists(Util.kfcPath + "data\\others\\vox\\"))
                {
                    Directory.CreateDirectory(Util.kfcPath + "data\\others\\vox\\");
                }

                Util.ClearCache();

                // DB backup (for later restore)
                Util.DbBackup();

                songList = new SongList.SongList();

                try
                {
                    songList.LoadFromDB();
                }
                catch (Exception e)
                {
                    Util.DbRestore();
                    return;
                }
            }
コード例 #2
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;
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // Arguments

            bool doTextures  = false;
            bool forceReload = false;
            bool forceMeta   = false;

            OptionSet p = new OptionSet()
            {
                { "p|path=", "The {PATH} of KFC directory.",
                  v => Util.SetKfcPath(v) },
                { "t|texture", "Do the texture replacement (which takes a long time).",
                  v => doTextures = v != null },
                { "f|force-reload", "Force reload all songs.",
                  v => forceReload = v != null },
                { "fm|force-meta", "Force reload meta DB and all songs.",
                  v => forceMeta = v != null }
            };

            List <string> extra;

            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("AutoLoad: ");
                Console.WriteLine(e.Message);
                return;
            }

            // Welcome message

            Util.ConsoleWrite(@"
  _  __    _  _________      __       
 | |/ /   | ||__   __\ \    / /       
 | ' / ___| |__ | | __\ \  / /____  __
 |  < / __| '_ \| |/ _ \ \/ / _ \ \/ /
 | . \\__ \ | | | | (_) \  / (_) >  <  March 2018. Alpha version
 |_|\_\___/_| |_|_|\___/ \/ \___/_/\_\ Author: NTUMG

");

            // Check if kfc dll exists.
            if (!File.Exists(Util.kfcPath + "soundvoltex.dll"))
            {
                Console.WriteLine("soundvoltex.dll not found! Please choose a valid KFC path.");
                Console.ReadKey();
                return;
            }

            // Check if folders exist.
            if (!Directory.Exists(Util.kfcPath + "KshSongs\\"))
            {
                Directory.CreateDirectory(Util.kfcPath + "KshSongs\\");
            }

            if (!Directory.Exists(Util.kfcPath + "data\\others\\vox\\"))
            {
                Directory.CreateDirectory(Util.kfcPath + "data\\others\\vox\\");
            }

            Util.ClearCache();

            // DB backup (for later restore)
            Util.DbBackup();

            if (forceMeta)
            {
                File.Delete(Util.kfcPath + "data\\others\\meta_usedId.xml");
            }

            SongList.SongList songList = new SongList.SongList();

            Util.ConsoleWrite("Loading from KshSongs...");
            try
            {
                if (!forceReload)
                {
                    songList.LoadFromDB();
                }

                songList.LoadFromKshSongs();
            }
            catch (Exception e)
            {
                Util.ConsoleWrite("*** Exception encountered while loading from KshSongs. ***");
                Util.ConsoleWrite(e.Message);

                Util.DbRestore();

                Console.ReadKey();

                return;
            }

            Util.ConsoleWrite("Saving song...");

            try
            {
                // The KFC data could be corrupted here even if the exceptions are caught,
                // so the music_db and metaDb should be removed before abort.
                songList.Save();
            }
            catch (Exception e)
            {
                Util.ConsoleWrite("*** Fatal: Exception encountered while saving ***");
                Util.ConsoleWrite(e.Message);

                File.Delete(Util.kfcPath + "\\data\\others\\music_db.xml");
                File.Delete(Util.kfcPath + "\\data\\others\\meta_usedId.xml");

                Util.ConsoleWrite(@"*** Please force reload with '--f' ***");

                Console.ReadKey();

                return;
            }

            Util.ClearCache();

            if (doTextures)
            {
                Util.ConsoleWrite("Saving texture... (This should took a while)");

                try
                {
                    // Chart data should be fine regardless of the result of SaveTexture.
                    // No need to erase the DBs in exceptions.
                    songList.SaveTexture();
                }
                catch (Exception e)
                {
                    Util.ConsoleWrite("*** Exception encountered while saving texture ***");
                    Util.ConsoleWrite(e.Message);
                    Util.ConsoleWrite("The charts will still be saved. (Without the custom jackets)");
                }
            }

            Util.ConsoleWrite(@"
/////////////////////////////////////////////////
///                                           ///
/// Loading Done! Press any key to proceed... ///
///                                           ///
/////////////////////////////////////////////////
");
            Console.ReadKey();
        }