diff --git a/File_Format_Library/FileFormats/BFRES/BFRES.cs b/File_Format_Library/FileFormats/BFRES/BFRES.cs index 45cef923..efbe7053 100644 --- a/File_Format_Library/FileFormats/BFRES/BFRES.cs +++ b/File_Format_Library/FileFormats/BFRES/BFRES.cs @@ -975,8 +975,6 @@ namespace FirstPlugin public void LoadFile(ResU.ResFile res) { - CanDelete = true; - resFileU = res; Text = resFileU.Name; diff --git a/File_Format_Library/NodeWrappers/Archives/BFRESWrapper.cs b/File_Format_Library/NodeWrappers/Archives/BFRESWrapper.cs index 11d4d7d9..7159a296 100644 --- a/File_Format_Library/NodeWrappers/Archives/BFRESWrapper.cs +++ b/File_Format_Library/NodeWrappers/Archives/BFRESWrapper.cs @@ -38,16 +38,6 @@ namespace FirstPlugin.NodeWrappers return Items.ToArray(); } - public override void Delete() - { - var editor = LibraryGUI.GetObjectEditor(); - if (editor != null) - { - editor.RemoveFile(this); - editor.ResetControls(); - } - } - protected void SettingBooleanAction(object sender, EventArgs e) { if (sender is ToolStripMenuItem) diff --git a/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs b/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs index 91e63646..b482be6f 100644 --- a/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs +++ b/Switch_Toolbox_Library/Forms/Custom/TreeViewCustom.cs @@ -71,7 +71,6 @@ namespace Toolbox.Library var editor = LibraryGUI.GetObjectEditor(); if (editor != null) { - editor.RemoveFile(this); editor.ResetControls(); } } diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditor.cs b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditor.cs index 98507339..11650b97 100644 --- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditor.cs +++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditor.cs @@ -20,8 +20,6 @@ namespace Toolbox.Library.Forms private ObjectEditorTree ObjectTree; private ObjectEditorList ObjectList; //Optionally usable for archives - private TreeView _fieldsTreeCache; - public void BeginUpdate() { ObjectTree.BeginUpdate(); } public void EndUpdate() { ObjectTree.EndUpdate(); } @@ -178,21 +176,10 @@ namespace Toolbox.Library.Forms if (viewport != null) viewport.FormClosing(); - - if (ObjectTree != null) ObjectTree.FormClosing(); } - public void RemoveFile(TreeNode File) - { - if (File is IFileFormat) { - ((IFileFormat)File).Unload(); - } - - ObjectTree.RemoveFile(File); - } - public void ResetControls() { ObjectTree.ResetControls(); diff --git a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs index 33ef327a..050d51b6 100644 --- a/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs +++ b/Switch_Toolbox_Library/Forms/Editors/Object Editor/ObjectEditorTree.cs @@ -23,8 +23,6 @@ namespace Toolbox.Library.Forms public ObjectEditor ObjectEditor; - private List _fieldsTreeCache = new List(); - public void BeginUpdate() { treeViewCustom1.BeginUpdate(); } public void EndUpdate() { treeViewCustom1.EndUpdate(); } @@ -258,8 +256,22 @@ namespace Toolbox.Library.Forms { if (e.Node is IContextMenuNode) { + bool IsRoot = e.Node.Parent == null; + treeNodeContextMenu.Items.Clear(); - treeNodeContextMenu.Items.AddRange(((IContextMenuNode)e.Node).GetContextMenuItems()); + if (IsRoot) + { + foreach (var item in ((IContextMenuNode)e.Node).GetContextMenuItems()) + { + if (item.Text != "Delete" || item.Text != "Remove") + treeNodeContextMenu.Items.Add(item); + } + treeNodeContextMenu.Items.Add(new ToolStripMenuItem("Delete", null, DeleteAction, Keys.Control | Keys.Delete)); + } + else + { + treeNodeContextMenu.Items.AddRange(((IContextMenuNode)e.Node).GetContextMenuItems()); + } treeNodeContextMenu.Show(Cursor.Position); //Select the node without the evemt @@ -275,6 +287,34 @@ namespace Toolbox.Library.Forms } } + private void DeleteAction(object sender, EventArgs args) + { + var node = treeViewCustom1.SelectedNode; + if (node != null) + { + if (node is IFileFormat) + { + ((IFileFormat)node).Unload(); + } + + treeViewCustom1.Nodes.Remove(node); + ResetEditor(); + } + } + + private void ResetEditor() + { + foreach (Control control in stPanel2.Controls) + { + if (control is STUserControl) + ((STUserControl)control).OnControlClosing(); + + control.Dispose(); + } + + stPanel2.Controls.Clear(); + } + private void OnAnimationSelected(TreeNode Node) { if (Node is Animation) @@ -351,8 +391,9 @@ namespace Toolbox.Library.Forms public void ResetControls() { treeViewCustom1.Nodes.Clear(); - stPanel2.Controls.Clear(); Text = ""; + + ResetEditor(); } bool UpdateViewport = false; diff --git a/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs b/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs index eae15909..7b5ac997 100644 --- a/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs +++ b/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs @@ -449,6 +449,7 @@ namespace Toolbox.Library } } + //Method from https://github.com/aboood40091/BNTX-Editor/blob/master/formConv.py private static byte[] DecodeLA8(byte[] Input, int Width, int Height) { int bpp = 16; @@ -1073,18 +1074,6 @@ namespace Toolbox.Library return comp; } - public override void Delete() - { - DisposeRenderable(); - - var editor = LibraryGUI.GetObjectEditor(); - if (editor != null) - { - editor.RemoveFile(this); - editor.ResetControls(); - } - } - public Properties GenericProperties { get diff --git a/Switch_Toolbox_Library/Toolbox.Library.dll b/Switch_Toolbox_Library/Toolbox.Library.dll index 2ce327b9..f4734f23 100644 Binary files a/Switch_Toolbox_Library/Toolbox.Library.dll and b/Switch_Toolbox_Library/Toolbox.Library.dll differ diff --git a/Switch_Toolbox_Library/Toolbox.Library.pdb b/Switch_Toolbox_Library/Toolbox.Library.pdb index 4c653302..c9a016b0 100644 Binary files a/Switch_Toolbox_Library/Toolbox.Library.pdb and b/Switch_Toolbox_Library/Toolbox.Library.pdb differ