summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-29 08:51:57 +0100
committerGitHub <noreply@github.com>2017-11-29 08:51:57 +0100
commit15a7b4a7502ce3b0b51fa1acb3edc52851600fa4 (patch)
treebe2f0d00bae09f3de8bd0dded18779aeb168d32c
parentedde7190abc65dcf2886cebc6f2486fd807e0e65 (diff)
parente718dd12bef16c1eef28874e7d5bb1d4c6a34f11 (diff)
Merge pull request #13384 from ianb96/scene_move_update
Moving open scenes in filesystem updates dependencies
-rw-r--r--editor/filesystem_dock.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index a5445ca153..9fe3e2ad25 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -781,6 +781,20 @@ void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_
}
}
+ // update scene if it is open
+ for (int i = 0; i < changed_paths.size(); ++i) {
+ String new_item_path = p_item.is_file ? new_path : changed_paths[i].replace_first(old_path, new_path);
+ if (ResourceLoader::get_resource_type(new_item_path) == "PackedScene" && editor->is_scene_open(changed_paths[i])) {
+ EditorData *ed = &editor->get_editor_data();
+ for (int j = 0; j < ed->get_edited_scene_count(); j++) {
+ if (ed->get_scene_path(j) == changed_paths[i]) {
+ ed->get_edited_scene_root(j)->set_filename(new_item_path);
+ break;
+ }
+ }
+ }
+ }
+
//Only treat as a changed dependency if it was successfully moved
for (int i = 0; i < changed_paths.size(); ++i) {
p_renames[changed_paths[i]] = changed_paths[i].replace_first(old_path, new_path);
@@ -803,7 +817,10 @@ void FileSystemDock::_update_dependencies_after_move(const Map<String, String> &
String file = p_renames.has(remaps[i]) ? p_renames[remaps[i]] : remaps[i];
print_line("Remapping dependencies for: " + file);
Error err = ResourceLoader::rename_dependencies(file, p_renames);
- if (err != OK) {
+ if (err == OK) {
+ if (ResourceLoader::get_resource_type(file) == "PackedScene")
+ editor->reload_scene(file);
+ } else {
EditorNode::get_singleton()->add_io_error(TTR("Unable to update dependencies:\n") + remaps[i] + "\n");
}
}