diff --git a/File_Format_Library/GUI/ViewportEditor.cs b/File_Format_Library/GUI/ViewportEditor.cs index 1f138966..bcede68e 100644 --- a/File_Format_Library/GUI/ViewportEditor.cs +++ b/File_Format_Library/GUI/ViewportEditor.cs @@ -158,8 +158,8 @@ namespace FirstPlugin.Forms OnLoadedTab(); } - public override void OnControlClosing() - { + public override void OnControlClosing() { + animationPanel.ClosePanel(); } private void OnLoadedTab() diff --git a/File_Format_Library/Resources/Hashes/Pkmn.txt b/File_Format_Library/Resources/Hashes/Pkmn.txt index 30078f50..447facf5 100644 --- a/File_Format_Library/Resources/Hashes/Pkmn.txt +++ b/File_Format_Library/Resources/Hashes/Pkmn.txt @@ -9,6 +9,7 @@ bin/pokemon/pm0000_00/anm/pm0000_00_battle01.gfbanmcfg bin/pokemon/pm0000_00/anm/pm0000_00_capture01.gfbanmcfg bin/pokemon/pm0000_00/anm/pm0000_00_camp.gfbanmcfg bin/pokemon/pm0000_00/anm/pm0000_00_app01.gfbanmcfg +bin/pokemon/pm0000_00/anm/pm0000_00_ba01_land01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_ba01_landA01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_ba01_landB01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_ba01_landC01.gfbanm @@ -31,7 +32,12 @@ bin/pokemon/pm0000_00/anm/pm0000_00_fi31_run_wait01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_fi31_wait_run01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_mouth01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_gloop01.gfbanm +bin/pokemon/pm0000_00/anm/pm0000_00_loop01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_eye01.gfbanm +bin/pokemon/pm0000_00/anm/pm0000_00_eye01.gfbanm +bin/pokemon/pm0000_00/anm/pm0000_00_cm10_bawait_kwwait01.gfbanm +bin/pokemon/pm0000_00/anm/pm0000_00_cm10_kwwait_bawait01.gfbanm +bin/pokemon/pm0000_00/anm/pm0000_00_kw01_wait01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_kw10_respond01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_kw11_turnA01.gfbanm bin/pokemon/pm0000_00/anm/pm0000_00_kw11_turnB01.gfbanm diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs index 3979521c..eadf688a 100644 --- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs +++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs @@ -64,7 +64,13 @@ namespace Toolbox.Library.Forms { if (FileRoot.FileNodes[i].Item2 is ArchiveFileWrapper) { - ((ArchiveFileWrapper)FileRoot.FileNodes[i].Item2).OpenFileFormat(treeViewCustom1); + try { + ((ArchiveFileWrapper)FileRoot.FileNodes[i].Item2).OpenFileFormat(treeViewCustom1); + } + catch + { + + } } } } @@ -310,27 +316,32 @@ namespace Toolbox.Library.Forms private void GetArchiveMenus(TreeNode node, ArchiveFileInfo info) { + STToolStipMenuItem menuItem = new STToolStipMenuItem("Archive"); + treeNodeContextMenu.Items.Add(menuItem); + var items = info.FileWrapper.GetContextMenuItems(); + foreach (var item in items) + menuItem.DropDownItems.Add(item); } private void treeViewCustom1_MouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == MouseButtons.Right) { + treeNodeContextMenu.Items.Clear(); + if (e.Node.Tag != null && e.Node.Tag is ArchiveFileInfo) + { + //The tag gets set when an archive is replaced by a treenode + //Todo store this in a better place as devs could possiblly replace this + //Create menus when an archive node is replaced + GetArchiveMenus(e.Node, (ArchiveFileInfo)e.Node.Tag); + } + if (e.Node is IContextMenuNode) { bool IsRoot = e.Node.Parent == null; bool HasChildren = e.Node.Nodes.Count > 0; - treeNodeContextMenu.Items.Clear(); - if (e.Node.Tag != null && e.Node.Tag is ArchiveFileInfo) - { - //The tag gets set when an archive is replaced by a treenode - //Todo store this in a better place as devs could possiblly replace this - //Create menus when an archive node is replaced - GetArchiveMenus(e.Node, (ArchiveFileInfo)e.Node.Tag); - } - if (IsRoot) { foreach (var item in ((IContextMenuNode)e.Node).GetContextMenuItems()) @@ -361,14 +372,15 @@ namespace Toolbox.Library.Forms if (!HasExpand && HasChildren) treeNodeContextMenu.Items.Add(new ToolStripMenuItem("Expand All", null, ExpandAllAction, Keys.Control | Keys.P)); - treeNodeContextMenu.Show(Cursor.Position); - //Select the node without the evemt //We don't want editors displaying on only right clicking SuppressAfterSelectEvent = true; treeViewCustom1.SelectedNode = e.Node; SuppressAfterSelectEvent = false; } + + if (treeNodeContextMenu.Items.Count > 0) + treeNodeContextMenu.Show(Cursor.Position); } else { @@ -493,6 +505,19 @@ namespace Toolbox.Library.Forms LibraryGUI.GetAnimationPanel().CurrentAnimation = running; } } + if (Node is IAnimationContainer) + { + Viewport viewport = LibraryGUI.GetActiveViewport(); + if (viewport == null) + return; + + var running = ((IAnimationContainer)Node).AnimationController; + if (LibraryGUI.GetAnimationPanel() != null) { + Console.WriteLine($"running {Node.Tag}"); + + LibraryGUI.GetAnimationPanel().CurrentSTAnimation = running; + } + } } public void RemoveFile(TreeNode File) diff --git a/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs b/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs index 7ffb4e5b..9eb703fa 100644 --- a/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs +++ b/Switch_Toolbox_Library/Interfaces/FileFormatting/IArchiveFile.cs @@ -126,7 +126,7 @@ namespace Toolbox.Library [Browsable(false)] public virtual Dictionary ExtensionImageKeyLookup { get; } - public virtual void Replace() + public virtual bool Replace() { string fileName = Path.GetFileName(FileName.RemoveIllegaleFileNameCharacters()); @@ -138,7 +138,9 @@ namespace Toolbox.Library if (ofd.ShowDialog() == DialogResult.OK) { FileData = File.ReadAllBytes(ofd.FileName); + return true; } + return false; } public virtual void Export() @@ -675,7 +677,7 @@ namespace Toolbox.Library { new STToolStripItem("Rename", RenameAction) { Enabled = ArchiveFile.CanRenameFiles }, new STToolStripItem("Extract Folder", ExtractAction), - new STToolStripItem("Replace Folder", ReplaceAction) { Enabled = ArchiveFile.CanReplaceFiles }, + new STToolStripItem("Replace Folder", ReplaceAction) { Enabled = ArchiveFile.CanReplaceFiles && ArchiveFile.CanAddFiles }, new STToolStripItem("Delete Folder", DeleteAction) { Enabled = ArchiveFile.CanDeleteFiles }, new STToolStripSeparator(), new STToolStripItem("Add Folder", AddFolderAction) { Enabled = ArchiveFile.CanAddFiles }, @@ -798,6 +800,7 @@ namespace Toolbox.Library { Extension = FindMatch(archiveFileInfo.FileData); } + switch (Extension) { @@ -807,6 +810,7 @@ namespace Toolbox.Library case ".aamp": SetImageKey("aamp"); break; case ".bfres": SetImageKey("bfres"); break; case ".sbfres": SetImageKey("sbfres"); break; + case ".gfbmdl": SetImageKey("model"); break; case ".dds": case ".tga": case ".jpg": @@ -932,15 +936,54 @@ namespace Toolbox.Library DialogResult result = MessageBox.Show($"Are your sure you want to remove {Text}? This cannot be undone!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { - ArchiveFile.DeleteFile(ArchiveFileInfo); - Parent.Nodes.Remove(this); + bool isRemoved = ArchiveFile.DeleteFile(ArchiveFileInfo); + if (!isRemoved) return; + + if (Parent != null) + Parent.Nodes.Remove(this); + else if (ArchiveFileInfo.FileFormat != null && + ArchiveFileInfo.FileFormat is TreeNode) + { + var prevNode = (TreeNode)ArchiveFileInfo.FileFormat; + var parent = prevNode.Parent; + + var index = parent.Nodes.IndexOf(prevNode); + parent.Nodes.RemoveAt(index); + } } } private void ReplaceAction(object sender, EventArgs args) { - ArchiveFileInfo.Replace(); - ArchiveFileInfo.FileFormat = null; + if (!ArchiveFile.CanReplaceFiles) return; + + bool IsReplaced = ArchiveFileInfo.Replace(); + if (!IsReplaced) return; + + if (ArchiveFileInfo.FileFormat != null) + { + if (ArchiveFileInfo.FileFormat is IArchiveFile) + { + + } + if (ArchiveFileInfo.FileFormat is TreeNode) + { + var prevNode = (TreeNode)ArchiveFileInfo.FileFormat; + var parent = prevNode.Parent; + + var index = parent.Nodes.IndexOf(prevNode); + parent.Nodes.RemoveAt(index); + parent.Nodes.Insert(index, this); + } + + ArchiveFileInfo.FileFormat.Unload(); + ArchiveFileInfo.FileFormat = null; + Nodes.Clear(); + + ArchiveFileInfo.OpenFile(); + OpenFileFormat(TreeView); + } + UpdateEditor(); }