Add better audio check for bars

This commit is contained in:
KillzXGaming 2019-07-13 15:04:56 -04:00
parent e1adbeee01
commit fbec00de01
16 changed files with 468 additions and 10 deletions

Binary file not shown.

View file

@ -10,6 +10,26 @@ using BrawlLib.Wii.Animations;
namespace BrawlboxHelper
{
public class KeyGroupData
{
public float Value;
}
public class BoneAnimKeyData
{
public Dictionary<int, KeyGroupData> XPOS = new Dictionary<int, KeyGroupData>();
public Dictionary<int, KeyGroupData> YPOS = new Dictionary<int, KeyGroupData>();
public Dictionary<int, KeyGroupData> ZPOS = new Dictionary<int, KeyGroupData>();
public Dictionary<int, KeyGroupData> XROT = new Dictionary<int, KeyGroupData>();
public Dictionary<int, KeyGroupData> YROT = new Dictionary<int, KeyGroupData>();
public Dictionary<int, KeyGroupData> ZROT = new Dictionary<int, KeyGroupData>();
public Dictionary<int, KeyGroupData> XSCA = new Dictionary<int, KeyGroupData>();
public Dictionary<int, KeyGroupData> YSCA = new Dictionary<int, KeyGroupData>();
public Dictionary<int, KeyGroupData> ZSCA = new Dictionary<int, KeyGroupData>();
}
public class FSHUConverter
{
public static ResU.ShaderParamAnim Clr02Fshu(string FileName)
@ -241,6 +261,8 @@ namespace BrawlboxHelper
public class FSKAConverter
{
public static List<BoneAnimKeyData> BoneAnimKeys = new List<BoneAnimKeyData>();
static float Deg2Rad = (float)(Math.PI / 180f);
static float Rad2Deg = (float)(180f / Math.PI);

View file

@ -72,7 +72,7 @@ namespace FirstPlugin
public class AudioEntry : TreeNodeCustom
{
public AudioType Type;
public string Magic;
public byte[] Data;
public AudioEntry()
@ -88,12 +88,12 @@ namespace FirstPlugin
}
public void SetupMusic()
{
if (Type == AudioType.Bfwav)
if (Magic == "FWAV" || Magic == "BWAV")
{
ImageKey = "bfwav";
SelectedImageKey = "bfwav";
}
else if (Type == AudioType.Bfstp)
else if (Magic == "FSTP")
{
ImageKey = "bfstp";
SelectedImageKey = "bfstp";
@ -148,9 +148,9 @@ namespace FirstPlugin
}
public void UpdateEditor()
{
switch (Type)
switch (Magic)
{
case AudioType.Bfwav:
case "FWAV":
// ShowHexView();
ShowBfwavPlayer();
break;
@ -245,16 +245,18 @@ namespace FirstPlugin
BARSAudioFile audio = bars.AudioEntries[i].AudioFile;
AudioEntry node = new AudioEntry();
node.Type = audio.AudioType;
node.Magic = audio.Magic;
node.Data = audio.data;
node.SetupMusic();
if (audio.AudioType == AudioType.Bfwav)
if (audio.Magic == "FWAV")
node.Text = audioName + ".bfwav";
else if (audio.AudioType == AudioType.Bfstp)
else if (audio.Magic == "FSTP")
node.Text = audioName + ".bfstp";
else if (audio.Magic == "BWAV")
node.Text = audioName + ".bwav";
else
node.Text = audioName + ".UNKOWN";
node.Text = $"{audioName}.{audio.Magic}";
Nodes[1].Nodes.Add(node);
}

View file

@ -82,6 +82,11 @@ namespace Bfres.Structs
Items.Add(new STToolStipMenuItem("Show All Models", null, ShowAllModelsAction, Keys.Control | Keys.A));
Items.Add(new STToolStipMenuItem("Hide All Models", null, HideAllModelsAction, Keys.Control | Keys.H));
}
if (Type == BRESGroupType.SkeletalAnim)
{
Items.Add(new STToolStripSeparator());
Items.Add(new STToolStipMenuItem("Batch Edit Base Data", null, BatchEditBaseAnimDataAction, Keys.Control | Keys.A));
}
return Items.ToArray();
}
@ -95,6 +100,66 @@ namespace Bfres.Structs
protected void HideAllModelsAction(object sender, EventArgs e) { HideAllModels(); }
protected void ShowAllModelsAction(object sender, EventArgs e) { ShowAllModels(); }
protected void BatchEditBaseAnimDataAction(object sender, EventArgs e) { BatchEditBaseAnimData(); }
private void BatchEditBaseAnimData()
{
if (Nodes.Count <= 0)
return;
return;
BatchEditBaseAnimDataForm form = new BatchEditBaseAnimDataForm();
form.LoadAnim((Animation)Nodes[0]);
if (form.ShowDialog()== DialogResult.OK)
{
foreach (FSKA animation in Nodes)
{
if (animation.SkeletalAnimU != null)
{
foreach (var boneAnim in animation.SkeletalAnimU.BoneAnims)
{
if (boneAnim.Name == form.TargetBone)
{
var baseData = boneAnim.BaseData;
if (form.HasCustomScale)
{
boneAnim.FlagsBase |= ResU.BoneAnimFlagsBase.Scale;
boneAnim.ApplyScaleOne = false;
boneAnim.ApplyScaleUniform = false;
baseData.Scale = new Syroot.Maths.Vector3F(form.ScaleX, form.ScaleY, form.ScaleZ);
}
boneAnim.BaseData = baseData;
}
}
}
else
{
foreach (var boneAnim in animation.SkeletalAnim.BoneAnims)
{
if (boneAnim.Name == form.TargetBone)
{
var baseData = boneAnim.BaseData;
if (form.HasCustomScale)
{
boneAnim.FlagsBase |= ResNX.BoneAnimFlagsBase.Scale;
boneAnim.ApplyScaleOne = false;
boneAnim.ApplyScaleUniform = false;
baseData.Scale = new Syroot.Maths.Vector3F(form.ScaleX, form.ScaleY, form.ScaleZ);
}
boneAnim.BaseData = baseData;
}
}
}
animation.OpenAnimationData();
}
}
}
public override void ReplaceAll()
{
FolderSelectDialog sfd = new FolderSelectDialog();

View file

@ -58,7 +58,6 @@ namespace Bfres.Structs
}
protected void NewAction(object sender, EventArgs e) { NewBoneAnim(); }
public void NewBoneAnim()
{
var boneAnim = new BoneAnimNode("NewBoneTarget", true);
@ -134,6 +133,11 @@ namespace Bfres.Structs
{
STSkeleton skeleton = GetActiveSkeleton();
for (int i = 0; i <= FrameCount; i++)
{
}
if (SkeletalAnimU != null)
BrawlboxHelper.FSKAConverter.Fska2Chr0(BfresPlatformConverter.FSKAConvertWiiUToSwitch(SkeletalAnimU), FileName);
else

View file

@ -0,0 +1,191 @@
namespace FirstPlugin
{
partial class BatchEditBaseAnimDataForm
{
/// <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.stLabel1 = new Switch_Toolbox.Library.Forms.STLabel();
this.boneListCB = new Switch_Toolbox.Library.Forms.STComboBox();
this.stLabel2 = new Switch_Toolbox.Library.Forms.STLabel();
this.stLabel3 = new Switch_Toolbox.Library.Forms.STLabel();
this.stLabel4 = new Switch_Toolbox.Library.Forms.STLabel();
this.scaleXUD = new Switch_Toolbox.Library.Forms.STNumbericUpDown();
this.scaleYUD = new Switch_Toolbox.Library.Forms.STNumbericUpDown();
this.scaleZUD = new Switch_Toolbox.Library.Forms.STNumbericUpDown();
this.stButton1 = new Switch_Toolbox.Library.Forms.STButton();
this.contentContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.scaleXUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.scaleYUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.scaleZUD)).BeginInit();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.stButton1);
this.contentContainer.Controls.Add(this.scaleZUD);
this.contentContainer.Controls.Add(this.scaleYUD);
this.contentContainer.Controls.Add(this.scaleXUD);
this.contentContainer.Controls.Add(this.stLabel4);
this.contentContainer.Controls.Add(this.stLabel3);
this.contentContainer.Controls.Add(this.stLabel2);
this.contentContainer.Controls.Add(this.boneListCB);
this.contentContainer.Controls.Add(this.stLabel1);
this.contentContainer.Size = new System.Drawing.Size(409, 259);
this.contentContainer.Controls.SetChildIndex(this.stLabel1, 0);
this.contentContainer.Controls.SetChildIndex(this.boneListCB, 0);
this.contentContainer.Controls.SetChildIndex(this.stLabel2, 0);
this.contentContainer.Controls.SetChildIndex(this.stLabel3, 0);
this.contentContainer.Controls.SetChildIndex(this.stLabel4, 0);
this.contentContainer.Controls.SetChildIndex(this.scaleXUD, 0);
this.contentContainer.Controls.SetChildIndex(this.scaleYUD, 0);
this.contentContainer.Controls.SetChildIndex(this.scaleZUD, 0);
this.contentContainer.Controls.SetChildIndex(this.stButton1, 0);
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(9, 40);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(66, 13);
this.stLabel1.TabIndex = 12;
this.stLabel1.Text = "Bone Target";
//
// boneListCB
//
this.boneListCB.BorderColor = System.Drawing.Color.Empty;
this.boneListCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.boneListCB.ButtonColor = System.Drawing.Color.Empty;
this.boneListCB.FormattingEnabled = true;
this.boneListCB.Location = new System.Drawing.Point(12, 56);
this.boneListCB.Name = "boneListCB";
this.boneListCB.ReadOnly = true;
this.boneListCB.Size = new System.Drawing.Size(132, 21);
this.boneListCB.TabIndex = 13;
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(9, 106);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(44, 13);
this.stLabel2.TabIndex = 14;
this.stLabel2.Text = "Scale X";
//
// stLabel3
//
this.stLabel3.AutoSize = true;
this.stLabel3.Location = new System.Drawing.Point(121, 106);
this.stLabel3.Name = "stLabel3";
this.stLabel3.Size = new System.Drawing.Size(44, 13);
this.stLabel3.TabIndex = 15;
this.stLabel3.Text = "Scale Y";
//
// stLabel4
//
this.stLabel4.AutoSize = true;
this.stLabel4.Location = new System.Drawing.Point(224, 106);
this.stLabel4.Name = "stLabel4";
this.stLabel4.Size = new System.Drawing.Size(44, 13);
this.stLabel4.TabIndex = 16;
this.stLabel4.Text = "Scale Z";
//
// scaleXUD
//
this.scaleXUD.Location = new System.Drawing.Point(12, 132);
this.scaleXUD.Name = "scaleXUD";
this.scaleXUD.Size = new System.Drawing.Size(106, 20);
this.scaleXUD.TabIndex = 17;
this.scaleXUD.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// scaleYUD
//
this.scaleYUD.Location = new System.Drawing.Point(124, 132);
this.scaleYUD.Name = "scaleYUD";
this.scaleYUD.Size = new System.Drawing.Size(106, 20);
this.scaleYUD.TabIndex = 18;
this.scaleYUD.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// scaleZUD
//
this.scaleZUD.Location = new System.Drawing.Point(227, 132);
this.scaleZUD.Name = "scaleZUD";
this.scaleZUD.Size = new System.Drawing.Size(106, 20);
this.scaleZUD.TabIndex = 19;
this.scaleZUD.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// stButton1
//
this.stButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.stButton1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(326, 229);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(75, 23);
this.stButton1.TabIndex = 20;
this.stButton1.Text = "Ok";
this.stButton1.UseVisualStyleBackColor = false;
//
// BatchEditBaseAnimDataForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(415, 264);
this.Name = "BatchEditBaseAnimDataForm";
this.Text = "BatchEditBaseAnimDataForm";
this.contentContainer.ResumeLayout(false);
this.contentContainer.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.scaleXUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.scaleYUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.scaleZUD)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Switch_Toolbox.Library.Forms.STLabel stLabel1;
private Switch_Toolbox.Library.Forms.STNumbericUpDown scaleYUD;
private Switch_Toolbox.Library.Forms.STNumbericUpDown scaleXUD;
private Switch_Toolbox.Library.Forms.STLabel stLabel4;
private Switch_Toolbox.Library.Forms.STLabel stLabel3;
private Switch_Toolbox.Library.Forms.STLabel stLabel2;
private Switch_Toolbox.Library.Forms.STComboBox boneListCB;
private Switch_Toolbox.Library.Forms.STButton stButton1;
private Switch_Toolbox.Library.Forms.STNumbericUpDown scaleZUD;
}
}

View file

@ -0,0 +1,44 @@
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 Switch_Toolbox.Library.Forms;
using Switch_Toolbox.Library.Animations;
namespace FirstPlugin
{
public partial class BatchEditBaseAnimDataForm : STForm
{
public float ScaleX => (float)scaleXUD.Value;
public float ScaleY => (float)scaleXUD.Value;
public float ScaleZ => (float)scaleXUD.Value;
public string TargetBone => boneListCB.GetSelectedText();
public BatchEditBaseAnimDataForm()
{
InitializeComponent();
}
public bool HasCustomScale
{
get
{
return ScaleX != 1 || ScaleY != 1 || ScaleZ != 1;
}
}
public void LoadAnim(Animation anim)
{
foreach (var bone in anim.Bones)
boneListCB.Items.Add(bone.Text);
boneListCB.SelectedIndex = 0;
}
}
}

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>

View file

@ -257,6 +257,12 @@
<Compile Include="FileFormats\Rom\GCDisk.cs" />
<Compile Include="GL\BMD_Renderer.cs" />
<Compile Include="GL\GXToOpenGL.cs" />
<Compile Include="GUI\BFRES\BatchEditBaseAnimDataForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\BFRES\BatchEditBaseAnimDataForm.Designer.cs">
<DependentUpon>BatchEditBaseAnimDataForm.cs</DependentUpon>
</Compile>
<Compile Include="GUI\BMD\BMDModelImportSettings.cs">
<SubType>Form</SubType>
</Compile>
@ -969,6 +975,9 @@
<EmbeddedResource Include="GUI\BCRES\Material\SamplerEditorSimple.resx">
<DependentUpon>SamplerEditorSimple.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\BatchEditBaseAnimDataForm.resx">
<DependentUpon>BatchEditBaseAnimDataForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\BFRES\BfresEditor.resx">
<DependentUpon>BfresEditor.cs</DependentUpon>
</EmbeddedResource>

View file

@ -333,3 +333,4 @@ C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Rele
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.Forms.ParamPatternMaterialEditor.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.SmoothNormalsMultiMeshForm.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.BMDModelImportSettings.resources
C:\Users\Nathan\Documents\GitHub\SwitchToolboxV1\Switch_FileFormatsMain\obj\Release\FirstPlugin.BatchEditBaseAnimDataForm.resources

Binary file not shown.

Binary file not shown.