private void Form1_Load(object sender, EventArgs e) { try { //设置初始页面 skinTabControl1.SelectTab(0); CheckForIllegalCrossThreadCalls = false; //抓取网页爬虫 Thread thread = new Thread(CheckUpdate); thread.Start(); point.Hide(); //加载MOD ListButton oldversion = new ListButton("SWAT4原版1.1", this, @"Content\System\swat4.exe", false); flowLayoutPanel1.Controls.Add(oldversion); ListButton newversion = new ListButton("SWAT4资料片1.0", this, @"ContentExpansion\System\swat4x.exe", false); flowLayoutPanel1.Controls.Add(newversion); string data = INIHelper.Read("launcher", "mod", "launcher.ini"); if (data != "on") { string[] datas = System.Text.RegularExpressions.Regex.Split(data, "%mod%"); foreach (string s in datas) { if (s == string.Empty) { continue; } string[] parts = System.Text.RegularExpressions.Regex.Split(s, "%file%"); ListButton btn = new ListButton(parts[0], this, parts[1], true); flowLayoutPanel1.Controls.Add(btn); } } //加载下载内容 string mods = INIHelper.Read("launcher", "download", "launcher.ini"); if (mods != "on") { string[] ModDetial = mods.Split(new char[] { ';' }); foreach (string mod in ModDetial) { if (mod == string.Empty) { break; } ModManager MM = new ModManager(); string[] d = mod.Split(new char[] { ':' }); MM.ModID = d[0]; MM.ModName = d[1]; flowLayoutPanel_manager.Controls.Add(MM); } } //刷新下载项目 new Thread(RefreshDownload).Start(); LoadMaps(); } catch (Exception ex) { Console.WriteLine(ex); } }
private void button2_Click(object sender, EventArgs e) { Directory.SetCurrentDirectory(System.Windows.Forms.Application.StartupPath); ModFinderDialog.ShowDialog(); if (ModFinderDialog.FileName != string.Empty) { Modname md = new Modname(); md.ShowDialog(); ListButton btn = new ListButton(md.name, this, ModFinderDialog.FileName, true); flowLayoutPanel1.Controls.Add(btn); string old = INIHelper.Read("launcher", "mod", "launcher.ini"); if (old == "on") { old = string.Empty; } INIHelper.Write("launcher", "mod", old + md.name + "%file%" + ModFinderDialog.FileName + "%mod%", "launcher.ini"); } }
public void install() { try { downloadButton1.TextLabel.Text = "安装中.."; unzip("KL_" + ModID + ".zip", System.Environment.CurrentDirectory); downloadButton1.setProgress(0); downloadButton1.TextLabel.Text = "已安装"; ModManager MM = new ModManager(); MM.ModID = ModID; MM.ModName = this.Modname.Text.Replace("名称:", string.Empty); this.Invoke(new EventHandler(delegate { manager.Controls.Add(MM); //添加mod到目录 if (add != "false") { ListButton btn = new ListButton(MM.ModName, frm1, add, true); ModLister.Controls.Add(btn); string oldmods = INIHelper.Read("launcher", "mod", "launcher.ini"); if (oldmods == "on") { oldmods = string.Empty; } INIHelper.Write("launcher", "mod", oldmods + MM.ModName + "%file%" + add + "%mod%", "launcher.ini"); } })); //添加到管理目录 string old = INIHelper.Read("launcher", "download", "launcher.ini"); old = old == "on" ? string.Empty : old; INIHelper.Write("launcher", "download", old + ModID + ":" + Modname.Text.Replace("名称:", string.Empty) + ";", "launcher.ini"); frm1.DownloadQueue.Remove(this); } catch (Exception x) { Console.WriteLine(x); } }