public override void Save(string filePath) { // Assume it's being exported for F2nd PS3 if (BinaryFormatUtilities.IsClassic(Format) && filePath.EndsWith(".txd", StringComparison.OrdinalIgnoreCase)) { Format = BinaryFormat.F2nd; Endianness = Endianness.Big; } // Or vice versa else if (BinaryFormatUtilities.IsModern(Format) && filePath.EndsWith(".bin", StringComparison.OrdinalIgnoreCase)) { Format = BinaryFormat.DT; Endianness = Endianness.Little; } // Save a TXI if we are modern if (filePath.EndsWith(".txd", StringComparison.OrdinalIgnoreCase)) { var textureDatabase = new TextureDatabase(); foreach (var texture in Textures) { textureDatabase.Textures.Add(new TextureInfo { Id = texture.Id, Name = texture.Name ?? Guid.NewGuid().ToString() }); } textureDatabase.Format = Format; textureDatabase.Endianness = Endianness; textureDatabase.Save(Path.ChangeExtension(filePath, "txi")); } base.Save(filePath); }
public void Convert(string path, string objdbpath, string texdbpath, string stagedbpath, string a3ddbpath, string mot_db, string acpath) { maxWorker = Environment.ProcessorCount; Console.Title = "LYB DIVA X2A"; Console.WriteLine("lyb's Diva X to A Conversion Utility"); Console.WriteLine("Credit : Skyth (MikuMikuLibrary), KorenKonder (KKtLib)," + " Raki Saionji (DivaScriptConv), Samyuu (DivaScript, ScriptUtilities)"); Console.WriteLine(""); divapvmod divapvmods = new divapvmod(); divapvmods.RestoreDb(true); if (Directory.Exists("a3d")) { Directory.Delete("a3d", true); } if (Directory.Exists("farc")) { Directory.Delete("farc", true); } if (Directory.Exists("temp")) { Directory.Delete("temp", true); } if (Directory.Exists("dsc")) { Directory.Delete("dsc", true); } if (Directory.Exists("mot")) { Directory.Delete("mot", true); } Directory.CreateDirectory("temp"); Directory.CreateDirectory("farc"); Directory.CreateDirectory("dsc"); Directory.CreateDirectory("farc"); if (!Directory.Exists(acpath + "\\divamods")) { Directory.CreateDirectory(acpath + "\\divamods"); } objdb.Load(objdbpath); staged.Load(stagedbpath); auth3d_db.load(a3ddbpath); new Thread(() => { Thread.CurrentThread.IsBackground = true; auth3d.ExtractA3D(path, acpath, auth3d_db); Interlocked.Decrement(ref currentWorker); }).Start(); Interlocked.Increment(ref currentWorker); foreach (string file in Directory.EnumerateFiles(path, "stgpv*.farc", SearchOption.TopDirectoryOnly)) { while (currentWorker > maxWorker) { Thread.Sleep(33); } new Thread(() => { Thread.CurrentThread.IsBackground = true; var le_model = divax.Stripify(file); model_list.Push(le_model); Interlocked.Decrement(ref currentWorker); }).Start(); Interlocked.Increment(ref currentWorker); } foreach (string file in Directory.EnumerateFiles(path, "effpv*.farc", SearchOption.TopDirectoryOnly)) { while (currentWorker > maxWorker) { Thread.Sleep(33); } new Thread(() => { Thread.CurrentThread.IsBackground = true; var le_model = divax.Stripify(file); model_list.Push(le_model); Interlocked.Decrement(ref currentWorker); }).Start(); Interlocked.Increment(ref currentWorker); } while (currentWorker != 0) { Thread.Sleep(33); } new Thread(() => { Thread.CurrentThread.IsBackground = true; auth3d.ConvertA3D(path, acpath, auth3d_db); Interlocked.Decrement(ref currentWorker); }).Start(); Interlocked.Increment(ref currentWorker); var texturedb = new TextureDatabase(); texturedb.Load(texdbpath); while (model_list.Count > 0) { models stgpv; model_list.TryPop(out stgpv); Console.WriteLine(Path.GetFileName(stgpv.fileName)); divax.GenerateObjSet(stgpv.fileName, stgpv.model, objdb, texturedb, staged, acpath, divamods, true, false); GC.Collect(); GC.WaitForPendingFinalizers(); } texturedb.Save(acpath + @"\rom\objset\tex_db.bin"); model_list.Clear(); GC.Collect(); GC.WaitForPendingFinalizers(); /* * foreach (string file in Directory.EnumerateFiles(path, "stgpv*.farc", SearchOption.TopDirectoryOnly)) * { * Console.WriteLine(Path.GetFileName(file)); * var stgpv = model_list.Where(c => c.fileName == Path.GetFileName(path)).First(); * divax.GenerateObjSet(file, stgpv.model, objdb, texdbpath, staged, acpath, divamods, true, false); * GC.Collect(); * GC.WaitForPendingFinalizers(); * } * * foreach (string file in Directory.EnumerateFiles(path, "effpv*.farc", SearchOption.TopDirectoryOnly)) * { * Console.WriteLine(Path.GetFileName(file)); * var stgpv = model_list.Where(c => c.fileName == Path.GetFileName(path)).First(); * divax.GenerateObjSet(file, stgpv.model, objdb, texdbpath, staged, acpath, divamods, true, false); * GC.Collect(); * GC.WaitForPendingFinalizers(); * } */ objdb.Save(acpath + @"\rom\objset\obj_db.bin"); staged.Save(acpath + @"\rom\stage_data.bin"); while (currentWorker != 0) { Thread.Sleep(33); } auth3d.CreateDBEntries(acpath, auth3d_db, divamods); auth3d_db.save(acpath + @"\rom\auth_3d\auth_3d_db.bin"); motion.Convert(path, acpath, mot_db, divamods); //motion.dbgme(path, acpath, divamods); dsc.ConvertDSC(path, acpath, divamods); var csv = File.ReadAllLines("x_pv.csv"); foreach (var i in csv) { var lines = i.Split(','); divamods.SetU1P2P(lines[0], lines[1], lines[2], lines[4]); } divamods.GenerateDivamods(acpath); divapvmods.ApplyMods(acpath, true); Console.WriteLine("DONE!"); Console.BackgroundColor = ConsoleColor.DarkBlue; Console.Beep(); Console.ReadKey(); }