diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-05 19:50:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-05 19:50:37 +0100 |
commit | bd32dd4a48ba0008dc72c8dcd75f8d41bc510aba (patch) | |
tree | f1f81f97853a605cfc56789b7e5e15db97193a08 /editor/import | |
parent | 5f42e0d0abad7b2c6d90e56cbc2064b8444e2a07 (diff) | |
parent | a6f34ea2d00d6cef252501a580fbaf08ec5ad423 (diff) |
Merge pull request #56943 from V-Sekai/override-import
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 d9448dd4a9..5d356604f4 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); } } @@ -1490,8 +1490,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); } } @@ -1843,13 +1843,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; } } @@ -1883,13 +1883,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; } } @@ -2088,6 +2088,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 13b55b5754..a3aeac4022 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; |