diff --git a/File_Format_Library/FileFormats/Byaml/BYAML.cs b/File_Format_Library/FileFormats/Byaml/BYAML.cs index 5e2d33c9..20c86c66 100644 --- a/File_Format_Library/FileFormats/Byaml/BYAML.cs +++ b/File_Format_Library/FileFormats/Byaml/BYAML.cs @@ -13,6 +13,7 @@ using ByamlExt; using SharpYaml.Serialization; using SharpYaml; using Syroot.BinaryData; +using Toolbox.Library.Security.Cryptography; namespace FirstPlugin { @@ -52,7 +53,41 @@ namespace FirstPlugin } } - public static Dictionary Hashes = new Dictionary(); + private static new Dictionary hashes = new Dictionary(); + + public static Dictionary Hashes + { + get + { + if (Hashes.Count == 0) + CreateHashList(); + return Hashes; + } + } + + private static void CreateHashList() + { + string dir = Path.Combine(Runtime.ExecutableDir, "Hashes"); + if (!Directory.Exists(dir)) + return; + + foreach (var file in Directory.GetFiles(dir)) + { + if (Utils.GetExtension(file) != ".txt") + continue; + + foreach (string hashStr in File.ReadAllLines(file)) { + CheckHash(hashStr); + } + } + } + + private static void CheckHash(string hashStr) + { + uint hash = Crc32.Compute(hashStr); + if (!hashes.ContainsKey(hash)) + hashes.Add(hash, hashStr); + } #region Text Converter Interface public TextFileType TextFileType => TextFileType.Yaml; diff --git a/Toolbox/Hashes/ACNH.txt b/Toolbox/Hashes/ACNH.txt new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/Toolbox/Hashes/ACNH.txt @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Toolbox/MainForm.cs b/Toolbox/MainForm.cs index 8815b352..db3da7da 100644 --- a/Toolbox/MainForm.cs +++ b/Toolbox/MainForm.cs @@ -1511,9 +1511,7 @@ namespace Toolbox path = Utils.RenameDuplicateString(batchExportFileList, path, 0, 3); batchExportFileList.Add(path); - path = $"{path}.{extension}"; - - DAE.Export(path, daesettings, model, textures, skeleton); + DAE.Export($"{path}.{extension}", daesettings, model, textures, skeleton); } fileFormat.Unload(); @@ -1528,9 +1526,8 @@ namespace Toolbox private void ExportTexture(STGenericTexture tex, string filePath, string ext) { filePath = Utils.RenameDuplicateString(batchExportFileList, filePath, 0, 3); batchExportFileList.Add(filePath); - filePath = $"{filePath}.{ext}"; - tex.Export(filePath); + tex.Export($"{filePath}.{ext}"); } private void SearchArchive(BatchFormatExport.Settings settings, IArchiveFile archiveFile, diff --git a/Toolbox/Toolbox.csproj b/Toolbox/Toolbox.csproj index 1437bab5..10c7606c 100644 --- a/Toolbox/Toolbox.csproj +++ b/Toolbox/Toolbox.csproj @@ -385,6 +385,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest