diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index a55ede7e418..d08a595fd2d 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -490,14 +490,24 @@ void EditorExportPlugin::add_shared_object(const String &p_path) { shared_objects.push_back(p_path); } -void EditorExportPlugin::_export_file_script(const String &p_path, const PoolVector &p_features) { +void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const PoolVector &p_features) { if (get_script_instance()) { - get_script_instance()->call("_export_file", p_path, p_features); + get_script_instance()->call("_export_file", p_path, p_type, p_features); } } -void EditorExportPlugin::_export_file(const String &p_path, const Set &p_features) { +void EditorExportPlugin::_export_begin_script(const PoolVector &p_features) { + + if (get_script_instance()) { + get_script_instance()->call("_export_begin", p_features); + } +} + +void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const Set &p_features) { +} + +void EditorExportPlugin::_export_begin(const Set &p_features) { } void EditorExportPlugin::skip() { @@ -511,7 +521,8 @@ void EditorExportPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file); ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip); - BIND_VMETHOD(MethodInfo("_export_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::POOL_STRING_ARRAY, "features"))); + BIND_VMETHOD(MethodInfo("_export_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "type"), PropertyInfo(Variant::POOL_STRING_ARRAY, "features"))); + BIND_VMETHOD(MethodInfo("_export_begin", PropertyInfo(Variant::POOL_STRING_ARRAY, "features"))); } EditorExportPlugin::EditorExportPlugin() { @@ -555,6 +566,25 @@ Error EditorExportPlatform::export_project_files(const Ref & _edit_filter_list(paths, p_preset->get_include_filter(), false); _edit_filter_list(paths, p_preset->get_exclude_filter(), true); + //initial export plugin callback + for (int i = 0; i < export_plugins.size(); i++) { + if (export_plugins[i]->get_script_instance()) { //script based + export_plugins[i]->_export_begin_script(features_pv); + } else { + export_plugins[i]->_export_begin(features); + } + if (p_so_func) { + for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { + p_so_func(p_udata, export_plugins[i]->shared_objects[j]); + } + } + for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { + p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size()); + } + + export_plugins[i]->_clear(); + } + //store everything in the export medium int idx = 0; int total = paths.size(); @@ -562,6 +592,7 @@ Error EditorExportPlatform::export_project_files(const Ref & for (Set::Element *E = paths.front(); E; E = E->next()) { String path = E->get(); + String type = ResourceLoader::get_resource_type(path); if (FileAccess::exists(path + ".import")) { //file is imported, replace by what it imports @@ -602,9 +633,9 @@ Error EditorExportPlatform::export_project_files(const Ref & bool do_export = true; for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based - export_plugins[i]->_export_file_script(path, features_pv); + export_plugins[i]->_export_file_script(path, type, features_pv); } else { - export_plugins[i]->_export_file(path, features); + export_plugins[i]->_export_file(path, type, features); } if (p_so_func) { for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { diff --git a/editor/editor_export.h b/editor/editor_export.h index 6b8164681f5..b6ea4fd889f 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -240,14 +240,16 @@ class EditorExportPlugin : public Reference { skipped = false; } - void _export_file_script(const String &p_path, const PoolVector &p_features); + void _export_file_script(const String &p_path, const String &p_type, const PoolVector &p_features); + void _export_begin_script(const PoolVector &p_features); protected: void add_file(const String &p_path, const Vector &p_file, bool p_remap); void add_shared_object(const String &p_path); void skip(); - virtual void _export_file(const String &p_path, const Set &p_features); + virtual void _export_file(const String &p_path, const String &p_type, const Set &p_features); + virtual void _export_begin(const Set &p_features); static void _bind_methods();