mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Make add_importer and add_post_importer_plugin override existing importers.
This commit is contained in:
parent
bc5ba38ff5
commit
a6f34ea2d0
@ -463,3 +463,8 @@ void ResourceImporter::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(IMPORT_ORDER_DEFAULT);
|
||||
BIND_ENUM_CONSTANT(IMPORT_ORDER_SCENE);
|
||||
}
|
||||
|
||||
void ResourceFormatImporter::add_importer(const Ref<ResourceImporter> &p_importer) {
|
||||
ERR_FAIL_COND(p_importer.is_null());
|
||||
importers.insert(0, p_importer);
|
||||
}
|
||||
|
@ -80,9 +80,8 @@ public:
|
||||
String get_internal_resource_path(const String &p_path) const;
|
||||
void get_internal_resource_path_list(const String &p_path, List<String> *r_paths);
|
||||
|
||||
void add_importer(const Ref<ResourceImporter> &p_importer) {
|
||||
importers.push_back(p_importer);
|
||||
}
|
||||
void add_importer(const Ref<ResourceImporter> &p_importer);
|
||||
|
||||
void remove_importer(const Ref<ResourceImporter> &p_importer) { importers.erase(p_importer); }
|
||||
Ref<ResourceImporter> get_importer_by_name(const String &p_name) const;
|
||||
Ref<ResourceImporter> get_importer_by_extension(const String &p_extension) const;
|
||||
|
@ -258,8 +258,8 @@ String ResourceImporterScene::get_visible_name() const {
|
||||
}
|
||||
|
||||
void ResourceImporterScene::get_recognized_extensions(List<String> *p_extensions) const {
|
||||
for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) {
|
||||
E->get()->get_extensions(p_extensions);
|
||||
for (Ref<EditorSceneFormatImporter> importer_elem : importers) {
|
||||
importer_elem->get_extensions(p_extensions);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1489,8 +1489,8 @@ void ResourceImporterScene::get_import_options(const String &p_path, List<Import
|
||||
post_importer_plugins.write[i]->get_import_options(p_path, r_options);
|
||||
}
|
||||
|
||||
for (Ref<EditorSceneFormatImporter> importer : importers) {
|
||||
importer->get_import_options(p_path, r_options);
|
||||
for (Ref<EditorSceneFormatImporter> importer_elem : importers) {
|
||||
importer_elem->get_import_options(p_path, r_options);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1841,13 +1841,13 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file) {
|
||||
EditorProgress progress("pre-import", TTR("Pre-Import Scene"), 0);
|
||||
progress.step(TTR("Importing Scene..."), 0);
|
||||
|
||||
for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) {
|
||||
for (Ref<EditorSceneFormatImporter> importer_elem : importers) {
|
||||
List<String> extensions;
|
||||
E->get()->get_extensions(&extensions);
|
||||
importer_elem->get_extensions(&extensions);
|
||||
|
||||
for (const String &F : extensions) {
|
||||
if (F.to_lower() == ext) {
|
||||
importer = E->get();
|
||||
importer = importer_elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1881,13 +1881,13 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
|
||||
EditorProgress progress("import", TTR("Import Scene"), 104);
|
||||
progress.step(TTR("Importing Scene..."), 0);
|
||||
|
||||
for (Set<Ref<EditorSceneFormatImporter>>::Element *E = importers.front(); E; E = E->next()) {
|
||||
for (Ref<EditorSceneFormatImporter> importer_elem : importers) {
|
||||
List<String> extensions;
|
||||
E->get()->get_extensions(&extensions);
|
||||
importer_elem->get_extensions(&extensions);
|
||||
|
||||
for (const String &F : extensions) {
|
||||
if (F.to_lower() == ext) {
|
||||
importer = E->get();
|
||||
importer = importer_elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2086,6 +2086,24 @@ ResourceImporterScene::ResourceImporterScene() {
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
void ResourceImporterScene::add_importer(Ref<EditorSceneFormatImporter> p_importer) {
|
||||
ERR_FAIL_COND(p_importer.is_null());
|
||||
importers.insert(0, p_importer);
|
||||
}
|
||||
|
||||
void ResourceImporterScene::remove_post_importer_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) {
|
||||
post_importer_plugins.erase(p_plugin);
|
||||
}
|
||||
|
||||
void ResourceImporterScene::add_post_importer_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) {
|
||||
ERR_FAIL_COND(p_plugin.is_null());
|
||||
post_importer_plugins.insert(0, p_plugin);
|
||||
}
|
||||
|
||||
void ResourceImporterScene::remove_importer(Ref<EditorSceneFormatImporter> p_importer) {
|
||||
importers.erase(p_importer);
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
uint32_t EditorSceneFormatImporterESCN::get_import_flags() const {
|
||||
|
@ -153,7 +153,7 @@ VARIANT_ENUM_CAST(EditorScenePostImportPlugin::InternalImportCategory)
|
||||
class ResourceImporterScene : public ResourceImporter {
|
||||
GDCLASS(ResourceImporterScene, ResourceImporter);
|
||||
|
||||
Set<Ref<EditorSceneFormatImporter>> importers;
|
||||
Vector<Ref<EditorSceneFormatImporter>> importers;
|
||||
|
||||
static ResourceImporterScene *singleton;
|
||||
|
||||
@ -224,13 +224,13 @@ class ResourceImporterScene : public ResourceImporter {
|
||||
public:
|
||||
static ResourceImporterScene *get_singleton() { return singleton; }
|
||||
|
||||
void add_post_importer_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) { post_importer_plugins.push_back(p_plugin); }
|
||||
void remove_post_importer_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) { post_importer_plugins.erase(p_plugin); }
|
||||
void add_post_importer_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin);
|
||||
void remove_post_importer_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin);
|
||||
|
||||
const Set<Ref<EditorSceneFormatImporter>> &get_importers() const { return importers; }
|
||||
const Vector<Ref<EditorSceneFormatImporter>> &get_importers() const { return importers; }
|
||||
|
||||
void add_importer(Ref<EditorSceneFormatImporter> p_importer) { importers.insert(p_importer); }
|
||||
void remove_importer(Ref<EditorSceneFormatImporter> p_importer) { importers.erase(p_importer); }
|
||||
void add_importer(Ref<EditorSceneFormatImporter> p_importer);
|
||||
void remove_importer(Ref<EditorSceneFormatImporter> p_importer);
|
||||
|
||||
virtual String get_importer_name() const override;
|
||||
virtual String get_visible_name() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user