diff options
author | K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com> | 2022-01-19 03:03:47 -0800 |
---|---|---|
committer | K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com> | 2022-01-19 04:53:28 -0800 |
commit | a6f34ea2d00d6cef252501a580fbaf08ec5ad423 (patch) | |
tree | 5d0912e00b03bcccfaae3d3d445fcf1630c9d5b6 /editor/import | |
parent | bc5ba38ff59f04a58107b9939fc2db97ca44314e (diff) |
Make add_importer and add_post_importer_plugin override existing importers.
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 38 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 12 |
2 files changed, 34 insertions, 16 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index b6624a8cfa..52a1b1a917 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -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 { diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 066e8b603b..4ee6cf7d25 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -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; |