mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Mark necessary EditorImportPlugin functions as required
This commit is contained in:
parent
30456ba095
commit
71723f74b7
3 changed files with 61 additions and 79 deletions
|
@ -124,17 +124,18 @@
|
|||
<return type="bool" />
|
||||
<description>
|
||||
Tells whether this importer can be run in parallel on threads, or, on the contrary, it's only safe for the editor to call it from the main thread, for one file at a time.
|
||||
If this method is not overridden, it will return [code]false[/code] by default.
|
||||
If this importer's implementation is thread-safe and can be run in parallel, override this with [code]true[/code] to optimize for concurrency.
|
||||
If not overridden, returns [code]false[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_format_version" qualifiers="virtual const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Gets the format version of this importer. Increment this version when making incompatible changes to the format of the imported resources.
|
||||
If not overridden, the format version is [code]0[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_import_options" qualifiers="virtual const">
|
||||
<method name="_get_import_options" qualifiers="virtual required const">
|
||||
<return type="Dictionary[]" />
|
||||
<param index="0" name="path" type="String" />
|
||||
<param index="1" name="preset_index" type="int" />
|
||||
|
@ -148,7 +149,7 @@
|
|||
Gets the order of this importer to be run when importing resources. Importers with [i]lower[/i] import orders will be called first, and higher values will be called later. Use this to ensure the importer runs after the dependencies are already imported. The default import order is [code]0[/code] unless overridden by a specific importer. See [enum ResourceImporter.ImportOrder] for some predefined values.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_importer_name" qualifiers="virtual const">
|
||||
<method name="_get_importer_name" qualifiers="virtual required const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Gets the unique name of the importer.
|
||||
|
@ -189,9 +190,10 @@
|
|||
<return type="int" />
|
||||
<description>
|
||||
Gets the number of initial presets defined by the plugin. Use [method _get_import_options] to get the default options for the preset and [method _get_preset_name] to get the name of the preset.
|
||||
By default, there are no presets.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_preset_name" qualifiers="virtual const">
|
||||
<method name="_get_preset_name" qualifiers="virtual required const">
|
||||
<return type="String" />
|
||||
<param index="0" name="preset_index" type="int" />
|
||||
<description>
|
||||
|
@ -204,31 +206,31 @@
|
|||
Gets the priority of this plugin for the recognized extension. Higher priority plugins will be preferred. The default priority is [code]1.0[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_recognized_extensions" qualifiers="virtual const">
|
||||
<method name="_get_recognized_extensions" qualifiers="virtual required const">
|
||||
<return type="PackedStringArray" />
|
||||
<description>
|
||||
Gets the list of file extensions to associate with this loader (case-insensitive). e.g. [code]["obj"][/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_resource_type" qualifiers="virtual const">
|
||||
<method name="_get_resource_type" qualifiers="virtual required const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Gets the Godot resource type associated with this loader. e.g. [code]"Mesh"[/code] or [code]"Animation"[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_save_extension" qualifiers="virtual const">
|
||||
<method name="_get_save_extension" qualifiers="virtual required const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Gets the extension used to save this resource in the [code].godot/imported[/code] directory (see [member ProjectSettings.application/config/use_hidden_project_data_directory]).
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_visible_name" qualifiers="virtual const">
|
||||
<method name="_get_visible_name" qualifiers="virtual required const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Gets the name to display in the import window. You should choose this name as a continuation to "Import as", e.g. "Import as Special Mesh".
|
||||
</description>
|
||||
</method>
|
||||
<method name="_import" qualifiers="virtual const">
|
||||
<method name="_import" qualifiers="virtual required const">
|
||||
<return type="int" enum="Error" />
|
||||
<param index="0" name="source_file" type="String" />
|
||||
<param index="1" name="save_path" type="String" />
|
||||
|
|
|
@ -35,38 +35,28 @@
|
|||
|
||||
String EditorImportPlugin::get_importer_name() const {
|
||||
String ret;
|
||||
if (GDVIRTUAL_CALL(_get_importer_name, ret)) {
|
||||
return ret;
|
||||
}
|
||||
ERR_FAIL_V_MSG(String(), "Unimplemented _get_importer_name in add-on.");
|
||||
GDVIRTUAL_CALL(_get_importer_name, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
String EditorImportPlugin::get_visible_name() const {
|
||||
String ret;
|
||||
if (GDVIRTUAL_CALL(_get_visible_name, ret)) {
|
||||
return ret;
|
||||
}
|
||||
ERR_FAIL_V_MSG(String(), "Unimplemented _get_visible_name in add-on.");
|
||||
GDVIRTUAL_CALL(_get_visible_name, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EditorImportPlugin::get_recognized_extensions(List<String> *p_extensions) const {
|
||||
Vector<String> extensions;
|
||||
|
||||
if (GDVIRTUAL_CALL(_get_recognized_extensions, extensions)) {
|
||||
for (int i = 0; i < extensions.size(); i++) {
|
||||
p_extensions->push_back(extensions[i]);
|
||||
}
|
||||
return;
|
||||
GDVIRTUAL_CALL(_get_recognized_extensions, extensions);
|
||||
for (int i = 0; i < extensions.size(); i++) {
|
||||
p_extensions->push_back(extensions[i]);
|
||||
}
|
||||
ERR_FAIL_MSG("Unimplemented _get_recognized_extensions in add-on.");
|
||||
}
|
||||
|
||||
String EditorImportPlugin::get_preset_name(int p_idx) const {
|
||||
String ret;
|
||||
if (GDVIRTUAL_CALL(_get_preset_name, p_idx, ret)) {
|
||||
return ret;
|
||||
}
|
||||
ERR_FAIL_V_MSG(itos(p_idx), "Unimplemented _get_preset_name in add-on.");
|
||||
GDVIRTUAL_CALL(_get_preset_name, p_idx, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EditorImportPlugin::get_preset_count() const {
|
||||
|
@ -79,18 +69,14 @@ int EditorImportPlugin::get_preset_count() const {
|
|||
|
||||
String EditorImportPlugin::get_save_extension() const {
|
||||
String ret;
|
||||
if (GDVIRTUAL_CALL(_get_save_extension, ret)) {
|
||||
return ret;
|
||||
}
|
||||
ERR_FAIL_V_MSG(String(), "Unimplemented _get_save_extension in add-on.");
|
||||
GDVIRTUAL_CALL(_get_save_extension, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
String EditorImportPlugin::get_resource_type() const {
|
||||
String ret;
|
||||
if (GDVIRTUAL_CALL(_get_resource_type, ret)) {
|
||||
return ret;
|
||||
}
|
||||
ERR_FAIL_V_MSG(String(), "Unimplemented _get_resource_type in add-on.");
|
||||
GDVIRTUAL_CALL(_get_resource_type, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
float EditorImportPlugin::get_priority() const {
|
||||
|
@ -120,35 +106,31 @@ int EditorImportPlugin::get_format_version() const {
|
|||
void EditorImportPlugin::get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options, int p_preset) const {
|
||||
Array needed = { "name", "default_value" };
|
||||
TypedArray<Dictionary> options;
|
||||
if (GDVIRTUAL_CALL(_get_import_options, p_path, p_preset, options)) {
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
Dictionary d = options[i];
|
||||
ERR_FAIL_COND(!d.has_all(needed));
|
||||
String name = d["name"];
|
||||
Variant default_value = d["default_value"];
|
||||
GDVIRTUAL_CALL(_get_import_options, p_path, p_preset, options);
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
Dictionary d = options[i];
|
||||
ERR_FAIL_COND(!d.has_all(needed));
|
||||
String name = d["name"];
|
||||
Variant default_value = d["default_value"];
|
||||
|
||||
PropertyHint hint = PROPERTY_HINT_NONE;
|
||||
if (d.has("property_hint")) {
|
||||
hint = (PropertyHint)d["property_hint"].operator int64_t();
|
||||
}
|
||||
|
||||
String hint_string;
|
||||
if (d.has("hint_string")) {
|
||||
hint_string = d["hint_string"];
|
||||
}
|
||||
|
||||
uint32_t usage = PROPERTY_USAGE_DEFAULT;
|
||||
if (d.has("usage")) {
|
||||
usage = d["usage"];
|
||||
}
|
||||
|
||||
ImportOption option(PropertyInfo(default_value.get_type(), name, hint, hint_string, usage), default_value);
|
||||
r_options->push_back(option);
|
||||
PropertyHint hint = PROPERTY_HINT_NONE;
|
||||
if (d.has("property_hint")) {
|
||||
hint = (PropertyHint)d["property_hint"].operator int64_t();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_MSG("Unimplemented _get_import_options in add-on.");
|
||||
String hint_string;
|
||||
if (d.has("hint_string")) {
|
||||
hint_string = d["hint_string"];
|
||||
}
|
||||
|
||||
uint32_t usage = PROPERTY_USAGE_DEFAULT;
|
||||
if (d.has("usage")) {
|
||||
usage = d["usage"];
|
||||
}
|
||||
|
||||
ImportOption option(PropertyInfo(default_value.get_type(), name, hint, hint_string, usage), default_value);
|
||||
r_options->push_back(option);
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorImportPlugin::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
|
||||
|
@ -176,16 +158,14 @@ Error EditorImportPlugin::import(ResourceUID::ID p_source_id, const String &p_so
|
|||
}
|
||||
|
||||
Error err = OK;
|
||||
if (GDVIRTUAL_CALL(_import, p_source_file, p_save_path, options, platform_variants, gen_files, err)) {
|
||||
for (int i = 0; i < platform_variants.size(); i++) {
|
||||
r_platform_variants->push_back(platform_variants[i]);
|
||||
}
|
||||
for (int i = 0; i < gen_files.size(); i++) {
|
||||
r_gen_files->push_back(gen_files[i]);
|
||||
}
|
||||
return err;
|
||||
GDVIRTUAL_CALL(_import, p_source_file, p_save_path, options, platform_variants, gen_files, err);
|
||||
for (int i = 0; i < platform_variants.size(); i++) {
|
||||
r_platform_variants->push_back(platform_variants[i]);
|
||||
}
|
||||
ERR_FAIL_V_MSG(ERR_METHOD_NOT_FOUND, "Unimplemented _import in add-on.");
|
||||
for (int i = 0; i < gen_files.size(); i++) {
|
||||
r_gen_files->push_back(gen_files[i]);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
bool EditorImportPlugin::can_import_threaded() const {
|
||||
|
|
|
@ -39,19 +39,19 @@ class EditorImportPlugin : public ResourceImporter {
|
|||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
GDVIRTUAL0RC(String, _get_importer_name)
|
||||
GDVIRTUAL0RC(String, _get_visible_name)
|
||||
GDVIRTUAL0RC_REQUIRED(String, _get_importer_name)
|
||||
GDVIRTUAL0RC_REQUIRED(String, _get_visible_name)
|
||||
GDVIRTUAL0RC(int, _get_preset_count)
|
||||
GDVIRTUAL1RC(String, _get_preset_name, int)
|
||||
GDVIRTUAL0RC(Vector<String>, _get_recognized_extensions)
|
||||
GDVIRTUAL2RC(TypedArray<Dictionary>, _get_import_options, String, int)
|
||||
GDVIRTUAL0RC(String, _get_save_extension)
|
||||
GDVIRTUAL0RC(String, _get_resource_type)
|
||||
GDVIRTUAL1RC_REQUIRED(String, _get_preset_name, int)
|
||||
GDVIRTUAL0RC_REQUIRED(Vector<String>, _get_recognized_extensions)
|
||||
GDVIRTUAL2RC_REQUIRED(TypedArray<Dictionary>, _get_import_options, String, int)
|
||||
GDVIRTUAL0RC_REQUIRED(String, _get_save_extension)
|
||||
GDVIRTUAL0RC_REQUIRED(String, _get_resource_type)
|
||||
GDVIRTUAL0RC(float, _get_priority)
|
||||
GDVIRTUAL0RC(int, _get_import_order)
|
||||
GDVIRTUAL0RC(int, _get_format_version)
|
||||
GDVIRTUAL3RC(bool, _get_option_visibility, String, StringName, Dictionary)
|
||||
GDVIRTUAL5RC(Error, _import, String, String, Dictionary, TypedArray<String>, TypedArray<String>)
|
||||
GDVIRTUAL5RC_REQUIRED(Error, _import, String, String, Dictionary, TypedArray<String>, TypedArray<String>)
|
||||
GDVIRTUAL0RC(bool, _can_import_threaded)
|
||||
|
||||
Error _append_import_external_resource(const String &p_file, const Dictionary &p_custom_options = Dictionary(), const String &p_custom_importer = String(), Variant p_generator_parameters = Variant());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue