mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-25 18:39:18 +01:00
Added use_on_initial_import() virtual method to ResourceImporter.
If it returns false and the resource importer would be used on a file's initial import it will be imported with the "Keep File (No Import)" setting.
This commit is contained in:
parent
14100c3ac0
commit
abb354860d
@ -107,6 +107,7 @@ public:
|
||||
virtual String get_resource_type() const = 0;
|
||||
virtual float get_priority() const { return 1.0; }
|
||||
virtual int get_import_order() const { return IMPORT_ORDER_DEFAULT; }
|
||||
virtual bool use_on_initial_import() const { return true; }
|
||||
|
||||
struct ImportOption {
|
||||
PropertyInfo option;
|
||||
|
@ -1806,6 +1806,30 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
|
||||
}
|
||||
}
|
||||
|
||||
if (load_default && !importer->use_on_initial_import()) {
|
||||
FileAccess *f = FileAccess::open(p_file + ".import", FileAccess::WRITE);
|
||||
ERR_FAIL_COND_MSG(!f, "Cannot open file from path '" + p_file + ".import'.");
|
||||
|
||||
f->store_line("[remap]");
|
||||
f->store_line("");
|
||||
f->store_line("importer=\"keep\"");
|
||||
f->store_line("");
|
||||
|
||||
f->close();
|
||||
memdelete(f);
|
||||
|
||||
//update modified times, to avoid reimport
|
||||
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;
|
||||
}
|
||||
|
||||
//mix with default params, in case a parameter is missing
|
||||
|
||||
List<ResourceImporter::ImportOption> opts;
|
||||
|
@ -87,6 +87,13 @@ int EditorImportPlugin::get_import_order() const {
|
||||
return get_script_instance()->call("get_import_order");
|
||||
}
|
||||
|
||||
bool EditorImportPlugin::use_on_initial_import() const {
|
||||
if (!(get_script_instance() && get_script_instance()->has_method("use_on_initial_import"))) {
|
||||
return ResourceImporter::use_on_initial_import();
|
||||
}
|
||||
return get_script_instance()->call("use_on_initial_import");
|
||||
}
|
||||
|
||||
void EditorImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options, int p_preset) const {
|
||||
ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("get_import_options")));
|
||||
Array needed;
|
||||
@ -162,6 +169,7 @@ void EditorImportPlugin::_bind_methods() {
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_resource_type"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::REAL, "get_priority"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_import_order"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "use_on_initial_import"));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "get_option_visibility", PropertyInfo(Variant::STRING, "option"), PropertyInfo(Variant::DICTIONARY, "options")));
|
||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "import", PropertyInfo(Variant::STRING, "source_file"), PropertyInfo(Variant::STRING, "save_path"), PropertyInfo(Variant::DICTIONARY, "options"), PropertyInfo(Variant::ARRAY, "platform_variants"), PropertyInfo(Variant::ARRAY, "gen_files")));
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
virtual String get_resource_type() const;
|
||||
virtual float get_priority() const;
|
||||
virtual int get_import_order() const;
|
||||
virtual bool use_on_initial_import() const;
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset) const;
|
||||
virtual bool get_option_visibility(const String &p_option, const RBMap<StringName, Variant> &p_options) const;
|
||||
virtual Error import(const String &p_source_file, const String &p_save_path, const RBMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user