public PatchForm() { InitializeComponent(); CurrentlyLoading = true; string gameFolder = LauncherSettings.GetValue(LauncherSettings.GAME_FOLDER); if (gameFolder != null) { tbGameDirectory.Text = gameFolder; UnlockPatchInterface(); } else { LockPatchInterface(); } btnRefreshAvailablePatches_Click(null, null); var exitlag = LauncherSettings.GetValue(LauncherSettings.EXITLAG); if (exitlag == "true") { cbExitLag.Checked = true; } CurrentlyLoading = false; }
private void btnRefreshAvailablePatches_Click(object sender, EventArgs e) { string downloadUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/patchlist.php"; try { var osVerMajor = System.Environment.OSVersion.Version.Major; var osVerMinor = System.Environment.OSVersion.Version.Minor; if (((osVerMajor <= 6) && (osVerMinor < 2))) { // OS Check for Win 7 SP1 (NT 6.2) or Lower //MessageBox.Show(System.Environment.OSVersion.Version.ToString()); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; } WebClient wc = new WebClient(); string patchlist = wc.DownloadString(downloadUrl); lbPatches.Items.Clear(); foreach (var item in patchlist.Split('|')) { if (!string.IsNullOrWhiteSpace(item)) { lbPatches.Items.Add(item); } } } catch (Exception ex) { MessageBox.Show($"Failed to list available patches\n\n{ex}"); } }
private void MainForm_Load(object sender, EventArgs e) { //Restores the last opened tab string lastTab = LauncherSettings.GetValue(LauncherSettings.LAUNCHER_TAB); if (lastTab != null) { var tab = tabControl.TabPages.OfType <TabPage>().FirstOrDefault(o => o.Text == lastTab); if (tab != null) { tabControl.SelectedTab = tab; } } string gameFolder = LauncherSettings.GetValue(LauncherSettings.GAME_FOLDER); if (gameFolder != null) { tbGameDirectory.Text = gameFolder; UnlockPatchInterface(); } else { LockPatchInterface(); } btnRefreshAvailablePatches_Click(null, null); }
public void lbPatches_SelectedIndexChanged(object sender, EventArgs e) { if (lbPatches.SelectedIndex == -1) { lbPatchDescription.Text = ""; lbPatchStatus.Text = ""; return; } string patchname = lbPatches.SelectedItem.ToString(); string patchDescriptionUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/{patchname}/description.txt"; string patchDateUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/{patchname}/patchdate.php"; try { WebClient wc = new WebClient(); string patchDescription = wc.DownloadString(patchDescriptionUrl); lbPatchDescription.Text = patchDescription; } catch { } //eat it string installedPatchDate = LauncherSettings.GetValue(patchname); if (installedPatchDate == null) { lbPatchStatus.Text = "Not installed"; } else { string serverPatchDate = null; try { WebClient wc = new WebClient(); serverPatchDate = wc.DownloadString(patchDateUrl); } catch { } //eat it if (serverPatchDate == null) { lbPatchStatus.Text = "Error fetching server patch date"; } else { string postText = (installedPatchDate == serverPatchDate ? "" : "\n(Update available)"); lbPatchStatus.Text = $"Installed patch date:\n{installedPatchDate}\n\nOnline patch date:\n{serverPatchDate}{postText}"; } } }
private void btnInstallPatch_Click(object sender, EventArgs e) { if (lbPatches.SelectedIndex == -1) { return; } string patchname = lbPatches.SelectedItem.ToString(); string patchPackUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/{patchname}/pack.zip"; string tempFilename = Path.Combine(LauncherSettings.TempDir, "pack.zip"); string ms2Folder = tbGameDirectory.Text; DownloadForm.DownloadFile(patchPackUrl, tempFilename, ms2Folder); }
public static void SwitchToExitlagIfNeeded() { try { var currentFilename = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; var currentName = new FileInfo(currentFilename).Name; var exitlag = LauncherSettings.GetValue(LauncherSettings.EXITLAG); if (exitlag == "true" && currentName != "gamestarter.exe") { string gamestarterExePath = Path.Combine(LauncherSettings.AppDir, "gamestarter.exe"); File.Copy(currentFilename, gamestarterExePath, true); Process.Start(gamestarterExePath); Environment.Exit(0); } } catch { } //eat it }
public BrowserForm() { this.InitializeComponent(); PageLoadedTimer.Interval = 500; PageLoadedTimer.Tick += PageLoadedTimer_Tick; this.WebBrowser.Url = new Uri(Arguments.LoginRedirectUrl); this.ModeToolStripComboBox.ComboBox.DataSource = this.StartModes.Keys.ToList(); this.ModeToolStripComboBox.SelectedItem = Settings.Default.StartMode; string pass = LauncherSettings.GetValue(LauncherSettings.REMEMBER_PASSWORD); if (!string.IsNullOrWhiteSpace(pass)) { tbRememberPassword.Text = pass; } }
public void ReloadPrevTabFromSettings() { //Restores the last opened tab string lastTab = LauncherSettings.GetValue(LauncherSettings.LAUNCHER_TAB); TabName tab = TabName.WELCOME; if (lastTab != null) { try { tab = (TabName)Enum.Parse(typeof(TabName), lastTab); } catch (Exception ex) { //MessageBox.Show(ex.ToString()); } } SelectTab(tab); }
public void DownloadComplete(string downloadedFile, string extractDirectory) { try { if (extractDirectory != null) { if (!Directory.Exists(extractDirectory)) { Directory.CreateDirectory(extractDirectory); } try { //System.IO.Compression.ZipFile.ExtractToDirectory(downloadedFile, extractDirectory); using (ZipArchive archive = ZipFile.OpenRead(downloadedFile)) { foreach (var entry in archive.Entries) { var entryPath = Path.Combine(extractDirectory, entry.FullName).Replace("/", "\\"); if (entryPath.EndsWith("\\")) { if (!Directory.Exists(entryPath)) { Directory.CreateDirectory(entryPath); } } else { entry.ExtractToFile(entryPath, true); } } } MessageBox.Show("Patch installed successfully"); string patchname = lbPatches.SelectedItem.ToString(); string patchDateUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/{patchname}/patchdate.php"; string serverPatchDate = null; try { WebClient wc = new WebClient(); serverPatchDate = wc.DownloadString(patchDateUrl); } catch { return; } //eat it LauncherSettings.SetValue(patchname, serverPatchDate); lbPatches_SelectedIndexChanged(null, null); } catch (Exception ex) { MessageBox.Show($"An error occurred during extraction\n\n{ex}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (File.Exists(downloadedFile)) { File.Delete(downloadedFile); } } else { Process.Start(downloadedFile); } } finally { dForm.Close(); dForm = null; } }