Обновление
* Добавлена архитектура сборки x86 * Ссылка на репозиторий с конфигурациями вынесена в конфигурационный файл (update.cfg) * Обновлен механизм создания и взаимодействия с файлом конфигурации (update.cfg) * Добавлена обработка ошибки декодирования файла при попытке его открыть Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
@@ -32,6 +32,26 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<LangVersion>7.3</LangVersion>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<LangVersion>7.3</LangVersion>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
|||||||
@@ -12,9 +12,31 @@ namespace SaveWizard
|
|||||||
{
|
{
|
||||||
private readonly string config_file_name = "update.cfg";
|
private readonly string config_file_name = "update.cfg";
|
||||||
|
|
||||||
|
// SIIDEC_RESULT_GENERIC_ERROR = -1;
|
||||||
|
// SIIDEC_RESULT_SUCCESS = 0;
|
||||||
|
// SIIDEC_RESULT_FORMAT_PLAINTEXT = 1;
|
||||||
|
// SIIDEC_RESULT_FORMAT_ENCRYPTED = 2;
|
||||||
|
// SIIDEC_RESULT_FORMAT_BINARY = 3;
|
||||||
|
// SIIDEC_RESULT_FORMAT_3NK = 4;
|
||||||
|
// SIIDEC_RESULT_FORMAT_UNKNOWN = 10;
|
||||||
|
// SIIDEC_RESULT_TOO_FEW_DATA = 11;
|
||||||
|
// SIIDEC_RESULT_BUFFER_TOO_SMALL = 12;
|
||||||
|
|
||||||
|
// SIIDEC_RESULT_GENERIC_ERROR - an unhandled exception have occured
|
||||||
|
// SIIDEC_RESULT_FORMAT_PLAINTEXT - plain-text SII file
|
||||||
|
// SIIDEC_RESULT_FORMAT_ENCRYPTED - encrypted SII file
|
||||||
|
// SIIDEC_RESULT_FORMAT_BINARY - binary form of SII file
|
||||||
|
// SIIDEC_RESULT_FORMAT_3NK - file is an 3nK-encoded SII file
|
||||||
|
// SIIDEC_RESULT_FORMAT_UNKNOWN - file of an unknown format
|
||||||
|
// SIIDEC_RESULT_TOO_FEW_DATA - file is too small to contain valid data for its format
|
||||||
[DllImport("SII_Decrypt.dll")]
|
[DllImport("SII_Decrypt.dll")]
|
||||||
public static extern int GetFileFormat(string FileName);
|
public static extern int GetFileFormat(string FileName);
|
||||||
|
|
||||||
|
// SIIDEC_RESULT_GENERIC_ERROR - an unhandled exception have occured
|
||||||
|
// SIIDEC_RESULT_SUCCESS - input file was successfully decrypted and/or decoded and result stored in the output file
|
||||||
|
// SIIDEC_RESULT_FORMAT_PLAINTEXT - input file contains plain-text SII file (does not need decryption or decoding)
|
||||||
|
// SIIDEC_RESULT_FORMAT_UNKNOWN - input file is of an uknown format
|
||||||
|
// SIIDEC_RESULT_TOO_FEW_DATA - input file is too small to contain a valid encrypted or encoded SII file
|
||||||
[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);
|
||||||
|
|
||||||
@@ -189,31 +211,39 @@ namespace SaveWizard
|
|||||||
foreach (TextBox txtbox in items.Keys)
|
foreach (TextBox txtbox in items.Keys)
|
||||||
txtbox.TextChanged += boxTextChanged;
|
txtbox.TextChanged += boxTextChanged;
|
||||||
txt_adr.TextChanged += boxTextChanged;
|
txt_adr.TextChanged += boxTextChanged;
|
||||||
Dictionary<string, bool> update_conf = new Dictionary<string, bool>
|
string config_path = Path.Combine(Environment.CurrentDirectory, config_file_name);
|
||||||
|
if (File.Exists(config_path))
|
||||||
{
|
{
|
||||||
{ "update_on_start", false }
|
Dictionary<string, object> update_conf = JsonConvert.DeserializeObject<Dictionary<string, object>>(File.ReadAllText(config_path));
|
||||||
};
|
if ((bool)update_conf["update_on_start"])
|
||||||
string path = Path.Combine(Environment.CurrentDirectory, config_file_name);
|
|
||||||
if (File.Exists(path))
|
|
||||||
update_conf = JsonConvert.DeserializeObject<Dictionary<string, bool>>(File.ReadAllText(path));
|
|
||||||
if (update_conf["update_on_start"])
|
|
||||||
{
|
{
|
||||||
chk_update_on_start.Checked = true;
|
chk_update_on_start.Checked = true;
|
||||||
UpdateForm window = new UpdateForm();
|
UpdateForm window = new UpdateForm((string)update_conf["respository_link"]);
|
||||||
window.ShowDialog();
|
window.ShowDialog();
|
||||||
window.Focus();
|
window.Focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File.WriteAllText(config_path,
|
||||||
|
JsonConvert.SerializeObject(new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "update_on_start", false },
|
||||||
|
{ "respository_link", "https://raw.githubusercontent.com/JDM170/SaveWizard_configs/main/" }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void chk_update_on_start_CheckedChanged(object sender, EventArgs e)
|
private void chk_update_on_start_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
File.WriteAllText(
|
string config_path = Path.Combine(Environment.CurrentDirectory, config_file_name);
|
||||||
Path.Combine(Environment.CurrentDirectory, config_file_name),
|
if (!File.Exists(config_path))
|
||||||
JsonConvert.SerializeObject(new Dictionary<string, bool>
|
return;
|
||||||
{
|
Dictionary<string, object> fileData = JsonConvert.DeserializeObject<Dictionary<string, object>>(File.ReadAllText(config_path));
|
||||||
{ "update_on_start", chk_update_on_start.Checked }
|
fileData["update_on_start"] = chk_update_on_start.Checked;
|
||||||
})
|
File.WriteAllText(config_path, JsonConvert.SerializeObject(fileData));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btn_open_save_Click(object sender, EventArgs e)
|
private void btn_open_save_Click(object sender, EventArgs e)
|
||||||
@@ -222,12 +252,18 @@ namespace SaveWizard
|
|||||||
OpenFileDialog ofd = new OpenFileDialog()
|
OpenFileDialog ofd = new OpenFileDialog()
|
||||||
{
|
{
|
||||||
Title = "Выберите файл сохранения",
|
Title = "Выберите файл сохранения",
|
||||||
Filter = "Сохранение в формате SII|game.sii",
|
Filter = "Файл game.sii|game.sii",
|
||||||
Multiselect = false,
|
Multiselect = false,
|
||||||
};
|
};
|
||||||
if (ofd.ShowDialog() == DialogResult.OK)
|
if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (GetFileFormat(ofd.FileName) == 2)
|
int fileFormat = GetFileFormat(ofd.FileName);
|
||||||
|
if (fileFormat == -1)
|
||||||
|
{
|
||||||
|
Utils.ShowError("The file name cannot contain spaces or special characters.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fileFormat >= 2 && fileFormat <= 4)
|
||||||
{
|
{
|
||||||
if (DecryptAndDecodeFile(ofd.FileName, ofd.FileName) != 0)
|
if (DecryptAndDecodeFile(ofd.FileName, ofd.FileName) != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,6 +49,26 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<LangVersion>7.3</LangVersion>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<LangVersion>7.3</LangVersion>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>$(SolutionDir)\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>$(SolutionDir)\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ namespace SaveWizard
|
|||||||
{
|
{
|
||||||
public partial class UpdateForm: Form
|
public partial class UpdateForm: Form
|
||||||
{
|
{
|
||||||
private static readonly string githubLink = "https://raw.githubusercontent.com/JDM170/SaveWizard_configs/main/";
|
private static string repositoryLink = "";
|
||||||
|
|
||||||
public UpdateForm()
|
public UpdateForm(string _repositoryLink)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
repositoryLink = _repositoryLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckPath(string path)
|
private static void CheckPath(string path)
|
||||||
@@ -47,7 +48,7 @@ namespace SaveWizard
|
|||||||
using (WebClient wb = new WebClient())
|
using (WebClient wb = new WebClient())
|
||||||
{
|
{
|
||||||
wb.Encoding = Encoding.UTF8;
|
wb.Encoding = Encoding.UTF8;
|
||||||
string responseInString = wb.DownloadString($"{githubLink}version.cfg");
|
string responseInString = wb.DownloadString($"{repositoryLink}version.cfg");
|
||||||
Dictionary<string, string> result = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseInString);
|
Dictionary<string, string> result = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseInString);
|
||||||
string[] splitted;
|
string[] splitted;
|
||||||
string path;
|
string path;
|
||||||
@@ -58,7 +59,7 @@ namespace SaveWizard
|
|||||||
CheckPath(path);
|
CheckPath(path);
|
||||||
if (Utils.GenerateMD5(path) != unit.Value)
|
if (Utils.GenerateMD5(path) != unit.Value)
|
||||||
{
|
{
|
||||||
string newConfigText = wb.DownloadString($"{githubLink}{path.Replace("configs/", "")}");
|
string newConfigText = wb.DownloadString($"{repositoryLink}{path.Replace("configs/", "")}");
|
||||||
File.WriteAllText(Path.Combine(Environment.CurrentDirectory, path), newConfigText.Replace("\n", "\r\n"));
|
File.WriteAllText(Path.Combine(Environment.CurrentDirectory, path), newConfigText.Replace("\n", "\r\n"));
|
||||||
}
|
}
|
||||||
backgroundWorker1.ReportProgress(progressBar1.Value + 1);
|
backgroundWorker1.ReportProgress(progressBar1.Value + 1);
|
||||||
|
|||||||
@@ -10,17 +10,27 @@ EndProject
|
|||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Debug|x86.Build.0 = Debug|x86
|
||||||
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{0EFCF0E0-4EBC-41A3-9207-0BF27630E397}.Release|x86.Build.0 = Release|x86
|
||||||
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Debug|x86.Build.0 = Debug|x86
|
||||||
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{A08C24B5-43A9-4E0B-8C5C-0AB019CBAFE8}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user