Doube click for sarc files. Minor fixes

This commit is contained in:
KillzXGaming 2018-11-22 17:06:22 -05:00
parent e8e5c39b8f
commit 898003ddb2
9 changed files with 147 additions and 77 deletions

View file

@ -33,13 +33,11 @@ namespace Bfres.Structs
} }
private void Clear(object sender, EventArgs args) private void Clear(object sender, EventArgs args)
{ {
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all objects? This cannot be undone!", "", MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all external files? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
Nodes.Clear(); Nodes.Clear();
((ResourceFile)Parent).BFRESRender.models.Clear();
((ResourceFile)Parent).BFRESRender.UpdateVertexData();
} }
} }
public override void OnClick(TreeView treeView) public override void OnClick(TreeView treeView)

View file

@ -34,7 +34,7 @@ namespace Bfres.Structs
} }
public void Clear(object sender, EventArgs args) public void Clear(object sender, EventArgs args)
{ {
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all objects? This cannot be undone!", "", MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all visibility animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {

View file

@ -2,12 +2,13 @@
using System.Windows.Forms; using System.Windows.Forms;
using Switch_Toolbox.Library; using Switch_Toolbox.Library;
using FirstPlugin; using FirstPlugin;
using Syroot.NintenTools.NSW.Bfres;
namespace Bfres.Structs namespace Bfres.Structs
{ {
public class FmmaFolder : TreeNodeCustom public class FmaaFolder : TreeNodeCustom
{ {
public FmmaFolder() public FmaaFolder()
{ {
Text = "Material Animations"; Text = "Material Animations";
Name = "FMAA"; Name = "FMAA";
@ -29,12 +30,22 @@ namespace Bfres.Structs
} }
public void ExportAll(object sender, EventArgs args) public void ExportAll(object sender, EventArgs args)
{ {
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
foreach (FMAA fmaa in Nodes)
{
string FileName = folderPath + '\\' + fmaa.Text + ".bfmaa";
((FMAA)fmaa).MaterialAnim.Export(FileName, fmaa.BFRESRender.resFile);
}
}
} }
private void Clear(object sender, EventArgs args) private void Clear(object sender, EventArgs args)
{ {
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all objects? This cannot be undone!", "", MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all material animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
Nodes.Clear(); Nodes.Clear();
@ -46,8 +57,14 @@ namespace Bfres.Structs
} }
} }
public class FMAA public class FMAA : TreeNodeCustom
{ {
public BFRESRender BFRESRender;
public MaterialAnim MaterialAnim;
public void Read(MaterialAnim anim)
{
MaterialAnim = anim;
}
} }
} }

View file

@ -2,6 +2,7 @@
using System.Windows.Forms; using System.Windows.Forms;
using Switch_Toolbox.Library; using Switch_Toolbox.Library;
using FirstPlugin; using FirstPlugin;
using Syroot.NintenTools.NSW.Bfres;
namespace Bfres.Structs namespace Bfres.Structs
{ {
@ -33,13 +34,23 @@ namespace Bfres.Structs
} }
private void Clear(object sender, EventArgs args) private void Clear(object sender, EventArgs args)
{ {
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all objects? This cannot be undone!", "", MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all scene animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
Nodes.Clear(); Nodes.Clear();
} }
} }
public void LoadAnimations(ResFile resFile, BFRESRender BFRESRender)
{
foreach (var scn in resFile.SceneAnims)
{
FSCN sceneAnim = new FSCN();
sceneAnim.Text = scn.Name;
sceneAnim.BFRESRender = BFRESRender;
sceneAnim.Read(scn);
Nodes.Add(sceneAnim);
}
}
public override void OnClick(TreeView treeView) public override void OnClick(TreeView treeView)
{ {
@ -47,8 +58,51 @@ namespace Bfres.Structs
} }
} }
public class FSCN public class FSCN : TreeNodeCustom
{ {
public SceneAnim SceneAnim;
public BFRESRender BFRESRender;
public FSCN()
{
ImageKey = "skeletonAnimation";
SelectedImageKey = "skeletonAnimation";
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;
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfska;";
sfd.FileName = Text;
sfd.DefaultExt = ".bfska";
if (sfd.ShowDialog() == DialogResult.OK)
{
SceneAnim.Export(sfd.FileName, BFRESRender.resFile);
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfska;";
if (ofd.ShowDialog() == DialogResult.OK)
{
SceneAnim.Import(ofd.FileName);
}
SceneAnim.Name = Text;
}
public void Read(SceneAnim scn)
{
SceneAnim = scn;
}
} }
} }

View file

@ -37,40 +37,12 @@ namespace Bfres.Structs
} }
private void Clear(object sender, EventArgs args) private void Clear(object sender, EventArgs args)
{ {
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all objects? This cannot be undone!", "", MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all skeletal animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
Nodes.Clear(); Nodes.Clear();
((ResourceFile)Parent).BFRESRender.models.Clear();
((ResourceFile)Parent).BFRESRender.UpdateVertexData();
} }
} }
public void LoadAnimations(ResU.ResFile resFile, BFRESRender BFRESRender)
{
foreach (var ska in resFile.SkeletalAnims.Values)
{
BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name);
skeletonAnim.BFRESRender = BFRESRender;
skeletonAnim.Read(ska, resFile);
Nodes.Add(skeletonAnim);
}
}
public void LoadAnimations(ResFile resFile, BFRESRender BFRESRender)
{
foreach (SkeletalAnim ska in resFile.SkeletalAnims)
{
BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name);
skeletonAnim.BFRESRender = BFRESRender;
skeletonAnim.Read(ska, resFile);
Nodes.Add(skeletonAnim);
}
}
/* public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}*/
} }
public class BfresSkeletonAnim : Animation public class BfresSkeletonAnim : Animation
@ -121,9 +93,7 @@ namespace Bfres.Structs
private void Export(object sender, EventArgs args) private void Export(object sender, EventArgs args)
{ {
SaveFileDialog sfd = new SaveFileDialog(); SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfska;|" + sfd.Filter = "Supported Formats|*.bfska;";
"Bfres Object (shape/vertices) |*.bfska|" +
"All files(*.*)|*.*";
sfd.FileName = Text; sfd.FileName = Text;
sfd.DefaultExt = ".bfska"; sfd.DefaultExt = ".bfska";
@ -135,9 +105,7 @@ namespace Bfres.Structs
private void Replace(object sender, EventArgs args) private void Replace(object sender, EventArgs args)
{ {
OpenFileDialog ofd = new OpenFileDialog(); OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfska;|" + ofd.Filter = "Supported Formats|*.bfska;";
"Bfres Object (shape/vertices) |*.bfska|" +
"All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)
{ {
@ -147,7 +115,6 @@ namespace Bfres.Structs
} }
public static List<Animation> SkeletonAnimations = new List<Animation>(); public static List<Animation> SkeletonAnimations = new List<Animation>();
public void Read(ResU.SkeletalAnim ska, ResU.ResFile b) public void Read(ResU.SkeletalAnim ska, ResU.ResFile b)
{ {

View file

@ -177,14 +177,10 @@ namespace Bfres.Structs
Text = resFile.Name; Text = resFile.Name;
UpdateTree(resFile); UpdateTree(resFile);
foreach (MaterialAnim anim in resFile.MaterialAnims)
Nodes["FMAA"].Nodes.Add(anim.Name);
foreach (ShapeAnim anim in resFile.ShapeAnims) foreach (ShapeAnim anim in resFile.ShapeAnims)
Nodes["FSHPA"].Nodes.Add(anim.Name); Nodes["FSHPA"].Nodes.Add(anim.Name);
foreach (VisibilityAnim anim in resFile.BoneVisibilityAnims) foreach (VisibilityAnim anim in resFile.BoneVisibilityAnims)
Nodes["FBNV"].Nodes.Add(anim.Name); Nodes["FBNV"].Nodes.Add(anim.Name);
foreach (SceneAnim anim in resFile.SceneAnims)
Nodes["FSCN"].Nodes.Add(anim.Name);
int ext = 0; int ext = 0;
foreach (ExternalFile extfile in resFile.ExternalFiles) foreach (ExternalFile extfile in resFile.ExternalFiles)
@ -261,19 +257,20 @@ namespace Bfres.Structs
if (resFile.SkeletalAnims.Count > 0) if (resFile.SkeletalAnims.Count > 0)
AddSkeletonAnims(resFile); AddSkeletonAnims(resFile);
if (resFile.MaterialAnims.Count > 0) if (resFile.MaterialAnims.Count > 0)
Nodes.Add(new FmmaFolder()); AddMaterialAnims(resFile);
if (resFile.ShapeAnims.Count > 0) if (resFile.ShapeAnims.Count > 0)
Nodes.Add(new FshpaFolder()); Nodes.Add(new FshpaFolder());
if (resFile.BoneVisibilityAnims.Count > 0) if (resFile.BoneVisibilityAnims.Count > 0)
Nodes.Add(new FbnvFolder()); Nodes.Add(new FbnvFolder());
if (resFile.SceneAnims.Count > 0) if (resFile.SceneAnims.Count > 0)
Nodes.Add(new FscnFolder()); AddSceneAnims(resFile);
if (resFile.ExternalFiles.Count > 0) if (resFile.ExternalFiles.Count > 0)
Nodes.Add(new EmbeddedFilesFolder()); Nodes.Add(new EmbeddedFilesFolder());
} }
private void AddFTEXTextures(ResU.ResFile resFile) private void AddFTEXTextures(ResU.ResFile resFile)
{ {
FTEXContainer ftexContainer = new FTEXContainer(); FTEXContainer ftexContainer = new FTEXContainer();
Nodes.Add(ftexContainer);
foreach (ResU.Texture tex in resFile.Textures.Values) foreach (ResU.Texture tex in resFile.Textures.Values)
{ {
string TextureName = tex.Name; string TextureName = tex.Name;
@ -283,19 +280,61 @@ namespace Bfres.Structs
ftexContainer.Textures.Add(texture.Text, texture); ftexContainer.Textures.Add(texture.Text, texture);
} }
PluginRuntime.ftexContainers.Add(ftexContainer); PluginRuntime.ftexContainers.Add(ftexContainer);
Nodes.Add(ftexContainer);
} }
private void AddSkeletonAnims(ResU.ResFile resFile) private void AddSkeletonAnims(ResU.ResFile resFile)
{ {
FskaFolder FSKA = new FskaFolder(); FskaFolder fksaFolder = new FskaFolder();
FSKA.LoadAnimations(resFile, BFRESRender); Nodes.Add(fksaFolder);
Nodes.Add(FSKA); foreach (ResU.SkeletalAnim ska in resFile.SkeletalAnims.Values)
{
BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name);
skeletonAnim.BFRESRender = BFRESRender;
skeletonAnim.Read(ska, resFile);
fksaFolder.Nodes.Add(skeletonAnim);
}
} }
private void AddSkeletonAnims(ResFile resFile) private void AddSkeletonAnims(ResFile resFile)
{ {
FskaFolder FSKA = new FskaFolder(); FskaFolder fksaFolder = new FskaFolder();
FSKA.LoadAnimations(resFile, BFRESRender); Nodes.Add(fksaFolder);
Nodes.Add(FSKA); foreach (SkeletalAnim ska in resFile.SkeletalAnims)
{
BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name);
skeletonAnim.BFRESRender = BFRESRender;
skeletonAnim.Read(ska, resFile);
fksaFolder.Nodes.Add(skeletonAnim);
}
}
private void AddSceneAnims(ResU.ResFile resFile)
{
FscnFolder FSCN = new FscnFolder();
Nodes.Add(FSCN);
}
private void AddSceneAnims(ResFile resFile)
{
FscnFolder fscnFolder = new FscnFolder();
Nodes.Add(fscnFolder);
foreach (var scn in resFile.SceneAnims)
{
FSCN sceneAnim = new FSCN();
sceneAnim.Text = scn.Name;
sceneAnim.BFRESRender = BFRESRender;
sceneAnim.Read(scn);
fscnFolder.Nodes.Add(sceneAnim);
}
}
private void AddMaterialAnims(ResFile resFile)
{
FmaaFolder fmaaFolder = new FmaaFolder();
Nodes.Add(fmaaFolder);
foreach (var fmaa in resFile.MaterialAnims)
{
FMAA materialAnim = new FMAA();
materialAnim.Text = fmaa.Name;
materialAnim.BFRESRender = BFRESRender;
materialAnim.Read(fmaa);
fmaaFolder.Nodes.Add(materialAnim);
}
} }
} }
} }

