mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-25 22:10:22 +00:00
Doube click for sarc files. Minor fixes
This commit is contained in:
parent
e8e5c39b8f
commit
898003ddb2
9 changed files with 147 additions and 77 deletions
|
@ -33,13 +33,11 @@ namespace Bfres.Structs
|
|||
}
|
||||
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)
|
||||
{
|
||||
Nodes.Clear();
|
||||
((ResourceFile)Parent).BFRESRender.models.Clear();
|
||||
((ResourceFile)Parent).BFRESRender.UpdateVertexData();
|
||||
}
|
||||
}
|
||||
public override void OnClick(TreeView treeView)
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Bfres.Structs
|
|||
}
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library;
|
||||
using FirstPlugin;
|
||||
using Syroot.NintenTools.NSW.Bfres;
|
||||
|
||||
namespace Bfres.Structs
|
||||
{
|
||||
public class FmmaFolder : TreeNodeCustom
|
||||
public class FmaaFolder : TreeNodeCustom
|
||||
{
|
||||
public FmmaFolder()
|
||||
public FmaaFolder()
|
||||
{
|
||||
Text = "Material Animations";
|
||||
Name = "FMAA";
|
||||
|
@ -29,12 +30,22 @@ namespace Bfres.Structs
|
|||
}
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library;
|
||||
using FirstPlugin;
|
||||
using Syroot.NintenTools.NSW.Bfres;
|
||||
|
||||
namespace Bfres.Structs
|
||||
{
|
||||
|
@ -33,13 +34,23 @@ namespace Bfres.Structs
|
|||
}
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,40 +37,12 @@ namespace Bfres.Structs
|
|||
}
|
||||
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)
|
||||
{
|
||||
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
|
||||
|
@ -121,9 +93,7 @@ namespace Bfres.Structs
|
|||
private void Export(object sender, EventArgs args)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "Supported Formats|*.bfska;|" +
|
||||
"Bfres Object (shape/vertices) |*.bfska|" +
|
||||
"All files(*.*)|*.*";
|
||||
sfd.Filter = "Supported Formats|*.bfska;";
|
||||
sfd.FileName = Text;
|
||||
sfd.DefaultExt = ".bfska";
|
||||
|
||||
|
@ -135,9 +105,7 @@ namespace Bfres.Structs
|
|||
private void Replace(object sender, EventArgs args)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Supported Formats|*.bfska;|" +
|
||||
"Bfres Object (shape/vertices) |*.bfska|" +
|
||||
"All files(*.*)|*.*";
|
||||
ofd.Filter = "Supported Formats|*.bfska;";
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
@ -147,7 +115,6 @@ namespace Bfres.Structs
|
|||
}
|
||||
|
||||
public static List<Animation> SkeletonAnimations = new List<Animation>();
|
||||
|
||||
public void Read(ResU.SkeletalAnim ska, ResU.ResFile b)
|
||||
{
|
||||
|
||||
|
|
|
@ -177,14 +177,10 @@ namespace Bfres.Structs
|
|||
Text = resFile.Name;
|
||||
UpdateTree(resFile);
|
||||
|
||||
foreach (MaterialAnim anim in resFile.MaterialAnims)
|
||||
Nodes["FMAA"].Nodes.Add(anim.Name);
|
||||
foreach (ShapeAnim anim in resFile.ShapeAnims)
|
||||
Nodes["FSHPA"].Nodes.Add(anim.Name);
|
||||
foreach (VisibilityAnim anim in resFile.BoneVisibilityAnims)
|
||||
Nodes["FBNV"].Nodes.Add(anim.Name);
|
||||
foreach (SceneAnim anim in resFile.SceneAnims)
|
||||
Nodes["FSCN"].Nodes.Add(anim.Name);
|
||||
|
||||
int ext = 0;
|
||||
foreach (ExternalFile extfile in resFile.ExternalFiles)
|
||||
|
@ -261,19 +257,20 @@ namespace Bfres.Structs
|
|||
if (resFile.SkeletalAnims.Count > 0)
|
||||
AddSkeletonAnims(resFile);
|
||||
if (resFile.MaterialAnims.Count > 0)
|
||||
Nodes.Add(new FmmaFolder());
|
||||
AddMaterialAnims(resFile);
|
||||
if (resFile.ShapeAnims.Count > 0)
|
||||
Nodes.Add(new FshpaFolder());
|
||||
if (resFile.BoneVisibilityAnims.Count > 0)
|
||||
Nodes.Add(new FbnvFolder());
|
||||
if (resFile.SceneAnims.Count > 0)
|
||||
Nodes.Add(new FscnFolder());
|
||||
AddSceneAnims(resFile);
|
||||
if (resFile.ExternalFiles.Count > 0)
|
||||
Nodes.Add(new EmbeddedFilesFolder());
|
||||
}
|
||||
private void AddFTEXTextures(ResU.ResFile resFile)
|
||||
{
|
||||
FTEXContainer ftexContainer = new FTEXContainer();
|
||||
Nodes.Add(ftexContainer);
|
||||
foreach (ResU.Texture tex in resFile.Textures.Values)
|
||||
{
|
||||
string TextureName = tex.Name;
|
||||
|
@ -283,19 +280,61 @@ namespace Bfres.Structs
|
|||
ftexContainer.Textures.Add(texture.Text, texture);
|
||||
}
|
||||
PluginRuntime.ftexContainers.Add(ftexContainer);
|
||||
Nodes.Add(ftexContainer);
|
||||
}
|
||||
private void AddSkeletonAnims(ResU.ResFile resFile)
|
||||
{
|
||||
FskaFolder FSKA = new FskaFolder();
|
||||
FSKA.LoadAnimations(resFile, BFRESRender);
|
||||
Nodes.Add(FSKA);
|
||||
FskaFolder fksaFolder = new FskaFolder();
|
||||
Nodes.Add(fksaFolder);
|
||||
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)
|
||||
{
|
||||
FskaFolder FSKA = new FskaFolder();
|
||||
FSKA.LoadAnimations(resFile, BFRESRender);
|
||||
Nodes.Add(FSKA);
|
||||
FskaFolder fksaFolder = new FskaFolder();
|
||||
Nodes.Add(fksaFolder);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,15 +193,6 @@ namespace FirstPlugin
|
|||
MessageBox.Show($"File has been saved to {FileName}");
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
public override void OnClick(TreeView treeview)
|
||||
{
|
||||
/* CallRecursive(treeview);
|
||||
foreach (TreeNode n in Nodes)
|
||||
{
|
||||
n.ExpandAll();
|
||||
}*/
|
||||
}
|
||||
private void CallRecursive(TreeView treeView)
|
||||
{
|
||||
// Print each node recursively.
|
||||
|
@ -260,10 +251,7 @@ namespace FirstPlugin
|
|||
ContextMenu.MenuItems.Add(rename);
|
||||
rename.Click += Rename;
|
||||
}
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
}
|
||||
public override void OnMouseLeftClick(TreeView treeView)
|
||||
public override void OnDoubleMouseClick(TreeView treeView)
|
||||
{
|
||||
ReplaceNode(this.Parent, this, OpenFile(Name, Data, this));
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@
|
|||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.selectItem);
|
||||
this.treeView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseClick);
|
||||
this.treeView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseDoubleClick);
|
||||
//
|
||||
// ObjectList
|
||||
//
|
||||
|
|
|
@ -153,13 +153,12 @@ namespace Switch_Toolbox.Library
|
|||
if (treeView1.SelectedNode is STGenericObject)
|
||||
{
|
||||
((STGenericObject)treeView1.SelectedNode).OnClick(treeView1);
|
||||
Viewport.Instance.Update();
|
||||
}
|
||||
if (treeView1.SelectedNode is STGenericMaterial)
|
||||
{
|
||||
((STGenericMaterial)treeView1.SelectedNode).OnClick(treeView1);
|
||||
}
|
||||
|
||||
Viewport.Instance.UpdateViewport();
|
||||
}
|
||||
|
||||
private void ObjectList_DockStateChanged(object sender, EventArgs e)
|
||||
|
@ -169,7 +168,6 @@ namespace Switch_Toolbox.Library
|
|||
|
||||
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
Viewport.Instance.UpdateViewport();
|
||||
}
|
||||
|
||||
private void searchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -203,5 +201,13 @@ namespace Switch_Toolbox.Library
|
|||
treeView1.SelectedNode = info.Node;
|
||||
}
|
||||
}
|
||||
|
||||
private void treeView1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (treeView1.SelectedNode is TreeNodeCustom)
|
||||
{
|
||||
((TreeNodeCustom)treeView1.SelectedNode).OnDoubleMouseClick(treeView1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue