添加活动PSD检测
parent
7e5c20a353
commit
063a08a967
|
|
@ -0,0 +1,5 @@
|
||||||
|
存放活动的资源
|
||||||
|
|
||||||
|
活动封面拼图psd_id编号从90000开始-99999(9万-9.9999万)
|
||||||
|
|
||||||
|
活动子关卡拼图psd_id编号从100000开始-149999(10万-14.9999万)
|
||||||
|
|
@ -42,11 +42,13 @@ def parse_psd(path):
|
||||||
max_width = 0
|
max_width = 0
|
||||||
max_height = 0
|
max_height = 0
|
||||||
|
|
||||||
|
is_activity_main_psd = path.find("activity/main_psd/") != -1
|
||||||
for item in psd.descendants():
|
for item in psd.descendants():
|
||||||
if not item.is_group():
|
if not item.is_group():
|
||||||
nArr = item.name.split('_')
|
nArr = item.name.split('_')
|
||||||
|
|
||||||
if item.name == "base":
|
#在活动背景中,基础图为base_1
|
||||||
|
if item.name == "base" or (is_activity_main_psd and item.name == "base_1"):
|
||||||
max_width = item.width
|
max_width = item.width
|
||||||
max_height = item.height
|
max_height = item.height
|
||||||
break
|
break
|
||||||
|
|
@ -55,18 +57,14 @@ def parse_psd(path):
|
||||||
if not item.is_group():
|
if not item.is_group():
|
||||||
nArr = item.name.split('_')
|
nArr = item.name.split('_')
|
||||||
|
|
||||||
if item.name == "base":
|
|
||||||
max_width = item.width
|
|
||||||
max_height = item.height
|
|
||||||
|
|
||||||
if item.name.strip() != item.name:
|
if item.name.strip() != item.name:
|
||||||
log.append("命名中存在空格:{}".format(item.name))
|
log.append("命名中存在空格:{}".format(item.name))
|
||||||
|
|
||||||
if nArr[0] == 'base':
|
if not is_activity_main_psd and nArr[0] == 'base':
|
||||||
if has_base:
|
if has_base:
|
||||||
log.append("存在多个base图层")
|
log.append("存在多个base图层")
|
||||||
has_base = True
|
has_base = True
|
||||||
elif nArr[0] == 'finish':
|
elif not is_activity_main_psd and nArr[0] == 'finish':
|
||||||
if has_finish:
|
if has_finish:
|
||||||
log.append("存在多个finish图层")
|
log.append("存在多个finish图层")
|
||||||
has_finish = True
|
has_finish = True
|
||||||
|
|
@ -96,6 +94,12 @@ def parse_psd(path):
|
||||||
auto_stages[nArr[1]].append(nArr[2])
|
auto_stages[nArr[1]].append(nArr[2])
|
||||||
elif nArr[0] == 'thumbnail' or nArr[0] == 'role' or nArr[0] == 'rptmp':
|
elif nArr[0] == 'thumbnail' or nArr[0] == 'role' or nArr[0] == 'rptmp':
|
||||||
pass
|
pass
|
||||||
|
elif is_activity_main_psd and nArr[0] == 'dot':
|
||||||
|
if len(nArr) != 4:
|
||||||
|
log.append("活动子点位,命名错误:{}".format(item.name))
|
||||||
|
elif is_activity_main_psd and nArr[0] == 'base':
|
||||||
|
if nArr[1] == '1':
|
||||||
|
has_base = True
|
||||||
else:
|
else:
|
||||||
log.append("命名错误:{}\n".format(item.name))
|
log.append("命名错误:{}\n".format(item.name))
|
||||||
|
|
||||||
|
|
@ -114,7 +118,7 @@ def parse_psd(path):
|
||||||
if not has_base:
|
if not has_base:
|
||||||
log.append("未检测到base图层\n")
|
log.append("未检测到base图层\n")
|
||||||
|
|
||||||
if not has_finish:
|
if not is_activity_main_psd and not has_finish:
|
||||||
log.append("未检测到finish图层\n")
|
log.append("未检测到finish图层\n")
|
||||||
|
|
||||||
for stage in patch_stages:
|
for stage in patch_stages:
|
||||||
|
|
@ -133,6 +137,7 @@ def parse_psd(path):
|
||||||
else:
|
else:
|
||||||
tmp[item] = 0
|
tmp[item] = 0
|
||||||
|
|
||||||
|
if not is_activity_main_psd:
|
||||||
if len(lines) > 0 and len(patch_stages) != len(lines):
|
if len(lines) > 0 and len(patch_stages) != len(lines):
|
||||||
log.append("阶段与线稿不对应,线稿:{} 关卡:".format(len(lines), len(patch_stages)))
|
log.append("阶段与线稿不对应,线稿:{} 关卡:".format(len(lines), len(patch_stages)))
|
||||||
|
|
||||||
|
|
@ -147,13 +152,13 @@ def parse_psd(path):
|
||||||
log.append("检测结束")
|
log.append("检测结束")
|
||||||
|
|
||||||
if len(log) == 2:
|
if len(log) == 2:
|
||||||
return True, len(lines) > 0
|
return True
|
||||||
else:
|
else:
|
||||||
for a_log in log:
|
for a_log in log:
|
||||||
print(a_log)
|
print(a_log)
|
||||||
return False, len(lines) > 0
|
return False
|
||||||
|
|
||||||
def convert_2_zip_file(path):
|
def convert_2_zip_file(path, is_activity_psd):
|
||||||
file_info_arr = os.path.split(path)
|
file_info_arr = os.path.split(path)
|
||||||
file_path = file_info_arr[0]
|
file_path = file_info_arr[0]
|
||||||
file_name = os.path.split(path)[1]
|
file_name = os.path.split(path)[1]
|
||||||
|
|
@ -163,6 +168,8 @@ def convert_2_zip_file(path):
|
||||||
file_name_without_ex = file_name.split(".")[0]
|
file_name_without_ex = file_name.split(".")[0]
|
||||||
utils.zip_file("{}.psd".format(file_name_without_ex), "{}.zip".format(file_name_without_ex))
|
utils.zip_file("{}.psd".format(file_name_without_ex), "{}.zip".format(file_name_without_ex))
|
||||||
os.chdir("../")
|
os.chdir("../")
|
||||||
|
if is_activity_psd:
|
||||||
|
os.chdir("../")
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
###生成version文件
|
###生成version文件
|
||||||
|
|
@ -239,16 +246,15 @@ if __name__ == '__main__':
|
||||||
hash_now = utils.calc_hash(psd_file)
|
hash_now = utils.calc_hash(psd_file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ret, has_line = parse_psd(psd_file)
|
ret = parse_psd(psd_file)
|
||||||
|
is_activity_psd = psd_file.find("activity/main_psd/") != -1 or psd_file.find("activity/level_psd/") != -1
|
||||||
if ret:
|
if ret:
|
||||||
if not has_line:
|
|
||||||
export_outline.export_outline(psd_file)
|
|
||||||
|
|
||||||
#检测成功,压缩到zip
|
#检测成功,压缩到zip
|
||||||
convert_2_zip_file(psd_file)
|
convert_2_zip_file(psd_file, is_activity_psd)
|
||||||
versions[key] = hash_now
|
versions[key] = hash_now
|
||||||
write_version();
|
write_version()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(name + " 解析失败:" + repr(e) + ",请检查命名规范,比如auto_1_1=>auto_1 或 patch_1_1=>patch_1")
|
print(name + " 解析失败:" + repr(e) + ",请检查命名规范,比如auto_1_1=>auto_1 或 patch_1_1=>patch_1")
|
||||||
elif hash_now == hash_old:
|
elif hash_now == hash_old:
|
||||||
convert_2_zip_file(src_file)
|
is_activity_psd = src_file.find("activity/main_psd/") != -1
|
||||||
|
convert_2_zip_file(src_file, is_activity_psd)
|
||||||
Loading…
Reference in New Issue