| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  editor_sub_scene.cpp                                                 */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							| 
									
										
										
										
											2017-08-27 14:16:55 +02:00
										 |  |  | /*                      https://godotengine.org                          */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2021-01-01 20:13:46 +01:00
										 |  |  | /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md).   */ | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the       */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including   */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,   */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to    */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to */ | 
					
						
							|  |  |  | /* the following conditions:                                             */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be        */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.       */ | 
					
						
							|  |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2018-01-05 00:50:27 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #include "editor_sub_scene.h"
 | 
					
						
							| 
									
										
										
										
											2017-01-16 08:04:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-02 16:40:51 -05:00
										 |  |  | #include "editor/editor_node.h"
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #include "scene/gui/margin_container.h"
 | 
					
						
							|  |  |  | #include "scene/resources/packed_scene.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void EditorSubScene::_path_selected(const String &p_path) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	path->set_text(p_path); | 
					
						
							|  |  |  | 	_path_changed(p_path); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void EditorSubScene::_path_changed(const String &p_path) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	tree->clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (scene) { | 
					
						
							|  |  |  | 		memdelete(scene); | 
					
						
							| 
									
										
										
										
											2021-05-04 16:00:45 +02:00
										 |  |  | 		scene = nullptr; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 	if (p_path == "") { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	Ref<PackedScene> ps = ResourceLoader::load(p_path, "PackedScene"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 	if (ps.is_null()) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	scene = ps->instance(); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 	if (!scene) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-04 16:00:45 +02:00
										 |  |  | 	_fill_tree(scene, nullptr); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorSubScene::_path_browse() { | 
					
						
							|  |  |  | 	file_dialog->popup_centered_ratio(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorSubScene::_notification(int p_what) { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		if (is_visible() && scene == nullptr) { | 
					
						
							| 
									
										
										
										
											2019-04-22 11:29:45 +10:00
										 |  |  | 			_path_browse(); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void EditorSubScene::_fill_tree(Node *p_node, TreeItem *p_parent) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	TreeItem *it = tree->create_item(p_parent); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	it->set_metadata(0, p_node); | 
					
						
							|  |  |  | 	it->set_text(0, p_node->get_name()); | 
					
						
							|  |  |  | 	it->set_editable(0, false); | 
					
						
							|  |  |  | 	it->set_selectable(0, true); | 
					
						
							| 
									
										
										
										
											2018-09-02 16:40:51 -05:00
										 |  |  | 	it->set_icon(0, EditorNode::get_singleton()->get_object_icon(p_node, "Node")); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (int i = 0; i < p_node->get_child_count(); i++) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		Node *c = p_node->get_child(i); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		if (c->get_owner() != scene) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 		_fill_tree(c, it); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | void EditorSubScene::_selected_changed() { | 
					
						
							| 
									
										
										
										
											2019-10-08 19:21:11 -07:00
										 |  |  | 	TreeItem *item = tree->get_selected(); | 
					
						
							|  |  |  | 	ERR_FAIL_COND(!item); | 
					
						
							|  |  |  | 	Node *n = item->get_metadata(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!n || !selection.find(n)) { | 
					
						
							|  |  |  | 		selection.clear(); | 
					
						
							|  |  |  | 		is_root = false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | void EditorSubScene::_item_multi_selected(Object *p_object, int p_cell, bool p_selected) { | 
					
						
							|  |  |  | 	if (!is_root) { | 
					
						
							|  |  |  | 		TreeItem *item = Object::cast_to<TreeItem>(p_object); | 
					
						
							|  |  |  | 		ERR_FAIL_COND(!item); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Node *n = item->get_metadata(0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		if (!n) { | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 		if (p_selected) { | 
					
						
							|  |  |  | 			if (n == scene) { | 
					
						
							|  |  |  | 				is_root = true; | 
					
						
							|  |  |  | 				selection.clear(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			selection.push_back(n); | 
					
						
							| 
									
										
										
										
											2019-10-08 19:21:11 -07:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			List<Node *>::Element *E = selection.find(n); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 			if (E) { | 
					
						
							| 
									
										
										
										
											2019-10-08 19:21:11 -07:00
										 |  |  | 				selection.erase(E); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-01 09:57:10 +01:00
										 |  |  | void EditorSubScene::_remove_selection_child(Node *p_node) { | 
					
						
							|  |  |  | 	if (p_node->get_child_count() > 0) { | 
					
						
							|  |  |  | 		for (int i = 0; i < p_node->get_child_count(); i++) { | 
					
						
							|  |  |  | 			Node *c = p_node->get_child(i); | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 			List<Node *>::Element *E = selection.find(c); | 
					
						
							|  |  |  | 			if (E) { | 
					
						
							|  |  |  | 				selection.move_to_back(E); | 
					
						
							|  |  |  | 				selection.pop_back(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (c->get_child_count() > 0) { | 
					
						
							|  |  |  | 				_remove_selection_child(c); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorSubScene::ok_pressed() { | 
					
						
							|  |  |  | 	if (selection.size() <= 0) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 		Node *c = E->get(); | 
					
						
							|  |  |  | 		_remove_selection_child(c); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	emit_signal("subscene_selected"); | 
					
						
							|  |  |  | 	hide(); | 
					
						
							|  |  |  | 	clear(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) { | 
					
						
							|  |  |  | 	if (p_node == scene) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		scene->set_filename(""); | 
					
						
							|  |  |  | 		p_to_reown->push_back(p_node); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	} else if (p_node->get_owner() == scene) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		p_to_reown->push_back(p_node); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (int i = 0; i < p_node->get_child_count(); i++) { | 
					
						
							|  |  |  | 		Node *c = p_node->get_child(i); | 
					
						
							|  |  |  | 		_reown(c, p_to_reown); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	if (!scene) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 	if (selection.size() <= 0) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 	for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 		Node *selnode = E->get(); | 
					
						
							|  |  |  | 		if (!selnode) { | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		List<Node *> to_reown; | 
					
						
							|  |  |  | 		_reown(selnode, &to_reown); | 
					
						
							|  |  |  | 		if (selnode != scene) { | 
					
						
							|  |  |  | 			selnode->get_parent()->remove_child(selnode); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 		p_new_parent->add_child(selnode); | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 		for (List<Node *>::Element *F = to_reown.front(); F; F = F->next()) { | 
					
						
							|  |  |  | 			F->get()->set_owner(p_new_owner); | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 	if (!is_root) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		memdelete(scene); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-05-04 16:00:45 +02:00
										 |  |  | 	scene = nullptr; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	//return selnode;
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorSubScene::clear() { | 
					
						
							|  |  |  | 	path->set_text(""); | 
					
						
							|  |  |  | 	_path_changed(""); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorSubScene::_bind_methods() { | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("_path_selected"), &EditorSubScene::_path_selected); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("_path_changed"), &EditorSubScene::_path_changed); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("_path_browse"), &EditorSubScene::_path_browse); | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 	ClassDB::bind_method(D_METHOD("_item_multi_selected"), &EditorSubScene::_item_multi_selected); | 
					
						
							|  |  |  | 	ClassDB::bind_method(D_METHOD("_selected_changed"), &EditorSubScene::_selected_changed); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ADD_SIGNAL(MethodInfo("subscene_selected")); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | EditorSubScene::EditorSubScene() { | 
					
						
							| 
									
										
										
										
											2021-05-04 16:00:45 +02:00
										 |  |  | 	scene = nullptr; | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 	is_root = false; | 
					
						
							| 
									
										
										
										
											2015-12-14 08:43:56 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-19 00:08:12 +02:00
										 |  |  | 	set_title(TTR("Select Node(s) to Import")); | 
					
						
							| 
									
										
										
										
											2015-12-14 08:43:56 -03:00
										 |  |  | 	set_hide_on_ok(false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	VBoxContainer *vb = memnew(VBoxContainer); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	add_child(vb); | 
					
						
							| 
									
										
										
										
											2017-01-14 12:26:56 +01:00
										 |  |  | 	//set_child_rect(vb);
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	HBoxContainer *hb = memnew(HBoxContainer); | 
					
						
							|  |  |  | 	path = memnew(LineEdit); | 
					
						
							|  |  |  | 	path->connect("text_entered", this, "_path_changed"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	hb->add_child(path); | 
					
						
							|  |  |  | 	path->set_h_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	Button *b = memnew(Button); | 
					
						
							| 
									
										
										
										
											2019-04-22 11:29:45 +10:00
										 |  |  | 	b->set_text(TTR("Browse")); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	hb->add_child(b); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	b->connect("pressed", this, "_path_browse"); | 
					
						
							|  |  |  | 	vb->add_margin_child(TTR("Scene Path:"), hb); | 
					
						
							| 
									
										
										
										
											2015-12-14 08:43:56 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	tree = memnew(Tree); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	tree->set_v_size_flags(SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	vb->add_margin_child(TTR("Import From Node:"), tree, true); | 
					
						
							| 
									
										
										
										
											2017-12-12 20:55:16 +08:00
										 |  |  | 	tree->set_select_mode(Tree::SELECT_MULTI); | 
					
						
							|  |  |  | 	tree->connect("multi_selected", this, "_item_multi_selected"); | 
					
						
							|  |  |  | 	//tree->connect("nothing_selected", this, "_deselect_items");
 | 
					
						
							|  |  |  | 	tree->connect("cell_selected", this, "_selected_changed"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	tree->connect("item_activated", this, "_ok", make_binds(), CONNECT_DEFERRED); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	file_dialog = memnew(EditorFileDialog); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	List<String> extensions; | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	for (List<String>::Element *E = extensions.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 		file_dialog->add_filter("*." + E->get()); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-06 09:44:38 -03:00
										 |  |  | 	file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	add_child(file_dialog); | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | 	file_dialog->connect("file_selected", this, "_path_selected"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } |