Merge pull request #16659 from vnen/plugin_order

Expose priority and order for custom import plugins
This commit is contained in:
Rémi Verschelde 2018-02-14 00:28:40 +01:00 committed by GitHub
commit c2d8960c9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View file

@ -64,6 +64,13 @@
Get the options and default values for the preset at this index. Returns an Array of Dictionaries with the following keys: "name", "default_value", "property_hint" (optional), "hint_string" (optional), "usage" (optional).
</description>
</method>
<method name="get_import_order" qualifiers="virtual">
<return type="int">
</return>
<description>
Get the order of this importer to be run when importing resources. Higher values will be called later. Use this to ensure the importer runs after the dependencies are already imported.
</description>
</method>
<method name="get_importer_name" qualifiers="virtual">
<return type="String">
</return>
@ -97,6 +104,13 @@
Get the name of the options preset at this index.
</description>
</method>
<method name="get_priority" qualifiers="virtual">
<return type="float">
</return>
<description>
Get the priority of this plugin for the recognized extension. Higher priority plugins will be preferred. Default value is 1.0.
</description>
</method>
<method name="get_recognized_extensions" qualifiers="virtual">
<return type="Array">
</return>

View file

@ -72,6 +72,20 @@ String EditorImportPlugin::get_resource_type() const {
return get_script_instance()->call("get_resource_type");
}
float EditorImportPlugin::get_priority() const {
if (!(get_script_instance() && get_script_instance()->has_method("get_priority"))) {
return EditorImportPlugin::get_priority();
}
return get_script_instance()->call("get_priority");
}
int EditorImportPlugin::get_import_order() const {
if (!(get_script_instance() && get_script_instance()->has_method("get_import_order"))) {
return EditorImportPlugin::get_import_order();
}
return get_script_instance()->call("get_import_order");
}
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")));
@ -148,6 +162,8 @@ void EditorImportPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::ARRAY, "get_import_options", PropertyInfo(Variant::INT, "preset")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_save_extension"));
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, "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, "r_platform_variants"), PropertyInfo(Variant::ARRAY, "r_gen_files")));
}

View file

@ -47,6 +47,8 @@ public:
virtual int get_preset_count() const;
virtual String get_save_extension() const;
virtual String get_resource_type() const;
virtual float get_priority() const;
virtual int get_import_order() const;
virtual void get_import_options(List<ImportOption> *r_options, int p_preset) const;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files);