private async void processButton_Click(object sender, EventArgs e) { processButton.Enabled = false; foreach (var btn in radioSet) { btn.Enabled = false; } _archive.Append(dummyFileName, dummyVfsPath, false, dummyFileContent); progressBar.Value = 0; progressBar.Maximum = _patcher.CandidateCount(); statusLabel.Text = "Processing shaders"; if (offRadio.Checked) { await _patcher.PatchAsync(new Progress <int>(UpdateProgressBar), Patcher.PatchMode.DisableDithering, 0.0f); } else if (wideRadio.Checked) { await _patcher.PatchAsync(new Progress <int>(UpdateProgressBar), Patcher.PatchMode.NarrowDithering, 32.0f); } else if (narrowRadio.Checked) { await _patcher.PatchAsync(new Progress <int>(UpdateProgressBar), Patcher.PatchMode.NarrowDithering, 56.0f); } else { await _patcher.PatchAsync(new Progress <int>(UpdateProgressBar), Patcher.PatchMode.NarrowDithering, 40.0f); } progressBar.Value = 0; progressBar.Maximum = _archive.Count(); statusLabel.Text = "Writing archive"; try { await _archive.SaveAsync(tempArchivePath, new Progress <int>(UpdateProgressBar)); // Use case: // - User applies patch, producing patched archive and backup archive // - Game update overwrites patched archive // - Backup archive is now present despite regular archive having no patch marker if (File.Exists(backupArchivePath)) { File.Delete(backupArchivePath); } File.Move(archivePath, backupArchivePath); File.Move(tempArchivePath, archivePath); } catch (IOException ex) { MessageBox.Show("Could not write shader archive. " + "Please ensure nothing is accessing the following paths (close the game if you're running it):\n\n" + archivePath + "\n" + tempArchivePath + "\n" + backupArchivePath + "\n\n" + "If you're still having problems, try running as Administrator and/or disabling your antivirus.\n\n" + "Details:\n" + ex.Message); Application.Exit(); } //await _patcher.DumpDiscardPsAsync(new Progress<int>(UpdateProgressBar)); statusLabel.Text = "Done"; }