private void button6_Click(object sender, EventArgs e) { String path = ToolSetting.Instance().ProcessTmp_dir + "\\截屏.jpg"; IconProcesser.getScreen(0, 0, -1, -1, path); System.Diagnostics.Process.Start(path); }
/// <summary> /// 打开指定的目录 /// </summary> private void ToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem iteam = sender as ToolStripMenuItem; String dir = ""; ToolSetting settting = ToolSetting.Instance(); // 载入设置信息 if (iteam == 裸包目录ToolStripMenuItem) { dir = settting.gameAPK_dir; } if (iteam == 道目录ToolStripMenuItem) { dir = settting.chargeAPK_dir; } if (iteam == 缓存目录ToolStripMenuItem) { dir = settting.ProcessTmp_dir; } if (iteam == 输出目录ToolStripMenuItem) { dir = settting.outputAPK_dir; } if (!dir.Equals("")) { if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } System.Diagnostics.Process.Start("explorer.exe", "/e, " + dir); } }
/// <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 + "完成"); } } }
private void 道附加资源ToolStripMenuItem_Click(object sender, EventArgs e) { List <String> list = new List <string>(); ToolSetting.confirmDir(settting.chargeAPK_dir + "\\所有渠道\\附加资源"); String tittle = "添加,渠道附加资源"; if (selectChannelIds.Count == 0) { //list.Add("所有渠道"); MessageBox.Show("您当前尚未选择任何渠道!\r\n请先选择需要操作的渠道,再进行此操作", tittle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { foreach (String channelId in selectChannelIds) { list.Add(channelId); } foreach (String channelId in list) { String Dir = settting.chargeAPK_dir + "\\" + channelId + "\\附加资源"; ToolSetting.confirmDir(Dir); System.Diagnostics.Process.Start("explorer.exe", "/e, " + Dir); } showTip(list.Count, tittle, "请在当前弹出的", "目录下,", "添加渠道附加资源\r\n\r\n如:res\\drawable-hdpi-v4\\icon.png"); } }
// 选择游戏包变动 private void comboBox_selectGame_SelectedIndexChanged(object sender, EventArgs e) { int index = comboBox_selectGame.SelectedIndex; if (index != -1) { selectGameId = gameIds[index]; // 选择游戏时,记录对应的游戏id信息 // 获取游戏裸包下的对应游戏目录,没有则创建 String gameDir = settting.gameAPK_dir + "\\" + selectGameId; ToolSetting.confirmDir(gameDir); // 载入游戏目录下的版本目录信息 DirectoryInfo[] dirs = getDirectories(gameDir); if (dirs.Length == 0) // 若版本目录为空,则创建 { ToolSetting.confirmDir(gameDir + "\\v1.0.0"); dirs = getDirectories(gameDir); } versionDirs = dirs; // 获取所有版本目录,忽略 游戏Icon或Logo 目录 List <String> ingnore = new List <string>(); ingnore.Add("游戏Icon或Logo"); ingnore.Add("附加资源"); String[] names = DirNames(dirs, ingnore).ToArray(); setCombox(comboBox_version, names); } }
/// <summary> /// '应用设置'按钮的事件处理. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnApplySetting_Click(object sender, EventArgs e) { /* * * 改变内存中的用户设置信息 * **/ ToolSetting.Language = ".Net"; ToolSetting.Postfix = this.txtDotNetPostfix.Text.Trim(); ToolSetting.TabSize = Convert.ToInt32(this.txtTabSize.Text.Trim()); ToolSetting.SavePath = this.txtSavePath.Text.Trim(); ToolSetting.References = ToolSetting.FormatStringArray( Regex.Split(this.rtbReferencesList.Text.Trim(), "\n+", RegexOptions.None)); ToolSetting.OracleDataMapping = (DataTable)this.dgvOracleMapping.DataSource; /* * 保存用户设置信息 * ***/ if (ToolSetting.SaveUserSetting()) { MessageBox.Show("用户设置信息保存成功!", "保存信息"); this.ApplySettingsWarning(); } else { MessageBox.Show("用户设置信息保存失败!", "保存信息"); //重新加载用户设置信息到内存. ToolSetting.LoadUserSettings(); } }
// "%~dp0Update.exe" "[CONFIG]https://git.oschina.net/joymeng/apkTool/raw/master/files/updateFiles.txt" "E:\tmp2\Update_Files\\" "渠道计费包\0000001\\" /// <summary> /// 调用Update.exe,更新以perfix为前缀的配置文件 /// </summary> public static void updateFiles(string perfix) { string update_EXE = curDir() + "tools\\" + "Update.exe"; //string url0 = "https://git.oschina.net/joymeng/apkTool/raw/master/files/updateFiles.txt"; string url0 = Update.apkMd5Url; string url = "[CONFIG]" + url0; string path = ToolSetting.Instance().serverRoot; // 设置"渠道计费包\0000001\\"为默认渠道配置 string configInfo = WebSettings.getWebData(url0); // 获取更新配置信息 示例:scimence( Name1(6JSO-F2CM-4LQJ-JN8P) )scimence if (configInfo.Equals("")) { return; } if (!configInfo.Contains(perfix) && !configInfo.Contains(perfix.Replace("\\", "/"))) { perfix = @"渠道计费包/0000001/->" + perfix; } url = AddQuotation(url); path = AddQuotation(path); perfix = AddQuotation(perfix); update_EXE = AddQuotation(update_EXE); // 调用更新插件执行软件更新逻辑 String arg = url + " " + path + " " + perfix; System.Diagnostics.Process.Start(update_EXE, arg); }
// Initialize application library public AssetProcessor() { Name = GetType().Name; ParameterSetting = new ToolSetting(); AvailablePlatforms = new List <BuildPlatform>(); ProcessResult = new ResultCode(ResultCode.SUCCESS_FALSE); }
/// <summary> /// config.txt文件合并逻辑,将SourceConfig中的所有配置合并到TargetConfig中 /// </summary> public static void Config_Combine(String SourceConfig, String TargetConfig, Cmd.Callback call = null, bool useDirMode = true) { if (useDirMode) { SourceConfig = SourceConfig + "\\assets\\ltsdk_res\\config.txt"; TargetConfig = TargetConfig + "\\assets\\ltsdk_res\\config.txt"; } LT_config config = new LT_config(); config.load_ConfigFile(TargetConfig); // 载入目标config配置信息 string data = FileProcess.fileToString(SourceConfig); if (!data.Equals("")) // 载入修改的配置信息 { config.AddValues(data); } // 确保目标路径存在 String parentDir = TargetConfig.Substring(0, TargetConfig.LastIndexOf("\\config.txt")); ToolSetting.confirmDir(parentDir); config.save(); // 保存配置信息 if (call != null) { call("【I】混合" + SourceConfig + "到\r\n" + TargetConfig + "中"); } }
/// <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); } } }
//========================== // apk解包打包逻辑封装 /// <summary> /// 若为apk文件,则先行解包 /// </summary> public static String apkUnpack(String apkFile, Cmd.Callback call, bool deletPublicXML = false) { // 若输入的为apk文件,则自动进行解包 if (Apktool.isApkFile(apkFile)) { if (call != null) { call("【I】" + Path.GetFileName(apkFile)); } if (call != null) { call("【I】apk解包开始..."); } string dir = Apktool.unPackage(apkFile, call, deletPublicXML); // 使用apktool进行apk的解包 if (dir.Contains("【E】")) { return(dir); } if (call != null) { call("【I】apk解包结束!\r\n"); } // 拷贝apk目录下的配置文件到解包文件所在目录 String configTxt = apkFile.Replace(".apk", ".txt"); String configTxt2 = apkFile.Replace(".apk", "-" + Settings.gameId + ".txt"); // 可按游戏获取游戏id对应的配置文件 if (File.Exists(configTxt2) && !File.Exists(dir + ".txt")) { File.Copy(configTxt2, dir + ".txt", false); } else if (File.Exists(configTxt) && !File.Exists(dir + ".txt")) { File.Copy(configTxt, dir + ".txt", false); } if (File.Exists(dir + ".txt")) { // 添加游戏附加配置信息到渠道包,打包配置中 String gameAttachConfig = ToolSetting.Instance().serverRoot + "游戏附加配置\\" + Settings.gameId + ".txt"; Settings.AppendSettingsTo(gameAttachConfig, dir + ".txt"); } return(dir); } else { return(apkFile); } }
// 应用程序,入口逻辑 public static void call() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (Update.Updated()) { DependentFiles.checksAll(); // 检测工具运行依赖文件 ToolSetting.Instance(); // 载入工具的配置信息 //Application.Run(new Form2()); Application.Run(new Form4()); } }
private void settingToolStripMenuItem_Click(object sender, EventArgs e) { FormCollection coll = Application.OpenForms; foreach (Form form in coll) { if (form is ToolSetting) { form.Focus(); return; } } ToolSetting settingForm = new ToolSetting(); settingForm.Show(); }
private void Form3_Load(object sender, EventArgs e) { Form1.loadSigns(comboBox_sign); // 载入签名文件信息 // 载入游戏裸包、和计费包列表 ToolSetting settting = ToolSetting.Instance(); gameApkDic = getApk_FileOrDir(settting.gameAPK_dir); loadApks(gameListBox, gameApkDic); channelApkDic = getApk_FileOrDir(settting.chargeAPK_dir); loadApks(channelListBox, channelApkDic); gameList = gameList_Data.getGameList(); // 获取游戏列表信息 setGameList(comboBox_selectGame, gameList, 0, true); }
private void 添加游戏附加资源ToolStripMenuItem_Click(object sender, EventArgs e) { if (!SelectVersionDir.Equals("")) { // 获取选中的游戏包所在的目录的附加资源 //String attachDir = SelectVersionDir + "\\附加资源"; String attachDir = settting.gameAPK_dir + "\\" + selectGameId + "\\附加资源"; List <String> list = new List <string>(); String gameName = selectGameId + "_" + gameList[selectGameId]; String tittle = "为游戏“" + gameName + "”添加附加资源"; DialogResult result = MessageBox.Show(this, "添加的资源,是否用于所有渠道?\r\n\r\n否,用于选中的渠道\r\n取消,不操作", tittle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (result.Equals(DialogResult.Yes)) { list.Add("所有渠道"); } else if (result.Equals(DialogResult.No)) { if (selectChannelIds.Count == 0) { MessageBox.Show(this, "您当前尚未选择任何渠道!\r\n请先选择需要操作的渠道,再进行此操作", tittle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { foreach (String channelId in selectChannelIds) { list.Add(channelId); } } } else if (result.Equals(DialogResult.Cancel)) { return; } foreach (String channelId in list) { String Dir = attachDir + "\\" + channelId; ToolSetting.confirmDir(Dir); System.Diagnostics.Process.Start("explorer.exe", "/e, " + Dir); } showTip(list.Count, tittle, "请在当前弹出的", "目录下,", "添加游戏附加资源\r\n\r\n如:res\\drawable-hdpi-v4\\icon.png"); } }
/// <summary> /// 窗体加载事件处理. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EntityClassGenerator_Load(object sender, EventArgs e) { //控制数据库参数输入控件的外观. this.gpbOracle.Visible = true; this.lblIsGenerating.Visible = false; this.gpbOracle.Location = new Point(32, 69); //加载用户设置信息. ToolSetting.LoadUserSettings(); //初始化用户设置控件. this.InitUserSettingControl(); this.ApplySettingsWarning(); //使初始状态显示第一个选项卡. this.tbcMain.SelectedIndex = 0; this.rdbOracle.Checked = true; }
private void 游戏Icon或LogoToolStripMenuItem_Click(object sender, EventArgs e) { String selectGameDir = settting.gameAPK_dir + "\\" + selectGameId + "\\游戏Icon或Logo"; List <String> list = new List <string>(); String gameName = selectGameId + "_" + gameList[selectGameId]; String tittle = "为游戏“" + gameName + "”添加Icon或Logo"; DialogResult result = MessageBox.Show(this, "添加的Icon或Logo,是否用于所有渠道?\r\n\r\n否,用于选中的渠道\r\n取消,不操作", tittle, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (result.Equals(DialogResult.Yes)) { list.Add("所有渠道"); } else if (result.Equals(DialogResult.No)) { if (selectChannelIds.Count == 0) { MessageBox.Show(this, "您当前尚未选择任何渠道!\r\n请先选择需要操作的渠道,再进行此操作", tittle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { foreach (String channelId in selectChannelIds) { list.Add(channelId); } } } else if (result.Equals(DialogResult.Cancel)) { return; } foreach (String channelId in list) { String Dir = selectGameDir + "\\" + channelId + "\\res\\drawable"; ToolSetting.confirmDir(Dir); System.Diagnostics.Process.Start("explorer.exe", "/e, " + Dir); } showTip(list.Count, tittle, "请在当前弹出的", "目录下,", "添加游戏Icon或Logo \r\n\r\n如:\r\nGAME_ICON.png 游戏icon \r\nGAME_LOGO.png 游戏logo"); }
public void Init(TerrainMakerEditorWindow root) { m_Root = root; //更新编辑器配置 string totalTerrainMakerDefineSettingPath = Application.dataPath + "/" + TerrainMakerDefineSettingPath; LogHelper.Trace?.Log("TerrainMakerTool", "totalTerrainMakerDefineSettingPath", totalTerrainMakerDefineSettingPath); if (File.Exists(totalTerrainMakerDefineSettingPath)) { string defineSettingStr = File.ReadAllText(totalTerrainMakerDefineSettingPath); m_ToolSetting = LitJson.JsonMapper.ToObject <ToolSetting>(defineSettingStr); } else { m_ToolSetting = new ToolSetting(); } __CreateToolConfig(); LogHelper.Trace?.Log("TerrainMakerTool", "m_ToolSetting", LogHelper.Object2String(m_ToolSetting)); //更新地形配置 string totalDefaultTerrainInfoPath = Application.dataPath + "/" + m_ToolSetting.DefaultTerrainInfoPath; LogHelper.Trace?.Log("TerrainMakerTool", "totalDefaultTerrainInfoPath", totalDefaultTerrainInfoPath); if (File.Exists(totalDefaultTerrainInfoPath)) { string defaultTerrainInfo = File.ReadAllText(totalDefaultTerrainInfoPath); m_CurrentDefaultTerrainInfo = LitJson.JsonMapper.ToObject <DefaultTerrainInfo>(defaultTerrainInfo); } else { m_CurrentDefaultTerrainInfo = new DefaultTerrainInfo(); } __CreateDefaultTerrainInfo(); m_RecordDefaultTerrainInfo = CloneHelper.DeepClone(m_CurrentDefaultTerrainInfo) as DefaultTerrainInfo; LogHelper.Trace?.Log("TerrainMakerTool", "m_RecordDefaultTerrainInfo", LogHelper.Object2String(m_RecordDefaultTerrainInfo)); }
/// <summary> /// 将表或视图的结构转换为字段信息. /// </summary> /// <param name="stru">表或视图的结构信息</param> /// <returns>字段信息</returns> public static DataTable ConvertTableOrViewStructure(DataTable stru) { DataTable fields = FieldMethods.GetFieldsTable(); string fieName = null; string fieType = null; string comments = null; string constrainttype = null; string dbfieType = null; int filedlenth = 0; for (int i = 0; i < stru.Rows.Count; i++) { fieName = stru.Rows[i][0].ToString(); fieType = ToolSetting.GetMapping(SystemSetting.DbType.Oracle, stru.Rows[i][1].ToString()); comments = stru.Rows[i]["comments"].ToString(); constrainttype = stru.Rows[i]["constraint_type"].ToString(); dbfieType = stru.Rows[i][1].ToString(); filedlenth = string.IsNullOrEmpty(stru.Rows[i]["DATA_LENGTH"].ToString()) ? 0 : Convert.ToInt32(stru.Rows[i]["DATA_LENGTH"].ToString()); fields.Rows.Add(new object[] { fieName, fieType, comments, constrainttype, dbfieType, filedlenth }); } return(fields); }
/// <summary> /// 执行打包处理逻辑 /// </summary> private void Combine_Click(object sender, EventArgs e) { ToolSetting settting = ToolSetting.Instance(); // 载入设置信息 foreach (object iteamGame in gameListBox.CheckedItems) { String gameApkName = iteamGame.ToString(); // 游戏包名称, 如:1000_卡丁车最新通用包.apk String gameApk = gameApkDic[gameApkName]; // 游戏包路径 String gameId = getNumber(gameApk); // 提取游戏id Settings.gameId = gameId; foreach (object iteamChannel in channelListBox.CheckedItems) { String chargeApkName = iteamChannel.ToString(); // 计费包名称, 如:0000694_lennovo_V2.6.1_float.apk String chargeAPK = channelApkDic[chargeApkName]; // 计费包路径 String channelId = getNumber(chargeAPK); // 渠道id Settings.channelId = channelId; // 获取游戏对应的渠道参数 Settings.getChannelparams(gameId, channelId, OutPut); // 设置apk工具的输出目录、缓存文件目录、和输出文件名 Apktool.outputAPK_dir = settting.outputAPK_dir + "\\" + gameId; String name = gameApkName.Replace(".apk", "").TrimEnd('.'); Apktool.outputAPK_name = gameId + "_" + channelId + "_" + comboBox_sign.Text + "_" + name + ".apk"; Apktool.ProcessTmp_dir = settting.ProcessTmp_dir; // 执行apk打包混合逻辑 Form2.CombineApk(chargeAPK, gameApk, comboBox_sign.Text, OutPut); Apktool.outputAPK_dir = ""; Apktool.outputAPK_name = ""; Apktool.ProcessTmp_dir = ""; } } }
// 拖拽载入的apk所在目录文件夹信息 private void loadApkDir(CheckedListBox checklist, String file_dir) { // 获取文件所在目录 if (File.Exists(file_dir)) { file_dir = Path.GetDirectoryName(file_dir); } ToolSetting settting = ToolSetting.Instance(); if (checklist == gameListBox) { settting.gameAPK_dir = file_dir; gameApkDic = getApk_FileOrDir(settting.gameAPK_dir); loadApks(gameListBox, gameApkDic); } else if (checklist == channelListBox) { settting.chargeAPK_dir = file_dir; channelApkDic = getApk_FileOrDir(settting.chargeAPK_dir); loadApks(channelListBox, channelApkDic); } settting.save(); }
// 载入所有选择渠道的计费文件信息 private void loadChannelApks() { selectChannelApks.Clear(); OutPut("【I】 载入所有选择渠道的计费文件信息..."); foreach (String channelId in selectChannelIds) { String path = settting.chargeAPK_dir + "\\" + channelId; ToolSetting.confirmDir(path); Dictionary <string, string> dic = Form3.getApk_FileOrDir(path); if (dic.Count > 0) { String channelApk = dic.ElementAt(0).Value; selectChannelApks.Add(channelId, channelApk); OutPut("【I】 渠道" + channelId + "_" + channelList[channelId] + " ,存在计费文件:\r\n" + channelApk); } else { OutPut("【E】 渠道" + channelId + "_" + channelList[channelId] + " ,无计费包!请添加渠道计费文件至目录:\r\n" + path); } } OutPut("【I】 载入选择渠道的计费文件信息完成"); }
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 } }
/// <summary> /// Oracle'连接数据库'按钮的事件处理. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOracleConnectDb_Click(object sender, EventArgs e) { string server = this.txtOracleServer.Text.Trim(); string uid = this.txtOracleUserID.Text.Trim(); string pwd = this.txtOraclePwd.Text.Trim(); //ToolSetting.Language = ".Net"; //ToolSetting.Postfix = this.txtDotNetPostfix.Text.Trim(); //ToolSetting.TabSize = Convert.ToInt32(this.txtTabSize.Text.Trim()); //ToolSetting.SavePath = this.txtSavePath.Text.Trim(); //ToolSetting.References = ToolSetting.FormatStringArray( // Regex.Split(this.rtbReferencesList.Text.Trim(), "\n+", RegexOptions.None)); //ToolSetting.OracleDataMapping = (DataTable)this.dgvOracleMapping.DataSource; ToolSetting.ServiceName = server; ToolSetting.UserName = uid; ToolSetting.UserPassWord = pwd; /* * 保存用户设置信息 * ***/ ToolSetting.SaveUserSetting(); //得到数据库参数. //相关验证. if (server.Equals("") || uid.Equals("")) { MessageBox.Show("服务名和用户名均不能为空!" , "警告" , MessageBoxButtons.OK , MessageBoxIcon.Warning); return; } //得到连接字符串. string conStr = ConnectOracle.GetConnectionStr(server, uid, pwd); //访问数据库. ConnectOracle.OpenConnection(conStr); DataTable tabs = ConnectOracle.GetAllTableAndViewName(); ConnectOracle.CloseConnection(); //必要的验证. if (tabs == null) { return; } //得到所有表和视图的结构信息. //this.GetOracleTablesStructure(tabs); //显示所有的表和视图的名称. if (tabs != null) { this.clbTablesAndView.Items.Clear(); for (int i = 0; i < tabs.Rows.Count; i++) { string type = tabs.Rows[i][1].ToString().Trim().ToUpper(); string temp = null; if (type.Equals("VIEW")) { temp = "@ "; } else { temp = ""; } this.clbTablesAndView.Items .Add(temp + tabs.Rows[i][0].ToString(), false); } } //显示第一个表或视图的结构信息. if (this.clbTablesAndView.Items.Count > 0) { this.clbTablesAndView.SelectedIndex = 0; string tabName = this.GetTableOrViewName (this.clbTablesAndView.Items[0].ToString()); this.lblTabStructure.Text = "表" + tabName + "相关实体类结构:"; this.FormatDgvTableStructure(); } this.lblTabList.Text = "Oracle表/视图:"; }
public ToolSetting() : base(typeof(SettingUI)) { instance = this; ui = uistate as SettingUI; }
/// <summary> /// 执行apk解包文件混合逻辑 /// </summary> public static void CombineApk(String dirSource, String dirTarget, String signFileName, Cmd.Callback call, bool deletTXT = true) { if (call != null) { call("【I】"); } ToolSetting toolSet = ToolSetting.Instance(); // 载入配置信息 String Set_gameId = Settings.gameId, Set_channelId = Settings.channelId; // 获取游戏id、渠道id //-------------------------1 // 游戏apk解包 dirTarget = apkUnpack(dirTarget, call /*, true*/); // 解包游戏包并删除res\values\public.xml文件 if (dirTarget.Contains("【E】")) { return; } //-------------------------2 // 渠道apk解包 dirSource = apkUnpack(dirSource, call); //ReplaceValues.ReplaceFileContent(dirSource, "0x7f0", "0x7ff"); //if (call != null) call("【I】替换渠道解包文件下,所有0x7f0 为 0x7ff"); if (dirSource.Contains("【E】")) { return; } // 添加游戏Icon或Logo到游戏解包文件 addGameAttachs(toolSet, call, dirTarget, "\\游戏Icon或Logo", Set_gameId, Set_channelId, "游戏解包目录"); // 添加游戏Icon或Logo到渠道解包文件 addGameAttachs(toolSet, call, dirSource, "\\游戏Icon或Logo", Set_gameId, Set_channelId, "渠道解包目录"); //-------------------------3 if (call != null) { call("【I】"); } if (call != null) { call("【I】执行apk混合逻辑..."); } if (call != null) { call("【I】添加" + dirSource + "\r\n到" + dirTarget + "中"); } // 进行apk文件的混合 ApkCombine.Combine(dirSource, dirTarget, call); if (call != null) { call("【I】apk混合完成!\r\n"); } //-------------------------4 // 添加渠道附加资源 addChannelAttachs(toolSet, call, dirTarget, "\\附加资源", Set_channelId); // 添加游戏包附加资源 addGameAttachs(toolSet, call, dirTarget, "\\附加资源", Set_gameId, Set_channelId); //-------------------------5 // 执行R文件修改逻辑 if (toolSet.R_Process) { bool R_result = R_process.Start(dirTarget, dirSource, call, toolSet.apktool_yml_Process, toolSet.R_Process_Game); if (!R_result) { return; } } //String path = R_process.create_publicXML(dirTarget, call); //String package = Settings.channel_param["package"]; // 获取包名信息 //R_process.rebuidR_smali(path, dirTarget + "\\smali", package, call); // 重新生成包名路径下的R文件 //File.Copy(path, dirTarget + @"\res\values\public.xml"); // 替换原有public.xml //-------------------------6 // apk重新打包 String result = apkPackage(dirTarget, signFileName, call); if (result.Contains("【E】")) { return; } // 打包完成后清除缓存中的解包文件 if (call != null) { call("【I】清除缓存目录," + dirSource); } Apktool.DeletDir(dirSource); if (call != null) { call("【I】清除缓存目录," + dirTarget); } Apktool.DeletDir(dirTarget); if (deletTXT) { if (call != null) { call("【I】清除缓存文件," + dirSource + ".txt"); } Apktool.DeletFile(dirSource + ".txt"); } }
//delegate void Combine_LogicCall(); // apk混合逻辑 private void Combine_Logic() { //if (this.InvokeRequired) //{ // Combine_LogicCall F = new Combine_LogicCall(Combine_Logic); // this.BeginInvoke(F); //} //else { // 打包前载入游戏裸包信息 showLoadApkInfo = false; comboBox_version_SelectedIndexChanged(null, null); if (!File.Exists(selectGameApk)) { OutPut("【E】 游戏裸包不存在,请先添加游戏裸包"); return; } FormFunctionLock(false); String gameName = gameList[selectGameId]; // 游戏名称 String packageErrorMessage = ""; if (selectChannelIds.Count == 0) { MessageBox.Show("请选择要打包的游戏渠道!"); } foreach (String channelId in selectChannelIds) { try { if (!selectChannelApks.Keys.Contains(channelId)) { continue; } Settings.gameId = selectGameId; // 记录当前的游戏id Settings.channelId = channelId; // 记录当前的渠道id String chargeAPK = selectChannelApks[channelId]; String channelName = channelList[channelId]; OutPut(""); OutPut("【T】" + "-----------------------------------------------------------"); OutPut("【T】" + selectGameId + "_" + channelId + "_" + gameName + "_" + channelName); OutPut("【T】" + "-----------------------------------------------------------"); if (!File.Exists(chargeAPK)) { OutPut("【E】 当前渠道无计费包,暂不支持打包"); continue; } // 获取游戏对应的渠道参数 Settings.getChannelparams(selectGameId, channelId, OutPut); Dictionary <String, String> param = Settings.channel_param; String versionName = "", versionCode = ""; // 设置版本名称和版本号 if (param.Keys.Contains("version_name") && param.Keys.Contains("version_code")) { if (!textBox_versionName.Text.Equals("")) { if (param.Keys.Contains("version_name")) { param["version_name"] = textBox_versionName.Text.Trim(); } else { param.Add("version_name", textBox_versionName.Text.Trim()); } } if (!textBox_versionCode.Text.Equals("")) { if (param.Keys.Contains("version_code")) { param["version_code"] = textBox_versionCode.Text.Trim(); } else { param.Add("version_code", textBox_versionCode.Text.Trim()); } } versionName = param["version_name"]; versionCode = param["version_code"]; } else { continue; } // 设置apk工具的输出目录、缓存文件目录、和输出文件名 Apktool.outputAPK_dir = settting.outputAPK_dir + "\\" + selectGameId + "\\" + channelId; ToolSetting.confirmDir(Apktool.outputAPK_dir); // 确保输出目录存在 Apktool.outputAPK_name = selectGameId + "_" + channelId + "_" + versionName + "_" + versionCode + "_" + comboBox_sign.Text + "_" + gameName + "_" + channelName + "_" + comboBox_version.Text.Trim() + ".apk"; if (Apktool.outputAPK_name.Contains(":") || Apktool.outputAPK_name.Contains(":")) { Apktool.outputAPK_name = Apktool.outputAPK_name.Replace(":", "_").Replace(":", "_"); } Apktool.ProcessTmp_dir = settting.ProcessTmp_dir; // 执行apk打包混合逻辑 Form2.CombineApk(chargeAPK, selectGameApk, comboBox_sign.Text, OutPut); Apktool.outputAPK_dir = ""; Apktool.outputAPK_name = ""; Apktool.ProcessTmp_dir = ""; } catch (Exception ex) { packageErrorMessage += "\r\n" + ex.Message + "\r\n"; } // 打完一个包后等待3秒 //Thread.Sleep(3000); } if (!packageErrorMessage.Equals("")) { MessageBox.Show("打包异常信息:" + packageErrorMessage); } OutPut("【T】" + "-------------------------打包结束------------------------"); if (StartParam.AutoRun) { //Application.Exit(); // 打包结束自动退出 System.Environment.Exit(0); } FormFunctionLock(true); } }
// 载入所需信息 private void load() { ToolSetting.instance = null; // 请除原有配置信息 settting = ToolSetting.Instance(); // 载入配置信息 if (StartParam.AutoRun && !StartParam.OUTDIR.Equals("")) // 设置apk输出目录 { settting.outputAPK_dir = StartParam.OUTDIR; } Form1.loadSigns(comboBox_sign); // 载入签名文件信息 gameList = gameList_Data.getGameList(OutPut); // 获取游戏列表信息 gameIds = gameList.Keys.ToList(); // 记录游戏id信息 if (StartParam.AutoRun) { // 设置打包的游戏id int index = gameIds.Contains(StartParam.GAMEID) ? gameIds.IndexOf(StartParam.GAMEID) : 0; Form3.setGameList(comboBox_selectGame, gameList, index); } else { Form3.setGameList(comboBox_selectGame, gameList); } channelList = channelList_Data.getChannelList(OutPut); // 获取游戏列表信息 settting.AppendLocalChannels(channelList); // 向渠道列表信息中添加本地的渠道列表信息 channelIds = channelList.Keys.ToList(); // 记录渠道id信息 setStartButtonEnable(gameList.Count > 0 && channelList.Count > 0, "网络异常"); // 设置打包按钮是否可用 // 从左侧渠道列表中移除右侧已选中的渠道信息 if (selectChannelIds.Count > 0) { foreach (string id in selectChannelIds) { if (channelIds.Contains(id)) { channelIds.Remove(id); } } } //channelIds = getSubDirNames(settting.chargeAPK_dir); // 获取所有计费渠道信息 ShowChannelList(listBox2.Items.Count > 0); // 载入通用配置信息 if (initLoading) { initLoading = false; DependentFiles.updateFiles("渠道计费包/通用配置.txt"); DependentFiles.updateFiles("渠道计费包/所有渠道/"); DependentFiles.updateFiles("游戏裸包/1000/v1.test/"); DependentFiles.updateFiles("游戏附加配置/"); if (StartParam.AutoRun) { // 设置选择的渠道id String[] channels = StartParam.CHANNELID.Replace(',', ',').Replace(';', ',').Replace(';', ',').Split(','); String[] ICONDIRs = StartParam.ICONDIR.Replace(',', ',').Replace(';', ',').Replace(';', ',').Split(','); // 渠道id对应的Icon for (int i = 0; i < channels.Length; i++) { String channel = channels[i]; if (channelIds.Contains(channel)) { int index = channelIds.IndexOf(channel); listBox1.SetSelected(index, true); } if (i < ICONDIRs.Length && !channelIconDir.ContainsKey(channel)) { channelIconDir.Add(channel, ICONDIRs[i]); } } button1_Click(null, null); } } }
//<public type="attr" name="circle_radius" id="0x7f010000" /> //<public type="attr" name="password_length" id="0x7f010001" /> // 修改data中所有Src中的id信息到Target根据相同name值进行修改 private static String updateIds(String data, List <xmlNode> listSrc, List <xmlNode> listTar, Cmd.Callback call) { Dictionary <String, String> dicSrc = toIdDic(listSrc, call); // 转化为name、id映射表 Dictionary <String, String> dicTar = toIdDic(listTar, call); bool showRsmaliModify = ToolSetting.Instance().showRsmaliModify; // 显示R文件id信息修改逻辑 bool contains0000 = false; // 文件中是否含有****0000的id值信息 foreach (String name in dicSrc.Keys) { String id = dicSrc[name]; if (!data.Contains(id)) // 若smali文件中不含有旧的资源id,则从smali文件中解析旧的资源id信息 { String idName = name; //if (idName.Equals("string:common_google_play_services_unknown_issue")) // idName = idName + ""; if (idName.Contains(":")) { idName = idName.Substring(idName.IndexOf(":") + 1); } String idTmp = getSmaliId(data, idName); if (!idTmp.Equals("")) { id = idTmp; } } if (data.Contains(id)) { if (id.EndsWith("0000")) { contains0000 = true; } if (dicTar.ContainsKey(name)) // 替换data中同名name对应的id值 { String idTar = dicTar[name]; // 目标id值 if (!id.Equals(idTar)) { String idTarTmp = "0x_@_" + idTar.Substring("0x".Length); // 替换0x7f00001这样的id串为0x_@_7f00001,避免重复,文件中全部id替换完成后,在统一替换回0x7f00001串 data = data.Replace(id, idTarTmp); if (showRsmaliModify && call != null) { call("【I】修改" + name + "的id值," + id + "->" + idTar); } } } else if (call != null) { call("【E】当前新生成的public.xml文件中,不含有资源" + name + "!"); } } } if (data.Contains("0x_@_")) { data = data.Replace("0x_@_", "0x"); // 剔除附加进去的"_@_" } if (contains0000 && data.Contains("const/high16")) { data = data.Replace("const/high16", "const"); // 剔除/high16的限制 if (showRsmaliModify && call != null) { call("【I】修改文件中所有\"const/high16\"为\"const\""); } } return(data); }
//从dirTarget目录下获取res资源,重新编译生成public.xml private static bool UpdatePublicXML(String dirTarget, Cmd.Callback call) { ToolSetting settting = ToolSetting.Instance(); // 载入设置信息 if (call != null) { call("【I】- 2.解包Empty.apk"); } String emptyApk = DependentFiles.curDir() + "\\tools\\Empty.apk"; // 空项目资源路径 if (emptyApk.Contains("\\\\")) { emptyApk = emptyApk.Replace("\\\\", "\\"); } String emptyDir = Apktool.unPackage(emptyApk, null, false); // 解包空apk if (emptyDir.Contains("【E】") && call != null) { call("【E】 解包Empty.apk异常"); return(false); } if (call != null) { call("【I】- 复制游戏res资源"); } String Res = emptyDir + "\\res"; ApkCombine.CopyFolderTo(dirTarget + "\\res", Res, true); // 复制Target目录到res目录,到空工程解包路径下 Program.Delay(3000); // 部分机器复制文件,存在异步延时,确保文件复制完成 if (call != null) { call("【I】- 3.使用新的res资源,生成新的Empty.apk"); } String apkFile = Apktool.package(emptyDir, null); // 使用apktool进行打包 if (apkFile.Contains("【E】") && call != null) { call("【E】 打包Empty.apk异常"); call("【E】 异常信息:" + apkFile); return(false); } if (call != null) { call("【I】- 4.解包Empty.apk"); } string unpackDir = Apktool.unPackage(apkFile, null, false); // 使用apktool进行apk的解包,生成新的public.xml if (unpackDir.Contains("【E】") || unpackDir.Trim().Equals("")) { if (call != null) { call("【E】 解包Empty.apk异常"); } return(false); } if (call != null) { call("【I】- 5.复制生成的public.xml文件,到游戏res目录中"); } String relativePath = @"\res\values\public.xml"; File.Copy(unpackDir + relativePath, dirTarget + relativePath, true); // 替换原有public.xml relativePath = @"\res\drawable\empty_ic_launcher.png"; File.Copy(unpackDir + relativePath, dirTarget + relativePath, true); relativePath = @"\res\layout\empty_activity_main.xml"; File.Copy(unpackDir + relativePath, dirTarget + relativePath, true); if (call != null) { call("【I】- 清除Empty.apk相关缓存资源..."); } // 清除缓存资源 Directory.Delete(emptyDir, true); // 删除空项目解包文件 File.Delete(apkFile); // 删除生成的临时文件 Directory.Delete(unpackDir, true); // 删除空工程解包目录 return(true); }