Compare commits

...

2 Commits

Author SHA1 Message Date
65070cd85b Обновление
* Добавлены методы для показа информационных сообщений
* Обновлена логика основной формы

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
2025-03-02 00:48:59 +07:00
9b7ee59707 Фикс логики основной формы
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
2025-03-01 17:22:32 +07:00
2 changed files with 19 additions and 13 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}
}