private void ShowDialog(GithubRelease Release, GitZipFile MainReleaseFile) { StringBuilder Response = new StringBuilder(); Response.AppendLine($"Current version: {SeamlessClient.Version} Latest: {Release.LatestVersion}"); Response.AppendLine($"Update: {Release.Name}"); Response.AppendLine($"Description: {Release.Description}"); Response.AppendLine($"Size: {MainReleaseFile.Size / 1000}kb"); Response.AppendLine(); Response.AppendLine("Warning: If you have a version less than latest seamless will be disabled to prevent crashes!"); Response.AppendLine("(Clicking yes should restart your game)"); DialogResult Result = MessageBox.Show(Response.ToString(), $"Download Seamless Client Plugin Update v{ Release.LatestVersion}?", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); SeamlessClient.TryShow(Response.ToString()); if (Result == DialogResult.Yes) { SeamlessClient.TryShow("Client wants to update!"); string DownloadPath = Path.Combine(PluginFolder, MainReleaseFile.Name); Client.DownloadFile(new Uri(MainReleaseFile.ZipURL), DownloadPath); if (!File.Exists(DownloadPath)) { SeamlessClient.TryShow("Failed to download zip!"); return; } if (ExtractAndReplace(DownloadPath)) { StringBuilder ErrorResponse = new StringBuilder(); ErrorResponse.AppendLine("There was an error during the extraction proccess! Check your logs for more information!"); ErrorResponse.AppendLine(); ErrorResponse.AppendLine("You can download manually here:"); ErrorResponse.AppendLine(Release.GitHubPage); SeamlessClient.TryShow(ErrorResponse.ToString()); MessageBox.Show(ErrorResponse.ToString(), $"Failed to update plugin to v{ Release.LatestVersion}!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return; } } else { SeamlessClient.TryShow("Client skipped Update!"); return; } }
private bool TryGetMainRelease(GitZipFile[] Files, out GitZipFile Release) { Release = null; //Sanity saftey checks if (Files == null || Files.Length <= 0) { return(false); } foreach (GitZipFile File in Files) { if (File.Name == "SeamlessClientPlugin.zip") { Release = File; return(true); } } return(false); }