2018-11-22 20:54:52 +00:00
using System ;
using System.Windows.Forms ;
using Switch_Toolbox.Library ;
using FirstPlugin ;
2018-11-22 22:06:22 +00:00
using Syroot.NintenTools.NSW.Bfres ;
2018-11-22 20:54:52 +00:00
namespace Bfres.Structs
{
2018-11-22 22:06:22 +00:00
public class FmaaFolder : TreeNodeCustom
2018-11-22 20:54:52 +00:00
{
2018-11-22 22:06:22 +00:00
public FmaaFolder ( )
2018-11-22 20:54:52 +00:00
{
Text = "Material Animations" ;
Name = "FMAA" ;
2018-11-22 21:17:03 +00:00
ContextMenu = new ContextMenu ( ) ;
MenuItem import = new MenuItem ( "Import" ) ;
ContextMenu . MenuItems . Add ( import ) ;
import . Click + = Import ;
MenuItem exportAll = new MenuItem ( "Export All" ) ;
ContextMenu . MenuItems . Add ( exportAll ) ;
exportAll . Click + = ExportAll ;
MenuItem clear = new MenuItem ( "Clear" ) ;
ContextMenu . MenuItems . Add ( clear ) ;
clear . Click + = Clear ;
}
public void Import ( object sender , EventArgs args )
{
}
public void ExportAll ( object sender , EventArgs args )
{
2018-11-22 22:06:22 +00:00
FolderSelectDialog sfd = new FolderSelectDialog ( ) ;
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
string folderPath = sfd . SelectedPath ;
foreach ( FMAA fmaa in Nodes )
{
string FileName = folderPath + '\\' + fmaa . Text + ".bfmaa" ;
2018-11-23 00:40:36 +00:00
( ( FMAA ) fmaa ) . MaterialAnim . Export ( FileName , fmaa . GetResFile ( ) ) ;
2018-11-22 22:06:22 +00:00
}
}
2018-11-22 21:17:03 +00:00
}
private void Clear ( object sender , EventArgs args )
{
2018-11-22 22:06:22 +00:00
DialogResult dialogResult = MessageBox . Show ( "Are you sure you want to remove all material animations? This cannot be undone!" , "" , MessageBoxButtons . YesNo ) ;
2018-11-22 21:17:03 +00:00
if ( dialogResult = = DialogResult . Yes )
{
Nodes . Clear ( ) ;
}
2018-11-22 20:54:52 +00:00
}
public override void OnClick ( TreeView treeView )
{
FormLoader . LoadEditor ( this , Text ) ;
}
}
2018-11-22 22:06:22 +00:00
public class FMAA : TreeNodeCustom
2018-11-22 20:54:52 +00:00
{
2018-11-22 22:06:22 +00:00
public BFRESRender BFRESRender ;
public MaterialAnim MaterialAnim ;
2018-11-23 20:39:16 +00:00
public FMAA ( )
{
ImageKey = "materialAnim" ;
SelectedImageKey = "materialAnim" ;
ContextMenu = new ContextMenu ( ) ;
MenuItem export = new MenuItem ( "Export" ) ;
ContextMenu . MenuItems . Add ( export ) ;
export . Click + = Export ;
MenuItem replace = new MenuItem ( "Replace" ) ;
ContextMenu . MenuItems . Add ( replace ) ;
replace . Click + = Replace ;
}
2018-11-22 20:54:52 +00:00
2018-11-23 00:40:36 +00:00
public ResFile GetResFile ( )
{
2018-12-02 22:30:46 +00:00
return ( ( BFRES ) Parent . Parent ) . resFile ;
2018-11-23 00:40:36 +00:00
}
2018-11-22 22:06:22 +00:00
public void Read ( MaterialAnim anim )
{
MaterialAnim = anim ;
}
2018-11-23 20:39:16 +00:00
private void Export ( object sender , EventArgs args )
{
SaveFileDialog sfd = new SaveFileDialog ( ) ;
sfd . Filter = "Supported Formats|*.bfmaa;" ;
sfd . FileName = Text ;
sfd . DefaultExt = ".bfska" ;
if ( sfd . ShowDialog ( ) = = DialogResult . OK )
{
MaterialAnim . Export ( sfd . FileName , GetResFile ( ) ) ;
}
}
private void Replace ( object sender , EventArgs args )
{
OpenFileDialog ofd = new OpenFileDialog ( ) ;
ofd . Filter = "Supported Formats|*.bfmaa;" ;
if ( ofd . ShowDialog ( ) = = DialogResult . OK )
{
MaterialAnim . Import ( ofd . FileName ) ;
}
MaterialAnim . Name = Text ;
}
2018-11-22 20:54:52 +00:00
}
}