private void btnBrowseGameDirectory_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult result = fbd.ShowDialog(); if (result != DialogResult.OK) { return; } string folder = fbd.SelectedPath; string x64Folder = Path.Combine(folder, "x64"); var rootFiles = Directory.GetFiles(folder); var x64Files = Directory.GetFiles(x64Folder); string MS2 = x64Files.FirstOrDefault(it => it.ToUpper().Contains("MAPLESTORY2.EXE")); string NGM = rootFiles.FirstOrDefault(it => it.ToUpper().Contains("NGM.EXE")); string NGM64 = rootFiles.FirstOrDefault(it => it.ToUpper().Contains("NGM64.EXE")); bool maplestoryLocated = !(string.IsNullOrWhiteSpace(MS2)); bool launcherLocated = !string.IsNullOrWhiteSpace(NGM) || !string.IsNullOrWhiteSpace(NGM64); if (!maplestoryLocated || !launcherLocated) { MessageBox.Show("Could not find Maplestory2 and/or the Nexon game launcher."); folder = ""; tbGameDirectory.Text = folder; LauncherSettings.DeleteValue(LauncherSettings.GAME_FOLDER); LockPatchInterface(); return; } tbGameDirectory.Text = folder; LauncherSettings.SetValue(LauncherSettings.GAME_FOLDER, folder); UnlockPatchInterface(); }
private void lbRememberPassword_TextChanged(object sender, EventArgs e) { LauncherSettings.SetValue(LauncherSettings.REMEMBER_PASSWORD, tbRememberPassword.Text); }
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; } }