| 
									
										
										
										
											2019-01-01 12:46:36 +01:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  editor_folding.cpp                                                   */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							|  |  |  | /*                      https://godotengine.org                          */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											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).   */ | 
					
						
							| 
									
										
										
										
											2019-01-01 12:46:36 +01: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-10-29 16:36:31 -03:00
										 |  |  | #include "editor_folding.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-29 17:38:51 -03:00
										 |  |  | #include "core/os/file_access.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | #include "editor_inspector.h"
 | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | #include "editor_settings.h"
 | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | Vector<String> EditorFolding::_get_unfolds(const Object *p_object) { | 
					
						
							|  |  |  | 	Vector<String> sections; | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 	sections.resize(p_object->editor_get_section_folding().size()); | 
					
						
							|  |  |  | 	if (sections.size()) { | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | 		String *w = sections.ptrw(); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 		int idx = 0; | 
					
						
							|  |  |  | 		for (const Set<String>::Element *E = p_object->editor_get_section_folding().front(); E; E = E->next()) { | 
					
						
							|  |  |  | 			w[idx++] = E->get(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return sections; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorFolding::save_resource_folding(const RES &p_resource, const String &p_path) { | 
					
						
							|  |  |  | 	Ref<ConfigFile> config; | 
					
						
							|  |  |  | 	config.instance(); | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | 	Vector<String> unfolds = _get_unfolds(p_resource.ptr()); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 	config->set_value("folding", "sections_unfolded", unfolds); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; | 
					
						
							|  |  |  | 	file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file); | 
					
						
							|  |  |  | 	config->save(file); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | void EditorFolding::_set_unfolds(Object *p_object, const Vector<String> &p_unfolds) { | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 	int uc = p_unfolds.size(); | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | 	const String *r = p_unfolds.ptr(); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 	p_object->editor_clear_section_folding(); | 
					
						
							|  |  |  | 	for (int i = 0; i < uc; i++) { | 
					
						
							|  |  |  | 		p_object->editor_set_section_unfold(r[i], true); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorFolding::load_resource_folding(RES p_resource, const String &p_path) { | 
					
						
							|  |  |  | 	Ref<ConfigFile> config; | 
					
						
							|  |  |  | 	config.instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; | 
					
						
							|  |  |  | 	file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (config->load(file) != OK) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | 	Vector<String> unfolds; | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (config->has_section_key("folding", "sections_unfolded")) { | 
					
						
							|  |  |  | 		unfolds = config->get_value("folding", "sections_unfolded"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	_set_unfolds(p_resource.ptr(), unfolds); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-20 13:51:51 +02:00
										 |  |  | void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, Set<RES> &resources) { | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 	if (p_root != p_node) { | 
					
						
							|  |  |  | 		if (!p_node->get_owner()) { | 
					
						
							|  |  |  | 			return; //not owned, bye
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (p_node->get_owner() != p_root && !p_root->is_editable_instance(p_node)) { | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-11 14:35:23 -03:00
										 |  |  | 	if (p_node->is_displayed_folded()) { | 
					
						
							|  |  |  | 		nodes_folded.push_back(p_root->get_path_to(p_node)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | 	Vector<String> unfolds = _get_unfolds(p_node); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (unfolds.size()) { | 
					
						
							|  |  |  | 		p_folds.push_back(p_root->get_path_to(p_node)); | 
					
						
							|  |  |  | 		p_folds.push_back(unfolds); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	List<PropertyInfo> plist; | 
					
						
							|  |  |  | 	p_node->get_property_list(&plist); | 
					
						
							|  |  |  | 	for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { | 
					
						
							| 
									
										
										
										
											2019-04-10 12:11:14 +02:00
										 |  |  | 		if (E->get().usage & PROPERTY_USAGE_EDITOR) { | 
					
						
							|  |  |  | 			if (E->get().type == Variant::OBJECT) { | 
					
						
							|  |  |  | 				RES res = p_node->get(E->get().name); | 
					
						
							|  |  |  | 				if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | 					Vector<String> res_unfolds = _get_unfolds(res.ptr()); | 
					
						
							| 
									
										
										
										
											2019-04-10 12:11:14 +02:00
										 |  |  | 					resource_folds.push_back(res->get_path()); | 
					
						
							|  |  |  | 					resource_folds.push_back(res_unfolds); | 
					
						
							|  |  |  | 					resources.insert(res); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (int i = 0; i < p_node->get_child_count(); i++) { | 
					
						
							| 
									
										
										
										
											2019-05-20 13:51:51 +02:00
										 |  |  | 		_fill_folds(p_root, p_node->get_child(i), p_folds, resource_folds, nodes_folded, resources); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-14 14:29:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) { | 
					
						
							| 
									
										
										
										
											2020-03-05 16:12:41 +05:30
										 |  |  | 	ERR_FAIL_NULL(p_scene); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-12 14:09:58 +01:00
										 |  |  | 	FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!file_check->file_exists(p_path)) { //This can happen when creating scene from FilesystemDock. It has path, but no file.
 | 
					
						
							| 
									
										
										
										
											2019-11-12 14:09:58 +01:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-11-12 14:09:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 	Ref<ConfigFile> config; | 
					
						
							|  |  |  | 	config.instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Array unfolds, res_unfolds; | 
					
						
							|  |  |  | 	Set<RES> resources; | 
					
						
							| 
									
										
										
										
											2019-04-11 14:35:23 -03:00
										 |  |  | 	Array nodes_folded; | 
					
						
							|  |  |  | 	_fill_folds(p_scene, p_scene, unfolds, res_unfolds, nodes_folded, resources); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	config->set_value("folding", "node_unfolds", unfolds); | 
					
						
							|  |  |  | 	config->set_value("folding", "resource_unfolds", res_unfolds); | 
					
						
							| 
									
										
										
										
											2019-04-11 14:35:23 -03:00
										 |  |  | 	config->set_value("folding", "nodes_folded", nodes_folded); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; | 
					
						
							|  |  |  | 	file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file); | 
					
						
							|  |  |  | 	config->save(file); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-05-14 14:29:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) { | 
					
						
							|  |  |  | 	Ref<ConfigFile> config; | 
					
						
							|  |  |  | 	config.instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	String path = EditorSettings::get_singleton()->get_project_settings_dir(); | 
					
						
							|  |  |  | 	String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; | 
					
						
							|  |  |  | 	file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (config->load(file) != OK) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Array unfolds; | 
					
						
							|  |  |  | 	if (config->has_section_key("folding", "node_unfolds")) { | 
					
						
							|  |  |  | 		unfolds = config->get_value("folding", "node_unfolds"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	Array res_unfolds; | 
					
						
							|  |  |  | 	if (config->has_section_key("folding", "resource_unfolds")) { | 
					
						
							|  |  |  | 		res_unfolds = config->get_value("folding", "resource_unfolds"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-04-11 14:35:23 -03:00
										 |  |  | 	Array nodes_folded; | 
					
						
							|  |  |  | 	if (config->has_section_key("folding", "nodes_folded")) { | 
					
						
							|  |  |  | 		nodes_folded = config->get_value("folding", "nodes_folded"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ERR_FAIL_COND(unfolds.size() & 1); | 
					
						
							|  |  |  | 	ERR_FAIL_COND(res_unfolds.size() & 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (int i = 0; i < unfolds.size(); i += 2) { | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 		NodePath path2 = unfolds[i]; | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | 		Vector<String> un = unfolds[i + 1]; | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 		Node *node = p_scene->get_node_or_null(path2); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 		if (!node) { | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		_set_unfolds(node, un); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (int i = 0; i < res_unfolds.size(); i += 2) { | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 		String path2 = res_unfolds[i]; | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 		RES res; | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 		if (ResourceCache::has(path2)) { | 
					
						
							|  |  |  | 			res = RES(ResourceCache::get(path2)); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if (res.is_null()) { | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-17 18:06:54 -03:00
										 |  |  | 		Vector<String> unfolds2 = res_unfolds[i + 1]; | 
					
						
							| 
									
										
										
										
											2019-02-12 21:10:08 +01:00
										 |  |  | 		_set_unfolds(res.ptr(), unfolds2); | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-04-11 14:35:23 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-20 13:51:51 +02:00
										 |  |  | 	for (int i = 0; i < nodes_folded.size(); i++) { | 
					
						
							| 
									
										
										
										
											2019-04-11 14:35:23 -03:00
										 |  |  | 		NodePath fold_path = nodes_folded[i]; | 
					
						
							|  |  |  | 		if (p_scene->has_node(fold_path)) { | 
					
						
							|  |  |  | 			Node *node = p_scene->get_node(fold_path); | 
					
						
							|  |  |  | 			node->set_display_folded(true); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-29 17:38:51 -03:00
										 |  |  | bool EditorFolding::has_folding_data(const String &p_path) { | 
					
						
							|  |  |  | 	String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; | 
					
						
							|  |  |  | 	file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file); | 
					
						
							|  |  |  | 	return FileAccess::exists(file); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | void EditorFolding::_do_object_unfolds(Object *p_object, Set<RES> &resources) { | 
					
						
							|  |  |  | 	List<PropertyInfo> plist; | 
					
						
							|  |  |  | 	p_object->get_property_list(&plist); | 
					
						
							|  |  |  | 	String group_base; | 
					
						
							|  |  |  | 	String group; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Set<String> unfold_group; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 		if (E->get().usage & PROPERTY_USAGE_CATEGORY) { | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | 			group = ""; | 
					
						
							|  |  |  | 			group_base = ""; | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		if (E->get().usage & PROPERTY_USAGE_GROUP) { | 
					
						
							|  |  |  | 			group = E->get().name; | 
					
						
							|  |  |  | 			group_base = E->get().hint_string; | 
					
						
							|  |  |  | 			if (group_base.ends_with("_")) { | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | 				group_base = group_base.substr(0, group_base.length() - 1); | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		//can unfold
 | 
					
						
							|  |  |  | 		if (E->get().usage & PROPERTY_USAGE_EDITOR) { | 
					
						
							|  |  |  | 			if (group != "") { //group
 | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | 				if (group_base == String() || E->get().name.begins_with(group_base)) { | 
					
						
							|  |  |  | 					bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); | 
					
						
							|  |  |  | 					if (can_revert) { | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | 						unfold_group.insert(group); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} else { //path
 | 
					
						
							| 
									
										
										
										
											2020-07-03 15:26:22 +02:00
										 |  |  | 				int last = E->get().name.rfind("/"); | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | 				if (last != -1) { | 
					
						
							|  |  |  | 					bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E->get().name); | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | 					if (can_revert) { | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | 						unfold_group.insert(E->get().name.substr(0, last)); | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-11 14:18:45 -03:00
										 |  |  | 			if (E->get().type == Variant::OBJECT) { | 
					
						
							|  |  |  | 				RES res = p_object->get(E->get().name); | 
					
						
							|  |  |  | 				print_line("res: " + String(E->get().name) + " valid " + itos(res.is_valid())); | 
					
						
							|  |  |  | 				if (res.is_valid()) { | 
					
						
							|  |  |  | 					print_line("path " + res->get_path()); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				if (res.is_valid() && !resources.has(res) && res->get_path() != String() && !res->get_path().is_resource_file()) { | 
					
						
							|  |  |  | 					resources.insert(res); | 
					
						
							|  |  |  | 					_do_object_unfolds(res.ptr(), resources); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | 	for (Set<String>::Element *E = unfold_group.front(); E; E = E->next()) { | 
					
						
							|  |  |  | 		p_object->editor_set_section_unfold(E->get(), true); | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorFolding::_do_node_unfolds(Node *p_root, Node *p_node, Set<RES> &resources) { | 
					
						
							|  |  |  | 	if (p_root != p_node) { | 
					
						
							|  |  |  | 		if (!p_node->get_owner()) { | 
					
						
							|  |  |  | 			return; //not owned, bye
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (p_node->get_owner() != p_root && !p_root->is_editable_instance(p_node)) { | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | 	_do_object_unfolds(p_node, resources); | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for (int i = 0; i < p_node->get_child_count(); i++) { | 
					
						
							|  |  |  | 		_do_node_unfolds(p_root, p_node->get_child(i), resources); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorFolding::unfold_scene(Node *p_scene) { | 
					
						
							|  |  |  | 	Set<RES> resources; | 
					
						
							| 
									
										
										
										
											2018-11-28 10:21:07 +01:00
										 |  |  | 	_do_node_unfolds(p_scene, p_scene, resources); | 
					
						
							| 
									
										
										
										
											2018-11-25 10:46:26 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-29 16:36:31 -03:00
										 |  |  | EditorFolding::EditorFolding() { | 
					
						
							|  |  |  | } |