Browse Source

Added type on export file callback, and initial export function.

Juan Linietsky 8 years ago
parent
commit
25f742cc3d
2 changed files with 41 additions and 8 deletions
  1. 37 6
      editor/editor_export.cpp
  2. 4 2
      editor/editor_export.h

+ 37 - 6
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<String> &p_features) {
+void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const PoolVector<String> &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<String> &p_features) {
+void EditorExportPlugin::_export_begin_script(const PoolVector<String> &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<String> &p_features) {
+}
+
+void EditorExportPlugin::_export_begin(const Set<String> &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<EditorExportPreset> &
 	_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<EditorExportPreset> &
 	for (Set<String>::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<EditorExportPreset> &
 			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++) {

+ 4 - 2
editor/editor_export.h

@@ -240,14 +240,16 @@ class EditorExportPlugin : public Reference {
 		skipped = false;
 	}
 
-	void _export_file_script(const String &p_path, const PoolVector<String> &p_features);
+	void _export_file_script(const String &p_path, const String &p_type, const PoolVector<String> &p_features);
+	void _export_begin_script(const PoolVector<String> &p_features);
 
 protected:
 	void add_file(const String &p_path, const Vector<uint8_t> &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<String> &p_features);
+	virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features);
+	virtual void _export_begin(const Set<String> &p_features);
 
 	static void _bind_methods();