浏览代码

Property install export templates when downloaded from http
added a scale parameter for scene import

Juan Linietsky 7 年之前
父节点
当前提交
3de20641f5
共有 3 个文件被更改,包括 20 次插入6 次删除
  1. 13 5
      editor/export_template_manager.cpp
  2. 1 1
      editor/export_template_manager.h
  3. 6 0
      editor/import/resource_importer_scene.cpp

+ 13 - 5
editor/export_template_manager.cpp

@@ -176,7 +176,7 @@ void ExportTemplateManager::_uninstall_template_confirm() {
 	_update_template_list();
 	_update_template_list();
 }
 }
 
 
-void ExportTemplateManager::_install_from_file(const String &p_file) {
+void ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_progress) {
 
 
 	FileAccess *fa = NULL;
 	FileAccess *fa = NULL;
 	zlib_filefunc_def io = zipio_create_io_from_file(&fa);
 	zlib_filefunc_def io = zipio_create_io_from_file(&fa);
@@ -259,7 +259,10 @@ void ExportTemplateManager::_install_from_file(const String &p_file) {
 
 
 	ret = unzGoToFirstFile(pkg);
 	ret = unzGoToFirstFile(pkg);
 
 
-	EditorProgress p("ltask", TTR("Extracting Export Templates"), fc);
+	EditorProgress *p = NULL;
+	if (p_use_progress) {
+		p = memnew(EditorProgress("ltask", TTR("Extracting Export Templates"), fc));
+	}
 
 
 	fc = 0;
 	fc = 0;
 
 
@@ -288,8 +291,9 @@ void ExportTemplateManager::_install_from_file(const String &p_file) {
 		*/
 		*/
 
 
 		file = file.get_file();
 		file = file.get_file();
-
-		p.step(TTR("Importing:") + " " + file, fc);
+		if (p) {
+			p->step(TTR("Importing:") + " " + file, fc);
+		}
 
 
 		FileAccess *f = FileAccess::open(template_path.plus_file(file), FileAccess::WRITE);
 		FileAccess *f = FileAccess::open(template_path.plus_file(file), FileAccess::WRITE);
 
 
@@ -302,6 +306,10 @@ void ExportTemplateManager::_install_from_file(const String &p_file) {
 		fc++;
 		fc++;
 	}
 	}
 
 
+	if (p) {
+		memdelete(p);
+	}
+
 	unzClose(pkg);
 	unzClose(pkg);
 
 
 	_update_template_list();
 	_update_template_list();
@@ -405,7 +413,7 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int
 					memdelete(f);
 					memdelete(f);
 					template_list_state->set_text(TTR("Download Complete."));
 					template_list_state->set_text(TTR("Download Complete."));
 					template_downloader->hide();
 					template_downloader->hide();
-					_install_from_file(path);
+					_install_from_file(path, false);
 				}
 				}
 			}
 			}
 		} break;
 		} break;

+ 1 - 1
editor/export_template_manager.h

@@ -69,7 +69,7 @@ class ExportTemplateManager : public ConfirmationDialog {
 	void _uninstall_template_confirm();
 	void _uninstall_template_confirm();
 
 
 	virtual void ok_pressed();
 	virtual void ok_pressed();
-	void _install_from_file(const String &p_file);
+	void _install_from_file(const String &p_file, bool p_use_progress = true);
 
 
 	void _http_download_mirror_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
 	void _http_download_mirror_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
 	void _http_download_templates_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
 	void _http_download_templates_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);

+ 6 - 0
editor/import/resource_importer_scene.cpp

@@ -1037,6 +1037,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
 	bool scenes_out = p_preset == PRESET_MULTIPLE_SCENES || p_preset == PRESET_MULTIPLE_SCENES_AND_MATERIALS;
 	bool scenes_out = p_preset == PRESET_MULTIPLE_SCENES || p_preset == PRESET_MULTIPLE_SCENES_AND_MATERIALS;
 	bool animations_out = p_preset == PRESET_SEPARATE_ANIMATIONS || p_preset == PRESET_SEPARATE_MESHES_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MATERIALS_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS;
 	bool animations_out = p_preset == PRESET_SEPARATE_ANIMATIONS || p_preset == PRESET_SEPARATE_MESHES_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MATERIALS_AND_ANIMATIONS || p_preset == PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS;
 
 
+	r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0));
 	r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/custom_script", PROPERTY_HINT_FILE, script_ext_hint), ""));
 	r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/custom_script", PROPERTY_HINT_FILE, script_ext_hint), ""));
 	r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "nodes/storage", PROPERTY_HINT_ENUM, "Single Scene,Instanced Sub-Scenes"), scenes_out ? 1 : 0));
 	r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "nodes/storage", PROPERTY_HINT_ENUM, "Single Scene,Instanced Sub-Scenes"), scenes_out ? 1 : 0));
 	r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), (meshes_out || materials_out) ? 1 : 0));
 	r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), (meshes_out || materials_out) ? 1 : 0));
@@ -1209,6 +1210,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
 		}
 		}
 	}
 	}
 
 
+	if (Object::cast_to<Spatial>(scene)) {
+		float root_scale = p_options["nodes/root_scale"];
+		Object::cast_to<Spatial>(scene)->scale(Vector3(root_scale, root_scale, root_scale));
+	}
+
 	scene->set_name(p_options["nodes/root_name"]);
 	scene->set_name(p_options["nodes/root_name"]);
 
 
 	err = OK;
 	err = OK;