diff --git a/MainForm.cs b/MainForm.cs index 9a0e53c..1e0ac78 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -107,7 +107,7 @@ namespace SaveWizard_rewritten owns[item.Key] = true; } else - MessageBox.Show($"'dlc.json' from '{selected_game}' have errors or not found, functionality has been limited", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + Utils.ShowError($"'dlc.json' from '{selected_game}' have errors or not found, functionality has been limited"); } btn_unlock_garages.Enabled = true; @@ -204,7 +204,7 @@ namespace SaveWizard_rewritten { if (DecryptAndDecodeFile(ofd.FileName, ofd.FileName) != 0) { - MessageBox.Show("Something went wrong with decrypting file. Try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + Utils.ShowError("Something went wrong with decrypting file. Try again."); return; } } @@ -218,12 +218,12 @@ namespace SaveWizard_rewritten string backup_path = opened_file_path + ".swbak"; if (!File.Exists(backup_path)) { - MessageBox.Show("Backup not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + Utils.ShowError("Backup not found."); return; } File.WriteAllLines(opened_file_path, File.ReadAllLines(backup_path)); File.Delete(backup_path); - MessageBox.Show("Backup successfully recovered.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); + Utils.ShowInfo("Backup successfully recovered."); GetFileData(opened_file_path); } @@ -234,7 +234,7 @@ namespace SaveWizard_rewritten RegexHandler.SetValue(RegexHandler.SearchLine(item.Value.GetString()), item.Key.Text); File.WriteAllLines(opened_file_path + ".swbak", RegexHandler.GetBackup()); File.WriteAllLines(opened_file_path, RegexHandler.GetAllLines()); - MessageBox.Show("Changes successfully applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); + Utils.ShowInfo("Changes successfully applied."); GetFileData(opened_file_path); } } diff --git a/Utils.cs b/Utils.cs index 51ae95c..0cd96fd 100644 --- a/Utils.cs +++ b/Utils.cs @@ -1,6 +1,7 @@ using System.IO; using System.Security.Cryptography; using System.Text; +using System.Windows.Forms; namespace SaveWizard_rewritten { @@ -23,5 +24,15 @@ namespace SaveWizard_rewritten return sb.ToString(); } } + + public static void ShowError(string message) + { + MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + public static void ShowInfo(string message) + { + MessageBox.Show(message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); + } } }