diff --git a/release/scripts/mgear/core/skin.py b/release/scripts/mgear/core/skin.py index 9fce7e62..89af6105 100644 --- a/release/scripts/mgear/core/skin.py +++ b/release/scripts/mgear/core/skin.py @@ -23,6 +23,9 @@ FILE_JSON_EXT = ".jSkin" PACK_EXT = ".gSkinPack" +NAMESPACE_REPLACER = "~" +CLASH_REPLACER = "!" + ###################################### # Skin getters ###################################### @@ -200,6 +203,22 @@ def collectData(skinCls, dataDic): # Skin export ###################################### +def clash_and_namespace_fixer(filepath, toFile=True): + # This is a gross approach, but it does work as Windows + # supports ! (or CLASH_REPLACER if changed) but not | + # Same with : Namespaces and NAMESPACE_REPLACER + filedir = os.path.dirname(filepath) + if filedir: + filedir = filedir + "/" + filename = os.path.basename(filepath) + raw_name, extension = os.path.splitext(filename) + if toFile: + filepath = filedir + raw_name.replace(":", NAMESPACE_REPLACER).replace("|", CLASH_REPLACER) + extension + else: + filepath = filedir + raw_name.replace(NAMESPACE_REPLACER, ":").replace(CLASH_REPLACER, "|") + extension + + return filepath + def exportSkin(filePath=None, objs=None, *args): if not objs: if pm.selected(): @@ -222,8 +241,7 @@ def exportSkin(filePath=None, objs=None, *args): filePath = pm.fileDialog2(fileMode=0, fileFilter=fileFilters) if filePath: - filePath = filePath[0] - + filePath = clash_and_namespace_fixer(filepath=filePath[0], toFile=True) else: return False @@ -317,7 +335,7 @@ def exportSkinPack(packPath=None, objs=None, use_json=False, *args): packDic["rootPath"], packName = os.path.split(packPath) for obj in objs: - fileName = obj.stripNamespace() + file_ext + fileName = clash_and_namespace_fixer(filepath=obj.name(), toFile=True) + file_ext filePath = os.path.join(packDic["rootPath"], fileName) if exportSkin(filePath, [obj], use_json): packDic["packFiles"].append(fileName) @@ -448,7 +466,6 @@ def getObjsFromSkinFile(filePath=None, *args): def importSkin(filePath=None, *args): - if not filePath: f1 = 'mGear Skin (*{0} *{1})'.format(FILE_EXT, FILE_JSON_EXT) f2 = ";;gSkin Binary (*{0});;jSkin ASCII (*{1})".format( @@ -557,7 +574,7 @@ def importSkinPack(filePath=None, *args): packDic = json.load(fp) for pFile in packDic["packFiles"]: filePath = os.path.join(os.path.split(filePath)[0], pFile) - importSkin(filePath, True) + importSkin(clash_and_namespace_fixer(filepath=filePath, toFile=True), True) ###################################### # Skin Copy