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

Add a "keep" import mode to keep files as-is and export them.

(cherry picked from commit 8d64f3bd76)
This commit is contained in:
Juan Linietsky
2021-03-22 16:41:47 -03:00
committed by Rémi Verschelde
parent 69e6ba1591
commit 24e1ba1298
5 changed files with 123 additions and 43 deletions

View File

@@ -372,6 +372,7 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
List<String> to_check;
String importer_name;
String source_file = "";
String source_md5 = "";
Vector<String> dest_files;
@@ -400,6 +401,8 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
for (int i = 0; i < fa.size(); i++) {
to_check.push_back(fa[i]);
}
} else if (assign == "importer") {
importer_name = value;
} else if (!p_only_imported_files) {
if (assign == "source_file") {
source_file = value;
@@ -415,6 +418,10 @@ bool EditorFileSystem::_test_for_reimport(const String &p_path, bool p_only_impo
memdelete(f);
if (importer_name == "keep") {
return false; //keep mode, do not reimport
}
// Read the md5's from a separate file (so the import parameters aren't dependent on the file version
String base_path = ResourceFormatImporter::get_singleton()->get_import_base_path(p_path);
FileAccess *md5s = FileAccess::open(base_path + ".md5", FileAccess::READ, &err);
@@ -1570,6 +1577,10 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
source_file_options[p_files[i]] = Map<StringName, Variant>();
importer_name = file_importer_name;
if (importer_name == "keep") {
continue; //do nothing
}
Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name);
ERR_FAIL_COND_V(!importer.is_valid(), ERR_FILE_CORRUPT);
List<ResourceImporter::ImportOption> options;
@@ -1594,6 +1605,10 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
base_paths[p_files[i]] = ResourceFormatImporter::get_singleton()->get_import_base_path(p_files[i]);
}
if (importer_name == "keep") {
return OK; // (do nothing)
}
ERR_FAIL_COND_V(importer_name == String(), ERR_UNCONFIGURED);
Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name);
@@ -1741,6 +1756,16 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
late_added_files.insert(p_file); //imported files do not call update_file(), but just in case..
}
if (importer_name == "keep") {
//keep files, do nothing.
fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import");
fs->files[cpos]->deps.clear();
fs->files[cpos]->type = "";
fs->files[cpos]->import_valid = false;
EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
return;
}
Ref<ResourceImporter> importer;
bool load_default = false;
//find the importer