Compare commits
2 Commits
e633408665
...
65070cd85b
| Author | SHA1 | Date | |
|---|---|---|---|
|
65070cd85b
|
|||
|
9b7ee59707
|
21
MainForm.cs
21
MainForm.cs
@@ -19,10 +19,7 @@ namespace SaveWizard_rewritten
|
||||
public static extern int DecryptAndDecodeFile(string InputFile, string OutputFile);
|
||||
|
||||
private Dictionary<TextBox, WindowText> items = null;
|
||||
|
||||
private string opened_file_path, selected_game;
|
||||
|
||||
private Dictionary<string, string> dlc = null;
|
||||
private Dictionary<string, bool> owns = null;
|
||||
|
||||
public MainForm()
|
||||
@@ -98,20 +95,19 @@ namespace SaveWizard_rewritten
|
||||
string config_path = $"configs/{selected_game}/dlc.json";
|
||||
if (File.Exists(config_path))
|
||||
{
|
||||
dlc = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(config_path));
|
||||
Dictionary<string, string> dlc = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(config_path));
|
||||
owns = new Dictionary<string, bool>
|
||||
{
|
||||
{ "base", true }
|
||||
};
|
||||
List<string> companies = RegexHandler.GetArrayItems(RegexHandler.SearchLine("companies:"));
|
||||
foreach (var company in companies)
|
||||
foreach (var item in dlc)
|
||||
foreach (string company in companies)
|
||||
foreach (KeyValuePair<string, string> item in dlc)
|
||||
if (company.Contains(item.Value))
|
||||
owns[item.Key] = true;
|
||||
owns = null;
|
||||
}
|
||||
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;
|
||||
@@ -124,7 +120,6 @@ namespace SaveWizard_rewritten
|
||||
opened_file_path = null;
|
||||
RegexHandler.FillLines(null);
|
||||
selected_game = null;
|
||||
dlc = null;
|
||||
owns = null;
|
||||
foreach (KeyValuePair<TextBox, WindowText> item in items)
|
||||
{
|
||||
@@ -209,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;
|
||||
}
|
||||
}
|
||||
@@ -223,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);
|
||||
}
|
||||
|
||||
@@ -239,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);
|
||||
}
|
||||
}
|
||||
|
||||
11
Utils.cs
11
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user