/// <summary> /// decompiles the flowscript returns true if it is successful /// </summary> private static bool TryDoFlowScriptDecompilation() { // Load binary file Logger.ConsoleInfo("Loading binary FlowScript file..."); FlowScript flowScript = null; var encoding = MessageScriptEncoding; var format = GetFlowScriptFormatVersion(); if (!TryPerformAction("Failed to load flow script from file", () => flowScript = FlowScript.FromFile(InputFilePath, encoding, format))) { return(false); } Logger.ConsoleInfo("Decompiling FlowScript..."); var decompiler = new FlowScriptDecompiler(); decompiler.Library = library; decompiler.AddListener(Listener); if (LibraryName != null) { var library = LibraryLookup.GetLibrary(LibraryName); if (library == null) { Logger.ConsoleError("Invalid library name specified"); return(false); } decompiler.Library = library; } if (!decompiler.TryDecompile(flowScript, OutputFilePath)) { Logger.ConsoleError("Failed to decompile FlowScript"); return(false); } //open flow script return(true); }
private static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Missing directory path argument"); return; } var directoryPath = args[0]; // @"D:\Modding\Persona 5 EU\Main game\ExtractedClean" var logger = new Logger(nameof(AtlusFlowScriptExtractor)); var listener = new ConsoleLogListener(true, LogLevel.All); listener.Subscribe(logger); using (var streamWriter = FileUtils.CreateText("AtlusFlowScriptExtractorOutput.txt")) { foreach (var file in Directory.EnumerateFiles(directoryPath, "*", SearchOption.AllDirectories)) { foreach (var foundScript in FindFlowScripts(file)) { var decompiler = new FlowScriptDecompiler(); decompiler.AddListener(listener); decompiler.Library = LibraryLookup.GetLibrary("p5"); decompiler.DecompileMessageScript = false; if (!decompiler.TryDecompile(foundScript.Item1, out var compilationUnit)) { logger.Error($"Failed to decompile FlowScript in: {foundScript.Item2}"); continue; } var writer = new CompilationUnitWriter(); streamWriter.WriteLine(); streamWriter.WriteLine("//"); streamWriter.WriteLine($"// File: {foundScript.Item2}"); streamWriter.WriteLine("//"); streamWriter.WriteLine(); writer.Write(compilationUnit, streamWriter); } } } logger.Info("Done"); }