|
@@ -29,7 +29,6 @@
|
|
/**************************************************************************/
|
|
/**************************************************************************/
|
|
|
|
|
|
#include "node.h"
|
|
#include "node.h"
|
|
-#include "node.compat.inc"
|
|
|
|
|
|
|
|
#include "core/config/project_settings.h"
|
|
#include "core/config/project_settings.h"
|
|
#include "core/core_string_names.h"
|
|
#include "core/core_string_names.h"
|
|
@@ -3006,7 +3005,7 @@ static void find_owned_by(Node *p_by, Node *p_node, List<Node *> *p_owned) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void Node::replace_by(Node *p_node, bool p_keep_groups, bool p_keep_children) {
|
|
|
|
|
|
+void Node::replace_by(Node *p_node, bool p_keep_groups) {
|
|
ERR_THREAD_GUARD
|
|
ERR_THREAD_GUARD
|
|
ERR_FAIL_NULL(p_node);
|
|
ERR_FAIL_NULL(p_node);
|
|
ERR_FAIL_COND(p_node->data.parent);
|
|
ERR_FAIL_COND(p_node->data.parent);
|
|
@@ -3027,13 +3026,13 @@ void Node::replace_by(Node *p_node, bool p_keep_groups, bool p_keep_children) {
|
|
_replace_connections_target(p_node);
|
|
_replace_connections_target(p_node);
|
|
|
|
|
|
if (data.owner) {
|
|
if (data.owner) {
|
|
- if (p_keep_children) {
|
|
|
|
- for (int i = 0; i < get_child_count(); i++) {
|
|
|
|
- find_owned_by(data.owner, get_child(i), &owned_by_owner);
|
|
|
|
- }
|
|
|
|
|
|
+ for (int i = 0; i < get_child_count(); i++) {
|
|
|
|
+ find_owned_by(data.owner, get_child(i), &owned_by_owner);
|
|
}
|
|
}
|
|
|
|
+
|
|
_clean_up_owner();
|
|
_clean_up_owner();
|
|
}
|
|
}
|
|
|
|
+
|
|
Node *parent = data.parent;
|
|
Node *parent = data.parent;
|
|
int index_in_parent = get_index(false);
|
|
int index_in_parent = get_index(false);
|
|
|
|
|
|
@@ -3045,33 +3044,31 @@ void Node::replace_by(Node *p_node, bool p_keep_groups, bool p_keep_children) {
|
|
|
|
|
|
emit_signal(SNAME("replacing_by"), p_node);
|
|
emit_signal(SNAME("replacing_by"), p_node);
|
|
|
|
|
|
- if (p_keep_children) {
|
|
|
|
- while (get_child_count()) {
|
|
|
|
- Node *child = get_child(0);
|
|
|
|
- remove_child(child);
|
|
|
|
- if (!child->is_owned_by_parent()) {
|
|
|
|
- // add the custom children to the p_node
|
|
|
|
- Node *child_owner = child->get_owner() == this ? p_node : child->get_owner();
|
|
|
|
- child->set_owner(nullptr);
|
|
|
|
- p_node->add_child(child);
|
|
|
|
- child->set_owner(child_owner);
|
|
|
|
- }
|
|
|
|
|
|
+ while (get_child_count()) {
|
|
|
|
+ Node *child = get_child(0);
|
|
|
|
+ remove_child(child);
|
|
|
|
+ if (!child->is_owned_by_parent()) {
|
|
|
|
+ // add the custom children to the p_node
|
|
|
|
+ Node *child_owner = child->get_owner() == this ? p_node : child->get_owner();
|
|
|
|
+ child->set_owner(nullptr);
|
|
|
|
+ p_node->add_child(child);
|
|
|
|
+ child->set_owner(child_owner);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- for (Node *E : owned) {
|
|
|
|
- if (E->data.owner != p_node) {
|
|
|
|
- E->set_owner(p_node);
|
|
|
|
- }
|
|
|
|
|
|
+ p_node->set_owner(owner);
|
|
|
|
+ for (Node *E : owned) {
|
|
|
|
+ if (E->data.owner != p_node) {
|
|
|
|
+ E->set_owner(p_node);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- for (Node *E : owned_by_owner) {
|
|
|
|
- if (E->data.owner != owner) {
|
|
|
|
- E->set_owner(owner);
|
|
|
|
- }
|
|
|
|
|
|
+ for (Node *E : owned_by_owner) {
|
|
|
|
+ if (E->data.owner != owner) {
|
|
|
|
+ E->set_owner(owner);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- p_node->set_owner(owner);
|
|
|
|
p_node->set_scene_file_path(get_scene_file_path());
|
|
p_node->set_scene_file_path(get_scene_file_path());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3598,7 +3595,7 @@ void Node::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween);
|
|
ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween);
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_USE_INSTANTIATION | DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS));
|
|
ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_USE_INSTANTIATION | DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS));
|
|
- ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_groups", "keep_children"), &Node::replace_by, DEFVAL(false), DEFVAL(true));
|
|
|
|
|
|
+ ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_groups"), &Node::replace_by, DEFVAL(false));
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_scene_instance_load_placeholder", "load_placeholder"), &Node::set_scene_instance_load_placeholder);
|
|
ClassDB::bind_method(D_METHOD("set_scene_instance_load_placeholder", "load_placeholder"), &Node::set_scene_instance_load_placeholder);
|
|
ClassDB::bind_method(D_METHOD("get_scene_instance_load_placeholder"), &Node::get_scene_instance_load_placeholder);
|
|
ClassDB::bind_method(D_METHOD("get_scene_instance_load_placeholder"), &Node::get_scene_instance_load_placeholder);
|