diff --git a/BrawlboxHelper/Syroot.NintenTools.Bfres.dll b/BrawlboxHelper/Syroot.NintenTools.Bfres.dll index 22e7a59d..641ad33e 100644 Binary files a/BrawlboxHelper/Syroot.NintenTools.Bfres.dll and b/BrawlboxHelper/Syroot.NintenTools.Bfres.dll differ diff --git a/BrawlboxHelper/Syroot.NintenTools.Bfres.pdb b/BrawlboxHelper/Syroot.NintenTools.Bfres.pdb index 57dff7a3..1a12fda5 100644 Binary files a/BrawlboxHelper/Syroot.NintenTools.Bfres.pdb and b/BrawlboxHelper/Syroot.NintenTools.Bfres.pdb differ diff --git a/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.dll b/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.dll index 3a26f60f..7d7717bd 100644 Binary files a/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.dll and b/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.dll differ diff --git a/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.pdb b/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.pdb index 439e4a63..2b4c1673 100644 Binary files a/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.pdb and b/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.pdb differ diff --git a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs index 35c4a768..f9aa7f8d 100644 --- a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs +++ b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FSKA.cs @@ -10,6 +10,7 @@ using OpenTK; using Toolbox.Library.Animations; using Toolbox.Library.Forms; using SELib; +using FirstPlugin.Forms; namespace Bfres.Structs { @@ -49,15 +50,19 @@ namespace Bfres.Structs OpenAnimationData(); } - public ToolStripItem[] GetContextMenuItems() + public override ToolStripItem[] GetContextMenuItems() { List Items = new List(); Items.AddRange(base.GetContextMenuItems()); + Items.Add(new ToolStripMenuItem("Copy", null, CopyAction, Keys.Control | Keys.C)); Items.Add(new ToolStripMenuItem("New Bone Target", null, NewAction, Keys.Control | Keys.W)); return Items.ToArray(); } + protected void CopyAction(object sender, EventArgs e) { CopyAnimForm(); } + protected void NewAction(object sender, EventArgs e) { NewBoneAnim(); } + public void NewBoneAnim() { var boneAnim = new BoneAnimNode("NewBoneTarget", true); @@ -84,6 +89,49 @@ namespace Bfres.Structs } } + public void CopyAnimForm() + { + BfresAnimationCopy copyDlg = new BfresAnimationCopy(); + + List anims = new List(); + foreach (var node in Parent.Nodes) + anims.Add((FSKA)node); + + copyDlg.LoadAnimationSections(this, anims); + if (copyDlg.ShowDialog() == DialogResult.OK) + { + foreach (var anim in copyDlg.GetAnimationCopies()) { + anim.CopyAnimation(this, copyDlg.CopySettings, + copyDlg.CopyBoneAnims, copyDlg.CopyUserData); + } + } + } + + public void CopyAnimation(FSKA target, bool copySettings, + bool copyBoneAnims, bool copyUserData) + { + if (SkeletalAnim != null) + { + SkeletalAnim.Copy(target.SkeletalAnim, new SkeletalAnim.CopyFilter() + { + CopyBoneAnims = copyBoneAnims, + CopySettings = copySettings, + CopyUserData = copyUserData, + }); + } + else + { + SkeletalAnimU.Copy(target.SkeletalAnimU, new ResU.SkeletalAnim.CopyFilter() + { + CopyBoneAnims = copyBoneAnims, + CopySettings = copySettings, + CopyUserData = copyUserData, + }); + } + + OpenAnimationData(); + } + public ResFile GetResFile() { return ((BFRESGroupNode)Parent).GetResFile(); } @@ -165,6 +213,15 @@ namespace Bfres.Structs else throw new Exception("No skeleton found to assign!"); } + else if (ext == ".json") + { + if (SkeletalAnimU != null) + System.IO.File.WriteAllText(FileName, Newtonsoft.Json.JsonConvert.SerializeObject(SkeletalAnimU, + Newtonsoft.Json.Formatting.Indented)); + else + System.IO.File.WriteAllText(FileName, Newtonsoft.Json.JsonConvert.SerializeObject(SkeletalAnim, + Newtonsoft.Json.Formatting.Indented)); + } } private STSkeleton GetActiveSkeleton() @@ -365,6 +422,10 @@ namespace Bfres.Structs var rotz = boneNode.ZROT.GetValue(0); var rotw = boneNode.WROT.GetValue(0); + var Value3One = Syroot.Maths.Vector3F.One; + var Value3Zero = Syroot.Maths.Vector3F.Zero; + var Value4Zero = Syroot.Maths.Vector4F.Zero; + BoneAnimData boneBaseData = new BoneAnimData(); boneBaseData.Translate = new Syroot.Maths.Vector3F(posx, posy, posz); boneBaseData.Scale = new Syroot.Maths.Vector3F(scax, scay, scaz); diff --git a/File_Format_Library/File_Format_Library.csproj b/File_Format_Library/File_Format_Library.csproj index fb28edab..1940af2c 100644 --- a/File_Format_Library/File_Format_Library.csproj +++ b/File_Format_Library/File_Format_Library.csproj @@ -499,6 +499,12 @@ LytAnimationWindow.cs + + Form + + + BfresAnimationCopy.cs + UserControl @@ -1608,6 +1614,9 @@ LytAnimationWindow.cs + + BfresAnimationCopy.cs + RenderStateEditor.cs diff --git a/File_Format_Library/GUI/BFRES/BfresAnimationCopy.Designer.cs b/File_Format_Library/GUI/BFRES/BfresAnimationCopy.Designer.cs new file mode 100644 index 00000000..e86ab9e6 --- /dev/null +++ b/File_Format_Library/GUI/BFRES/BfresAnimationCopy.Designer.cs @@ -0,0 +1,175 @@ +namespace FirstPlugin.Forms +{ + partial class BfresAnimationCopy + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.stPanel1 = new Toolbox.Library.Forms.STPanel(); + this.chkUserData = new Toolbox.Library.Forms.STCheckBox(); + this.chkBoneAnims = new Toolbox.Library.Forms.STCheckBox(); + this.chkAnimSettings = new Toolbox.Library.Forms.STCheckBox(); + this.stPanel2 = new Toolbox.Library.Forms.STPanel(); + this.listViewCustom1 = new Toolbox.Library.Forms.ListViewCustom(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.stPanel3 = new Toolbox.Library.Forms.STPanel(); + this.btnOk = new Toolbox.Library.Forms.STButton(); + this.contentContainer.SuspendLayout(); + this.stPanel1.SuspendLayout(); + this.stPanel2.SuspendLayout(); + this.stPanel3.SuspendLayout(); + this.SuspendLayout(); + // + // contentContainer + // + this.contentContainer.Controls.Add(this.btnOk); + this.contentContainer.Controls.Add(this.stPanel3); + this.contentContainer.Size = new System.Drawing.Size(543, 388); + this.contentContainer.Controls.SetChildIndex(this.stPanel3, 0); + this.contentContainer.Controls.SetChildIndex(this.btnOk, 0); + // + // stPanel1 + // + this.stPanel1.Controls.Add(this.chkUserData); + this.stPanel1.Controls.Add(this.chkBoneAnims); + this.stPanel1.Controls.Add(this.chkAnimSettings); + this.stPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.stPanel1.Location = new System.Drawing.Point(180, 0); + this.stPanel1.Name = "stPanel1"; + this.stPanel1.Size = new System.Drawing.Size(349, 319); + this.stPanel1.TabIndex = 1; + // + // chkUserData + // + this.chkUserData.AutoSize = true; + this.chkUserData.Location = new System.Drawing.Point(20, 58); + this.chkUserData.Name = "chkUserData"; + this.chkUserData.Size = new System.Drawing.Size(74, 17); + this.chkUserData.TabIndex = 2; + this.chkUserData.Text = "User Data"; + this.chkUserData.UseVisualStyleBackColor = true; + // + // chkBoneAnims + // + this.chkBoneAnims.AutoSize = true; + this.chkBoneAnims.Location = new System.Drawing.Point(20, 35); + this.chkBoneAnims.Name = "chkBoneAnims"; + this.chkBoneAnims.Size = new System.Drawing.Size(105, 17); + this.chkBoneAnims.TabIndex = 1; + this.chkBoneAnims.Text = "Bone Animations"; + this.chkBoneAnims.UseVisualStyleBackColor = true; + // + // chkAnimSettings + // + this.chkAnimSettings.AutoSize = true; + this.chkAnimSettings.Location = new System.Drawing.Point(20, 12); + this.chkAnimSettings.Name = "chkAnimSettings"; + this.chkAnimSettings.Size = new System.Drawing.Size(113, 17); + this.chkAnimSettings.TabIndex = 0; + this.chkAnimSettings.Text = "Animation Settings"; + this.chkAnimSettings.UseVisualStyleBackColor = true; + // + // stPanel2 + // + this.stPanel2.Controls.Add(this.listViewCustom1); + this.stPanel2.Dock = System.Windows.Forms.DockStyle.Left; + this.stPanel2.Location = new System.Drawing.Point(0, 0); + this.stPanel2.Name = "stPanel2"; + this.stPanel2.Size = new System.Drawing.Size(180, 319); + this.stPanel2.TabIndex = 2; + // + // listViewCustom1 + // + this.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.listViewCustom1.CheckBoxes = true; + this.listViewCustom1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1}); + this.listViewCustom1.Dock = System.Windows.Forms.DockStyle.Fill; + this.listViewCustom1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.listViewCustom1.HideSelection = false; + this.listViewCustom1.Location = new System.Drawing.Point(0, 0); + this.listViewCustom1.Name = "listViewCustom1"; + this.listViewCustom1.OwnerDraw = true; + this.listViewCustom1.Size = new System.Drawing.Size(180, 319); + this.listViewCustom1.TabIndex = 0; + this.listViewCustom1.UseCompatibleStateImageBehavior = false; + this.listViewCustom1.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Width = 179; + // + // stPanel3 + // + this.stPanel3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.stPanel3.Controls.Add(this.stPanel1); + this.stPanel3.Controls.Add(this.stPanel2); + this.stPanel3.Location = new System.Drawing.Point(5, 31); + this.stPanel3.Name = "stPanel3"; + this.stPanel3.Size = new System.Drawing.Size(529, 319); + this.stPanel3.TabIndex = 3; + // + // btnOk + // + this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOk.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnOk.Location = new System.Drawing.Point(459, 361); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 23); + this.btnOk.TabIndex = 4; + this.btnOk.Text = "Ok"; + this.btnOk.UseVisualStyleBackColor = false; + // + // BfresAnimationCopy + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(549, 393); + this.Name = "BfresAnimationCopy"; + this.Text = "Animation Copy"; + this.contentContainer.ResumeLayout(false); + this.stPanel1.ResumeLayout(false); + this.stPanel1.PerformLayout(); + this.stPanel2.ResumeLayout(false); + this.stPanel3.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + private Toolbox.Library.Forms.STPanel stPanel1; + private Toolbox.Library.Forms.STPanel stPanel2; + private Toolbox.Library.Forms.ListViewCustom listViewCustom1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private Toolbox.Library.Forms.STCheckBox chkUserData; + private Toolbox.Library.Forms.STCheckBox chkBoneAnims; + private Toolbox.Library.Forms.STCheckBox chkAnimSettings; + private Toolbox.Library.Forms.STPanel stPanel3; + private Toolbox.Library.Forms.STButton btnOk; + } +} \ No newline at end of file diff --git a/File_Format_Library/GUI/BFRES/BfresAnimationCopy.cs b/File_Format_Library/GUI/BFRES/BfresAnimationCopy.cs new file mode 100644 index 00000000..fce3018f --- /dev/null +++ b/File_Format_Library/GUI/BFRES/BfresAnimationCopy.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Bfres.Structs; +using Toolbox.Library.Forms; + +namespace FirstPlugin.Forms +{ + public partial class BfresAnimationCopy : STForm + { + public bool CopySettings => chkAnimSettings.Checked; + public bool CopyBoneAnims => chkBoneAnims.Checked; + public bool CopyUserData => chkUserData.Checked; + + public BfresAnimationCopy() + { + InitializeComponent(); + } + + public void LoadAnimationSections(FSKA target, List skeletalAnims) + { + this.Text = $"Animation Copy [{target.Text}]"; + + listViewCustom1.Items.Clear(); + for (int i = 0; i < skeletalAnims.Count; i++) { + if (target != skeletalAnims[i]) + listViewCustom1.Items.Add(new ListViewItem(skeletalAnims[i].Text) + { + Tag = skeletalAnims[i] + }); + } + } + + public List GetAnimationCopies() + { + List anims = new List(); + foreach (ListViewItem item in listViewCustom1.Items) + if (item.Checked) + anims.Add(item.Tag as FSKA); + return anims; + } + } +} diff --git a/File_Format_Library/GUI/BFRES/BfresAnimationCopy.resx b/File_Format_Library/GUI/BFRES/BfresAnimationCopy.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/File_Format_Library/GUI/BFRES/BfresAnimationCopy.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Toolbox/Lib/Syroot.NintenTools.Bfres.dll b/Toolbox/Lib/Syroot.NintenTools.Bfres.dll index 22e7a59d..641ad33e 100644 Binary files a/Toolbox/Lib/Syroot.NintenTools.Bfres.dll and b/Toolbox/Lib/Syroot.NintenTools.Bfres.dll differ diff --git a/Toolbox/Lib/Syroot.NintenTools.Bfres.pdb b/Toolbox/Lib/Syroot.NintenTools.Bfres.pdb index 57dff7a3..1a12fda5 100644 Binary files a/Toolbox/Lib/Syroot.NintenTools.Bfres.pdb and b/Toolbox/Lib/Syroot.NintenTools.Bfres.pdb differ diff --git a/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll b/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll index 8195dbf0..7d7717bd 100644 Binary files a/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll and b/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll differ diff --git a/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb b/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb index 3f00982f..2b4c1673 100644 Binary files a/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb and b/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb differ