private void updateButton_Click(object sender, EventArgs e) { log("[Update Start]"); statusBar.Text = "Patching..."; detailInfoBar.Text = ""; // reset log text updateButton.Enabled = false; exitButton.Enabled = false; detailButton.Enabled = false; Updater patcher = new Updater(this, PATCH_MPQ_NAME, mpqPath, gamePath, true); patcher.DeleteAll(); patcher.ExportAll(); patcher.AddAll(); patcher.Flush(); patcher.Compact(); patcher.Close(); patcher.EncryptMpq(); if (!is_zhCN) statusBar.Text = "Finish!"; else statusBar.Text = "完成!"; updateButton.Enabled = true; exitButton.Enabled = true; detailButton.Enabled = true; log("[Update Finish]"); updateButton.Enabled = false; DialogResult result; if (!is_zhCN) { result = MessageBox.Show("Update Finished!\nDo you wish to exit?", "Finish", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } else { result = MessageBox.Show("更新完成!是否退出?", "完成", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } if (result == DialogResult.OK) { Application.DoEvents(); this.Close(); this.Dispose(); } }
private void Form1_Load(object sender, EventArgs e) { appPath = Application.StartupPath + '\\'; statusBar.Text = "Initializing..."; gamePath = Utils.getGamePath(); mpqPath = gamePath + "Nirvana.mpq"; // set version variables Updater patcher = new Updater(null, PATCH_MPQ_NAME, mpqPath, gamePath, true); SOURCE_VERSION = patcher.GetSourceVersion(); DEST_VERSION = patcher.GetDestVersion(); patcher.Close(); // set windows props //this.Text += " [" + SOURCE_VERSION + " -> " + DEST_VERSION + "]"; // set window height this.Height = 170; //check game string checkMsg = "[Game Check] - "; if (gamePath == "") { log(checkMsg + "Error - nirvana not found."); if (!is_zhCN) { statusBar.Text = "Error: Nirvana Not Found!"; } else { statusBar.Text = "错误: 找不到Nirvana!"; } updateButton.Enabled = false; return; } else log(checkMsg + "Success!"); // check version checkMsg = "[Version Check] - "; string version = Utils.getGameVersion(gamePath); //if (version.Trim() == "") version = "beta"; //string[] srcVersions=SOURCE_VERSION.Split(new char[] {'|'}, StringSplitOptions.RemoveEmptyEntries); if (version != SOURCE_VERSION) //if (!srcVersions.Contains(version)) { log(checkMsg + "Error - source version: " + SOURCE_VERSION + ", target version: " + version + "."); if (!is_zhCN) { statusBar.Text = "Error: Wrong Version!"; } else { statusBar.Text = "错误: 该补丁不支持当前版本!"; } updateButton.Enabled = false; if (!is_zhCN) { MessageBox.Show("This patch is for Nirvana (" + SOURCE_VERSION + "), but your local version is (" + version + ").", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("该补丁需要 Nirvana (" + SOURCE_VERSION + ") 版本, 您当前的版本为 (" + version + ").", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } else { log(checkMsg + "Success!"); if (!is_zhCN) { statusBar.Text = "Ready to Patch!"; } else { statusBar.Text = "补丁准备就绪!"; } log("Ready to Patch - " + gamePath); } // patch start }