1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Porting 3.0 filessytem_dock's context menu to 2.1

This commit is contained in:
sersoong
2017-11-19 11:21:36 +08:00
parent fa000c6327
commit 320ee1851f
5 changed files with 370 additions and 8 deletions

View File

@@ -409,16 +409,22 @@ void DependencyRemoveDialog::show(const Vector<String> &to_erase) {
}
void DependencyRemoveDialog::ok_pressed() {
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
for (Map<String, TreeItem *>::Element *E = files.front(); E; E = E->next()) {
if (ResourceCache::has(E->key())) {
Resource *res = ResourceCache::get(E->key());
res->set_path(""); //clear reference to path
if (da->dir_exists(E->key()))
{
String path = OS::get_singleton()->get_resource_dir() + E->key().replace_first("res://", "/");
OS::get_singleton()->move_path_to_trash(path);
EditorFileSystem::get_singleton()->scan();
} else {
if (ResourceCache::has(E->key())) {
Resource *res = ResourceCache::get(E->key());
res->set_path(""); //clear reference to path
}
da->remove(E->key());
EditorFileSystem::get_singleton()->update_file(E->key());
}
da->remove(E->key());
EditorFileSystem::get_singleton()->update_file(E->key());
}
memdelete(da);
}