public void Process(ref MorphemeAssetProcessor.Result result) { try { // get the paths from the Network string mcpFile; string mcnFile; string intermediateFile; MorphemeHelper.GetFilePathsFromNetwork(Network, ExportRootPath, out mcpFile, out mcnFile, out intermediateFile); result.Platform = AssetCompilerExe; if (File.Exists(intermediateFile) == false) { result.Success = false; result.ErrorString = "Cannot find intermediate file: " + intermediateFile; return; } // extract the root path FileInfo mcpfileInfo = new FileInfo(mcpFile); string rootPath = mcpfileInfo.DirectoryName; string commandLine = "-baseDir \"" + rootPath + "\" -outputDir \"" + ExportRootPath + ProcessSubPath + "\" " + Settings.GetInstance().AssetCompilerCommandLine + " -asset \"" + intermediateFile + "\""; if (!CommandLineOptions.Equals("")) { commandLine += " "; commandLine += CommandLineOptions; } // get ready to start the asset compiler with the above command line in a hidden window ProcessStartInfo procStartInfo = new ProcessStartInfo(AssetCompilerExe, commandLine); procStartInfo.WindowStyle = ProcessWindowStyle.Hidden; // run the asset compiler using (Process proc = System.Diagnostics.Process.Start(procStartInfo)) { // wait for the process to end proc.WaitForExit(); if (proc.ExitCode != 0) { result.Success = false; result.ErrorString = AssetCompilerExe + " " + commandLine + " exited with code " + proc.ExitCode.ToString(); } } } catch (System.Exception ex) { result.Success = false; result.ErrorString = ex.ToString(); } }
public void BatchExport(ref MorphemeConnectExporter.Result result) { try { string morphemeConnectExe = MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().MorphemeConnectPath); string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); appDataFolder += MorphemeConnectExporter.AppDataSubFolder; string luaLogDirectory = appDataFolder += MorphemeConnectExporter.LuaLogSubDirectory; if (false == Directory.Exists(luaLogDirectory)) { Directory.CreateDirectory(luaLogDirectory); } string lua = ""; foreach (MorphemeConnectData morphemeConnectData in morphemeConnectDataList) { string mcpFile; string mcnFile; string intermediateFile; MorphemeHelper.GetFilePathsFromNetwork(morphemeConnectData.Network, morphemeConnectData.ExportPath, out mcpFile, out mcnFile, out intermediateFile); // TODO optimization. pre-sort on mcp and only open when project changes // generate the lua to open the project, open the mcn and export the mcn lua += string.Format(" project.open({0})\n mcn.open({1})\n mcn.export({2})", '\"' + mcpFile + '\"', '\"' + mcnFile + '\"', '\"' + intermediateFile + "\"\n"); } string luaFileName = "BatchExport_" + DateTime.Now.Ticks.ToString() + ".lua"; MorphemeHelper.CreateLuaAndLaunchConnect(luaFileName, lua, morphemeConnectExe, ref result); } catch (System.Exception ex) { result.Success = false; result.ErrorString = ex.ToString(); } }
public void Export(ref MorphemeConnectExporter.Result result) { try { string morphemeConnectExe = MacrosSystem.GetInstance().ExpandMacro(Settings.GetInstance().MorphemeConnectPath); string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); appDataFolder += MorphemeConnectExporter.AppDataSubFolder; string luaLogDirectory = appDataFolder += MorphemeConnectExporter.LuaLogSubDirectory; if (false == Directory.Exists(luaLogDirectory)) { Directory.CreateDirectory(luaLogDirectory); } string mcpFile; string mcnFile; string intermediateFile; MorphemeHelper.GetFilePathsFromNetwork(morphemeConnectData.Network, morphemeConnectData.ExportPath, out mcpFile, out mcnFile, out intermediateFile); // generate the lua to open the project, open the mcn and export the mcn string lua = string.Format(" project.open({0})\n mcn.open({1})\n mcn.export({2})", '\"' + mcpFile + '\"', '\"' + mcnFile + '\"', '\"' + intermediateFile + '\"'); // generate the lua fileName FileInfo mcnfileInfo = new FileInfo(mcnFile); string luaFileName = Path.GetFileNameWithoutExtension(mcnfileInfo.Name); luaFileName += "_" + DateTime.Now.Ticks.ToString() + ".lua"; MorphemeHelper.CreateLuaAndLaunchConnect(luaFileName, lua, morphemeConnectExe, ref result); } catch (System.Exception ex) { result.Success = false; result.ErrorString = ex.ToString(); } }