// 选择游戏包变动 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); } }
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"); } }
/// <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 + "中"); } }
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"); } }
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"); }
// 载入所有选择渠道的计费文件信息 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】 载入选择渠道的计费文件信息完成"); }
//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); } }