def CopyConfigDataToAndroid(self): dir1 = mainResource.GetConfigDataDir() dir2 = mainResource.GetRootDirAndroidAsset() + "/ConfigData" flag = os.path.exists(dir2) if flag: shutil.rmtree(dir2) # print(CopyConfigDataToAndroid:dir1=",dir1," dir2=",dir2 shutil.copytree(dir1, dir2)
def LoadJsonIAP(self, isHD, stros): if stros == Source.ANDROID: jsonfile = mainResource.GetConfigDataDir( ) + "/IAP/IAP_android.json" if isHD: jsonfile = mainResource.GetConfigDataDir( ) + "/IAP/IAP_android_hd.json" if stros == Source.IOS: jsonfile = mainResource.GetConfigDataDir() + "/IAP/IAP_ios.json" if isHD: jsonfile = mainResource.GetConfigDataDir( ) + "/IAP/IAP_ios_hd.json" jsonfile = os.path.normpath(jsonfile) strfile = FileUtil.GetFileString(jsonfile) return json.loads(strfile)
def CopyResConfigData(self): # ResConfigDataCommon reousceDataRoot = mainResource.GetResourceDataRoot() dirname = "ConfigDataCommon" dirUnity = mainResource.GetRootUnityAssetsResource() dir1 = reousceDataRoot+"/"+dirname dir2 = dirUnity+"/"+dirname flag = os.path.exists(dir2) if flag: shutil.rmtree(dir2) shutil.copytree(dir1,dir2) # ConfigData dir1 = mainResource.GetConfigDataDir() dir2 = dirUnity+"/ConfigData" flag = os.path.exists(dir2) if flag: shutil.rmtree(dir2) shutil.copytree(dir1,dir2)
def SetConfigDataAppId(self,os,chanel,appid,ishd): dirconfig = mainResource.GetConfigDataDir() filepath = "" if os==Source.ANDROID: filepath = dirconfig+"/config/config_android.json" if ishd: filepath = dirconfig+"/config/config_android_hd.json" if os==Source.IOS: filepath = dirconfig+"/config/config_ios.json" if ishd: filepath = dirconfig+"/config/config_ios_hd.json" with open(filepath) as json_file: data = json.load(json_file) data["APPID"][chanel] = appid # SaveJson(filepath,data) JsonUtil.SaveJson(filepath,data)
def GetConfigDataAppId(self, os, chanel): dirconfig = mainResource.GetConfigDataDir() filepath = "" appid = "" if os == Source.ANDROID: filepath = dirconfig + "/config/config_android.json" if self.isHd: filepath = dirconfig + "/config/config_android_hd.json" if os == Source.IOS: filepath = dirconfig + "/config/config_ios.json" if self.isHd: filepath = dirconfig + "/config/config_ios_hd.json" with open(filepath) as json_file: data = json.load(json_file) appid = data["APPID"][chanel] return appid
def updateName(self,isHd,isAuto): name = mainAppInfo.GetAppStoreAcount(isHd,Source.HUAWEI) mainHuaweiAppGalleryApi.ClientId = mainAppStoreAcount.GetClientId(Source.HUAWEI,name) mainHuaweiAppGalleryApi.ClientSecret = mainAppStoreAcount.GetClientSecret(Source.HUAWEI,name) appinfoOld = AppInfoOld(isHd) if appinfoOld.IsOldVersion(): # 转换 self.ConvertOld2New(isHd,appinfoOld) rootConfig = mainResource.GetProjectConfigApp() strHD = "HD" project_ios = rootConfig + "/ios/project" project_android = rootConfig + "/android/project" if isHd: project_ios = rootConfig + "/ios/project_hd" project_android = rootConfig + "/android/project_hd" # android file_name_cn_android = project_android + "/res/values/strings.xml" file_name_en_android = project_android + "/res/values-en/strings.xml" file_AndroidManifest = project_android + "/xml/AndroidManifest.xml" file_AndroidManifest_GP = project_android + "/xml_gp/AndroidManifest.xml" file_google_service_android = project_android + "/config/google-services.json" # ios file_name_cn_ios = project_ios + "/appname/zh-Hans.lproj/InfoPlist.strings" file_name_en_ios = project_ios + "/appname/en.lproj/InfoPlist.strings" file_info_plist_ios = project_ios + "/Info.plist" # loadJson data = self.loadJson(isHd) appname = data["appname"] APP_NAME_CN_ANDROID = appname[Source.ANDROID]["cn"] APP_NAME_EN_ANDROID = appname[Source.ANDROID]["en"] APP_NAME_CN_IOS = appname[Source.IOS]["cn"] APP_NAME_EN_IOS = appname[Source.IOS]["en"] PACKAGE_ANDROID = data["apppackage"][Source.ANDROID]["default"] PACKAGE_IOS = data["apppackage"][Source.IOS]["default"] self.versionCode = data["appversion"][Source.ANDROID]["code"] APPVERSION_IOS = data["appversion"][Source.IOS]["value"] #appid appid_ios = self.GetJsonAppId(data,Source.APPSTORE) appid_taptap = self.GetJsonAppId(data,Source.TAPTAP) appid_huawei = self.GetJsonAppId(data,Source.HUAWEI) self.SetConfigDataAppId(Source.IOS,Source.APPSTORE,appid_ios,isHd) self.SetConfigDataAppId(Source.ANDROID,Source.TAPTAP,appid_taptap,isHd) self.SetConfigDataAppId(Source.ANDROID,Source.HUAWEI,appid_huawei,isHd) csvfile = mainResource.GetConfigDataDir()+"/language/language.csv" self.UpdateLanguageName(csvfile,APP_NAME_CN_ANDROID,APP_NAME_EN_ANDROID,isHd) csvfile = mainResource.GetRootUnityAssetsResource()+"/ConfigData/language/language.csv" self.UpdateLanguageName(csvfile,APP_NAME_CN_ANDROID,APP_NAME_EN_ANDROID,isHd) # if data.has_key("PACKAGE_HD_ANDROID"): # PACKAGE_HD_ANDROID = data["PACKAGE_HD_ANDROID"] if isAuto==True: self.autoPlusVersion(isHd,data) # 重新加载 data = self.loadJson(isHd) APPVERSION_IOS = data["appversion"][Source.IOS]["value"] self.versionCode = data["appversion"][Source.ANDROID]["code"] APPVERSION_ANDROID = self.versionCodeToVersion(self.versionCode) APPVERSION_CODE_ANDROID = self.versionCode # appversion.json if isAuto==False: src = mainResource.GetProjectConfigDefault()+"/appinfo/appversion.json" dst = mainResource.GetProjectConfigApp()+"/appinfo/appversion.json" flag = os.path.exists(dst) # if not isHd: shutil.copyfile(src,dst) strfile = FileUtil.GetFileString(dst) key = "_VERSION_ANDROID_" if isHd: key = "_VERSION_HD_ANDROID_" # 保存版本 # android print("appid_huawei=",appid_huawei+" ishd=",isHd) # if len(appid_huawei)>1: version_web = mainHuaweiAppGalleryApi.GetVersion(appid_huawei) strfile = strfile.replace(key,version_web) FileUtil.SaveString2File(strfile,dst) self.SetAppVersion(isHd,Source.ANDROID,version_web) strcode = version_web.replace(".","") self.SetAppVersionCode(isHd,Source.ANDROID,strcode) # ios appid_apple = self.GetJsonAppId(data,Source.APPSTORE) version_web = mainAppVersionApple.ParseVersion(appid_apple) print("AppVersionApple=",version_web+" appid_apple=",appid_apple) self.SetAppVersion(isHd,Source.IOS,version_web) strcode = version_web.replace(".","") self.SetAppVersionCode(isHd,Source.IOS,strcode) filepath = mainResource.GetProjectConfigAppType()+"/appversion.json" flag = os.path.exists(filepath) strFileJson = "{}" if flag: strFileJson = FileUtil.GetFileString(filepath) dataRoot = json.loads(strFileJson) dataRoot[mainResource.getGameName()]= json.loads(strfile) JsonUtil.SaveJson(filepath,dataRoot) # 重新加载 data = self.loadJson(isHd) APPVERSION_IOS = data["appversion"][Source.IOS]["value"] self.versionCode = data["appversion"][Source.ANDROID]["code"] APPVERSION_ANDROID = self.versionCodeToVersion(self.versionCode) APPVERSION_CODE_ANDROID = self.versionCode print (APP_NAME_CN_ANDROID) print (APP_NAME_EN_ANDROID) print (APP_NAME_CN_IOS) print (APP_NAME_EN_IOS) print (PACKAGE_ANDROID) print("android version:"+APPVERSION_ANDROID) print("ios version:"+APPVERSION_IOS) # android # name strStart = "app_name\">" strEnd = "<" # cn strOut = self.replaceStringOfFile( file_name_cn_android, strStart, strEnd, APP_NAME_CN_ANDROID) self.saveString2File(strOut, file_name_cn_android) # en strOut = self.replaceStringOfFile( file_name_en_android, strStart, strEnd, APP_NAME_EN_ANDROID) self.saveString2File(strOut, file_name_en_android) self.updateAndroidManifest(file_AndroidManifest,PACKAGE_ANDROID,APPVERSION_ANDROID,APPVERSION_CODE_ANDROID,isHd) self.updateAndroidManifest(file_AndroidManifest_GP,PACKAGE_ANDROID,APPVERSION_ANDROID,APPVERSION_CODE_ANDROID,isHd) # admob self.replaceGoogleServiceFile(file_google_service_android, PACKAGE_ANDROID) # ios #appname self.replaceFile(file_info_plist_ios,"_APP_NAME_",APP_NAME_CN_IOS) file_name_cn_ios = project_ios + "/appname/zh-Hans.lproj/InfoPlist.strings" file_name_en_ios = project_ios + "/appname/en.lproj/InfoPlist.strings" # cn self.replaceFile(file_name_cn_ios,"_APP_NAME_",APP_NAME_CN_IOS) # en self.replaceFile(file_name_en_ios,"_APP_NAME_",APP_NAME_EN_IOS) # package self.replaceFile(file_info_plist_ios,"_APP_PACKAGE_",PACKAGE_IOS) # version self.replaceFile(file_info_plist_ios,"_APP_VERSION_",APPVERSION_IOS) #admob appid appid = mainAdConfig.GetCommonAppId(Source.ADMOB,Source.IOS,isHd) self.replaceFile(file_info_plist_ios,"_APP_ID_ADMOB_",appid) # CFBundleURLSchemes src = Source.WEIBO appid = mainConfig.GetShareAppId(src,Source.IOS,isHd) self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0) src = Source.WEIXIN appid = mainConfig.GetShareAppId(src,Source.IOS,isHd) self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0) src = Source.QQ appid = mainConfig.GetShareAppId(src,Source.IOS,isHd) self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0) self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,1) # xiaomi aso keyword self.updateXiaoASOkeyword(data,isHd) # win self.updateNameWin(isHd,isAuto)
def LoadJsonConfigCommon(self): jsonfile = mainResource.GetConfigDataDir()+"/config/config_common.json" jsonfile = os.path.normpath(jsonfile) strfile = FileUtil.GetFileString(jsonfile) return json.loads(strfile)