You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
7.1 KiB
139 lines
7.1 KiB
# -*- coding:utf-8 -*-
|
|
# python 3.10
|
|
import json,shutil,os
|
|
# 当前目录
|
|
curPath = os.getcwd()
|
|
|
|
# 原始assets目录
|
|
assetPath = "D:/project/submit/wdzcrj/assets"
|
|
|
|
# 导出的目录
|
|
daochu_assetPath = "D:/project/submit/wozhishangbaopeng/assets"
|
|
|
|
# 原始的GameConfig.json
|
|
jsonpath = assetPath + "/resources/Json/GameConfig.json"
|
|
|
|
# 导出的GameConfig.json
|
|
daochu_jsonpath = daochu_assetPath + "/resources/Json/GameConfig.json"
|
|
|
|
# AppConfig.ts路径
|
|
AppConfigPath = daochu_assetPath + "/FrameWork/Config/AppConfig.ts"
|
|
|
|
# 设置各自游戏的appId
|
|
TT_APP_ID_custom = "ttad4fdbf23245032202";#抖音 app id
|
|
WX_APP_ID_custom = "ttad4fdbf23245032202";#微信 app id
|
|
QQ_APP_ID_custom = "ttad4fdbf23245032202";#QQ app id
|
|
VIVO_APP_ID_custom = "ttad4fdbf23245032202";#vivo app id
|
|
OPPO_APP_ID_custom = "ttad4fdbf23245032202";#opop app id
|
|
APK_APP_ID_custom = "ttad4fdbf23245032202";#Android app id
|
|
|
|
# 设置tt_adUnitIdArr_custom
|
|
tt_adUnitIdArr_custom = ["c6290d8qe7tkqnbn6f", "2d4swal32964fe8oni", "2qgjcqoeubc3kkgjst"]
|
|
|
|
# 要替换图片路径
|
|
imgpath1 = daochu_assetPath + "/ZoomGame/texure/successAndFail/我的找茬日记.png"
|
|
imgpath2 = daochu_assetPath + "/ZoomGame/texure/successAndFail/我眼神儿好首页.png"
|
|
imgpath3 = daochu_assetPath + "/ZoomGame/texure/game/zoomArtLevel/loading(标).png"
|
|
imgpath4 = daochu_assetPath + "/ZoomGame/texure/game/zoomArtLevel/loading(标)-1.png"
|
|
imgpath5 = daochu_assetPath + "/ZoomGame/texure/game/zoomArtLevel/loading…….png"
|
|
imgpath6 = daochu_assetPath + "/ZoomGame/texure/game/zoomArtLevel/背景底图.jpg"
|
|
imgpath7 = daochu_assetPath + "/ZoomGame/texure/game/zoomArtLevel/进目标度框.png"
|
|
imgpath8 = daochu_assetPath + "/ZoomGame/texure/game/zoomArtLevel/目标进度条.png"
|
|
imgpath9 = daochu_assetPath + "/ZoomGame/texure/game/gameScene/底栏/入口有奖.png"
|
|
|
|
# 老图片的路径数组
|
|
oldImgs = [imgpath1,imgpath2,imgpath3,imgpath4,imgpath5,imgpath6,imgpath7,imgpath8,imgpath9]
|
|
#新图片的名字,对应上面
|
|
newImgs = [curPath+"/img/我的找茬日记.png",curPath+"/img/我的找茬日记.png",curPath+"/img/我的找茬日记.png",curPath+"/img/我的找茬日记.png",
|
|
curPath+"/img/loading…….png",curPath+"/img/背景底图.jpg",curPath+"/img/进目标度框.png",curPath+"/img/目标进度条.png",curPath+"/img/入口有奖.png"]
|
|
|
|
# 需要打进去的游戏
|
|
gamename = ["铁箱逃生","一场误会","飞行危机","上班迟到","真爱至上","西游找穷","千亿假富","西游街舞","逆袭人生","三国全家福","湖南特色","生日惊喜"]
|
|
|
|
# 和gamename下标对应的新游戏名
|
|
newgamename = ["我智商爆棚"]
|
|
|
|
|
|
# 拷贝所需游戏并记录GameConfig配置-------------------------------------------------------------------------------------------------------------------------------------
|
|
# 读取json文件
|
|
with open(jsonpath, 'r', encoding='utf-8') as file:
|
|
data = json.load(file)
|
|
# print(data)
|
|
# 清空ZoomLevels文件夹
|
|
def clear_folder(folder_path):
|
|
shutil.rmtree(folder_path)
|
|
os.makedirs(folder_path)
|
|
clear_folder(daochu_assetPath + "/ZoomLevels")
|
|
# 遍历修改和拷贝
|
|
_zmGameConfig = data['zmGameConfig']
|
|
newzmGameConfig = []
|
|
for index in range(len(gamename)):
|
|
_gamenam = gamename[index]
|
|
for _config in _zmGameConfig:
|
|
if 'title2' in _config:
|
|
# print(_gamenam,_config['title2'])
|
|
if _gamenam.lower() in _config['title2'].lower():
|
|
# print(_config)
|
|
if index <= len(newgamename) - 1 and newgamename[index] != '' and newgamename[index] != "":
|
|
_config['title2'] = newgamename[index]
|
|
_config['titleUrl'] = newgamename[index]
|
|
_config['index'] = len(newzmGameConfig)
|
|
newzmGameConfig.append(_config)
|
|
bundlepath = _config['bundle']
|
|
if "zhaoChaCommon" == _config['bundle']:
|
|
bundlepath = "zhaCha" + '/' + _config['subbundle']
|
|
shutil.copy(assetPath + '/ZoomLevels/' + "zhaCha" + '.meta', daochu_assetPath + '/ZoomLevels/' + "zhaCha" + '.meta')
|
|
elif "ZhaoCha_Version2" == _config['bundle']:
|
|
bundlepath = "ZhaoCha_Version2" + '/' + _config['subbundle']
|
|
shutil.copy(assetPath + '/ZoomLevels/' + "ZhaoCha_Version2" + '.meta', daochu_assetPath + '/ZoomLevels/' + "ZhaoCha_Version2" + '.meta')
|
|
shutil.copytree(assetPath + '/ZoomLevels/' + bundlepath, daochu_assetPath + '/ZoomLevels/' + bundlepath)
|
|
shutil.copy(assetPath + '/ZoomLevels/' + bundlepath + '.meta', daochu_assetPath + '/ZoomLevels/' + bundlepath + '.meta')
|
|
break
|
|
print(newzmGameConfig)
|
|
data['zmGameConfig'] = newzmGameConfig
|
|
data['GameAllType'][0]['Levels'] = []
|
|
for _i in range(len(newzmGameConfig)):
|
|
data['GameAllType'][0]['Levels'].append(_i)
|
|
print(data['GameAllType'][0]['Levels'])
|
|
|
|
# 根据记录导出GameConfig-------------------------------------------------------------------------------------------------------------------------------------
|
|
with open(daochu_jsonpath, 'w',encoding='utf-8') as file:
|
|
json.dump(data, file,ensure_ascii=False)
|
|
|
|
# 替换AppConfig.ts里面的APP_ID_custom,替换tt_adUnitIdArr_custom-------------------------------------------------------------------------------------------------------------------------------------
|
|
# 打开文件读取内容
|
|
with open(AppConfigPath, 'r',encoding='utf-8') as file:
|
|
content = file.read()
|
|
# 替换内容
|
|
old_string = 'TT_APP_ID_custom = "tt13e565588cd74ff802"'
|
|
new_string = 'TT_APP_ID_custom = "{}"'.format(TT_APP_ID_custom)
|
|
content = content.replace(old_string, new_string)
|
|
old_string = 'WX_APP_ID_custom = "tt13e565588cd74ff802"'
|
|
new_string = 'WX_APP_ID_custom = "{}"'.format(WX_APP_ID_custom)
|
|
content = content.replace(old_string, new_string)
|
|
old_string = 'QQ_APP_ID_custom = "tt13e565588cd74ff802"'
|
|
new_string = 'QQ_APP_ID_custom = "{}"'.format(QQ_APP_ID_custom)
|
|
content = content.replace(old_string, new_string)
|
|
old_string = 'VIVO_APP_ID_custom = "tt13e565588cd74ff802"'
|
|
new_string = 'VIVO_APP_ID_custom = "{}"'.format(VIVO_APP_ID_custom)
|
|
content = content.replace(old_string, new_string)
|
|
old_string = 'OPPO_APP_ID_custom = "tt13e565588cd74ff802"'
|
|
new_string = 'OPPO_APP_ID_custom = "{}"'.format(OPPO_APP_ID_custom)
|
|
content = content.replace(old_string, new_string)
|
|
old_string = 'APK_APP_ID_custom = "tt13e565588cd74ff802"'
|
|
new_string = 'APK_APP_ID_custom = "{}"'.format(APK_APP_ID_custom)
|
|
content = content.replace(old_string, new_string)
|
|
old_string = 'tt_adUnitIdArr_custom = ["h3jc8f4h7qo7qmihk4", "137bn708k34egmkj00", "1p0cddd88l7oe6k5ia"]'
|
|
new_string = 'tt_adUnitIdArr_custom = {}'.format(tt_adUnitIdArr_custom)
|
|
content = content.replace(old_string, new_string)
|
|
# 将修改后的内容写回文件
|
|
with open(AppConfigPath, 'w',encoding='utf-8') as file:
|
|
file.write(content)
|
|
|
|
# 替换图片-------------------------------------------------------------------------------------------------------------------------------------
|
|
def copy_and_replace(src, dst):
|
|
if os.path.isfile(dst):
|
|
os.remove(dst) # 删除目标位置已存在的文件
|
|
shutil.copy(src, dst) # 复制文件
|
|
for index in range(len(oldImgs)):
|
|
copy_and_replace(newImgs[index],oldImgs[index]) |