Fixed issue #210

This will fix the issue described in #210.

Co-Authored-By: VNC <52937757+VNNCC@users.noreply.github.com>
This commit is contained in:
W2.Wizard
2021-02-05 15:49:01 +01:00
co-authored by VNC
parent 3661b19d6c
commit 0e57b32082
2 changed files with 14 additions and 30 deletions
@@ -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;
}
}
+10 -28
View File
@@ -396,7 +396,7 @@ namespace FlaxEditor.Windows
/// <param name="item">The item to delete.</param>
public void Delete(ContentItem item)
{
Delete(new List<ContentItem> { item });
Delete(new List<ContentItem>(1) { item });
}
/// <summary>
@@ -405,42 +405,24 @@ namespace FlaxEditor.Windows
/// <param name="items">The items to delete.</param>
public void Delete(List<ContentItem> 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<ContentItem>(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]);