mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-26 06:20:24 +00:00
Improve file removing from object editor
This commit is contained in:
parent
25bc66e505
commit
2340d6a7a4
8 changed files with 46 additions and 42 deletions
|
@ -975,8 +975,6 @@ namespace FirstPlugin
|
|||
|
||||
public void LoadFile(ResU.ResFile res)
|
||||
{
|
||||
CanDelete = true;
|
||||
|
||||
resFileU = res;
|
||||
|
||||
Text = resFileU.Name;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -71,7 +71,6 @@ namespace Toolbox.Library
|
|||
var editor = LibraryGUI.GetObjectEditor();
|
||||
if (editor != null)
|
||||
{
|
||||
editor.RemoveFile(this);
|
||||
editor.ResetControls();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -23,8 +23,6 @@ namespace Toolbox.Library.Forms
|
|||
|
||||
public ObjectEditor ObjectEditor;
|
||||
|
||||
private List<TreeNode> _fieldsTreeCache = new List<TreeNode>();
|
||||
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue