private void OnUpdateContent(object sender, RoutedEventArgs e) { MessageBoxResult result; if (!ValidPathTest()) { return; } result = TriggerMessageBox.Show(this, MessageIcon.Question, "Are you sure you want to update the rupee content files?", "Update Rupees", MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { return; } try { ContentReplacer.Replace(); ContentReplacer.SaveXmlConfiguration(); TriggerMessageBox.Show(this, MessageIcon.Info, "Rupee content files successfully updated!", "Rupees Updated"); } catch (Exception ex) { result = TriggerMessageBox.Show(this, MessageIcon.Error, "An error occurred while updating rupee content files! Would you like to see the error?", "Patch Error", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { ErrorMessageBox.Show(ex, true); } return; } }
private void OnRestoreAndPatch(object sender, RoutedEventArgs e) { MessageBoxResult result; if (!ValidPathTest()) { return; } if (!File.Exists(Patcher.BackupPath)) { TriggerMessageBox.Show(this, MessageIcon.Error, "Could not find Terraria backup!", "Missing Backup"); return; } result = TriggerMessageBox.Show(this, MessageIcon.Question, "Are you sure you want to restore Terraria from its backup and then patch it?", "Patch & Restore Terraria", MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { return; } if (File.Exists(Patcher.ExePath) && IL.GetAssemblyVersion(Patcher.BackupPath) < IL.GetAssemblyVersion(Patcher.ExePath)) { result = TriggerMessageBox.Show(this, MessageIcon.Warning, "The backed up Terraria executable is an older game version. Are you sure you want to restore it?", "Older Version", MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { return; } } if (!CheckSupportedVersion(Patcher.BackupPath)) { return; } try { Patcher.Restore(false); } catch (Exception ex) { result = TriggerMessageBox.Show(this, MessageIcon.Error, "An error occurred while restoring Terraria! Would you like to see the error?", "Restore Error", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { ErrorMessageBox.Show(ex, true); } return; } try { Patcher.Patch(); ContentReplacer.Replace(); ContentReplacer.SaveXmlConfiguration(); TriggerMessageBox.Show(this, MessageIcon.Info, "Terraria successfully restored and patched!", "Terraria Repatched"); } catch (AlreadyPatchedException) { TriggerMessageBox.Show(this, MessageIcon.Error, "The backup executable has already been patched by Rupee Replacer!", "Already Patched"); } catch (Exception ex) { result = TriggerMessageBox.Show(this, MessageIcon.Error, "An error occurred while patching Terraria! Would you like to see the error?", "Patch Error", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { ErrorMessageBox.Show(ex, true); } } }
//-------------------------------- #region Patching private void OnPatch(object sender = null, RoutedEventArgs e = null) { MessageBoxResult result; if (!ValidPathTest()) { return; } if (!File.Exists(Patcher.ExePath)) { TriggerMessageBox.Show(this, MessageIcon.Error, "Could not find Terraria executable!", "Missing Exe"); return; } result = TriggerMessageBox.Show(this, MessageIcon.Question, "Are you sure you want to patch the current Terraria executable?", "Patch Terraria", MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { return; } if (!CheckSupportedVersion(Patcher.ExePath)) { return; } try { Patcher.Patch(); ContentReplacer.Replace(); ContentReplacer.SaveXmlConfiguration(); TriggerMessageBox.Show(this, MessageIcon.Info, "Terraria successfully patched!", "Terraria Patched"); } catch (AlreadyPatchedException) { TriggerMessageBox.Show(this, MessageIcon.Error, "This executable has already been patched by Rupee Replacer! Use Restore & Patch instead.", "Already Patched"); } catch (Exception ex) { result = TriggerMessageBox.Show(this, MessageIcon.Error, "An error occurred while patching Terraria! Would you like to see the error?", "Patch Error", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { ErrorMessageBox.Show(ex, true); } } }