| 1455 | } |
| 1456 | |
| 1457 | void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) { |
| 1458 | SceneTree *scene_tree = SceneTree::get_singleton(); |
| 1459 | if (!scene_tree) { |
| 1460 | return; |
| 1461 | } |
| 1462 | |
| 1463 | Node *base = nullptr; |
| 1464 | if (scene_tree->root->has_node(live_edit_root)) { |
| 1465 | base = scene_tree->root->get_node(live_edit_root); |
| 1466 | } |
| 1467 | |
| 1468 | HashMap<String, HashSet<Node *>>::Iterator E = live_scene_edit_cache.find(live_edit_scene); |
| 1469 | if (!E) { |
| 1470 | return; //scene not editable |
| 1471 | } |
| 1472 | |
| 1473 | for (Node *F : E->value) { |
| 1474 | Node *n = F; |
| 1475 | |
| 1476 | if (base && !base->is_ancestor_of(n)) { |
| 1477 | continue; |
| 1478 | } |
| 1479 | |
| 1480 | if (!n->has_node(p_at)) { |
| 1481 | continue; |
| 1482 | } |
| 1483 | Node *nfrom = n->get_node(p_at); |
| 1484 | |
| 1485 | if (!n->has_node(p_new_place)) { |
| 1486 | continue; |
| 1487 | } |
| 1488 | Node *nto = n->get_node(p_new_place); |
| 1489 | |
| 1490 | nfrom->get_parent()->remove_child(nfrom); |
| 1491 | nfrom->set_name(p_new_name); |
| 1492 | |
| 1493 | nto->add_child(nfrom); |
| 1494 | if (p_at_pos >= 0) { |
| 1495 | nto->move_child(nfrom, p_at_pos); |
| 1496 | } |
| 1497 | } |
| 1498 | } |
| 1499 | |
| 1500 | /// RuntimeNodeSelect |
| 1501 | RuntimeNodeSelect *RuntimeNodeSelect::get_singleton() { |
no test coverage detected