View file

@ -193,15 +193,6 @@ namespace FirstPlugin
MessageBox.Show($"File has been saved to {FileName}"); MessageBox.Show($"File has been saved to {FileName}");
Cursor.Current = Cursors.Default; Cursor.Current = Cursors.Default;
} }
public override void OnClick(TreeView treeview)
{
/* CallRecursive(treeview);
foreach (TreeNode n in Nodes)
{
n.ExpandAll();
}*/
}
private void CallRecursive(TreeView treeView) private void CallRecursive(TreeView treeView)
{ {
// Print each node recursively. // Print each node recursively.
@ -260,10 +251,7 @@ namespace FirstPlugin
ContextMenu.MenuItems.Add(rename); ContextMenu.MenuItems.Add(rename);
rename.Click += Rename; rename.Click += Rename;
} }
public override void OnClick(TreeView treeView) public override void OnDoubleMouseClick(TreeView treeView)
{
}
public override void OnMouseLeftClick(TreeView treeView)
{ {
ReplaceNode(this.Parent, this, OpenFile(Name, Data, this)); ReplaceNode(this.Parent, this, OpenFile(Name, Data, this));
} }

View file

@ -124,6 +124,7 @@
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.selectItem); this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.selectItem);
this.treeView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseClick); this.treeView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseClick);
this.treeView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseDoubleClick);
// //
// ObjectList // ObjectList
// //

