做网站什么主题比较好,深圳创业补贴2024,济南市住房和城乡建设局网站,chatgpt 网址创建cocos工程.bat在多人合作的cocos项目中#xff0c;大家公用一个ccs文件#xff0c;存在的问题是如果大家都提交ccs文件比较容易出现冲突#xff0c;解决冲突麻烦要耗费时间#xff0c;不提交的话就拉不到其他人更新的csd文件。
方案一 解决冲突#xff0c;更新提交c…创建cocos工程.bat在多人合作的cocos项目中大家公用一个ccs文件存在的问题是如果大家都提交ccs文件比较容易出现冲突解决冲突麻烦要耗费时间不提交的话就拉不到其他人更新的csd文件。
方案一 解决冲突更新提交ccs文件
这种方案也可以说没有方案容易造成开发人员不愿意提交自己的ccs文件
方案二 每个人拷贝一个ccs文件自己用
这种方案比较简单粗暴缺点是要看别人的csd文件需要打开别人的工程
方案三 ccs文件不进行维护由脚本生成
先说工作流当需要看别人的csd的时候
1.更新svn(假如版控用svn)
2.执行脚本
CreateCocosProject.py注意读者需要根据脚本存放位置适当修改文件
#!/usr/bin/python
# -*- coding: utf-8 -*-import os, shutil, re, sys
import xml.etree.ElementTree as ET
from xml.dom import minidomSCRIPT_PATH os.path.dirname(os.path.realpath(__file__))COCOS_PATH os.path.realpath(os.path.join(SCRIPT_PATH, .., cocosstudio))
PROJECT_NAME sys.argv[1]# COCOS_INCLUDE_DIRS {res:True, csb:True, preview:True}
# COCOS_UNINCLUDE_DIRS {res/csb:True, res/spine:True, res/chatEmoji:True}
OUT_PATH os.path.realpath(os.path.join(COCOS_PATH, ..,PROJECT_NAME))# 获取csd文件类型
def GetCsdFileType(csdPath):print(csdPath)tree ET.parse(csdPath)propertyGroupNode tree.getroot().find(./PropertyGroup)attrib propertyGroupNode.attribreturn attrib[Type]#创建一个工程节点
def CreateProjectNode(csdPath):e ET.Element(Project)csdType GetCsdFileType(csdPath)csdName os.path.basename(csdPath)e.set(Type, csdType)e.set(Name, csdName)return e#获取plsit文件frames
def GetPlistFrames(plistPath):tree ET.parse(plistPath)rootDict tree.getroot().find(dict)frames []dictList list(rootDict)sizeStr for i in range(0, len(dictList), 2):node1 dictList[i]node2 dictList[i1]if node1.text frames:framesNodes node2.findall(./key)for frameNameNode in framesNodes:frames.append(frameNameNode.text)return framesdef CreatePListNode(plistPath):e ET.Element(PlistImageFolder)plistName os.path.basename(plistPath)plistBaseName os.path.splitext(plistName)[0]e.set(PListFile, plistName)e.set(Name, .%s_PList.Dir % plistBaseName)# 添加子节点frames GetPlistFrames(plistPath)for frame in frames:childE ET.Element(PlistImageFile)childE.set(Name, frame)childE.set(Key, frame)e.append(childE)return edef CreateFolderNode(folderName):e ET.Element(Folder)e.set(Name, folderName)return edef CreateNode(tag, filePath):e ET.Element(tag)eBaseName os.path.basename(filePath)e.set(Name, eBaseName)return e
def CreateCsiNode(csiName):eBaseName os.path.basename(csiName)e ET.Element(PlistInfo)eBaseName os.path.basename(csiName)e.set(Name, eBaseName)e.set(Type, Plist)return ezh_pattern re.compile(u[\u4e00-\u9fa5])
def contain_zh(word):if word.find( ) ! -1:print(uError:发现空格)print(word)return Truetry:word word.encode(utf-8)global zh_patternmatch zh_pattern.search(word)return matchexcept UnicodeError:print(uError:发现中文)print(word)return Truereturn matchdef CreateHead():Solution ET.Element(Solution)PropertyGroup ET.Element(PropertyGroup, {Name:CocosProject, Type:CocosStudio, Version:3.10.0.0})SolutionFolder ET.Element(SolutionFolder)Group ET.Element(Group, {ctype:ResourceGroup})RootFolder ET.Element(RootFolder, {Name:.})Solution.append(PropertyGroup)Solution.append(SolutionFolder)SolutionFolder.append(Group)Group.append(RootFolder)return Solution, RootFolderdef checkCanAdd(dirName):# if dirName.find(.svn) ! -1:# return False# p dirName[len(COCOS_PATH) 1:]# p p.replace(os.path.sep, /)# for k in COCOS_INCLUDE_DIRS:# if re.match(r^%s.*%k, p):# for j in COCOS_UNINCLUDE_DIRS:# if re.match(r^%s.*%j, p):# return False# return Truereturn Truedef TraversalDir(dirPath):rootNode, rootFolderNode CreateHead()nodeDict {}nodeDict[] rootNodeindex 0for root, dirs, files in os.walk(dirPath):if not checkCanAdd(root):continueif re.match(r.*_PList.Dir.*, root):continueif contain_zh(root):exit(-1)tempFolderPath root[len(COCOS_PATH) 1:]rIndex tempFolderPath.rfind(os.path.sep)folderNode NonedirName NonedirKey Noneif -1 ! rIndex:dirName tempFolderPath[rIndex1:]dirKey tempFolderPath[0:rIndex]parentNode nodeDict[dirKey]folderNode CreateFolderNode(dirName)parentNode.append(folderNode)nodeDict[tempFolderPath] folderNodeelif tempFolderPath :folderNode rootFolderNodeelse:folderNode CreateFolderNode(tempFolderPath)nodeDict[tempFolderPath] folderNoderootFolderNode.append(folderNode)for file in files:if contain_zh(os.path.join(root, file)):exit(-1)childNode Noneext os.path.splitext(file)if len(ext) 2 :extName ext[1].lower()if extName .png or extName .jpg:if not os.path.exists(os.path.join(root, ext[0].plist)):childNode CreateNode(Image, file)elif extName .mp3:childNode CreateNode(Audio, file)elif extName .ttf:childNode CreateNode(TTF, file)elif extName .fnt:childNode CreateNode(Fnt, file)elif extName .csd:fullCsdPath os.path.join(root, file)childNode CreateProjectNode(fullCsdPath)elif extName .csi:childNode CreateCsiNode(file)elif extName .plist:if root.find(particle) ! -1:childNode CreateNode(PlistParticleFile, file) else:if os.path.exists(os.path.join(root, ext[0].png)):fullPlistPath os.path.join(root, file)childNode CreatePListNode(fullPlistPath)if childNode is not None:folderNode.append(childNode)# tree.write(OUT_PATH)# strArr PrettyDumpXml(rootNode, 0)# rootNode.write(OUT_PATH)# print(list(rootFolderNode))# for node in list(rootFolderNode):# print(node.attrib)pFile open(OUT_PATH, w)pFile.write(ET.tostring(rootNode))pFile.close()def rewriteXml():doc_xml minidom.parse(OUT_PATH)pFile open(OUT_PATH, w)doc_xml.writexml(pFile, \t, \t, \n, utf-8)pFile.close()TraversalDir(COCOS_PATH)
rewriteXml()
创建cocos工程.bat
echo off
set dir%~dp0
cd %dir%scripts
echo %dir%scripts
python CreateCocosProject.py game_ui_edit.ccs
pause