Fix #8819. Adds _import_node() that, when used in conjunction with _import_scene, recurses through the scene tree and exports all available nodes.

This commit is contained in:
Jon Ross 2017-05-18 15:23:51 -07:00
parent 06f77f941b
commit 4ed2722589
2 changed files with 17 additions and 14 deletions

View File

@ -35,23 +35,18 @@ void TileSetEditor::edit(const Ref<TileSet> &p_tileset) {
tileset = p_tileset;
}
void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_merge) {
if (!p_merge)
p_library->clear();
void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
for (int i = 0; i < scene->get_child_count(); i++) {
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *child = scene->get_child(i);
Node *child = p_node->get_child(i);
if(!child->cast_to<Sprite>()) {
if(child->get_child_count() > 0) {
child = child->get_child(0);
if (!child->cast_to<Sprite>()) {
continue;
_import_node(child, p_library);
}
} else
continue;
}
@ -136,6 +131,13 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me
}
}
void TileSetEditor::_import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge) {
if (!p_merge)
p_library->clear();
_import_node(p_scene, p_library);
}
void TileSetEditor::_menu_confirm() {
switch (option) {

View File

@ -59,6 +59,7 @@ class TileSetEditor : public Control {
void _menu_confirm();
void _name_dialog_confirm(const String &name);
static void _import_node(Node *p_node, Ref<TileSet> p_library);
static void _import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge);
protected: