private static bool TryDoMessageScriptCompilation() { // Compile source Logger.Info("Compiling MessageScript..."); var version = GetMessageScriptFormatVersion(); if (version == AtlusScriptLibrary.MessageScriptLanguage.FormatVersion.Detect) { Logger.Error("Invalid MessageScript file format"); return(false); } var encoding = GetEncoding(); var compiler = new MessageScriptCompiler(GetMessageScriptFormatVersion(), encoding); compiler.AddListener(Listener); if (LibraryName != null) { var library = LibraryLookup.GetLibrary(LibraryName); if (library == null) { Logger.Error("Invalid library name specified"); return(false); } compiler.Library = library; } bool success = false; MessageScript script = null; try { success = compiler.TryCompile(File.OpenText(InputFilePath), out script); } catch (UnsupportedCharacterException e) { Logger.Error($"Character '{e.Character}' not supported by encoding '{e.EncodingName}'"); } if (!success) { Logger.Error("One or more errors occured during compilation!"); return(false); } // Write binary Logger.Info("Writing binary to file..."); if (!TryPerformAction("An error occured while saving the file.", () => script.ToFile(OutputFilePath))) { return(false); } return(true); }
public void TryCompile_DialogWindow_ShouldReturnTrue() { string input = $"[dlg {GenerateTestIdentifier()} {GenerateTestIdentifier()}][f 0 5 0xFFFF][f 3 77 0xffff][f 222 222 -1][x 8223 39755]jasdhjdhquyqwy2893y38973290188290804759856273y3dhjakbdnbx zx dkjaughwuidhkadjiyquwd9u892y3gahsdkjqbwhgua../,/.,.,/..,/.,';;';';';';!!!!!=-=-=-=\\\\ \n\\!@##@#$%^&***()_+:[e][e]-80253895639258310-11239057825257389"; var compiler = new MessageScriptCompiler(FormatVersion.Version1BigEndian); Assert.IsTrue(compiler.TryCompile(input, out var script)); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine($"Missing filename"); return; } MessageScript msg = null; var filePath = args[0]; if (filePath.EndsWith("bf", StringComparison.InvariantCultureIgnoreCase)) { msg = FlowScript.FromFile(filePath).MessageScript; } else if (filePath.EndsWith("bmd")) { msg = MessageScript.FromFile(args[0]); } else if (filePath.EndsWith("msg")) { var msgCompiler = new MessageScriptCompiler(AtlusScriptLibrary.MessageScriptLanguage.FormatVersion.Version1); msg = msgCompiler.Compile(File.OpenText(filePath)); } else { Console.WriteLine("Can't detect input type (unknown extension)"); return; } using (var writer = File.CreateText($"{Path.GetFileNameWithoutExtension( args[ 0 ] )}_ids.txt")) { for (var i = 0; i < msg.Dialogs.Count; i++) { var dialog = msg.Dialogs[i]; writer.WriteLine($"{i}\t\t{dialog.Name}"); } } }