From 0e57b32082846e52c81bc72047d22c85b9606d34 Mon Sep 17 00:00:00 2001 From: "W2.Wizard" Date: Fri, 5 Feb 2021 15:49:01 +0100 Subject: [PATCH 1/2] Fixed issue #210 This will fix the issue described in #210. Co-Authored-By: VNC <52937757+VNNCC@users.noreply.github.com> --- Source/Editor/Content/Tree/ContentTreeNode.cs | 6 ++- Source/Editor/Windows/ContentWindow.cs | 38 +++++-------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/Source/Editor/Content/Tree/ContentTreeNode.cs b/Source/Editor/Content/Tree/ContentTreeNode.cs index 7df407e08..07ce7f803 100644 --- a/Source/Editor/Content/Tree/ContentTreeNode.cs +++ b/Source/Editor/Content/Tree/ContentTreeNode.cs @@ -295,7 +295,8 @@ namespace FlaxEditor.Content StartRenaming(); return true; case KeyboardKeys.Delete: - Editor.Instance.Windows.ContentWin.Delete(Folder); + if(Folder.Exists) + Editor.Instance.Windows.ContentWin.Delete(Folder); return true; } if (RootWindow.GetKey(KeyboardKeys.Control)) @@ -303,7 +304,8 @@ namespace FlaxEditor.Content switch (key) { case KeyboardKeys.D: - Editor.Instance.Windows.ContentWin.Duplicate(Folder); + if(Folder.Exists) + Editor.Instance.Windows.ContentWin.Duplicate(Folder); return true; } } diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index 66ed50daf..a09bc1c6e 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -396,7 +396,7 @@ namespace FlaxEditor.Windows /// The item to delete. public void Delete(ContentItem item) { - Delete(new List { item }); + Delete(new List(1) { item }); } /// @@ -405,42 +405,24 @@ namespace FlaxEditor.Windows /// The items to delete. public void Delete(List items) { + if (items.Count == 0) return; + // TODO: remove items that depend on different items in the list: use wants to remove `folderA` and `folderA/asset.x`, we should just remove `folderA` var toDelete = new List(items); + string msg = toDelete.Count == 1 ? + string.Format("Are you sure to delete \'{0}\'?\nThis action cannot be undone. Files will be deleted permanently.", items[0].Path) + : string.Format("Are you sure to delete {0} selected items?\nThis action cannot be undone. Files will be deleted permanently.", items.Count); + // Ask user - if (toDelete.Count == 1) - { - // Single item - if (MessageBox.Show(string.Format("Are you sure to delete \'{0}\'?\nThis action cannot be undone. Files will be deleted permanently.", items[0].Path), - "Delete asset(s)", - MessageBoxButtons.OKCancel, - MessageBoxIcon.Question) - != DialogResult.OK) - { - // Break - return; - } - } - else - { - // Many items - if (MessageBox.Show(string.Format("Are you sure to delete {0} selected items?\nThis action cannot be undone. Files will be deleted permanently.", items.Count), - "Delete asset(s)", - MessageBoxButtons.OKCancel, - MessageBoxIcon.Question) - != DialogResult.OK) - { - // Break - return; - } - } + if (MessageBox.Show(msg, "Delete asset(s)", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) + return; // Clear navigation // TODO: just remove invalid locations from the history (those are removed) NavigationClearHistory(); - // Delete items + // Delete for (int i = 0; i < toDelete.Count; i++) Editor.ContentDatabase.Delete(toDelete[i]); From 2fbfe61f2c230884fed0c1042152e08b6caf0a53 Mon Sep 17 00:00:00 2001 From: "W2.Wizard" Date: Fri, 5 Feb 2021 15:59:35 +0100 Subject: [PATCH 2/2] Restore comment Co-Authored-By: VNC <52937757+VNNCC@users.noreply.github.com> --- Source/Editor/Windows/ContentWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Windows/ContentWindow.cs b/Source/Editor/Windows/ContentWindow.cs index a09bc1c6e..145c0d972 100644 --- a/Source/Editor/Windows/ContentWindow.cs +++ b/Source/Editor/Windows/ContentWindow.cs @@ -422,7 +422,7 @@ namespace FlaxEditor.Windows // TODO: just remove invalid locations from the history (those are removed) NavigationClearHistory(); - // Delete + // Delete items for (int i = 0; i < toDelete.Count; i++) Editor.ContentDatabase.Delete(toDelete[i]);