static void CompileFile(string inputPath, string outputPath) { outputPath = String.IsNullOrEmpty(outputPath) ? inputPath : outputPath; outputPath = Path.ChangeExtension(outputPath, ".MBIN"); var data = EXmlFile.ReadTemplate(inputPath); if (data == null) { Console.WriteLine("Failed to deserialize EXML file, is it formatted correctly?"); return; } if (data.GetType() == typeof(TkGeometryData)) { outputPath = Path.ChangeExtension(outputPath, ".MBIN.PC"); } if (File.Exists(outputPath)) { File.Delete(outputPath); // todo: ask for confirmation? } using (var file = new MBINFile(outputPath)) { file.Header = new MBINHeader(); file.Header.SetDefaults(); if (data.GetType() == typeof(TkGeometryData)) { file.Header.Magic = 0xDDDDDDDD; // only used by TkGeometryData / .MBIN.PC files, maybe used to signal the file is PC only? } if (data.GetType() == typeof(TkAnimMetadata)) { file.Header.Tag = 0xFFFFFFFFFFFFFFFF; file.Header.MbinVersion = 0x9B251350AE1ABCA7; file.Header.EndPadding = 0xFEFEFEFEFEFEFEFE; } file.SetData(data); // this will also get the length of the data if (data.GetType() != typeof(TkAnimMetadata)) { file.Header.EndPadding = file.FileLength; } file.Save(); } Console.WriteLine($"MBIN data written to \"{outputPath}\" successfully?"); }
static void CompileFile(string input, string output) { if (String.IsNullOrEmpty(output)) { output = input; } output = Path.ChangeExtension(output, ".MBIN"); var data = EXmlFile.ReadTemplate(input); if (data == null) { Console.WriteLine("Failed to deserialize EXML file, is it formatted correctly?"); return; } if (data.GetType() == typeof(Models.Structs.TkGeometryData)) { output = Path.ChangeExtension(output, ".MBIN.PC"); } if (File.Exists(output)) { File.Delete(output); // todo: ask for confirmation? } using (var file = new MBINFile(output)) { file.Header = new Models.MBINHeader(); file.Header.SetDefaults(); if (data.GetType() == typeof(Models.Structs.TkGeometryData)) { file.Header.Magic = 0xDDDDDDDD; // only used by TkGeometryData / .MBIN.PC files, maybe used to signal the file is PC only? } file.SetData(data); file.Save(); } Console.WriteLine($"MBIN data written to \"{output}\" successfully?"); }