Обновление

* Реализовано сохранение и восстановление бекапа
* Обновлен RegexHandler

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2025-02-27 22:18:41 +07:00
parent ec5f1f6e46
commit e633408665
3 changed files with 51 additions and 16 deletions

View File

@@ -7,10 +7,16 @@ namespace SaveWizard_rewritten
static class RegexHandler
{
private static List<string> lines;
private static List<string> backup;
public static void FillLines(List<string> _lines)
{
lines = _lines;
if (_lines == null)
return;
lines = new List<string>();
lines.AddRange(_lines);
backup = new List<string>();
backup.AddRange(_lines);
}
public static string GetLine(int index)
@@ -23,6 +29,11 @@ namespace SaveWizard_rewritten
return lines;
}
public static List<string> GetBackup()
{
return backup;
}
public static int SearchLine(string term, int start = 0, string cancel = "this_string_must_not_exist")
{
if (lines[start].Contains(term))
@@ -64,7 +75,6 @@ namespace SaveWizard_rewritten
public static void SetValue(int line, string value)
{
//string name = Regex.Match(lines[line], "(.+):").Value;
string name = Regex.Match(lines[line], "(.+):").Groups[1].ToString();
lines[line] = $"{name}: {value}";
}
@@ -76,7 +86,6 @@ namespace SaveWizard_rewritten
public static int GetArrayLength(int line)
{
//return Convert.ToInt32(Regex.Match(lines[line], ": ([0-9]+)$").Value);
return Convert.ToInt32(GetValue(line));
}
@@ -101,7 +110,6 @@ namespace SaveWizard_rewritten
{
List<string> items = new List<string>();
for (int i = 0; i < GetArrayLength(line); i++)
//items.Add(Regex.Match(lines[line + i + 1], ": (.+)$").Value);
items.Add(Regex.Match(lines[line + i + 1], ": (.+)$").Groups[1].ToString());
if (items.Count == 0)
return null;
@@ -110,7 +118,6 @@ namespace SaveWizard_rewritten
public static void AddArrayValue(int line, string value)
{
//string name = Regex.Match(lines[line], "(.+):").Value;
string name = Regex.Match(lines[line], "(.+):").Groups[1].ToString();
int length = GetArrayLength(line);
lines[line] = $"{name}: {length + 1}";