void EditorSubScene::move(Node *p_new_parent, Node *p_new_owner) { if (!scene) { return; } if (selection.size() <= 0) { return; } 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); } p_new_parent->add_child(selnode); for (List<Node *>::Element *F = to_reown.front(); F; F = F->next()) { F->get()->set_owner(p_new_owner); } } if (!is_root) { memdelete(scene); } scene = NULL; //return selnode; }
void EditorSubScene::_reown(Node *p_node, List<Node *> *p_to_reown) { if (p_node == scene) { scene->set_filename(""); p_to_reown->push_back(p_node); } else if (p_node->get_owner() == scene) { p_to_reown->push_back(p_node); } for (int i = 0; i < p_node->get_child_count(); i++) { Node *c = p_node->get_child(i); _reown(c, p_to_reown); } }
void EditorSubScene::move(Node* p_new_parent, Node* p_new_owner) { if (!scene) { return; } TreeItem *s = tree->get_selected(); if (!s) { return; } Node *selnode = s->get_metadata(0); if (!selnode) { return; } List<Node*> to_reown; _reown(selnode,&to_reown); if (selnode!=scene) { selnode->get_parent()->remove_child(selnode); } p_new_parent->add_child(selnode); for (List<Node*>::Element *E=to_reown.front();E;E=E->next()) { E->get()->set_owner(p_new_owner); } if (selnode!=scene) { memdelete(scene); } scene=NULL; //return selnode; }