Browse Source

适配一剑斩仙

zqbo 5 years ago
parent
commit
ab8ca635bf
2 changed files with 74 additions and 7 deletions
  1. 73 7
      package_utils.py
  2. 1 0
      package_web.py

+ 73 - 7
package_utils.py

@@ -24,6 +24,7 @@ import uuid
 import zipfile
 
 ignoreLauncher = ['jm_ysdk', 'jm_yijie', 'jm_quick', 'jm_beiyu', 'jm_xq_jrtt']
+adaptApp = ['yjzx']
 
 def pack(game, sdk, config):
     config['cache'] = uuid.uuid1()
@@ -98,6 +99,8 @@ def pack(game, sdk, config):
             return ret
     # 添加多图标
     #ret = addMoreIcon(game, sdk, subChannel, config)
+    # 复制icon图标到res
+    ret = copyIcon(game, sdk, subChannel, config)
     #if ret:
     #    return ret
     # 打包lib依赖
@@ -311,12 +314,44 @@ def copyAppRes(game, sdk, subChannel, config):
 
     # assets
     print('copy assets...')
-    assetsPath = file_utils.getFullPath(channelPath, 'assets')
-    decomplieAssetsPath = file_utils.getFullPath(decompliePath, 'assets')
-    if os.path.exists(assetsPath):
-        ret = file_utils.copyFileAllDir(assetsPath, decomplieAssetsPath)
-        if ret:
-            return ret
+    #适配一剑斩仙
+    if config['app'] in adaptApp:
+        print('适配一剑斩仙...')
+        decomplieAssetsPath = file_utils.getFullPath(decompliePath, 'assets')
+        skinZipPath = os.path.join(decomplieAssetsPath, 'skin.zip')
+        skinPath = os.path.join(decomplieAssetsPath, 'skin')
+        if os.path.exists(skinZipPath):
+            with zipfile.ZipFile(skinZipPath) as zf:
+                zf.extractall(decomplieAssetsPath)
+                print('create unzip skin' )
+            assetsPath = file_utils.getFullPath(channelPath, 'assets')
+            decomplieAssetsPath = file_utils.getFullPath(decompliePath, 'assets')
+            if os.path.exists(assetsPath):
+                ret = file_utils.copyFileAllDir(assetsPath, decomplieAssetsPath)
+            with zipfile.ZipFile(skinZipPath, 'w') as z:
+                for root, dirs, files in os.walk(skinPath):
+                    for single_file in files:
+                        filepath = os.path.join(root, single_file)
+                        print ('create zip ---> ' + filepath)
+                        temPath = 'skin/' + single_file
+                        z.write(filepath, temPath)
+            z.close()
+        else:
+            print('normal copy assets...')
+            assetsPath = file_utils.getFullPath(channelPath, 'assets')
+            decomplieAssetsPath = file_utils.getFullPath(decompliePath, 'assets')
+            if os.path.exists(assetsPath):
+                ret = file_utils.copyFileAllDir(assetsPath, decomplieAssetsPath)
+                if ret:
+                    return ret
+    else:
+        print('normal copy assets...')
+        assetsPath = file_utils.getFullPath(channelPath, 'assets')
+        decomplieAssetsPath = file_utils.getFullPath(decompliePath, 'assets')
+        if os.path.exists(assetsPath):
+            ret = file_utils.copyFileAllDir(assetsPath, decomplieAssetsPath)
+            if ret:
+                return ret
 
     # icon
     print('copy icon...')
@@ -573,6 +608,37 @@ def addMoreIcon(game, sdk, subChannel, config):
     manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
     return xml_utils.addMoreIcon(manifest, icon, switchIcon)
 
+def copyIcon(game, sdk, subChannel, config):
+    '''
+    复制icon到res ,一键登录使用
+    '''
+    if config['changeIcon']:
+        decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
+        decomplieResPath = file_utils.getFullPath(decompliePath, 'res')
+        iconPath = os.path.join(decomplieResPath, 'mipmap-xhdpi', 'common_sdk_icon.png')
+        desPath = os.path.join(decomplieResPath, 'drawable-hdpi', 'jm_cmcc_icon.png')
+        file_utils.copyFile(iconPath, desPath)
+    else:
+        decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
+        decomplieResPath = file_utils.getFullPath(decompliePath, 'res')
+        desPath = os.path.join(decomplieResPath, 'drawable-hdpi', 'jm_cmcc_icon.png')
+
+        manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+        icon = xml_utils.getApplicationAttr(manifest, 'icon')
+        tag = icon[1:].split("/")
+        if len(tag) < 1:
+            return
+        hdpi = ['-xhdpi', '-xxhdpi', '-xxxhdpi']
+        for h in hdpi:
+            p1 = '%s%s' % (tag[0],h)
+            png = tag[1] + ".png"
+            iconPath = os.path.join(decomplieResPath, p1, png)
+            if os.path.exists(iconPath):
+                print ('iconPath = ' + iconPath)
+                file_utils.copyFile(iconPath, desPath)
+                break
+
+
 def formatHex(millisecond):
     '''
     将毫秒转为16进制,4位格式
@@ -581,7 +647,7 @@ def formatHex(millisecond):
     timeHex = timeHex[2:]
     formatHex = ''
     if len(timeHex) == 3:
-        formatHex = '0x0' + timeHex
+        formatHex = '0x0' + timeHexaddLauncher
     elif len(timeHex) == 4:
         formatHex = '0x' + timeHex
     else:

+ 1 - 0
package_web.py

@@ -74,6 +74,7 @@ def package(config, sdk):
         jsonConfig['subChannel'] = config['subChannel']
 
     # 必须参数
+    jsonConfig['app'] = config['app']
     jsonConfig['packageName'] = config['packageName']
     jsonConfig['name'] = config['name']