Обновление
* Добавлено считывание ADR * Переименован класс содержащий элементы окна * Добавлена перегрузка GetArrayItems Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
59
MainForm.cs
59
MainForm.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace SaveWizard_rewritten
|
namespace SaveWizard_rewritten
|
||||||
@@ -18,7 +19,7 @@ namespace SaveWizard_rewritten
|
|||||||
[DllImport("SII_Decrypt.dll")]
|
[DllImport("SII_Decrypt.dll")]
|
||||||
public static extern int DecryptAndDecodeFile(string InputFile, string OutputFile);
|
public static extern int DecryptAndDecodeFile(string InputFile, string OutputFile);
|
||||||
|
|
||||||
private Dictionary<TextBox, WindowText> items = null;
|
private Dictionary<TextBox, WindowItem> items = null;
|
||||||
private string opened_file_path, selected_game;
|
private string opened_file_path, selected_game;
|
||||||
private Dictionary<string, bool> owns = null;
|
private Dictionary<string, bool> owns = null;
|
||||||
|
|
||||||
@@ -34,12 +35,12 @@ namespace SaveWizard_rewritten
|
|||||||
// File.Delete(path);
|
// File.Delete(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class WindowText
|
private class WindowItem
|
||||||
{
|
{
|
||||||
private readonly CheckBox Check;
|
private readonly CheckBox Check;
|
||||||
private readonly string Str;
|
private readonly string Str;
|
||||||
|
|
||||||
public WindowText(CheckBox _check, string _str)
|
public WindowItem(CheckBox _check, string _str)
|
||||||
{
|
{
|
||||||
Check = _check;
|
Check = _check;
|
||||||
Str = _str;
|
Str = _str;
|
||||||
@@ -59,31 +60,54 @@ namespace SaveWizard_rewritten
|
|||||||
private void boxTextChanged(object sender, EventArgs e)
|
private void boxTextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
TextBox _sender = sender as TextBox;
|
TextBox _sender = sender as TextBox;
|
||||||
items[_sender].GetCheck().Checked = false;
|
if (_sender != txt_adr)
|
||||||
|
items[_sender].GetCheck().Checked = false;
|
||||||
|
else
|
||||||
|
chk_adr.Checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateBasic(object sender, KeyPressEventArgs e)
|
private void ValidateBasic(object sender, KeyPressEventArgs e)
|
||||||
{
|
{
|
||||||
if (!(e.KeyChar >= '0' && e.KeyChar <= '9') && !char.IsControl(e.KeyChar))
|
//if (!(e.KeyChar >= '0' && e.KeyChar <= '9') && !char.IsControl(e.KeyChar))
|
||||||
|
if (!(e.KeyChar >= '0' && e.KeyChar <= '9') && e.KeyChar != (char)Keys.Back)
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateSkills(object sender, KeyPressEventArgs e)
|
private void ValidateSkills(object sender, KeyPressEventArgs e)
|
||||||
{
|
{
|
||||||
if (!(e.KeyChar >= '0' && e.KeyChar <= '6') && !char.IsControl(e.KeyChar))
|
//if (!(e.KeyChar >= '0' && e.KeyChar <= '6') && !char.IsControl(e.KeyChar))
|
||||||
|
if (!(e.KeyChar >= '0' && e.KeyChar <= '6') && e.KeyChar != (char)Keys.Back)
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<string> GetADR(string value)
|
||||||
|
{
|
||||||
|
string binaryCode = Convert.ToString(int.Parse(value), 2);
|
||||||
|
binaryCode = new string('0', 6 - binaryCode.Length) + binaryCode;
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
foreach (char character in binaryCode)
|
||||||
|
result.Add(character.ToString());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void GetFileData(string filename)
|
private void GetFileData(string filename)
|
||||||
{
|
{
|
||||||
RegexHandler.FillLines(File.ReadAllLines(filename).ToList());
|
RegexHandler.FillLines(File.ReadAllLines(filename).ToList());
|
||||||
|
|
||||||
foreach (KeyValuePair<TextBox, WindowText> item in items)
|
foreach (KeyValuePair<TextBox, WindowItem> item in items)
|
||||||
{
|
{
|
||||||
item.Key.Text = RegexHandler.GetValue(RegexHandler.SearchLine(item.Value.GetString()));
|
item.Key.Text = RegexHandler.GetValue(RegexHandler.SearchLine(item.Value.GetString()));
|
||||||
item.Value.GetCheck().Checked = true;
|
item.Value.GetCheck().Checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<string> adr_value = GetADR(RegexHandler.GetValue(RegexHandler.SearchLine("adr:")));
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
txt_adr.Text += adr_value[i];
|
||||||
|
if (i != 5)
|
||||||
|
txt_adr.Text += ",";
|
||||||
|
}
|
||||||
|
|
||||||
if (RegexHandler.SearchLine("company.volatile.stokes.calais") != 0)
|
if (RegexHandler.SearchLine("company.volatile.stokes.calais") != 0)
|
||||||
selected_game = "ets2";
|
selected_game = "ets2";
|
||||||
else if (RegexHandler.SearchLine("company.volatile.ed_mkt.elko") != 0)
|
else if (RegexHandler.SearchLine("company.volatile.ed_mkt.elko") != 0)
|
||||||
@@ -121,7 +145,7 @@ namespace SaveWizard_rewritten
|
|||||||
RegexHandler.FillLines(null);
|
RegexHandler.FillLines(null);
|
||||||
selected_game = null;
|
selected_game = null;
|
||||||
owns = null;
|
owns = null;
|
||||||
foreach (KeyValuePair<TextBox, WindowText> item in items)
|
foreach (KeyValuePair<TextBox, WindowItem> item in items)
|
||||||
{
|
{
|
||||||
item.Key.Text = "";
|
item.Key.Text = "";
|
||||||
item.Value.GetCheck().Checked = true;
|
item.Value.GetCheck().Checked = true;
|
||||||
@@ -144,16 +168,16 @@ namespace SaveWizard_rewritten
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
items = new Dictionary<TextBox, WindowText>
|
items = new Dictionary<TextBox, WindowItem>
|
||||||
{
|
{
|
||||||
{ txt_money, new WindowText(chk_money, "money_account:") },
|
{ txt_money, new WindowItem(chk_money, "money_account:") },
|
||||||
{ txt_experience, new WindowText(chk_experience, "experience_points:") },
|
{ txt_experience, new WindowItem(chk_experience, "experience_points:") },
|
||||||
{ txt_loan_limit, new WindowText(chk_loan_limit, "loan_limit:") },
|
{ txt_loan_limit, new WindowItem(chk_loan_limit, "loan_limit:") },
|
||||||
{ txt_long_distance, new WindowText(chk_long_distance, "long_dist:") },
|
{ txt_long_distance, new WindowItem(chk_long_distance, "long_dist:") },
|
||||||
{ txt_high_value_cargo, new WindowText(chk_high_value_cargo, "heavy:") },
|
{ txt_high_value_cargo, new WindowItem(chk_high_value_cargo, "heavy:") },
|
||||||
{ txt_fragile_cargo, new WindowText(chk_fragile_cargo, "fragile:") },
|
{ txt_fragile_cargo, new WindowItem(chk_fragile_cargo, "fragile:") },
|
||||||
{ txt_urgent_delivery, new WindowText(chk_urgent_delivery, "urgent:") },
|
{ txt_urgent_delivery, new WindowItem(chk_urgent_delivery, "urgent:") },
|
||||||
{ txt_ecodriving, new WindowText(chk_ecodriving, "mechanical:") },
|
{ txt_ecodriving, new WindowItem(chk_ecodriving, "mechanical:") },
|
||||||
};
|
};
|
||||||
KeyPressEventHandler basic = new KeyPressEventHandler(ValidateBasic);
|
KeyPressEventHandler basic = new KeyPressEventHandler(ValidateBasic);
|
||||||
txt_money.KeyPress += basic;
|
txt_money.KeyPress += basic;
|
||||||
@@ -168,6 +192,7 @@ namespace SaveWizard_rewritten
|
|||||||
txt_ecodriving.KeyPress += skills;
|
txt_ecodriving.KeyPress += skills;
|
||||||
foreach (TextBox txtbox in items.Keys)
|
foreach (TextBox txtbox in items.Keys)
|
||||||
txtbox.TextChanged += boxTextChanged;
|
txtbox.TextChanged += boxTextChanged;
|
||||||
|
txt_adr.TextChanged += boxTextChanged;
|
||||||
Dictionary<string, bool> update_conf = new Dictionary<string, bool>
|
Dictionary<string, bool> update_conf = new Dictionary<string, bool>
|
||||||
{
|
{
|
||||||
{ "update_on_start", false }
|
{ "update_on_start", false }
|
||||||
|
|||||||
@@ -117,6 +117,16 @@ namespace SaveWizard_rewritten
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<string> GetArrayItems(int line)
|
||||||
|
{
|
||||||
|
List<string> items = new List<string>();
|
||||||
|
for (int i = 0; i < GetArrayLength(line); i++)
|
||||||
|
items.Add(Regex.Match(lines[line + i + 1], ": (.+)$").Groups[1].ToString());
|
||||||
|
if (items.Count == 0)
|
||||||
|
return null;
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddArrayValue(int line, string value)
|
public static void AddArrayValue(int line, string value)
|
||||||
{
|
{
|
||||||
string name = Regex.Match(lines[line], "(.+):").Groups[1].ToString();
|
string name = Regex.Match(lines[line], "(.+):").Groups[1].ToString();
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ namespace SaveWizard_rewritten
|
|||||||
}
|
}
|
||||||
List<string> all_cities = AllCities();
|
List<string> all_cities = AllCities();
|
||||||
int file_line = RegexHandler.SearchLine(search_line);
|
int file_line = RegexHandler.SearchLine(search_line);
|
||||||
List<string> unlocked_cities = RegexHandler.GetArrayItems(search_line);
|
List<string> unlocked_cities = RegexHandler.GetArrayItems(file_line);
|
||||||
foreach (string element in cities_list)
|
foreach (string element in cities_list)
|
||||||
if (all_cities.Contains(element) && (unlocked_cities == null || !unlocked_cities.Contains(element)))
|
if (all_cities.Contains(element) && (unlocked_cities == null || !unlocked_cities.Contains(element)))
|
||||||
RegexHandler.AddArrayValue(file_line, element);
|
RegexHandler.AddArrayValue(file_line, element);
|
||||||
|
|||||||
Reference in New Issue
Block a user