示例#1
0
        /// <summary>
        /// 添加渠道附加资源
        /// </summary>
        private static void addChannelAttachs(ToolSetting toolSet, Cmd.Callback call, String dirSource, String channelAttachDir, String Set_channelId)
        {
            // 获取渠道附加目录资源路径
            String channelDir = toolSet.chargeAPK_dir + "\\" + Set_channelId;
            //String channelAttachDir = channelDir + "\\附加资源";
            String channelAttachDir2 = channelDir + channelAttachDir;

            // 复制渠道附加目录中的文件
            if (Directory.Exists(channelAttachDir2) && !ApkCombine.isEmptyDirectorty(channelAttachDir2))
            {
                bool isEmptyDir = ApkCombine.isEmptyDirectorty(channelAttachDir);

                if (!isEmptyDir && call != null)
                {
                    call("【I】");
                }
                if (!isEmptyDir && call != null)
                {
                    call("【I】复制," + channelAttachDir);
                }
                ApkCombine.CopyFolderTo(channelAttachDir2, dirSource, true, call);
                if (!isEmptyDir && call != null)
                {
                    call("【I】复制," + channelAttachDir + "完成");
                }
            }
        }
示例#2
0
        /// <summary>
        /// 添加游戏附加资源
        /// </summary>
        private static void addGameAttachs(ToolSetting toolSet, Cmd.Callback call, String dirTarget, String gameAttachDir, String Set_gameId, String Set_channelId, String tittle = "")
        {
            // 获取选中的游戏包所在的目录的附加资源
            //toolSet.gameAPK_dir + "\\" + Settings.gameId + "\\"
            String selectGameDir = toolSet.gameAPK_dir + "\\" + Set_gameId;

            //String selectVersionDir = Form4.SelectVersionDir;
            //String[] attachDirs = { selectGameDir + "\\游戏Icon或Logo", selectVersionDir + "\\附加资源" };
            //foreach (String gameAttachDir0 in attachDirs)
            {
                String gameAttachDir2 = selectGameDir + gameAttachDir;     // 生成附加资源路径

                // 复制游戏附加目录中的文件
                List <String> list_channel = new List <string>();
                list_channel.Add("所有渠道");
                list_channel.Add(Set_channelId);

                bool isEmptyDir = ApkCombine.isEmptyDirectorty(gameAttachDir2);
                if (!isEmptyDir && call != null)
                {
                    call("【I】");
                }
                if (!isEmptyDir && call != null)
                {
                    call("【I】复制," + gameAttachDir + (tittle.Equals("") ? "" : ("到" + tittle)));
                }
                foreach (String channelId in list_channel)
                {
                    String Dir = gameAttachDir2 + "\\" + channelId;
                    isEmptyDir = ApkCombine.isEmptyDirectorty(Dir);

                    // 拷贝游戏附加资源目录
                    if (channelId != null && !channelId.Equals("") && Directory.Exists(Dir) && !ApkCombine.isEmptyDirectorty(Dir))
                    {
                        if (!isEmptyDir && call != null)
                        {
                            call("【I】复制," + gameAttachDir + "\\" + channelId);
                        }
                        ApkCombine.CopyFolderTo(Dir, dirTarget, true, call);
                        if (!isEmptyDir && call != null)
                        {
                            call("【I】复制," + gameAttachDir + "\\" + channelId + " 完成");
                        }
                    }
                }
            }

            // 复制游戏Icon、Logo
            if (gameAttachDir.Equals("\\游戏Icon或Logo") && StartParam.AutoRun && Form4.channelIconDir.ContainsKey(Set_channelId))
            {
                String ICONDIR = Form4.channelIconDir[Set_channelId];
                if (!ICONDIR.Equals("") && Directory.Exists(ICONDIR))
                {
                    ApkCombine.CopyFolderTo(ICONDIR, dirTarget + @"\res\drawable", true, call);
                }
            }
        }
示例#3
0
        static bool showCopyInfo = false;  // 是否显示复制信息

        /// <summary>
        /// 对两个apk解包后的文件进行混合,复制目录dirSource下的文件到dirDest中
        /// </summary>
        public static void Combine(String dirSource, String dirDest, Cmd.Callback call)
        {
            if (Apktool.isApkDir(dirDest) && Apktool.isApkDir(dirSource))
            {
                Cmd.Callback tmp = Settings.call;   // 记录call

                Settings.call = call;
                Settings setting = Settings.Load(dirSource, dirDest);

                //setting.GetPackageName_GAMEPRE_CHANNEL(dirSource, dirDest);      // 更新渠道参数信息

                // 若设置为使用所有渠道通用基础配置,则拷贝混合基础配置信息到游戏包
                if (setting.useAllChannelCommon)
                {
                    ToolSetting toolSet = ToolSetting.Instance();                               // 载入配置信息
                    //String AllChannelCommon = toolSet.chargeAPK_dir + "\\所有渠道\\附加资源";   // 获取所有渠道配置目录
                    //ToolSetting.confirmDir(AllChannelCommon);

                    //// 混合所有渠道公用配置
                    //if (!ApkCombine.isEmptyDirectorty(AllChannelCommon))
                    //{
                    //    if (call != null) call("【L】拷贝所有渠道附加资源:");
                    //    Combine(AllChannelCommon, dirDest, call);
                    //    if (call != null) call("【I】拷贝所有渠道附加资源完成!");
                    //}

                    String commonDir = toolSet.chargeAPK_dir + "\\所有渠道";                      // 获取所有渠道配置目录
                    Dictionary <String, String> apk_dirs = Form3.getApk_FileOrDir(commonDir); // 获取目录下的apk文件或解压目录
                    if (apk_dirs.Count > 0)
                    {
                        String apk_dir = apk_dirs.Values.ToArray <String>()[0];
                        if (call != null)
                        {
                            call("【I】");
                        }
                        if (call != null)
                        {
                            call("【I】---------------------------------");
                        }
                        if (call != null)
                        {
                            call("【L】混合,所有渠道,通用基础包资源:\r\n" + apk_dir);
                        }

                        // 所有渠道通用apk解包
                        String AllChannelCommon = Form2.apkUnpack(apk_dir, call);     // 获取所有渠道配置目录
                        if (AllChannelCommon.Contains("【E】"))
                        {
                            return;
                        }

                        // 混合所有渠道公用配置
                        if (!ApkCombine.isEmptyDirectorty(AllChannelCommon))
                        {
                            if (call != null)
                            {
                                call("【L】拷贝所有渠道附加资源:");
                            }
                            Combine(AllChannelCommon, dirDest, call);
                            if (call != null)
                            {
                                call("【I】拷贝所有渠道附加资源完成!");
                            }
                        }
                        if (call != null)
                        {
                            call("【I】---------------------------------\r\n");
                        }

                        // 拷贝所有渠道配置中的【其他渠道参数替换文件列表】
                        string   str        = FileProcess.fileToString(AllChannelCommon + ".txt");
                        Settings allChannel = Settings.Parse(str);
                        setting.addSettings(allChannel, 5);
                        setting.ReplaceLateParams();            // 替换设置的关键字信息为在线获取的参数

                        // 清除所有渠道通用配置缓存
                        Apktool.DeletDir(AllChannelCommon);
                        Apktool.DeletFile(AllChannelCommon + ".txt");   // 清除配置文件信息
                    }
                }


                if (call != null)
                {
                    call("【L】1、拷贝文件前,清除游戏包中指定的文件:");
                }
                RemoveDirFile(dirDest, call, setting);


                if (call != null)
                {
                    call("【L】2、复制所有文件,并忽略忽略列表中的文件和目录:");
                }
                CopyFolderTo_Ignore(dirSource, dirDest, call, setting);    // 复制所有文件,并忽略忽略列表中的文件和目录


                if (call != null)
                {
                    call("【L】3、附加拷贝,附加列表中的文件和目录:");
                }
                CopyFolderTo_addCopyDir(dirSource, dirDest, call, setting); // 附加拷贝,附加列表中的文件和目录
                RemoveDirFile(dirDest, call, setting);                      // 清除复制时,原有目录


                String ManifestPath = dirDest + "\\" + "AndroidManifest.xml";
                if (File.Exists(ManifestPath))
                {
                    if (call != null)
                    {
                        call("【L】4、修改Manifest.xml文件:");
                    }

                    Manifest manifest = new Manifest(ManifestPath);        // 创建Manifest对象
                    Settings.gameLabel = manifest.label;                   // 获取游戏显示名称,如: @string/app_name

                    manifest.runCMD(setting.ManifestCMD);                  // 执行manifest修改逻辑
                    manifest.save();                                       // 保存manifest
                    Settings.gameIcon = manifest.icon;                     // 获取游戏图标名称,如: @drawable/icon
                }


                setting.ReplaceFiles_ChannelParams(dirDest);                // 替换其他文件中配置的渠道参数变量
                setting.ProcessIcon(dirDest);                               // 处理icon


                Settings.call = tmp;    //还原call
            }
        }