summaryrefslogtreecommitdiff
path: root/editor/editor_file_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_file_system.cpp')
-rw-r--r--editor/editor_file_system.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index d73bf86f64..94eb1a3399 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -466,6 +466,7 @@ bool EditorFileSystem::_update_scan_actions() {
bool fs_changed = false;
Vector<String> reimports;
+ Vector<String> reloads;
for (List<ItemAction>::Element *E = scan_actions.front(); E; E = E->next()) {
@@ -545,12 +546,25 @@ bool EditorFileSystem::_update_scan_actions() {
fs_changed = true;
} break;
+ case ItemAction::ACTION_FILE_RELOAD: {
+
+ int idx = ia.dir->find_file_index(ia.file);
+ ERR_CONTINUE(idx == -1);
+ String full_path = ia.dir->get_file_path(idx);
+
+ reloads.push_back(full_path);
+
+ } break;
}
}
if (reimports.size()) {
reimport_files(reimports);
}
+
+ if (reloads.size()) {
+ emit_signal("resources_reload", reloads);
+ }
scan_actions.clear();
return fs_changed;
@@ -905,11 +919,11 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
continue;
}
+ String path = cd.plus_file(p_dir->files[i]->file);
+
if (import_extensions.has(p_dir->files[i]->file.get_extension().to_lower())) {
//check here if file must be imported or not
- String path = cd.plus_file(p_dir->files[i]->file);
-
uint64_t mt = FileAccess::get_modified_time(path);
bool reimport = false;
@@ -936,6 +950,20 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const
ia.file = p_dir->files[i]->file;
scan_actions.push_back(ia);
}
+ } else if (ResourceCache::has(path)) { //test for potential reload
+
+ uint64_t mt = FileAccess::get_modified_time(path);
+
+ if (mt != p_dir->files[i]->modified_time) {
+
+ p_dir->files[i]->modified_time = mt; //save new time, but test for reload
+
+ ItemAction ia;
+ ia.action = ItemAction::ACTION_FILE_RELOAD;
+ ia.dir = p_dir;
+ ia.file = p_dir->files[i]->file;
+ scan_actions.push_back(ia);
+ }
}
}
@@ -1305,11 +1333,6 @@ void EditorFileSystem::_save_late_updated_files() {
}
}
-void EditorFileSystem::_resource_saved(const String &p_path) {
-
- EditorFileSystem::get_singleton()->update_file(p_path);
-}
-
Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) {
List<String> deps;
@@ -1731,6 +1754,7 @@ void EditorFileSystem::_bind_methods() {
ADD_SIGNAL(MethodInfo("filesystem_changed"));
ADD_SIGNAL(MethodInfo("sources_changed", PropertyInfo(Variant::BOOL, "exist")));
ADD_SIGNAL(MethodInfo("resources_reimported", PropertyInfo(Variant::POOL_STRING_ARRAY, "resources")));
+ ADD_SIGNAL(MethodInfo("resources_reload", PropertyInfo(Variant::POOL_STRING_ARRAY, "resources")));
}
void EditorFileSystem::_update_extensions() {
@@ -1772,7 +1796,6 @@ EditorFileSystem::EditorFileSystem() {
abort_scan = false;
scanning_changes = false;
scanning_changes_done = false;
- ResourceSaver::set_save_callback(_resource_saved);
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
if (da->change_dir("res://.import") != OK) {