diff --git a/.gitignore b/.gitignore index 8148ba81..9468b60f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,3 @@ *.resources Debug/ Release/ -Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll -Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.pdb -Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.xml diff --git a/Switch_FileFormatsMain/FileFormats/BFRES.cs b/Switch_FileFormatsMain/FileFormats/BFRES.cs index ffbbdf86..e961743e 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES.cs @@ -366,8 +366,8 @@ namespace FirstPlugin Nodes.Add(fksaFolder); foreach (ResU.SkeletalAnim ska in resFile.SkeletalAnims.Values) { - BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name); - skeletonAnim.Read(ska, resFile); + FSKA skeletonAnim = new FSKA(ska.Name); + skeletonAnim.Read(ska); fksaFolder.Nodes.Add(skeletonAnim); } } @@ -377,8 +377,8 @@ namespace FirstPlugin Nodes.Add(fksaFolder); foreach (SkeletalAnim ska in resFile.SkeletalAnims) { - BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name); - skeletonAnim.Read(ska, resFile); + FSKA skeletonAnim = new FSKA(ska.Name); + skeletonAnim.Read(ska); fksaFolder.Nodes.Add(skeletonAnim); } } @@ -462,7 +462,7 @@ namespace FirstPlugin } if (Nodes.ContainsKey("FSKA")) { - foreach (BfresSkeletonAnim ska in Nodes["FSKA"].Nodes) + foreach (FSKA ska in Nodes["FSKA"].Nodes) resFile.SkeletalAnims.Add(ska.SkeletalAnim); } if (Nodes.ContainsKey("FMAA")) @@ -495,7 +495,7 @@ namespace FirstPlugin { var resFileU = BFRESRender.ResFileNode.resFileU; resFileU.Models.Clear(); - // resFileU.SkeletalAnims.Clear(); + resFileU.SkeletalAnims.Clear(); // resFileU.SceneAnims.Clear(); // resFileU.ShapeAnims.Clear(); // resFileU.BoneVisibilityAnims.Clear(); @@ -516,6 +516,15 @@ namespace FirstPlugin resFileU.Textures.Add(tex.Text, tex.texture); } } + if (Nodes.ContainsKey("FSKA")) + { + foreach (FSKA ska in Nodes["FSKA"].Nodes) + { + ska.SkeletalAnimU.Name = ska.Text; + resFileU.SkeletalAnims.Add(ska.Text, ska.SkeletalAnimU); + } + } + else throw new Exception("Failed to find textures"); diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/FSKA.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/FSKA.cs index 69f551ae..33992b94 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/FSKA.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/FSKA.cs @@ -37,10 +37,14 @@ namespace Bfres.Structs if (sfd.ShowDialog() == DialogResult.OK) { string folderPath = sfd.SelectedPath; - foreach (BfresSkeletonAnim fska in Nodes) + foreach (FSKA fska in Nodes) { string FileName = folderPath + '\\' + fska.Text + ".bfska"; - ((BfresSkeletonAnim)fska).SkeletalAnim.Export(FileName, fska.GetResFile()); + + if (fska.GetResFileU() != null) + ((FSKA)fska).SkeletalAnimU.Export(FileName, fska.GetResFileU()); + else + ((FSKA)fska).SkeletalAnim.Export(FileName, fska.GetResFile()); } } } @@ -54,7 +58,7 @@ namespace Bfres.Structs } } - public class BfresSkeletonAnim : Animation + public class FSKA : Animation { public enum TrackType { @@ -71,7 +75,7 @@ namespace Bfres.Structs public SkeletalAnim SkeletalAnim; public ResU.SkeletalAnim SkeletalAnimU; - public BfresSkeletonAnim() + public FSKA() { ImageKey = "skeletonAnimation"; SelectedImageKey = "skeletonAnimation"; @@ -84,7 +88,7 @@ namespace Bfres.Structs ContextMenu.MenuItems.Add(replace); replace.Click += Replace; } - public BfresSkeletonAnim(string name) + public FSKA(string name) { Text = name; @@ -120,7 +124,7 @@ namespace Bfres.Structs { if (GetResFileU() != null) { - throw new Exception("Wii U unsupported!"); + SkeletalAnimU.Export(sfd.FileName, GetResFileU()); } else { @@ -137,19 +141,24 @@ namespace Bfres.Structs { if (GetResFileU() != null) { - throw new Exception("Wii U unsupported!"); + SkeletalAnimU.Import(ofd.FileName, GetResFileU()); + SkeletalAnimU.Name = Text; + Read(SkeletalAnimU); } else { SkeletalAnim.Import(ofd.FileName); + SkeletalAnim.Name = Text; + Read(SkeletalAnim); } } - SkeletalAnim.Name = Text; } - public static List SkeletonAnimations = new List(); - public void Read(ResU.SkeletalAnim ska, ResU.ResFile b) + public void Read(ResU.SkeletalAnim ska) { + Nodes.Clear(); + Bones.Clear(); + FrameCount = ska.FrameCount; SkeletalAnimU = ska; @@ -220,8 +229,11 @@ namespace Bfres.Structs } } } - public void Read(SkeletalAnim ska, ResFile b) + public void Read(SkeletalAnim ska) { + Nodes.Clear(); + Bones.Clear(); + FrameCount = ska.FrameCount; SkeletalAnim = ska; @@ -311,8 +323,6 @@ namespace Bfres.Structs public List tracks = new List(); public FSKANode(ResU.BoneAnim b) { - return; - Text = b.Name; sca = new Vector3(b.BaseData.Scale.X, b.BaseData.Scale.Y, b.BaseData.Scale.Z); diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BfresSwitch.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BfresSwitch.cs index bc5e74aa..5d3bc669 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BfresSwitch.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BfresSwitch.cs @@ -338,7 +338,7 @@ namespace FirstPlugin VertexBufferHelperAttrib attd = helper[attName]; return attd.Data; } - public static SkeletalAnim SetSkeletalAniamtion(BfresSkeletonAnim anim) + public static SkeletalAnim SetSkeletalAniamtion(FSKA anim) { SkeletalAnim animation = new SkeletalAnim(); @@ -359,7 +359,7 @@ namespace FirstPlugin return animation; } - private static BoneAnim createBoneAnim(Animation.KeyNode bone, BfresSkeletonAnim anim) + private static BoneAnim createBoneAnim(Animation.KeyNode bone, FSKA anim) { BoneAnim boneAnim = new BoneAnim(); boneAnim.Name = bone.Name; diff --git a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll index 1e49e56d..e6b10f13 100644 Binary files a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll and b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.dll differ diff --git a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.pdb b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.pdb index cc5fe952..cf1b9047 100644 Binary files a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.pdb and b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.pdb differ diff --git a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.xml b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.xml index 210152de..be3e2b6d 100644 --- a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.xml +++ b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.xml @@ -2417,6 +2417,11 @@ Starts serializing the data from the root. + + + Starts serializing the data from the root. + + Starts serializing the data from the root. @@ -5316,6 +5321,34 @@ Gets or sets customly attached instances. + + + Initializes a new instance of the class from the given which + is optionally left open. + + The to load the data from. + true to leave the stream open after reading, otherwise false. + + + + Initializes a new instance of the class from the file with the given + . + + The name of the file to load the data from. + + + + Saves the contents in the given and optionally leaves it open + + The to save the contents into. + true to leave the stream open after writing, otherwise false. + + + + Saves the contents in the file with the given . + + The name of the file to save the contents into. + Represents flags specifying how animation data is stored or should be played. diff --git a/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.zip b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.zip new file mode 100644 index 00000000..2ef01503 Binary files /dev/null and b/Switch_Toolbox/Lib/Syroot.NintenTools.Bfres.zip differ diff --git a/Switch_Toolbox_Library/GUI Custom/TreeViewCustom.cs b/Switch_Toolbox_Library/GUI Custom/TreeViewCustom.cs index 8d04893f..55eeb241 100644 --- a/Switch_Toolbox_Library/GUI Custom/TreeViewCustom.cs +++ b/Switch_Toolbox_Library/GUI Custom/TreeViewCustom.cs @@ -16,7 +16,7 @@ namespace Switch_Toolbox.Library public virtual void OnMouseRightClick(TreeView treeview) { } public virtual void OnDoubleMouseClick(TreeView treeview) { } - public void Sort(TreeNode node) + public void SortNodes(TreeNode node) { /* string[] array = new string[Nodes.Count]; for (int i = 0; i < Nodes.Count; ++i) @@ -29,7 +29,7 @@ namespace Switch_Toolbox.Library //Good enough for now. I'll update with a more cleaner method later foreach (TreeNode n in node.Nodes) - Sort(n); + SortNodes(n); try { TreeNode temp = null;