public static byte[] GetByml(string XmlText) { BymlConverter app = new BymlConverter(); app.LoadedFile = app.ImportFromXml(XmlText); return(app.LoadedFile.MakeFile(app.LoadedFile.header.BigEndian)); }
public static string GetXml(byte[] Data) { BymlConverter app = new BymlConverter(); app.LoadedFile = new BymlFile(Data); return(app.exportToXml(app.LoadedFile)); }
static void PatchCCNT(string[] Args) { string message = ""; if (Args.Length > 1) { for (int i = 1; i < Args.Length; i++) { message += Args[i] + " "; } } CommonCompressors.YAZ0 y = new CommonCompressors.YAZ0(); NDS.NitroSystem.FND.NARC SzsArch = new NDS.NitroSystem.FND.NARC(); SzsArch = new NDS.NitroSystem.FND.NARC(y.Decompress(File.ReadAllBytes(@"CreatorClassNameTable.szs"))); string ConvertedCCN = BymlConverter.GetXml(SzsArch.ToFileSystem().Files[0].Data); Dictionary <string, string> ccnt = LoadCCNT(ConvertedCCN); Dictionary <string, string> ccnt2 = LoadCCNT(File.ReadAllText("CCNTpatch.xml", Form1.DefEnc)); foreach (string k in ccnt2.Keys.ToArray()) { if (!ccnt.ContainsKey(k)) { ccnt.Add(k, ccnt2[k]); } } FormEditors.FrmCCNTEdit.SaveFile(ref ccnt); MessageBox.Show(message + "\r\n\r\nThe4Dimension by Exelix11\r\nEvery File Explorer by Gericom"); }
static void Main(string[] Args) { System.IO.Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1.DefEnc = Encoding.GetEncoding("Shift-JIS"); if (Args.Length != 0) { if (Args[0].ToLower() == "batch") { AttachConsole(ATTACH_PARENT_PROCESS); Console.Write("\n"); foreach (string a in Args.Skip(1)) { try { string Cont = System.IO.File.ReadAllText(a, Form1.DefEnc); if (Cont.StartsWith("<?xml")) { File.WriteAllBytes(a + ".byml", BymlConverter.GetByml(Cont)); } else if (Cont.StartsWith("YB") || Cont.StartsWith("BY")) { File.WriteAllText(a + ".xml", BymlConverter.GetXml(a), Form1.DefEnc); } else { Console.WriteLine(a + " : filetype not supported"); continue; } Console.WriteLine(a + " : Done"); } catch (Exception ex) { Console.WriteLine(a + " : " + ex.Message); Console.WriteLine(ex.StackTrace); } } FreeConsole(); } else if (Args[0].ToLower() == "ccntpatch") { if (File.Exists(@"CreatorClassNameTable.szs") && File.Exists(@"CCNTpatch.xml")) { PatchCCNT(Args); } else { MessageBox.Show("To apply the patch you need both the CreatorClassNameTable.szs and CCNTpatch.xml in this folder !"); } } else if (File.Exists("CCNTpatch.xml") && !File.Exists("HelixToolkit.Wpf.dll")) { MessageBox.Show("This executable can't be manually launched, run the batch file provided with it."); return; } else { string Cont = System.IO.File.ReadAllText(Args[0], Form1.DefEnc); if (Cont.StartsWith("<?xml") || Cont.StartsWith("YB") || Cont.StartsWith("BY")) { if (Cont.StartsWith("<?xml")) { new FormEditors.FrmXmlEditor(File.ReadAllText(Args[0], Form1.DefEnc), Args[0], true).ShowDialog(); } else { new FormEditors.FrmXmlEditor(BymlConverter.GetXml(Args[0]), Args[0], true).ShowDialog(); } } else { RunApp(Args[0].Trim()); } } } else { if (File.Exists("CCNTpatch.xml") && !File.Exists("HelixToolkit.Wpf.dll")) { MessageBox.Show("This executable can't be manually launched, run the batch file provided with it."); return; } RunApp(); } }