diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index f99c0956..b3a22750 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 db9ed52d..051a4261 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 3b987a33..40411897 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/BFRES/BFRESGroup.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BFRESGroup.cs index 00aee2b3..b6f646d6 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BFRESGroup.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BFRESGroup.cs @@ -35,7 +35,12 @@ namespace Bfres.Structs { get { - return ((BFRES)Parent).IsWiiU; + if (Parent is BFRES) + return ((BFRES)Parent).IsWiiU; + else if (Parent.Parent is BFRES) + return ((BFRES)Parent.Parent).IsWiiU; + else + return ((BFRES)Parent.Parent.Parent).IsWiiU; } } diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs index ff514819..70ce256e 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs @@ -186,9 +186,9 @@ namespace Bfres.Structs string ext = Utils.GetExtension(FileName); if (ext == ".bfska") { - if (GetResFileU() != null) + if (resFileU != null) { - SkeletalAnimU.Import(FileName, GetResFileU()); + SkeletalAnimU.Import(FileName, resFileU); SkeletalAnimU.Name = Text; LoadAnim(SkeletalAnimU); } @@ -212,7 +212,7 @@ namespace Bfres.Structs { if (SkeletalAnimU != null) LoadAnimData(SkeletalAnimU); - else + else if (SkeletalAnim != null) LoadAnimData(SkeletalAnim); } diff --git a/Switch_FileFormatsMain/FileFormats/Bin/KartParts.cs b/Switch_FileFormatsMain/FileFormats/Bin/KartParts.cs new file mode 100644 index 00000000..4c93436b --- /dev/null +++ b/Switch_FileFormatsMain/FileFormats/Bin/KartParts.cs @@ -0,0 +1,126 @@ +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 Syroot.NintenTools.MarioKart8.BinData; +using Syroot.NintenTools.MarioKart8; +using System.IO; + + +namespace FirstPlugin.Turbo +{ + public class PartsBIN : TreeNodeFile, IFileFormat + { + public bool CanSave { get; set; } + public string[] Description { get; set; } = new string[] { "Mario Kart 8 Kart Parts" }; + public string[] Extension { get; set; } = new string[] { "*.bin" }; + public string FileName { get; set; } + public string FilePath { get; set; } + public IFileInfo IFileInfo { get; set; } + + public bool Identify(System.IO.Stream stream) + { + using (var reader = new Switch_Toolbox.Library.IO.FileReader(stream, true)) + { + return reader.CheckSignature(4, "PRTS"); + } + } + + public Type[] Types + { + get + { + List types = new List(); + return types.ToArray(); + } + } + + public class TIRE + { + + } + + public class KART + { + + } + + public class GLIDER + { + + } + + BinFile binFile; + public void Load(System.IO.Stream stream) + { + binFile = new BinFile(stream); + + for (int sectionIndex = 0; sectionIndex < binFile.Sections.Count; sectionIndex++) + { + + } + + + // Dump the BIN file to CSV. + using (FileStream streamF = new FileStream("test.csv", FileMode.Create, FileAccess.Write, FileShare.None)) + using (StreamWriter writer = new StreamWriter(streamF, Encoding.UTF8, 1024, true)) + { + // Write file header information. + Write(writer, 0, $"BIN File Report for", FileName); + Write(writer, 0, "Identifier", binFile.Format); + Write(writer, 0, "Section count", binFile.Sections.Count); + Write(writer, 0, "Unknown", binFile.ID); + writer.WriteLine(); + + int sectionIndex = 1; + foreach (var section in GetDwordSectionData(binFile)) + { + Write(writer, 0, $"Section {sectionIndex++}"); + Write(writer, 1, "Identifier", section.Name); + Write(writer, 1, "Group count", section.ParamCount); + Write(writer, 1, "Type", section.ID.ToString("X")); + writer.WriteLine(); + + DwordSectionData sectionData = (DwordSectionData)section.Data; + + for (int d = 0; d < sectionData.Data.Length; d++) + { + foreach (Dword[] element in sectionData.Data[d]) + { + Write(writer, 1, String.Join('\t'.ToString(), element)); + } + } + } + } + } + + private IEnumerable
GetDwordSectionData(BinFile binFile) + { + foreach (Section section in binFile.Sections) + { + if (section.Data is DwordSectionData sectionData) + yield return section; + } + } + + + private static void Write(StreamWriter writer, int indent, params object[] values) + { + writer.WriteLine(new string('\t', indent) + String.Join('\t'.ToString(), values)); + } + + + public void Unload() + { + + } + public byte[] Save() + { + return null; + } + } +} diff --git a/Switch_FileFormatsMain/Main.cs b/Switch_FileFormatsMain/Main.cs index 53b53716..23f05ff4 100644 --- a/Switch_FileFormatsMain/Main.cs +++ b/Switch_FileFormatsMain/Main.cs @@ -153,8 +153,9 @@ namespace FirstPlugin Formats.Add(typeof(TMPK)); Formats.Add(typeof(Turbo.Course_MapCamera_bin)); + Formats.Add(typeof(Turbo.PartsBIN)); + - return Formats.ToArray(); } #endregion diff --git a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj index b4064e03..2d76adea 100644 --- a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj +++ b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj @@ -141,6 +141,9 @@ ..\Toolbox\Lib\Syroot.NintenTools.Bfres.dll False + + ..\Toolbox\Lib\Syroot.NintenTools.MarioKart8.dll + ..\Toolbox\Lib\Syroot.NintenTools.NSW.Bfres.dll False @@ -200,6 +203,7 @@ + diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index e6494588..d24daf67 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/DesignTimeResolveAssemblyReferencesInput.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache index 2775c0f3..fa6c8df9 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll index 5ad6b756..152c4179 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll differ diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb index 905083d0..45142f97 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache index 51b190d4..84ccf047 100644 --- a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache +++ b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -f116fcf22bd14b1cb853244a6978b4a40935e43b +303eb09c135d9731661be3be002bdbe8c1380569 diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 423dbd62..4713d6ac 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/Toolbox/Lib/Syroot.NintenTools.MarioKart8.dll b/Toolbox/Lib/Syroot.NintenTools.MarioKart8.dll new file mode 100644 index 00000000..227a7890 Binary files /dev/null and b/Toolbox/Lib/Syroot.NintenTools.MarioKart8.dll differ