aboutsummaryrefslogtreecommitdiff
path: root/tools/editor/editor_import_export.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2015-03-03 14:41:36 -0300
committerJuan Linietsky2015-03-03 14:41:36 -0300
commit2c2894ceb674927a35d2798b3e63adabdb020077 (patch)
tree9e8950e0acc8fb7531fa60ce8c0321a5b60c335a /tools/editor/editor_import_export.cpp
parent4d2198110b4af7f203eeef95697255569e49bce7 (diff)
parenta0ee5cc3531786a652ee43d3a57cb69dff34bd70 (diff)
downloadgodot-2c2894ceb674927a35d2798b3e63adabdb020077.tar.gz
godot-2c2894ceb674927a35d2798b3e63adabdb020077.tar.zst
godot-2c2894ceb674927a35d2798b3e63adabdb020077.zip
Merge branch 'master' of https://github.com/okamstudio/godot
Conflicts: modules/gdscript/gd_tokenizer.cpp scene/resources/shader_graph.h
Diffstat (limited to 'tools/editor/editor_import_export.cpp')
-rw-r--r--tools/editor/editor_import_export.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp
index 0881739cb..e6ec11e9d 100644
--- a/tools/editor/editor_import_export.cpp
+++ b/tools/editor/editor_import_export.cpp
@@ -1167,10 +1167,36 @@ EditorImportExport* EditorImportExport::singleton=NULL;
void EditorImportExport::add_import_plugin(const Ref<EditorImportPlugin>& p_plugin) {
+ // Need to make sure the name is unique if we are going to lookup by it
+ ERR_FAIL_COND(by_idx.has(p_plugin->get_name()));
+
by_idx[ p_plugin->get_name() ]=plugins.size();
plugins.push_back(p_plugin);
}
+void EditorImportExport::remove_import_plugin(const Ref<EditorImportPlugin>& p_plugin) {
+
+ String plugin_name = p_plugin->get_name();
+
+ // Keep the indices the same
+ // Find the index of the target plugin
+ ERR_FAIL_COND(!by_idx.has(plugin_name));
+ int idx = by_idx[plugin_name];
+ int last_idx = plugins.size() - 1;
+
+ // Swap the last plugin and the target one
+ SWAP(plugins[idx], plugins[last_idx]);
+
+ // Update the index of the old last one
+ by_idx[plugins[idx]->get_name()] = idx;
+
+ // Remove the target plugin's by_idx entry
+ by_idx.erase(plugin_name);
+
+ // Erase the plugin
+ plugins.remove(last_idx);
+}
+
int EditorImportExport::get_import_plugin_count() const{
return plugins.size();