diff options
Diffstat (limited to 'editor/export/editor_export_platform.cpp')
-rw-r--r-- | editor/export/editor_export_platform.cpp | 191 |
1 files changed, 89 insertions, 102 deletions
diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 527544fea3..c0646dc572 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -797,10 +797,6 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector if (!customize_scenes_plugins.is_empty()) { for (Ref<EditorExportPlugin> &plugin : customize_scenes_plugins) { Node *customized = plugin->_customize_scene(node, p_path); - if (plugin->skipped) { - plugin->_clear(); - return String(); - } if (customized != nullptr) { node = customized; modified = true; @@ -834,10 +830,6 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector if (!customize_resources_plugins.is_empty()) { for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) { Ref<Resource> new_res = plugin->_customize_resource(res, p_path); - if (plugin->skipped) { - plugin->_clear(); - return String(); - } if (new_res.is_valid()) { modified = true; if (new_res != res) { @@ -1132,33 +1124,97 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } //store everything in the export medium - int idx = 0; int total = paths.size(); + // idx is incremented at the beginning of the paths loop to easily allow + // for continue statements without accidentally skipping an increment. + int idx = total > 0 ? -1 : 0; for (const String &E : paths) { + idx++; String path = E; String type = ResourceLoader::get_resource_type(path); - if (FileAccess::exists(path + ".import")) { - // Before doing this, try to see if it can be customized. + bool has_import_file = FileAccess::exists(path + ".import"); + Ref<ConfigFile> config; + if (has_import_file) { + config.instantiate(); + err = config->load(path + ".import"); + if (err != OK) { + ERR_PRINT("Could not parse: '" + path + "', not exported."); + continue; + } + + String importer_type = config->get_value("remap", "importer"); + + if (importer_type == "skip") { + // Skip file. + continue; + } + } + + bool do_export = true; + for (int i = 0; i < export_plugins.size(); i++) { + if (GDVIRTUAL_IS_OVERRIDDEN_PTR(export_plugins[i], _export_file)) { + export_plugins.write[i]->_export_file_script(path, type, features_psa); + } else { + export_plugins.write[i]->_export_file(path, type, features); + } + if (p_so_func) { + for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { + err = p_so_func(p_udata, export_plugins[i]->shared_objects[j]); + if (err != OK) { + return err; + } + } + } + + for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { + err = p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; + } + if (export_plugins[i]->extra_files[j].remap) { + do_export = false; // If remap, do not. + path_remaps.push_back(path); + path_remaps.push_back(export_plugins[i]->extra_files[j].path); + } + } + + if (export_plugins[i]->skipped) { + do_export = false; + } + export_plugins.write[i]->_clear(); + + if (!do_export) { + break; + } + } + if (!do_export) { + continue; + } + + if (has_import_file) { + String importer_type = config->get_value("remap", "importer"); + + if (importer_type == "keep") { + // Just keep file as-is. + Vector<uint8_t> array = FileAccess::get_file_as_bytes(path); + err = p_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key); + + if (err != OK) { + return err; + } - String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, false); - if (export_path.is_empty()) { - // Skipped from plugin. continue; } + // Before doing this, try to see if it can be customized. + String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, false); + if (export_path != path) { // It was actually customized. // Since the original file is likely not recognized, just use the import system. - Ref<ConfigFile> config; - config.instantiate(); - err = config->load(path + ".import"); - if (err != OK) { - ERR_PRINT("Could not parse: '" + path + "', not exported."); - continue; - } config->set_value("remap", "type", ResourceLoader::get_resource_type(export_path)); // Erase all Paths. @@ -1194,33 +1250,6 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } else { // File is imported and not customized, replace by what it imports. - Ref<ConfigFile> config; - config.instantiate(); - err = config->load(path + ".import"); - if (err != OK) { - ERR_PRINT("Could not parse: '" + path + "', not exported."); - continue; - } - - String importer_type = config->get_value("remap", "importer"); - - if (importer_type == "skip") { - // Skip file. - continue; - } - - if (importer_type == "keep") { - // Just keep file as-is. - Vector<uint8_t> array = FileAccess::get_file_as_bytes(path); - err = p_func(p_udata, path, array, idx, total, enc_in_filters, enc_ex_filters, key); - - if (err != OK) { - return err; - } - - continue; - } - List<String> remaps; config->get_section_keys("remap", &remaps); @@ -1282,66 +1311,24 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } else { - // Customize. + // Just store it as it comes. - bool do_export = true; - for (int i = 0; i < export_plugins.size(); i++) { - if (GDVIRTUAL_IS_OVERRIDDEN_PTR(export_plugins[i], _export_file)) { - export_plugins.write[i]->_export_file_script(path, type, features_psa); - } else { - export_plugins.write[i]->_export_file(path, type, features); - } - if (p_so_func) { - for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { - err = p_so_func(p_udata, export_plugins[i]->shared_objects[j]); - if (err != OK) { - return err; - } - } - } - - for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { - err = p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total, enc_in_filters, enc_ex_filters, key); - if (err != OK) { - return err; - } - if (export_plugins[i]->extra_files[j].remap) { - do_export = false; //if remap, do not - path_remaps.push_back(path); - path_remaps.push_back(export_plugins[i]->extra_files[j].path); - } - } + // Customization only happens if plugins did not take care of it before. + bool force_binary = convert_text_to_binary && (path.get_extension().to_lower() == "tres" || path.get_extension().to_lower() == "tscn"); + String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, force_binary); - if (export_plugins[i]->skipped) { - do_export = false; - } - export_plugins.write[i]->_clear(); - - if (!do_export) { - break; //apologies, not exporting - } + if (export_path != path) { + // Add a remap entry. + path_remaps.push_back(path); + path_remaps.push_back(export_path); } - //just store it as it comes - if (do_export) { - // Customization only happens if plugins did not take care of it before - bool force_binary = convert_text_to_binary && (path.get_extension().to_lower() == "tres" || path.get_extension().to_lower() == "tscn"); - String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, force_binary); - - if (export_path != path) { - // Add a remap entry - path_remaps.push_back(path); - path_remaps.push_back(export_path); - } - Vector<uint8_t> array = FileAccess::get_file_as_bytes(export_path); - err = p_func(p_udata, export_path, array, idx, total, enc_in_filters, enc_ex_filters, key); - if (err != OK) { - return err; - } + Vector<uint8_t> array = FileAccess::get_file_as_bytes(export_path); + err = p_func(p_udata, export_path, array, idx, total, enc_in_filters, enc_ex_filters, key); + if (err != OK) { + return err; } } - - idx++; } if (convert_text_to_binary || !customize_resources_plugins.is_empty() || !customize_scenes_plugins.is_empty()) { |