diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 648b5d04..3c5dcd00 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 699c2b6e..c4b1f37a 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-shm b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm index df96ea50..10696b40 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index 5392ef9c..1d333be0 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/Archives/NARC.cs b/Switch_FileFormatsMain/FileFormats/Archives/NARC.cs index d254cec2..157130d3 100644 --- a/Switch_FileFormatsMain/FileFormats/Archives/NARC.cs +++ b/Switch_FileFormatsMain/FileFormats/Archives/NARC.cs @@ -132,9 +132,9 @@ namespace FirstPlugin { uint decompSize = reader.ReadUInt32(); uint compSize = (uint)reader.BaseStream.Length; - compSize -= 16; + compSize -= 10; - byte[] filedata = reader.getSection(16, (int)compSize); + byte[] filedata = reader.getSection(10, (int)compSize); reader.Close(); reader.Dispose(); diff --git a/Switch_FileFormatsMain/FileFormats/Archives/NXARC.cs b/Switch_FileFormatsMain/FileFormats/Archives/NXARC.cs new file mode 100644 index 00000000..8f91b51a --- /dev/null +++ b/Switch_FileFormatsMain/FileFormats/Archives/NXARC.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Switch_Toolbox; +using System.Windows.Forms; +using Switch_Toolbox.Library; +using Switch_Toolbox.Library.IO; + +namespace FirstPlugin +{ + public class NXARC : IArchiveFile, IFileFormat + { + public FileType FileType { get; set; } = FileType.Layout; + + public bool CanSave { get; set; } + public string[] Description { get; set; } = new string[] { "NX Archive" }; + public string[] Extension { get; set; } = new string[] { "*.nxarc" }; + public string FileName { get; set; } + public string FilePath { get; set; } + public IFileInfo IFileInfo { get; set; } + + public bool CanAddFiles { get; set; } + public bool CanRenameFiles { get; set; } + public bool CanReplaceFiles { get; set; } + public bool CanDeleteFiles { get; set; } + + public bool Identify(System.IO.Stream stream) + { + using (var reader = new Switch_Toolbox.Library.IO.FileReader(stream, true)) + { + return reader.CheckSignature(4, "RAXN"); + } + } + + public Type[] Types + { + get + { + List types = new List(); + return types.ToArray(); + } + } + + public List files = new List(); + + public IEnumerable Files => files; + + public void Load(System.IO.Stream stream) + { + using (var reader = new FileReader(stream)) + { + reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian; + reader.ReadSignature(4, "RAXN"); + uint unk = reader.ReadUInt32(); + char[] Type = reader.ReadChars(4); + uint OffsetBlock = reader.ReadUInt32(); + uint HeaderSize = reader.ReadUInt32(); + uint FileCount = reader.ReadUInt32(); + uint BlockSize = reader.ReadUInt32(); + + List FileNames = new List(); + reader.Seek(OffsetBlock, System.IO.SeekOrigin.Begin); + for (int i = 0; i < FileCount; i++) + { + FileNames.Add(reader.ReadZeroTerminatedString()); + } + + reader.Seek(HeaderSize, System.IO.SeekOrigin.Begin); + for (int i = 0; i < FileCount; i++) + { + if (i == 0) + { + //Skip string table + reader.Seek(32); + } + else + { + var file = new FileEntry(); + file.FileName = FileNames[i]; + file.Read(reader); + files.Add(file); + } + } + + reader.Seek(HeaderSize, System.IO.SeekOrigin.Begin); + } + } + + public void Unload() + { + + } + + public byte[] Save() + { + return null; + } + + public bool AddFile(ArchiveFileInfo archiveFileInfo) + { + return false; + } + + public bool DeleteFile(ArchiveFileInfo archiveFileInfo) + { + return false; + } + + public class FileEntry : ArchiveFileInfo + { + public void Read(FileReader reader) + { + ulong Size = reader.ReadUInt64(); + ulong Offset = reader.ReadUInt64(); + ulong Flag = reader.ReadUInt64(); + ulong Unknown = reader.ReadUInt64(); + + using (reader.TemporarySeek((long)Offset, System.IO.SeekOrigin.Begin)) + { + FileData = reader.ReadBytes((int)Size); + if (Flag == 1) + { + FileData = STLibraryCompression.ZLIB.Decompress(FileData); + } + } + } + + public void Write(FileWriter writer) + { + + } + } + } +} diff --git a/Switch_FileFormatsMain/Main.cs b/Switch_FileFormatsMain/Main.cs index 119a8770..438d8b37 100644 --- a/Switch_FileFormatsMain/Main.cs +++ b/Switch_FileFormatsMain/Main.cs @@ -293,6 +293,7 @@ namespace FirstPlugin // Formats.Add(typeof(SDF)); Formats.Add(typeof(TMPK)); Formats.Add(typeof(TEX3DS)); + Formats.Add(typeof(NXARC)); Formats.Add(typeof(Turbo.Course_MapCamera_bin)); Formats.Add(typeof(Turbo.PartsBIN)); diff --git a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj index 0d9962f2..252e82f7 100644 --- a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj +++ b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj @@ -191,6 +191,7 @@ + diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index a65e1619..f0bd2e5b 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache index a79c4d76..39aa351b 100644 --- a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache +++ b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -b3fd6195e956ad1a3ce80bfdafc7f0f462fb99cc +f3116c416a062081738ca7e7aee034e76dab7162 diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 94e78c28..cf975e0f 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/FileFormats/Animation/SEANIM.cs b/Switch_Toolbox_Library/FileFormats/Animation/SEANIM.cs index 1a7dd3fe..aa213c3c 100644 --- a/Switch_Toolbox_Library/FileFormats/Animation/SEANIM.cs +++ b/Switch_Toolbox_Library/FileFormats/Animation/SEANIM.cs @@ -9,7 +9,7 @@ namespace Switch_Toolbox.Library.Animations { SEAnim seAnim = new SEAnim(); seAnim.Looping = anim.CanLoop; - + seAnim.AnimType = AnimationType.Absolute; //Reset active animation to 0 anim.SetFrame(0); for (int frame = 0; frame < anim.FrameCount; frame++) diff --git a/Switch_Toolbox_Library/IO/FileIO.cs b/Switch_Toolbox_Library/IO/FileIO.cs index f9f1be85..40d2ddf6 100644 --- a/Switch_Toolbox_Library/IO/FileIO.cs +++ b/Switch_Toolbox_Library/IO/FileIO.cs @@ -70,13 +70,13 @@ namespace Switch_Toolbox.Library.IO { public static byte[] Decompress(byte[] b) { - var output = new MemoryStream(); - using (var compressedStream = new MemoryStream(b)) { - using (var zipStream = new DeflateStream(compressedStream, CompressionMode.Decompress)) - { - zipStream.CopyTo(output); - return output.ToArray(); - } + using (var br = new FileReader(new MemoryStream(b), true)) + { + var ms = new System.IO.MemoryStream(); + br.BaseStream.Position = 2; + using (var ds = new DeflateStream(new MemoryStream(br.ReadBytes((int)br.BaseStream.Length - 6)), CompressionMode.Decompress)) + ds.CopyTo(ms); + return ms.ToArray(); } }