string GetDirectoryFormatCMDStr(TpDicInfo dicInfo, ref TpCmd cmd) { string outputDic = PathAlign(GetOutputDirectory(dicInfo.directoryInfo)) + "/"; string outFormat = outputDic + GetFormatName(dicInfo.directoryInfo.Name, this.m_format); string outFormatPlist = outputDic + GetFormatName(dicInfo.directoryInfo.Name, TPFormat.PLIST); string cmdStr = "TexturePacker "; bool hasPng = false; foreach (TpFileInfo file in dicInfo.files) { if (file.bePng && !file.beInPlist) { cmd.lstTpFile.Add(file); file.tagFileName = GetRelatePath(dicInfo.directoryInfo.FullName) + "/" + GetFormatName(dicInfo.directoryInfo.Name, this.m_format); cmdStr += file.info.FullName + " "; hasPng = true; } } if (!hasPng) { return(""); } cmdStr = cmdStr + TPConfig.cmdStr + " --data " + outFormatPlist + " --sheet " + outFormat + "\n"; cmd.outFormat = outFormat; cmd.outPlist = outFormatPlist; cmd.cmd = cmdStr; return(cmdStr); }
string GetPngFormatCMDStr(TpDicInfo dicInfo) { string cmdStr = ""; if (dicInfo.beTMXMapPath || dicInfo.bePlistBuildList) { foreach (TpFileInfo file in dicInfo.files) { if (file.bePng) { TpCmd cmd = new TpCmd(); cmdStr += GetEachPngFormatCMDStr(file, ref cmd); this.listCmd.Add(cmd); } } } //在CocosStudioProject项目文件夹 else if (dicInfo.beCocosStudioProject) { if (!dicInfo.beNotBuild) { if (dicInfo.beSingleBuild) { foreach (TpFileInfo file in dicInfo.files) { if (file.bePng && !file.beInPlist) { TpCmd cmd = new TpCmd(); cmdStr += GetEachPngFormatCMDStr(file, ref cmd); this.listCmd.Add(cmd); } } } else { TpCmd cmd = new TpCmd(); cmdStr += this.GetDirectoryFormatCMDStr(dicInfo, ref cmd); if (cmd.cmd != "") { this.listCmd.Add(cmd); } } } else //TODO:不打包png,直接复制 { } } //TODO:未在CocosStudioProject项目文件夹,需要酌情处理 else { } foreach (TpDicInfo subdicInfo in dicInfo.directorys) { cmdStr += GetPngFormatCMDStr(subdicInfo); } return(cmdStr); }
void ProcessCmd(TpCmd cmd) { this.AddLogContent("处理文件夹:" + GetRelatePath(cmd.lstTpFile[0].parent.directoryInfo.FullName)); this.AddLogContent("处理图片: "); string pngs = ""; foreach (TpFileInfo tpInfo in cmd.lstTpFile) { pngs += tpInfo.info.Name + " "; } this.AddLogContent(pngs); string result = cmd.cmd; Process p = new Process(); // 初始化新的进程 p.StartInfo.FileName = "CMD.EXE"; //创建CMD.EXE 进程 p.StartInfo.RedirectStandardInput = true; //重定向输入 p.StartInfo.RedirectStandardOutput = true; //重定向输出 p.StartInfo.UseShellExecute = false; // 不调用系统的Shell p.StartInfo.RedirectStandardError = true; // 重定向Error p.StartInfo.CreateNoWindow = true; //不创建窗口 p.Start(); // 启动进程 p.StandardInput.WriteLine(result); // Cmd 命令 p.StandardInput.WriteLine("exit"); // 退出 p.WaitForExit(); this.AddLogContent("生成:" + cmd.outFormat); this.AddLogContent("生成:" + cmd.outPlist); this.AddLogContent("******************************************生成成功******************************************\r\n"); }
/// <summary> /// 获取单个文件的TexturePacker命令行 /// </summary> /// <returns></returns> string GetEachPngFormatCMDStr(TpFileInfo file, ref TpCmd cmd) { cmd.lstTpFile.Add(file); string outputDic = PathAlign(GetOutputDirectory(file.parent.directoryInfo)) + "/"; string outFormat = outputDic + GetFormatName(file.info.Name, this.m_format); string outFormatPlist = GetSinglePlistDirectory() + "/" + GetFormatName(file.info.Name, TPFormat.PLIST); file.tagFileName = GetCocostudioRelatePath(file.parent.directoryInfo.FullName + "/" + GetFormatName(file.info.Name, this.m_format)); cmd.outFormat = outFormat; cmd.outPlist = outFormatPlist; string cmdStr = "TexturePacker " + file.info.FullName + TPConfig.singleCmdStr + " --data " + outFormatPlist + " --sheet " + outFormat; cmdStr = cmdStr + "\n"; cmd.cmd = cmdStr; m_tpInfos[GetCocostudioRelatePath(file.parent.directoryInfo.FullName) + "/" + file.info.Name] = file; return(cmdStr); }
string GetDirectoryFormatCMDStr(TpDicInfo dicInfo,ref TpCmd cmd) { string outputDic = PathAlign(GetOutputDirectory(dicInfo.directoryInfo)) + "/"; string outFormat = outputDic + GetFormatName(dicInfo.directoryInfo.Name, this.m_format); string outFormatPlist = outputDic + GetFormatName(dicInfo.directoryInfo.Name, TPFormat.PLIST); string cmdStr = "TexturePacker "; bool hasPng = false; foreach (TpFileInfo file in dicInfo.files) { if (file.bePng && !file.beInPlist) { cmd.lstTpFile.Add(file); file.tagFileName = GetRelatePath(dicInfo.directoryInfo.FullName) + "/" + GetFormatName(dicInfo.directoryInfo.Name, this.m_format); cmdStr += file.info.FullName + " "; hasPng = true; } } if (!hasPng) { return ""; } cmdStr = cmdStr + TPConfig.cmdStr + " --data " + outFormatPlist + " --sheet " + outFormat + "\n"; cmd.outFormat = outFormat; cmd.outPlist = outFormatPlist; cmd.cmd = cmdStr; return cmdStr; }
/// <summary> /// 获取单个文件的TexturePacker命令行 /// </summary> /// <returns></returns> string GetEachPngFormatCMDStr(TpFileInfo file,ref TpCmd cmd) { cmd.lstTpFile.Add(file); string outputDic = PathAlign(GetOutputDirectory(file.parent.directoryInfo)) + "/"; string outFormat = outputDic + GetFormatName(file.info.Name, this.m_format); string outFormatPlist = GetSinglePlistDirectory() + "/" + GetFormatName(file.info.Name,TPFormat.PLIST); file.tagFileName = GetCocostudioRelatePath(file.parent.directoryInfo.FullName + "/" + GetFormatName(file.info.Name, this.m_format)); cmd.outFormat = outFormat; cmd.outPlist = outFormatPlist; string cmdStr = "TexturePacker " + file.info.FullName + TPConfig.singleCmdStr + " --data " + outFormatPlist + " --sheet " + outFormat; cmdStr = cmdStr + "\n"; cmd.cmd = cmdStr; m_tpInfos[GetCocostudioRelatePath(file.parent.directoryInfo.FullName) + "/"+file.info.Name] = file; return cmdStr; }
string GetPngFormatCMDStr(TpDicInfo dicInfo) { string cmdStr = ""; if (dicInfo.beTMXMapPath || dicInfo.bePlistBuildList) { foreach (TpFileInfo file in dicInfo.files) { if (file.bePng) { TpCmd cmd = new TpCmd(); cmdStr += GetEachPngFormatCMDStr(file, ref cmd); this.listCmd.Add(cmd); } } } //在CocosStudioProject项目文件夹 else if (dicInfo.beCocosStudioProject) { if (!dicInfo.beNotBuild) { if (dicInfo.beSingleBuild) { foreach (TpFileInfo file in dicInfo.files) { if (file.bePng && !file.beInPlist) { TpCmd cmd = new TpCmd(); cmdStr += GetEachPngFormatCMDStr(file, ref cmd); this.listCmd.Add(cmd); } } } else { TpCmd cmd = new TpCmd(); cmdStr += this.GetDirectoryFormatCMDStr(dicInfo,ref cmd); if (cmd.cmd != "") { this.listCmd.Add(cmd); } } } else //TODO:不打包png,直接复制 { } } //TODO:未在CocosStudioProject项目文件夹,需要酌情处理 else { } foreach (TpDicInfo subdicInfo in dicInfo.directorys) { cmdStr += GetPngFormatCMDStr(subdicInfo); } return cmdStr; }
void ProcessCmd(TpCmd cmd) { this.AddLogContent("处理文件夹:" + GetRelatePath(cmd.lstTpFile[0].parent.directoryInfo.FullName)); this.AddLogContent("处理图片: "); string pngs = ""; foreach (TpFileInfo tpInfo in cmd.lstTpFile) { pngs += tpInfo.info.Name + " "; } this.AddLogContent(pngs); string result = cmd.cmd; Process p = new Process(); // 初始化新的进程 p.StartInfo.FileName = "CMD.EXE"; //创建CMD.EXE 进程 p.StartInfo.RedirectStandardInput = true; //重定向输入 p.StartInfo.RedirectStandardOutput = true;//重定向输出 p.StartInfo.UseShellExecute = false; // 不调用系统的Shell p.StartInfo.RedirectStandardError = true; // 重定向Error p.StartInfo.CreateNoWindow = true; //不创建窗口 p.Start(); // 启动进程 p.StandardInput.WriteLine(result); // Cmd 命令 p.StandardInput.WriteLine("exit"); // 退出 p.WaitForExit(); this.AddLogContent("生成:" + cmd.outFormat); this.AddLogContent("生成:" + cmd.outPlist); this.AddLogContent("******************************************生成成功******************************************\r\n"); }