1
0
mirror of synced 2024-11-28 01:10:51 +01:00

Add dialog to copy skeletal animations

This commit is contained in:
KillzXGaming 2020-02-02 20:40:26 -05:00
parent 2df413a28d
commit c01be70a71
13 changed files with 415 additions and 1 deletions

View File

@ -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<ToolStripItem> Items = new List<ToolStripItem>();
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<FSKA> anims = new List<FSKA>();
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);

View File

@ -499,6 +499,12 @@
<Compile Include="GUI\BFLYT\Animations\LytAnimationWindow.Designer.cs">
<DependentUpon>LytAnimationWindow.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFRES\BfresAnimationCopy.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\BFRES\BfresAnimationCopy.Designer.cs">
<DependentUpon>BfresAnimationCopy.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BFRES\Materials\RenderState\RenderStateEditor.cs">
<SubType>UserControl</SubType>
</Compile>
@ -1608,6 +1614,9 @@
<EmbeddedResource Include="GUI\BFLYT\Animations\LytAnimationWindow.resx">
<DependentUpon>LytAnimationWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\BfresAnimationCopy.resx">
<DependentUpon>BfresAnimationCopy.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\Materials\RenderState\RenderStateEditor.resx">
<DependentUpon>RenderStateEditor.cs</DependentUpon>
</EmbeddedResource>

View File

@ -0,0 +1,175 @@
namespace FirstPlugin.Forms
{
partial class BfresAnimationCopy
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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<FSKA> 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<FSKA> GetAnimationCopies()
{
List<FSKA> anims = new List<FSKA>();
foreach (ListViewItem item in listViewCustom1.Items)
if (item.Checked)
anims.Add(item.Tag as FSKA);
return anims;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>