diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 8fa5032d..f5acfc61 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index e48c0167..21f5e71f 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index f2adc0e4..10590d5d 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs b/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs index d0b6495f..08a51ab3 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/BNTX.cs @@ -206,7 +206,7 @@ namespace FirstPlugin FileNameText = FileName; if (!IsLoadingArray) - LoadBNTXArray(stream, this); + LoadBNTXArray(ContainerArray, stream, this); LoadFile(stream, Name); @@ -214,12 +214,13 @@ namespace FirstPlugin } static bool IsLoadingArray = false; - private static void LoadBNTXArray(Stream stream, BNTX bntx) + static bool IsSavingArray = false; + List ContainerArray = new List(); + private static void LoadBNTXArray(List Containers, Stream stream, BNTX bntx) { IsLoadingArray = true; int Alignment = 4096; - List Containers = new List(); using (var reader = new FileReader(stream, true)) { SearchForBinaryContainerFile(reader, Alignment, Containers); @@ -237,6 +238,23 @@ namespace FirstPlugin IsLoadingArray = false; } + private static void SaveBNTXArray(MemoryStream mem, List Containers) + { + IsSavingArray = true; + + int Alignment = 4096; + using (var saver = new FileWriter(mem)) + { + foreach (var container in Containers) + { + saver.Write(container.Save()); + saver.Align(Alignment); + } + } + + IsSavingArray = false; + } + private static void SearchForBinaryContainerFile(FileReader reader, int Alignment, List Containers) { long Pos = reader.Position; @@ -793,32 +811,38 @@ namespace FirstPlugin } public byte[] Save() { + MemoryStream mem = new MemoryStream(); + BinaryTexFile.Textures.Clear(); BinaryTexFile.TextureDict.Clear(); - foreach (TextureData tex in Textures.Values) + if (ContainerArray.Count > 0 && !IsSavingArray) { - if (tex.IsEdited) + SaveBNTXArray(mem, ContainerArray); + } + else + { + foreach (TextureData tex in Textures.Values) { - for (int i = 0; i < tex.EditedImages.Length; i++) + if (tex.IsEdited) { - tex.SetImageData(tex.EditedImages[i].bitmap, tex.EditedImages[i].ArrayLevel); - tex.EditedImages[i].bitmap.Dispose(); + for (int i = 0; i < tex.EditedImages.Length; i++) + { + tex.SetImageData(tex.EditedImages[i].bitmap, tex.EditedImages[i].ArrayLevel); + tex.EditedImages[i].bitmap.Dispose(); + } + tex.EditedImages = new EditedBitmap[0]; } - tex.EditedImages = new EditedBitmap[0]; + + tex.Texture.Name = tex.Text; + + BinaryTexFile.Textures.Add(tex.Texture); + BinaryTexFile.TextureDict.Add(tex.Text); } - tex.Texture.Name = tex.Text; - - BinaryTexFile.Textures.Add(tex.Texture); - BinaryTexFile.TextureDict.Add(tex.Text); + BinaryTexFile.Save(mem); } - - - MemoryStream mem = new MemoryStream(); - BinaryTexFile.Save(mem); - return mem.ToArray(); } diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index a17b275b..876e9293 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