示例#1
0
        public void runAndroidDecompile()
        {
            AndroidApp androidApp = new AndroidApp(Config);

            androidApp.OutputDataReceived += logText;

            outputDirName            = buildOutputDir();
            androidApp.OutputDirName = outputDirName;
            Directory.CreateDirectory(androidApp.getOutputPath(""));
            logText("build " + outputDirName + " finished!");
            androidApp.FileBackupName = "temp.bak";
            androidApp.loadFile(SourceFile);
            logText("copy to " + androidApp.FileBackupName + " finished!");
            androidApp.runDecompile();
            logText("decompile finished!");
            androidApp.readVersion(out VersionName, out VersionCode);
        }
示例#2
0
        public void runAndroidCommand()
        {
            AndroidApp resourceApp = null;
            AndroidApp androidApp  = new AndroidApp(Config);

            androidApp.OutputDataReceived += logText;

            outputDirName            = buildOutputDir();
            androidApp.OutputDirName = outputDirName;
            Directory.CreateDirectory(androidApp.getOutputPath(""));
            logText("build " + outputDirName + " finished!");
            androidApp.FileBackupName = "temp.bak";
            androidApp.loadFile(SourceFile);
            logText("copy to " + androidApp.FileBackupName + " finished!");
            androidApp.runDecompile();
            logText("decompile " + androidApp.FileBackupName + " finished!");

            if (Config.EnableCopyFile)
            {
                androidApp.unzipFileList(Config.CopyFileList.ToArray());
            }

            androidApp.deleteFileAndDir(DeletePath.ToArray());

            if (DeleteGameResDir)
            {
                androidApp.deleteGameResDir();
            }

            if (!String.IsNullOrEmpty(ResourceApkPath))
            {
                resourceApp = new AndroidApp(Config);
                resourceApp.OutputDataReceived += logText;

                resourceApp.OutputDirName  = outputDirName;
                resourceApp.FileBackupName = "resource.bak";
                resourceApp.loadFile(ResourceApkPath);
                logText("copy to " + resourceApp.FileBackupName + " finished!");
                resourceApp.runDecompile();
                logText("decompile " + resourceApp.FileBackupName + " finished!");

                logText("start copy...");

                JObject funJson  = resourceApp.readFunctionTxt();
                string  gameDir  = funJson["GamePath"].ToObject <string>();
                bool    resEncry = funJson["EncryptResource"].ToObject <bool>();

                foreach (string itemName in Config.ResourceFileList)
                {
                    string pathName  = itemName;
                    bool   needEncry = false;
                    if (itemName.Contains("%gamedir%"))
                    {
                        pathName  = itemName.Replace("%gamedir%", gameDir);
                        needEncry = !resEncry;
                    }

                    if (Directory.Exists(resourceApp.getTempPath(pathName)))
                    {
                        resourceApp.DirectoryCopy(resourceApp.getTempPath(pathName), androidApp.getTempPath(pathName), needEncry);
                    }
                    else if (File.Exists(resourceApp.getTempPath(pathName)))
                    {
                        resourceApp.FileCopy(resourceApp.getTempPath(pathName), androidApp.getTempPath(pathName), needEncry);
                    }
                }

                logText("copy from " + resourceApp.FileBackupName + " finished!");
            }

            foreach (string strPath in EncryptOverwrite)
            {
                if (Directory.Exists(strPath))
                {
                    androidApp.DirectoryCopy(strPath, androidApp.getAssetPath(""), true);
                    logText("copy " + strPath + " finished!");
                }
            }

            foreach (string strPath in NormalOverwrite)
            {
                if (Directory.Exists(strPath))
                {
                    androidApp.DirectoryCopy(strPath, androidApp.getTempPath(""), false);
                    logText("copy " + strPath + " finished!");
                }
            }

            {
                JObject funJson = androidApp.readFunctionTxt();
                string  gameDir = funJson["GamePath"].ToObject <string>();
                foreach (string strPath in OtherJsonFile)
                {
                    string fileName = Path.GetFileName(strPath);
                    androidApp.FileCopy(strPath, androidApp.getJsonPath(gameDir, fileName), true);
                }
            }
            foreach (string strPath in GlobalresOverwrite)
            {
                if (Directory.Exists(strPath))
                {
                    androidApp.DirectoryCopy(strPath, androidApp.getAssetPath(""), false);
                    logText("copy " + strPath + " finished!");
                }
            }

            //修改AppName
            androidApp.editAppName(Package.AppName);

            foreach (ChannelItem channel in ChannelList)
            {
                logText("pack " + channel.ChannelId);

                int    appVerCode = 0;
                string appVerName = "";
                androidApp.readVersion(out appVerName, out appVerCode);

                if (String.IsNullOrEmpty(VersionName))
                {
                    VersionName = appVerName;
                }
                if (VersionCode <= 0)
                {
                    VersionCode = appVerCode;
                }
                //修改AndroidManifest文件
                androidApp.editAndroidManifest(channel, Package, PermissionDelete, VersionName, VersionCode);
                logText("editAndroidManifest finished!");

                androidApp.editFunctionTxt(channel.ChannelId, true, Package.PackageName);
                logText("editFunctionTxt finished!");

                androidApp.packApk(channel.ChannelId, Package.PackageName, VersionName);
            }

            if (Config.DeleteTemp)
            {
                androidApp.deleteTempDir();
                if (resourceApp != null)
                {
                    resourceApp.deleteTempDir();
                }
            }
            logText("all finished!");
        }