diff options
Diffstat (limited to 'scene/main/node.cpp')
| -rw-r--r-- | scene/main/node.cpp | 84 |
1 files changed, 57 insertions, 27 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 8d5133311a..e730f47607 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -34,6 +34,7 @@ #include "core/core_string_names.h" #include "core/io/resource_loader.h" #include "core/object/message_queue.h" +#include "core/object/script_language.h" #include "core/string/print_string.h" #include "instance_placeholder.h" #include "scene/animation/tween.h" @@ -674,7 +675,7 @@ const Variant Node::get_node_rpc_config() const { Error Node::_rpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { if (p_argcount < 1) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument = 1; + r_error.expected = 1; return ERR_INVALID_PARAMETER; } @@ -696,7 +697,7 @@ Error Node::_rpc_bind(const Variant **p_args, int p_argcount, Callable::CallErro Error Node::_rpc_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { if (p_argcount < 2) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument = 2; + r_error.expected = 2; return ERR_INVALID_PARAMETER; } @@ -967,7 +968,11 @@ void Node::set_process_priority(int p_priority) { if (_is_any_processing()) { _remove_from_process_thread_group(); - data.process_priority = p_priority; + } + + data.process_priority = p_priority; + + if (_is_any_processing()) { _add_to_process_thread_group(); } } @@ -989,7 +994,11 @@ void Node::set_physics_process_priority(int p_priority) { if (_is_any_processing()) { _remove_from_process_thread_group(); - data.physics_process_priority = p_priority; + } + + data.physics_process_priority = p_priority; + + if (_is_any_processing()) { _add_to_process_thread_group(); } } @@ -1347,6 +1356,10 @@ void Node::_generate_serial_child_name(const Node *p_child, StringName &name) co } } +Node::InternalMode Node::get_internal_mode() const { + return data.internal_mode; +} + void Node::_add_child_nocheck(Node *p_child, const StringName &p_name, InternalMode p_internal_mode) { //add a child node quickly, without name validation @@ -1842,7 +1855,7 @@ void Node::_set_owner_nocheck(Node *p_owner) { } void Node::_release_unique_name_in_owner() { - ERR_FAIL_NULL(data.owner); // Sanity check. + ERR_FAIL_NULL(data.owner); // Safety check. StringName key = StringName(UNIQUE_NODE_PREFIX + data.name.operator String()); Node **which = data.owner->data.owned_unique_nodes.getptr(key); if (which == nullptr || *which != this) { @@ -1852,12 +1865,12 @@ void Node::_release_unique_name_in_owner() { } void Node::_acquire_unique_name_in_owner() { - ERR_FAIL_NULL(data.owner); // Sanity check. + ERR_FAIL_NULL(data.owner); // Safety check. StringName key = StringName(UNIQUE_NODE_PREFIX + data.name.operator String()); Node **which = data.owner->data.owned_unique_nodes.getptr(key); if (which != nullptr && *which != this) { String which_path = is_inside_tree() ? (*which)->get_path() : data.owner->get_path_to(*which); - WARN_PRINT(vformat(RTR("Setting node name '%s' to be unique within scene for '%s', but it's already claimed by '%s'.\n'%s' is no longer set as having a unique name."), + WARN_PRINT(vformat("Setting node name '%s' to be unique within scene for '%s', but it's already claimed by '%s'.\n'%s' is no longer set as having a unique name.", get_name(), is_inside_tree() ? get_path() : data.owner->get_path_to(this), which_path, which_path)); data.unique_name_in_owner = false; return; @@ -1925,7 +1938,7 @@ Node *Node::get_owner() const { } void Node::_clean_up_owner() { - ERR_FAIL_NULL(data.owner); // Sanity check. + ERR_FAIL_NULL(data.owner); // Safety check. if (data.unique_name_in_owner) { _release_unique_name_in_owner(); @@ -2152,30 +2165,40 @@ int Node::get_persistent_group_count() const { return count; } -void Node::_print_tree_pretty(const String &prefix, const bool last) { - String new_prefix = last ? String::utf8(" ┖╴") : String::utf8(" ┠╴"); - print_line(prefix + new_prefix + String(get_name())); +void Node::print_tree_pretty() { + print_line(_get_tree_string_pretty("", true)); +} + +void Node::print_tree() { + print_line(_get_tree_string(this)); +} + +String Node::_get_tree_string_pretty(const String &p_prefix, bool p_last) { + String new_prefix = p_last ? String::utf8(" ┖╴") : String::utf8(" ┠╴"); _update_children_cache(); + String return_tree = p_prefix + new_prefix + String(get_name()) + "\n"; for (uint32_t i = 0; i < data.children_cache.size(); i++) { - new_prefix = last ? String::utf8(" ") : String::utf8(" ┃ "); - data.children_cache[i]->_print_tree_pretty(prefix + new_prefix, i == data.children_cache.size() - 1); + new_prefix = p_last ? String::utf8(" ") : String::utf8(" ┃ "); + return_tree += data.children_cache[i]->_get_tree_string_pretty(p_prefix + new_prefix, i == data.children_cache.size() - 1); } + return return_tree; } -void Node::print_tree_pretty() { - _print_tree_pretty("", true); +String Node::get_tree_string_pretty() { + return _get_tree_string_pretty("", true); } -void Node::print_tree() { - _print_tree(this); -} - -void Node::_print_tree(const Node *p_node) { - print_line(String(p_node->get_path_to(this))); +String Node::_get_tree_string(const Node *p_node) { _update_children_cache(); + String return_tree = String(p_node->get_path_to(this)) + "\n"; for (uint32_t i = 0; i < data.children_cache.size(); i++) { - data.children_cache[i]->_print_tree(p_node); + return_tree += data.children_cache[i]->_get_tree_string(p_node); } + return return_tree; +} + +String Node::get_tree_string() { + return _get_tree_string(this); } void Node::_propagate_reverse_notification(int p_notification) { @@ -2718,9 +2741,15 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { copytarget = p_copy->get_node(ptarget); } - if (copy && copytarget) { - const Callable copy_callable = Callable(copytarget, E.callable.get_method()); + if (copy && copytarget && E.callable.get_method() != StringName()) { + Callable copy_callable = Callable(copytarget, E.callable.get_method()); if (!copy->is_connected(E.signal.get_name(), copy_callable)) { + int arg_count = E.callable.get_bound_arguments_count(); + if (arg_count > 0) { + copy_callable = copy_callable.bindv(E.callable.get_bound_arguments()); + } else if (arg_count < 0) { + copy_callable = copy_callable.unbind(-arg_count); + } copy->connect(E.signal.get_name(), copy_callable, E.flags); } } @@ -3143,7 +3172,7 @@ void Node::unhandled_key_input(const Ref<InputEvent> &p_key_event) { Variant Node::_call_deferred_thread_group_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { if (p_argcount < 1) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument = 0; + r_error.expected = 1; return Variant(); } @@ -3166,7 +3195,7 @@ Variant Node::_call_deferred_thread_group_bind(const Variant **p_args, int p_arg Variant Node::_call_thread_safe_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) { if (p_argcount < 1) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument = 0; + r_error.expected = 1; return Variant(); } @@ -3268,6 +3297,8 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("get_index", "include_internal"), &Node::get_index, DEFVAL(false)); ClassDB::bind_method(D_METHOD("print_tree"), &Node::print_tree); ClassDB::bind_method(D_METHOD("print_tree_pretty"), &Node::print_tree_pretty); + ClassDB::bind_method(D_METHOD("get_tree_string"), &Node::get_tree_string); + ClassDB::bind_method(D_METHOD("get_tree_string_pretty"), &Node::get_tree_string_pretty); ClassDB::bind_method(D_METHOD("set_scene_file_path", "scene_file_path"), &Node::set_scene_file_path); ClassDB::bind_method(D_METHOD("get_scene_file_path"), &Node::get_scene_file_path); ClassDB::bind_method(D_METHOD("propagate_notification", "what"), &Node::propagate_notification); @@ -3411,7 +3442,6 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_POST_ENTER_TREE); BIND_CONSTANT(NOTIFICATION_DISABLED); BIND_CONSTANT(NOTIFICATION_ENABLED); - BIND_CONSTANT(NOTIFICATION_NODE_RECACHE_REQUESTED); BIND_CONSTANT(NOTIFICATION_EDITOR_PRE_SAVE); BIND_CONSTANT(NOTIFICATION_EDITOR_POST_SAVE); |
