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); }
private TpDicInfo GetTpDicInfoByType(TpDicInfo par, DICTYPE type) { foreach (TpDicInfo dic in par.directorys) { if (type == DICTYPE.CocostudioType) { if (dic.beCocosStudioProject) { return(dic); } } else if (type == DICTYPE.MapType) { if (TPConfig.BeTmxMap(dic.directoryInfo.Name)) { return(dic); } } TpDicInfo sub = GetTpDicInfoByType(dic, type); if (sub != null) { return(sub); } } return(null); }
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); }
public TpFileInfo(FileInfo info, TpDicInfo parent) { this.info = info; this.parent = parent; this.beInPlist = false; this.tagFileName = ""; if (info.Name.EndsWith(".png") || info.Name.EndsWith(".PNG")) { this.bePng = true; } }
void initPlistBuild(TpDicInfo dicInfo, ref List <TpDicInfo> listDicInfo) { if (dicInfo.bePlistBuildList) { listDicInfo.Add(dicInfo); } foreach (TpDicInfo dic in dicInfo.directorys) { initPlistBuild(dic, ref listDicInfo); } }
private void btn_create_Click(object sender, EventArgs e) { fileCongig.filePath = PathAlign(txt_work.Text); fileCongig.createPath = PathAlign(txt_create.Text); if (fileCongig.filePath == "") { MessageBox.Show("请选择资源目录"); return; } if (!Directory.Exists(fileCongig.filePath)) { MessageBox.Show("请选择正确的择资源目录"); return; } if (fileCongig.createPath == "") { MessageBox.Show("请选择保存目录"); return; } if (!Directory.Exists(fileCongig.createPath)) { MessageBox.Show("请选择正确保存目录"); return; } fileCongig.SaveFileConfig(); listCmd.Clear(); m_tpInfos.Clear(); DirectoryInfo dicInfo = new DirectoryInfo(fileCongig.filePath); this.m_rootDic = new TpDicInfo(dicInfo, null); DirectoryInfo srcdicInfo = new DirectoryInfo(fileCongig.filePath + "/../src"); this.m_srcDic = new TpDicInfo(srcdicInfo, null); this.m_cocostudioDic = this.GetCocoStudioDir(); this.m_mapDic = this.GetMapDir(); string result = GetPngFormatCMDStr(this.m_rootDic); CopyFileAndInitTpInfos(); DealTMXMAp(); DealPlistBuild(); StartCreate(); CreatNormalListJson(); CreateCocoStudioListJson(); ModifyAllCocostudioJson(); }
void CIDictory(TpDicInfo dicInfo) { this.AddLogContent("处理文件夹:" + dicInfo.directoryInfo.Name); if (dicInfo == this.m_mapDic) { return; } if (dicInfo.bePlistBuildList) { return; } if (!dicInfo.beCocosStudioProject || (dicInfo.beCocosStudioProject && dicInfo.beNotBuild)) { foreach (TpFileInfo file in dicInfo.files) { this.AddLogContent("移动文件:" + file.info.Name); string outputPath = PathAlign(GetOutputDirectory(dicInfo.directoryInfo)) + "/" + file.info.Name; System.IO.File.Copy(file.info.FullName, outputPath, true); } } else { foreach (TpFileInfo file in dicInfo.files) { if (file.beInPlist) { this.AddLogContent("移动文件:" + file.info.Name); string outputPath = PathAlign(GetOutputDirectory(dicInfo.directoryInfo)) + "/" + file.info.Name; System.IO.File.Copy(file.info.FullName, outputPath, true); } else if (!file.bePng) { this.AddLogContent("移动文件:" + file.info.Name); string outputPath = PathAlign(GetOutputDirectory(dicInfo.directoryInfo)) + "/" + file.info.Name; System.IO.File.Copy(file.info.FullName, outputPath, true); } } } foreach (TpDicInfo info in dicInfo.directorys) { CIDictory(info); } }
private void GetAllNormalTPFiles(TpDicInfo dic, ref List <TpFileInfo> lst, bool beCocostudio = false) { if (beCocostudio == false && dic.beCocosStudioProject == true) { return; } List <TpFileInfo> allFiles = dic.files; for (int index = 0; index < allFiles.Count; index++) { List <string> files = new List <string>(); lst.Add(allFiles[index]); } List <TpDicInfo> alldirectory = dic.directorys; for (int index = 0; index < alldirectory.Count; index++) { GetAllNormalTPFiles(alldirectory[index], ref lst, beCocostudio); } }
private TpDicInfo GetTpDicInfoByType(TpDicInfo par, DICTYPE type) { foreach (TpDicInfo dic in par.directorys) { if (type == DICTYPE.CocostudioType) { if (dic.beCocosStudioProject) { return dic; } } else if (type == DICTYPE.MapType) { if (TPConfig.BeTmxMap(dic.directoryInfo.Name)) { return dic; } } TpDicInfo sub = GetTpDicInfoByType(dic, type); if (sub != null) { return sub; } } return null; }
private void btn_create_Click(object sender, EventArgs e) { fileCongig.filePath = PathAlign(txt_work.Text); fileCongig.createPath = PathAlign(txt_create.Text); if (fileCongig.filePath == "") { MessageBox.Show("请选择资源目录"); return; } if (!Directory.Exists(fileCongig.filePath)) { MessageBox.Show("请选择正确的择资源目录"); return; } if (fileCongig.createPath == "") { MessageBox.Show("请选择保存目录"); return; } if (!Directory.Exists(fileCongig.createPath)) { MessageBox.Show("请选择正确保存目录"); return; } fileCongig.SaveFileConfig(); listCmd.Clear(); m_tpInfos.Clear(); DirectoryInfo dicInfo = new DirectoryInfo(fileCongig.filePath); this.m_rootDic = new TpDicInfo(dicInfo, null); DirectoryInfo srcdicInfo = new DirectoryInfo(fileCongig.filePath + "/../src"); this.m_srcDic = new TpDicInfo(srcdicInfo, null); this.m_cocostudioDic = this.GetCocoStudioDir(); this.m_mapDic = this.GetMapDir(); string result = GetPngFormatCMDStr(this.m_rootDic); CopyFileAndInitTpInfos(); DealTMXMAp(); DealPlistBuild(); StartCreate(); CreatNormalListJson(); CreateCocoStudioListJson(); ModifyAllCocostudioJson(); }
private void GetAllNormalTPFiles(TpDicInfo dic, ref List<TpFileInfo> lst,bool beCocostudio = false) { if (beCocostudio == false && dic.beCocosStudioProject == true) { return; } List<TpFileInfo> allFiles = dic.files; for (int index = 0; index < allFiles.Count; index++) { List<string> files = new List<string>(); lst.Add(allFiles[index]); } List<TpDicInfo> alldirectory = dic.directorys; for (int index = 0; index < alldirectory.Count; index++) { GetAllNormalTPFiles(alldirectory[index], ref lst, beCocostudio); } }
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 CIDictory(TpDicInfo dicInfo) { this.AddLogContent("处理文件夹:" + dicInfo.directoryInfo.Name); if (dicInfo == this.m_mapDic) { return; } if (dicInfo.bePlistBuildList) { return; } if (!dicInfo.beCocosStudioProject || (dicInfo.beCocosStudioProject && dicInfo.beNotBuild)) { foreach (TpFileInfo file in dicInfo.files) { this.AddLogContent("移动文件:" + file.info.Name); string outputPath = PathAlign(GetOutputDirectory(dicInfo.directoryInfo)) + "/" + file.info.Name; System.IO.File.Copy(file.info.FullName, outputPath, true); } } else { foreach (TpFileInfo file in dicInfo.files) { if (file.beInPlist) { this.AddLogContent("移动文件:" + file.info.Name); string outputPath = PathAlign(GetOutputDirectory(dicInfo.directoryInfo)) + "/" + file.info.Name; System.IO.File.Copy(file.info.FullName, outputPath, true); } else if (!file.bePng) { this.AddLogContent("移动文件:" + file.info.Name); string outputPath = PathAlign(GetOutputDirectory(dicInfo.directoryInfo)) + "/" + file.info.Name; System.IO.File.Copy(file.info.FullName, outputPath, true); } } } foreach (TpDicInfo info in dicInfo.directorys) { CIDictory(info); } }
public TpDicInfo(DirectoryInfo directoryInfo, TpDicInfo parent) { this.directoryInfo = directoryInfo; this.parent = parent; if (parent == null) { this.beNotBuild = false; this.beSingleBuild = false; this.beCocosStudioProject = false; this.bePlistBuildList = false; this.beTMXMapPath = false; } else { this.beNotBuild = parent.beNotBuild; this.beSingleBuild = parent.beSingleBuild; this.beCocosStudioProject = parent.beCocosStudioProject; this.bePlistBuildList = parent.bePlistBuildList; this.beTMXMapPath = parent.beTMXMapPath; } if (!this.beNotBuild) { if (TPConfig.BeInNotBuildList(this.directoryInfo.Name)) { this.beNotBuild = true; } } if (!this.beSingleBuild) { if (TPConfig.BeInSingleBuildList(this.directoryInfo.Name)) { this.beSingleBuild = true; } } if (!this.beCocosStudioProject) { if (TPConfig.BeInCocoStudioList(this.directoryInfo.Name)) { this.beCocosStudioProject = true; } } if (!this.bePlistBuildList) { if (TPConfig.BeInPlistBuildList(this.directoryInfo.Name)) { this.bePlistBuildList = true; } } if (!this.beTMXMapPath) { if (TPConfig.BeTmxMap(this.directoryInfo.Name)) { this.beTMXMapPath = true; } } FileInfo [] fs = directoryInfo.GetFiles(); foreach (FileInfo info in fs) { files.Add(new TpFileInfo(info, this)); } for (int index = 0; index < files.Count; index++) { TpFileInfo info = files[index]; if (info.bePng) { if (BePngInPlist(files, info.info.Name)) { files[index].beInPlist = true; } } else { if (info.info.Name.EndsWith(".plist")) { if (BePlistInPlist(files, info.info.Name)) { files[index].beInPlist = true; } } } } DirectoryInfo[] dicInfos = directoryInfo.GetDirectories(); foreach (DirectoryInfo info in dicInfos) { directorys.Add(new TpDicInfo(info, this)); } }
public TpFileInfo(FileInfo info, TpDicInfo parent) { this.info = info; this.parent = parent; this.beInPlist = false; this.tagFileName = ""; if (info.Name.EndsWith(".png") || info.Name.EndsWith(".PNG")) { this.bePng = true; } }
public TpDicInfo(DirectoryInfo directoryInfo, TpDicInfo parent) { this.directoryInfo = directoryInfo; this.parent = parent; if (parent == null) { this.beNotBuild = false; this.beSingleBuild = false; this.beCocosStudioProject = false; this.bePlistBuildList = false; this.beTMXMapPath = false; } else { this.beNotBuild = parent.beNotBuild; this.beSingleBuild = parent.beSingleBuild; this.beCocosStudioProject = parent.beCocosStudioProject; this.bePlistBuildList = parent.bePlistBuildList; this.beTMXMapPath = parent.beTMXMapPath; } if (!this.beNotBuild) { if (TPConfig.BeInNotBuildList(this.directoryInfo.Name)) { this.beNotBuild = true; } } if (!this.beSingleBuild) { if (TPConfig.BeInSingleBuildList(this.directoryInfo.Name)) { this.beSingleBuild = true; } } if (!this.beCocosStudioProject) { if (TPConfig.BeInCocoStudioList(this.directoryInfo.Name)) { this.beCocosStudioProject = true; } } if (!this.bePlistBuildList) { if (TPConfig.BeInPlistBuildList(this.directoryInfo.Name)) { this.bePlistBuildList = true; } } if (!this.beTMXMapPath) { if (TPConfig.BeTmxMap(this.directoryInfo.Name)) { this.beTMXMapPath = true; } } FileInfo []fs = directoryInfo.GetFiles(); foreach (FileInfo info in fs) { files.Add(new TpFileInfo(info, this)); } for (int index = 0; index < files.Count;index++ ) { TpFileInfo info = files[index]; if (info.bePng) { if (BePngInPlist(files, info.info.Name)) { files[index].beInPlist = true; } } else { if (info.info.Name.EndsWith(".plist")) { if (BePlistInPlist(files, info.info.Name)) { files[index].beInPlist = true; } } } } DirectoryInfo[] dicInfos = directoryInfo.GetDirectories(); foreach (DirectoryInfo info in dicInfos) { directorys.Add(new TpDicInfo(info, this)); } }
void initPlistBuild(TpDicInfo dicInfo, ref List<TpDicInfo> listDicInfo) { if (dicInfo.bePlistBuildList) { listDicInfo.Add(dicInfo); } foreach (TpDicInfo dic in dicInfo.directorys) { initPlistBuild(dic, ref listDicInfo); } }