View file

@ -153,13 +153,12 @@ namespace Switch_Toolbox.Library
if (treeView1.SelectedNode is STGenericObject) if (treeView1.SelectedNode is STGenericObject)
{ {
((STGenericObject)treeView1.SelectedNode).OnClick(treeView1); ((STGenericObject)treeView1.SelectedNode).OnClick(treeView1);
Viewport.Instance.Update();
} }
if (treeView1.SelectedNode is STGenericMaterial) if (treeView1.SelectedNode is STGenericMaterial)
{ {
((STGenericMaterial)treeView1.SelectedNode).OnClick(treeView1); ((STGenericMaterial)treeView1.SelectedNode).OnClick(treeView1);
} }
Viewport.Instance.UpdateViewport();
} }
private void ObjectList_DockStateChanged(object sender, EventArgs e) private void ObjectList_DockStateChanged(object sender, EventArgs e)
@ -169,7 +168,6 @@ namespace Switch_Toolbox.Library
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e) private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
{ {
Viewport.Instance.UpdateViewport();
} }
private void searchToolStripMenuItem_Click(object sender, EventArgs e) private void searchToolStripMenuItem_Click(object sender, EventArgs e)
@ -203,5 +201,13 @@ namespace Switch_Toolbox.Library
treeView1.SelectedNode = info.Node; treeView1.SelectedNode = info.Node;
} }
} }
private void treeView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (treeView1.SelectedNode is TreeNodeCustom)
{
((TreeNodeCustom)treeView1.SelectedNode).OnDoubleMouseClick(treeView1);
}
}
} }
} }