Merge pull request #54976 from reduz/importer-options-by-path
This commit is contained in:
commit
8bb163807a
|
@ -134,8 +134,8 @@ public:
|
|||
virtual int get_preset_count() const { return 0; }
|
||||
virtual String get_preset_name(int p_idx) const { return String(); }
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const = 0;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const = 0;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const = 0;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const = 0;
|
||||
virtual String get_option_group_file() const { return String(); }
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) = 0;
|
||||
|
|
|
@ -116,7 +116,8 @@
|
|||
<methods>
|
||||
<method name="_get_import_options" qualifiers="virtual const">
|
||||
<return type="Array" />
|
||||
<argument index="0" name="preset_index" type="int" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
<argument index="1" name="preset_index" type="int" />
|
||||
<description>
|
||||
Gets the options and default values for the preset at this index. Returns an Array of Dictionaries with the following keys: [code]name[/code], [code]default_value[/code], [code]property_hint[/code] (optional), [code]hint_string[/code] (optional), [code]usage[/code] (optional).
|
||||
</description>
|
||||
|
@ -135,8 +136,9 @@
|
|||
</method>
|
||||
<method name="_get_option_visibility" qualifiers="virtual const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="option_name" type="StringName" />
|
||||
<argument index="1" name="options" type="Dictionary" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
<argument index="1" name="option_name" type="StringName" />
|
||||
<argument index="2" name="options" type="Dictionary" />
|
||||
<description>
|
||||
This method can be overridden to hide specific import options if conditions are met. This is mainly useful for hiding options that depend on others if one of them is disabled. For example:
|
||||
[codeblocks]
|
||||
|
|
|
@ -20,6 +20,19 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_import_options" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_option_visibility" qualifiers="virtual const">
|
||||
<return type="Variant" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
<argument index="1" name="option" type="String" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="_import_animation" qualifiers="virtual">
|
||||
<return type="Animation" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<methods>
|
||||
<method name="_get_import_options" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
<description>
|
||||
Override to add general import options. These will appear in the main import dock on the editor. Add options via [method add_import_option] and [method add_import_option_advanced].
|
||||
</description>
|
||||
|
@ -40,7 +41,8 @@
|
|||
</method>
|
||||
<method name="_get_option_visibility" qualifiers="virtual const">
|
||||
<return type="Variant" />
|
||||
<argument index="0" name="option" type="String" />
|
||||
<argument index="0" name="path" type="String" />
|
||||
<argument index="1" name="option" type="String" />
|
||||
<description>
|
||||
Return true or false whether a given option should be visible. Return null to ignore.
|
||||
</description>
|
||||
|
|
|
@ -82,7 +82,7 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
|
||||
void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
for (const PropertyInfo &E : properties) {
|
||||
if (platform->get_option_visibility(E.name, values)) {
|
||||
if (platform->get_export_option_visibility(E.name, values)) {
|
||||
p_list->push_back(E);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ public:
|
|||
|
||||
virtual void get_export_options(List<ExportOption> *r_options) = 0;
|
||||
virtual bool should_update_export_options() { return false; }
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; }
|
||||
virtual bool get_export_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; }
|
||||
|
||||
virtual String get_os_name() const = 0;
|
||||
virtual String get_name() const = 0;
|
||||
|
|
|
@ -1633,7 +1633,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
|
|||
Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(importer_name);
|
||||
ERR_FAIL_COND_V(!importer.is_valid(), ERR_FILE_CORRUPT);
|
||||
List<ResourceImporter::ImportOption> options;
|
||||
importer->get_import_options(&options);
|
||||
importer->get_import_options(p_files[i], &options);
|
||||
//set default values
|
||||
for (const ResourceImporter::ImportOption &E : options) {
|
||||
source_file_options[p_files[i]][E.option.name] = E.default_value;
|
||||
|
@ -1714,7 +1714,7 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
|
|||
//store options in provided order, to avoid file changing. Order is also important because first match is accepted first.
|
||||
|
||||
List<ResourceImporter::ImportOption> options;
|
||||
importer->get_import_options(&options);
|
||||
importer->get_import_options(file, &options);
|
||||
//set default values
|
||||
for (const ResourceImporter::ImportOption &F : options) {
|
||||
String base = F.option.name;
|
||||
|
@ -1851,7 +1851,7 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName
|
|||
//mix with default params, in case a parameter is missing
|
||||
|
||||
List<ResourceImporter::ImportOption> opts;
|
||||
importer->get_import_options(&opts);
|
||||
importer->get_import_options(p_file, &opts);
|
||||
for (const ResourceImporter::ImportOption &E : opts) {
|
||||
if (!params.has(E.option.name)) { //this one is not present
|
||||
params[E.option.name] = E.default_value;
|
||||
|
|
|
@ -110,12 +110,12 @@ int EditorImportPlugin::get_import_order() const {
|
|||
ERR_FAIL_V_MSG(-1, "Unimplemented _get_import_order in add-on.");
|
||||
}
|
||||
|
||||
void EditorImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options, int p_preset) const {
|
||||
void EditorImportPlugin::get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options, int p_preset) const {
|
||||
Array needed;
|
||||
needed.push_back("name");
|
||||
needed.push_back("default_value");
|
||||
Array options;
|
||||
if (GDVIRTUAL_CALL(_get_import_options, p_preset, 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));
|
||||
|
@ -146,7 +146,7 @@ void EditorImportPlugin::get_import_options(List<ResourceImporter::ImportOption>
|
|||
ERR_FAIL_MSG("Unimplemented _get_import_options in add-on.");
|
||||
}
|
||||
|
||||
bool EditorImportPlugin::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool EditorImportPlugin::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
Dictionary d;
|
||||
Map<StringName, Variant>::Element *E = p_options.front();
|
||||
while (E) {
|
||||
|
@ -154,7 +154,7 @@ bool EditorImportPlugin::get_option_visibility(const String &p_option, const Map
|
|||
E = E->next();
|
||||
}
|
||||
bool visible;
|
||||
if (GDVIRTUAL_CALL(_get_option_visibility, p_option, d, visible)) {
|
||||
if (GDVIRTUAL_CALL(_get_option_visibility, p_path, p_option, d, visible)) {
|
||||
return visible;
|
||||
}
|
||||
|
||||
|
@ -192,11 +192,11 @@ void EditorImportPlugin::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_get_preset_count)
|
||||
GDVIRTUAL_BIND(_get_preset_name, "preset_index")
|
||||
GDVIRTUAL_BIND(_get_recognized_extensions)
|
||||
GDVIRTUAL_BIND(_get_import_options, "preset_index")
|
||||
GDVIRTUAL_BIND(_get_import_options, "path", "preset_index")
|
||||
GDVIRTUAL_BIND(_get_save_extension)
|
||||
GDVIRTUAL_BIND(_get_resource_type)
|
||||
GDVIRTUAL_BIND(_get_priority)
|
||||
GDVIRTUAL_BIND(_get_import_order)
|
||||
GDVIRTUAL_BIND(_get_option_visibility, "option_name", "options")
|
||||
GDVIRTUAL_BIND(_get_option_visibility, "path", "option_name", "options")
|
||||
GDVIRTUAL_BIND(_import, "source_file", "save_path", "options", "platform_variants", "gen_files");
|
||||
}
|
||||
|
|
|
@ -44,12 +44,12 @@ protected:
|
|||
GDVIRTUAL0RC(int, _get_preset_count)
|
||||
GDVIRTUAL1RC(String, _get_preset_name, int)
|
||||
GDVIRTUAL0RC(Vector<String>, _get_recognized_extensions)
|
||||
GDVIRTUAL1RC(Array, _get_import_options, int)
|
||||
GDVIRTUAL2RC(Array, _get_import_options, String, int)
|
||||
GDVIRTUAL0RC(String, _get_save_extension)
|
||||
GDVIRTUAL0RC(String, _get_resource_type)
|
||||
GDVIRTUAL0RC(float, _get_priority)
|
||||
GDVIRTUAL0RC(int, _get_import_order)
|
||||
GDVIRTUAL2RC(bool, _get_option_visibility, StringName, Dictionary)
|
||||
GDVIRTUAL3RC(bool, _get_option_visibility, String, StringName, Dictionary)
|
||||
GDVIRTUAL5RC(int, _import, String, String, Dictionary, Array, Array)
|
||||
|
||||
public:
|
||||
|
@ -63,8 +63,8 @@ public:
|
|||
virtual String get_resource_type() const override;
|
||||
virtual float get_priority() const override;
|
||||
virtual int get_import_order() const override;
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
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, Variant *r_metadata = nullptr) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ String ResourceImporterBitMap::get_resource_type() const {
|
|||
return "BitMap";
|
||||
}
|
||||
|
||||
bool ResourceImporterBitMap::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterBitMap::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ String ResourceImporterBitMap::get_preset_name(int p_idx) const {
|
|||
return String();
|
||||
}
|
||||
|
||||
void ResourceImporterBitMap::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterBitMap::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "create_from", PROPERTY_HINT_ENUM, "Black & White,Alpha"), 0));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.5));
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
ResourceImporterBitMap();
|
||||
|
|
|
@ -56,11 +56,11 @@ String ResourceImporterBMFont::get_resource_type() const {
|
|||
return "FontData";
|
||||
}
|
||||
|
||||
bool ResourceImporterBMFont::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterBMFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ResourceImporterBMFont::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterBMFont::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true));
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ public:
|
|||
virtual String get_save_extension() const override;
|
||||
virtual String get_resource_type() const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ String ResourceImporterCSVTranslation::get_resource_type() const {
|
|||
return "Translation";
|
||||
}
|
||||
|
||||
bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const {
|
|||
return "";
|
||||
}
|
||||
|
||||
void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterCSVTranslation::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "delimiter", PROPERTY_HINT_ENUM, "Comma,Semicolon,Tab"), 0));
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ String ResourceImporterDynamicFont::get_resource_type() const {
|
|||
return "FontData";
|
||||
}
|
||||
|
||||
bool ResourceImporterDynamicFont::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterDynamicFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
if (p_option == "msdf_pixel_range" && !bool(p_options["multichannel_signed_distance_field"])) {
|
||||
return false;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ String ResourceImporterDynamicFont::get_preset_name(int p_idx) const {
|
|||
}
|
||||
}
|
||||
|
||||
void ResourceImporterDynamicFont::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterDynamicFont::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
bool msdf = p_preset == PRESET_MSDF;
|
||||
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true));
|
||||
|
|
|
@ -57,8 +57,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
bool has_advanced_options() const override;
|
||||
void show_advanced_options(const String &p_path) override;
|
||||
|
|
|
@ -55,7 +55,7 @@ String ResourceImporterImage::get_resource_type() const {
|
|||
return "Image";
|
||||
}
|
||||
|
||||
bool ResourceImporterImage::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterImage::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ String ResourceImporterImage::get_preset_name(int p_idx) const {
|
|||
return String();
|
||||
}
|
||||
|
||||
void ResourceImporterImage::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterImage::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
}
|
||||
|
||||
Error ResourceImporterImage::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, Variant *r_metadata) {
|
||||
|
|
|
@ -47,8 +47,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
|
@ -55,11 +55,11 @@ String ResourceImporterImageFont::get_resource_type() const {
|
|||
return "FontData";
|
||||
}
|
||||
|
||||
bool ResourceImporterImageFont::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterImageFont::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ResourceImporterImageFont::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterImageFont::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "character_ranges"), Vector<String>()));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "columns"), 1));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "rows"), 1));
|
||||
|
|
|
@ -47,8 +47,8 @@ public:
|
|||
virtual String get_save_extension() const override;
|
||||
virtual String get_resource_type() const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ String ResourceImporterLayeredTexture::get_resource_type() const {
|
|||
ERR_FAIL_V(String());
|
||||
}
|
||||
|
||||
bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterLayeredTexture::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
if (p_option == "compress/lossy_quality" && p_options.has("compress/mode")) {
|
||||
return int(p_options["compress/mode"]) == COMPRESS_LOSSY;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const {
|
|||
return "";
|
||||
}
|
||||
|
||||
void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterLayeredTexture::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless (PNG),Lossy (WebP),Video RAM (S3TC/ETC/BPTC),Uncompressed,Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 1));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_compression", PROPERTY_HINT_ENUM, "Disabled,Opaque Only,Always"), 1));
|
||||
|
|
|
@ -84,8 +84,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
void _save_tex(Vector<Ref<Image>> p_images, const String &p_to_path, int p_compress_mode, float p_lossy, Image::CompressMode p_vram_compression, Image::CompressSource p_csource, Image::UsedChannels used_channels, bool p_mipmaps, bool p_force_po2);
|
||||
|
||||
|
|
|
@ -504,14 +504,14 @@ String ResourceImporterOBJ::get_preset_name(int p_idx) const {
|
|||
return "";
|
||||
}
|
||||
|
||||
void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterOBJ::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_tangents"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "scale_mesh"), Vector3(1, 1, 1)));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::VECTOR3, "offset_mesh"), Vector3(0, 0, 0)));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "optimize_mesh"), true));
|
||||
}
|
||||
|
||||
bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterOBJ::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
|
@ -91,6 +91,16 @@ Ref<Animation> EditorSceneFormatImporter::import_animation(const String &p_path,
|
|||
ERR_FAIL_V(nullptr);
|
||||
}
|
||||
|
||||
void EditorSceneFormatImporter::get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options) {
|
||||
GDVIRTUAL_CALL(_get_import_options, p_path);
|
||||
}
|
||||
|
||||
Variant EditorSceneFormatImporter::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) {
|
||||
Variant ret;
|
||||
GDVIRTUAL_CALL(_get_option_visibility, p_path, p_option, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//for documenters, these functions are useful when an importer calls an external conversion helper (like, fbx2gltf),
|
||||
//and you want to load the resulting file
|
||||
|
||||
|
@ -110,6 +120,8 @@ void EditorSceneFormatImporter::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_get_extensions);
|
||||
GDVIRTUAL_BIND(_import_scene, "path", "flags", "bake_fps");
|
||||
GDVIRTUAL_BIND(_import_animation, "path", "flags", "bake_fps");
|
||||
GDVIRTUAL_BIND(_get_import_options, "path");
|
||||
GDVIRTUAL_BIND(_get_option_visibility, "path", "option");
|
||||
|
||||
BIND_CONSTANT(IMPORT_SCENE);
|
||||
BIND_CONSTANT(IMPORT_ANIMATION);
|
||||
|
@ -193,15 +205,15 @@ void EditorScenePostImportPlugin::internal_process(InternalImportCategory p_cate
|
|||
current_options_dict = nullptr;
|
||||
}
|
||||
|
||||
void EditorScenePostImportPlugin::get_import_options(List<ResourceImporter::ImportOption> *r_options) {
|
||||
void EditorScenePostImportPlugin::get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options) {
|
||||
current_option_list = r_options;
|
||||
GDVIRTUAL_CALL(_get_import_options);
|
||||
GDVIRTUAL_CALL(_get_import_options, p_path);
|
||||
current_option_list = nullptr;
|
||||
}
|
||||
Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
Variant EditorScenePostImportPlugin::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
current_options = &p_options;
|
||||
Variant ret;
|
||||
GDVIRTUAL_CALL(_get_option_visibility, p_option, ret);
|
||||
GDVIRTUAL_CALL(_get_option_visibility, p_path, p_option, ret);
|
||||
current_options = nullptr;
|
||||
return ret;
|
||||
}
|
||||
|
@ -227,8 +239,8 @@ void EditorScenePostImportPlugin::_bind_methods() {
|
|||
GDVIRTUAL_BIND(_get_internal_option_visibility, "category", "option");
|
||||
GDVIRTUAL_BIND(_get_internal_option_update_view_required, "category", "option");
|
||||
GDVIRTUAL_BIND(_internal_process, "category", "base_node", "node", "resource");
|
||||
GDVIRTUAL_BIND(_get_import_options);
|
||||
GDVIRTUAL_BIND(_get_option_visibility, "option");
|
||||
GDVIRTUAL_BIND(_get_import_options, "path");
|
||||
GDVIRTUAL_BIND(_get_option_visibility, "path", "option");
|
||||
GDVIRTUAL_BIND(_pre_process, "scene");
|
||||
GDVIRTUAL_BIND(_post_process, "scene");
|
||||
|
||||
|
@ -269,7 +281,7 @@ int ResourceImporterScene::get_format_version() const {
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool ResourceImporterScene::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterScene::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
if (p_option.begins_with("animation/")) {
|
||||
if (p_option != "animation/import" && !bool(p_options["animation/import"])) {
|
||||
return false;
|
||||
|
@ -281,7 +293,14 @@ bool ResourceImporterScene::get_option_visibility(const String &p_option, const
|
|||
}
|
||||
|
||||
for (int i = 0; i < post_importer_plugins.size(); i++) {
|
||||
Variant ret = post_importer_plugins.write[i]->get_option_visibility(p_option, p_options);
|
||||
Variant ret = post_importer_plugins.write[i]->get_option_visibility(p_path, p_option, p_options);
|
||||
if (ret.get_type() == Variant::BOOL) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
for (Ref<EditorSceneFormatImporter> importer : importers) {
|
||||
Variant ret = importer->get_option_visibility(p_path, p_option, p_options);
|
||||
if (ret.get_type() == Variant::BOOL) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -1404,7 +1423,7 @@ bool ResourceImporterScene::get_internal_option_update_view_required(InternalImp
|
|||
return false;
|
||||
}
|
||||
|
||||
void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterScene::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Node3D"));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_name"), "Scene Root"));
|
||||
|
||||
|
@ -1434,7 +1453,11 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
|
|||
r_options->push_back(ImportOption(PropertyInfo(Variant::DICTIONARY, "_subresources", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), Dictionary()));
|
||||
|
||||
for (int i = 0; i < post_importer_plugins.size(); i++) {
|
||||
post_importer_plugins.write[i]->get_import_options(r_options);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ protected:
|
|||
GDVIRTUAL0RC(Vector<String>, _get_extensions)
|
||||
GDVIRTUAL3R(Object *, _import_scene, String, uint32_t, uint32_t)
|
||||
GDVIRTUAL3R(Ref<Animation>, _import_animation, String, uint32_t, uint32_t)
|
||||
GDVIRTUAL1(_get_import_options, String)
|
||||
GDVIRTUAL2RC(Variant, _get_option_visibility, String, String)
|
||||
|
||||
public:
|
||||
enum ImportFlags {
|
||||
|
@ -69,6 +71,8 @@ public:
|
|||
virtual void get_extensions(List<String> *r_extensions) const;
|
||||
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr);
|
||||
virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps);
|
||||
virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options);
|
||||
virtual Variant get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options);
|
||||
|
||||
EditorSceneFormatImporter() {}
|
||||
};
|
||||
|
@ -115,8 +119,8 @@ protected:
|
|||
GDVIRTUAL2RC(Variant, _get_internal_option_visibility, int, String)
|
||||
GDVIRTUAL2RC(Variant, _get_internal_option_update_view_required, int, String)
|
||||
GDVIRTUAL4(_internal_process, int, Node *, Node *, RES)
|
||||
GDVIRTUAL0(_get_import_options)
|
||||
GDVIRTUAL1RC(Variant, _get_option_visibility, String)
|
||||
GDVIRTUAL1(_get_import_options, String)
|
||||
GDVIRTUAL2RC(Variant, _get_option_visibility, String, String)
|
||||
GDVIRTUAL1(_pre_process, Node *)
|
||||
GDVIRTUAL1(_post_process, Node *)
|
||||
|
||||
|
@ -133,8 +137,8 @@ public:
|
|||
|
||||
virtual void internal_process(InternalImportCategory p_category, Node *p_base_scene, Node *p_node, RES p_resource, const Dictionary &p_options);
|
||||
|
||||
virtual void get_import_options(List<ResourceImporter::ImportOption> *r_options);
|
||||
virtual Variant get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
|
||||
virtual void get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options);
|
||||
virtual Variant get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const;
|
||||
|
||||
virtual void pre_process(Node *p_scene, const Map<StringName, Variant> &p_options);
|
||||
virtual void post_process(Node *p_scene, const Map<StringName, Variant> &p_options);
|
||||
|
@ -250,8 +254,8 @@ public:
|
|||
bool get_internal_option_visibility(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const;
|
||||
bool get_internal_option_update_view_required(InternalImportCategory p_category, const String &p_option, const Map<StringName, Variant> &p_options) const;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
// Import scenes *after* everything else (such as textures).
|
||||
virtual int get_import_order() const override { return ResourceImporter::IMPORT_ORDER_SCENE; }
|
||||
|
||||
|
|
|
@ -65,10 +65,10 @@ String ResourceImporterShaderFile::get_preset_name(int p_idx) const {
|
|||
return String();
|
||||
}
|
||||
|
||||
void ResourceImporterShaderFile::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterShaderFile::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
}
|
||||
|
||||
bool ResourceImporterShaderFile::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterShaderFile::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ String ResourceImporterTexture::get_resource_type() const {
|
|||
return "StreamTexture2D";
|
||||
}
|
||||
|
||||
bool ResourceImporterTexture::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterTexture::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
if (p_option == "compress/lossy_quality") {
|
||||
int compress_mode = int(p_options["compress/mode"]);
|
||||
if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VRAM_COMPRESSED) {
|
||||
|
@ -194,7 +194,7 @@ String ResourceImporterTexture::get_preset_name(int p_idx) const {
|
|||
return preset_names[p_idx];
|
||||
}
|
||||
|
||||
void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterTexture::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,VRAM Compressed,VRAM Uncompressed,Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_compression", PROPERTY_HINT_ENUM, "Disabled,Opaque Only,Always"), 1));
|
||||
|
|
|
@ -95,8 +95,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ String ResourceImporterTextureAtlas::get_resource_type() const {
|
|||
return "Texture2D";
|
||||
}
|
||||
|
||||
bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterTextureAtlas::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ String ResourceImporterTextureAtlas::get_preset_name(int p_idx) const {
|
|||
return String();
|
||||
}
|
||||
|
||||
void ResourceImporterTextureAtlas::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterTextureAtlas::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "atlas_file", PROPERTY_HINT_SAVE_FILE, "*.png"), ""));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_mode", PROPERTY_HINT_ENUM, "Region,Mesh2D"), 0));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "crop_to_region"), false));
|
||||
|
|
|
@ -60,8 +60,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual String get_option_group_file() const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
|
|
@ -58,7 +58,7 @@ String ResourceImporterWAV::get_resource_type() const {
|
|||
return "AudioStreamSample";
|
||||
}
|
||||
|
||||
bool ResourceImporterWAV::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterWAV::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
if (p_option == "force/max_rate_hz" && !bool(p_options["force/max_rate"])) {
|
||||
return false;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ String ResourceImporterWAV::get_preset_name(int p_idx) const {
|
|||
return String();
|
||||
}
|
||||
|
||||
void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterWAV::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/8_bit"), false));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/mono"), false));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
|
||||
|
|
|
@ -46,8 +46,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
static void _compress_ima_adpcm(const Vector<float> &p_data, Vector<uint8_t> &dst_data) {
|
||||
/*p_sample_data->data = (void*)malloc(len);
|
||||
|
|
|
@ -664,7 +664,7 @@ void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) {
|
|||
List<ResourceImporter::ImportOption> options;
|
||||
|
||||
if (scene_import_settings_data->category == ResourceImporterScene::INTERNAL_IMPORT_CATEGORY_MAX) {
|
||||
ResourceImporterScene::get_singleton()->get_import_options(&options);
|
||||
ResourceImporterScene::get_singleton()->get_import_options(base_path, &options);
|
||||
} else {
|
||||
ResourceImporterScene::get_singleton()->get_internal_import_options(scene_import_settings_data->category, &options);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ protected:
|
|||
return;
|
||||
}
|
||||
for (const PropertyInfo &E : properties) {
|
||||
if (importer->get_option_visibility(E.name, values)) {
|
||||
if (importer->get_option_visibility("", E.name, values)) {
|
||||
p_list->push_back(E);
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ void ImportDefaultsEditor::_update_importer() {
|
|||
|
||||
if (importer.is_valid()) {
|
||||
List<ResourceImporter::ImportOption> options;
|
||||
importer->get_import_options(&options);
|
||||
importer->get_import_options("", &options);
|
||||
Dictionary d;
|
||||
if (ProjectSettings::get_singleton()->has_setting("importer_defaults/" + importer->get_importer_name())) {
|
||||
d = ProjectSettings::get_singleton()->get("importer_defaults/" + importer->get_importer_name());
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
Vector<String> paths;
|
||||
Set<StringName> checked;
|
||||
bool checking;
|
||||
String base_options_path;
|
||||
|
||||
bool _set(const StringName &p_name, const Variant &p_value) {
|
||||
if (values.has(p_name)) {
|
||||
|
@ -66,7 +67,7 @@ public:
|
|||
}
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const {
|
||||
for (const PropertyInfo &E : properties) {
|
||||
if (!importer->get_option_visibility(E.name, values)) {
|
||||
if (!importer->get_option_visibility(base_options_path, E.name, values)) {
|
||||
continue;
|
||||
}
|
||||
PropertyInfo pi = E;
|
||||
|
@ -104,8 +105,9 @@ void ImportDock::set_edit_path(const String &p_path) {
|
|||
|
||||
params->paths.clear();
|
||||
params->paths.push_back(p_path);
|
||||
params->base_options_path = p_path;
|
||||
|
||||
_update_options(config);
|
||||
_update_options(p_path, config);
|
||||
|
||||
List<Ref<ResourceImporter>> importers;
|
||||
ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(), &importers);
|
||||
|
@ -146,17 +148,18 @@ void ImportDock::_add_keep_import_option(const String &p_importer_name) {
|
|||
}
|
||||
}
|
||||
|
||||
void ImportDock::_update_options(const Ref<ConfigFile> &p_config) {
|
||||
void ImportDock::_update_options(const String &p_path, const Ref<ConfigFile> &p_config) {
|
||||
List<ResourceImporter::ImportOption> options;
|
||||
|
||||
if (params->importer.is_valid()) {
|
||||
params->importer->get_import_options(&options);
|
||||
params->importer->get_import_options(p_path, &options);
|
||||
}
|
||||
|
||||
params->properties.clear();
|
||||
params->values.clear();
|
||||
params->checking = params->paths.size() > 1;
|
||||
params->checked.clear();
|
||||
params->base_options_path = p_path;
|
||||
|
||||
for (const ResourceImporter::ImportOption &E : options) {
|
||||
params->properties.push_back(E.option);
|
||||
|
@ -184,10 +187,12 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
|
|||
|
||||
// Use the value that is repeated the most.
|
||||
Map<String, Dictionary> value_frequency;
|
||||
Set<String> extensions;
|
||||
|
||||
for (int i = 0; i < p_paths.size(); i++) {
|
||||
Ref<ConfigFile> config;
|
||||
config.instantiate();
|
||||
extensions.insert(p_paths[i].get_extension());
|
||||
Error err = config->load(p_paths[i] + ".import");
|
||||
ERR_CONTINUE(err != OK);
|
||||
|
||||
|
@ -223,13 +228,18 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
|
|||
|
||||
ERR_FAIL_COND(params->importer.is_null());
|
||||
|
||||
String base_path;
|
||||
if (extensions.size() == 1 && p_paths.size() > 0) {
|
||||
base_path = p_paths[0];
|
||||
}
|
||||
List<ResourceImporter::ImportOption> options;
|
||||
params->importer->get_import_options(&options);
|
||||
params->importer->get_import_options(base_path, &options);
|
||||
|
||||
params->properties.clear();
|
||||
params->values.clear();
|
||||
params->checking = true;
|
||||
params->checked.clear();
|
||||
params->base_options_path = base_path;
|
||||
|
||||
for (const ResourceImporter::ImportOption &E : options) {
|
||||
params->properties.push_back(E.option);
|
||||
|
@ -327,22 +337,22 @@ void ImportDock::_importer_selected(int i_idx) {
|
|||
String name = import_as->get_selected_metadata();
|
||||
if (name == "keep") {
|
||||
params->importer.unref();
|
||||
_update_options(Ref<ConfigFile>());
|
||||
_update_options(params->base_options_path, Ref<ConfigFile>());
|
||||
} else {
|
||||
Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(name);
|
||||
ERR_FAIL_COND(importer.is_null());
|
||||
|
||||
params->importer = importer;
|
||||
|
||||
Ref<ConfigFile> config;
|
||||
if (params->paths.size()) {
|
||||
String path = params->paths[0];
|
||||
config.instantiate();
|
||||
Error err = config->load(params->paths[0] + ".import");
|
||||
Error err = config->load(path + ".import");
|
||||
if (err != OK) {
|
||||
config.unref();
|
||||
}
|
||||
}
|
||||
_update_options(config);
|
||||
_update_options(params->base_options_path, config);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +397,7 @@ void ImportDock::_preset_selected(int p_idx) {
|
|||
default: {
|
||||
List<ResourceImporter::ImportOption> options;
|
||||
|
||||
params->importer->get_import_options(&options, p_idx);
|
||||
params->importer->get_import_options(params->base_options_path, &options, p_idx);
|
||||
|
||||
if (params->checking) {
|
||||
params->checked.clear();
|
||||
|
|
|
@ -64,7 +64,7 @@ class ImportDock : public VBoxContainer {
|
|||
|
||||
void _preset_selected(int p_idx);
|
||||
void _importer_selected(int i_idx);
|
||||
void _update_options(const Ref<ConfigFile> &p_config = Ref<ConfigFile>());
|
||||
void _update_options(const String &p_path, const Ref<ConfigFile> &p_config = Ref<ConfigFile>());
|
||||
void _update_preset_menu();
|
||||
void _add_keep_import_option(const String &p_importer_name);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ String ResourceImporterMP3::get_resource_type() const {
|
|||
return "AudioStreamMP3";
|
||||
}
|
||||
|
||||
bool ResourceImporterMP3::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterMP3::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ String ResourceImporterMP3::get_preset_name(int p_idx) const {
|
|||
return String();
|
||||
}
|
||||
|
||||
void ResourceImporterMP3::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterMP3::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "loop_offset"), 0));
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ public:
|
|||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ String ResourceImporterOGGVorbis::get_resource_type() const {
|
|||
return "AudioStreamOGGVorbis";
|
||||
}
|
||||
|
||||
bool ResourceImporterOGGVorbis::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
bool ResourceImporterOGGVorbis::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ String ResourceImporterOGGVorbis::get_preset_name(int p_idx) const {
|
|||
return String();
|
||||
}
|
||||
|
||||
void ResourceImporterOGGVorbis::get_import_options(List<ImportOption> *r_options, int p_preset) const {
|
||||
void ResourceImporterOGGVorbis::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "loop_offset"), 0));
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public:
|
|||
virtual String get_visible_name() const override;
|
||||
virtual int get_preset_count() const override;
|
||||
virtual String get_preset_name(int p_idx) const override;
|
||||
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
virtual void get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset = 0) const override;
|
||||
virtual bool get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const override;
|
||||
|
||||
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 = nullptr, Variant *r_metadata = nullptr) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue