summaryrefslogtreecommitdiff
path: root/scene/main/node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r--scene/main/node.cpp115
1 files changed, 101 insertions, 14 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 5ea83a3b6e..672f54e187 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -89,6 +89,7 @@ void Node::_notification(int p_notification) {
data.network_owner=this;
}
+
if (data.input)
add_to_group("_vp_input"+itos(get_viewport()->get_instance_ID()));
if (data.unhandled_input)
@@ -128,6 +129,26 @@ void Node::_notification(int p_notification) {
if (get_script_instance()) {
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_input)) {
+ set_process_input(true);
+ }
+
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_unhandled_input)) {
+ set_process_unhandled_input(true);
+ }
+
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_unhandled_key_input)) {
+ set_process_unhandled_key_input(true);
+ }
+
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_process)) {
+ set_process(true);
+ }
+
+ if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_fixed_process)) {
+ set_fixed_process(true);
+ }
+
Variant::CallError err;
get_script_instance()->call_multilevel_reversed(SceneStringNames::get_singleton()->_ready,NULL,0);
}
@@ -173,7 +194,10 @@ void Node::_propagate_ready() {
data.children[i]->_propagate_ready();
}
data.blocked--;
- notification(NOTIFICATION_READY);
+ if (data.ready_first) {
+ notification(NOTIFICATION_READY);
+ data.ready_first=false;
+ }
}
@@ -294,6 +318,7 @@ void Node::_propagate_exit_tree() {
data.tree->tree_changed();
data.inside_tree=false;
+ data.ready_notified=false;
data.tree=NULL;
data.depth=-1;
@@ -401,6 +426,33 @@ void Node::set_fixed_process(bool p_process) {
_change_notify("fixed_process");
}
+bool Node::is_fixed_processing() const {
+
+ return data.fixed_process;
+}
+
+void Node::set_fixed_process_internal(bool p_process_internal) {
+
+ if (data.fixed_process_internal==p_process_internal)
+ return;
+
+ data.fixed_process_internal=p_process_internal;
+
+ if (data.fixed_process_internal)
+ add_to_group("fixed_process_internal",false);
+ else
+ remove_from_group("fixed_process_internal");
+
+ data.fixed_process_internal=p_process_internal;
+ _change_notify("fixed_process_internal");
+}
+
+bool Node::is_fixed_processing_internal() const {
+
+ return data.fixed_process_internal;
+}
+
+
void Node::set_pause_mode(PauseMode p_mode) {
if (data.pause_mode==p_mode)
@@ -1115,6 +1167,14 @@ float Node::get_fixed_process_delta_time() const {
return 0;
}
+float Node::get_process_delta_time() const {
+
+ if (data.tree)
+ return data.tree->get_idle_process_time();
+ else
+ return 0;
+}
+
void Node::set_process(bool p_idle_process) {
if (data.idle_process==p_idle_process)
@@ -1131,22 +1191,31 @@ void Node::set_process(bool p_idle_process) {
_change_notify("idle_process");
}
-float Node::get_process_delta_time() const {
- if (data.tree)
- return data.tree->get_idle_process_time();
- else
- return 0;
+bool Node::is_processing() const {
+
+ return data.idle_process;
}
-bool Node::is_fixed_processing() const {
+void Node::set_process_internal(bool p_idle_process_internal) {
- return data.fixed_process;
+ if (data.idle_process_internal==p_idle_process_internal)
+ return;
+
+ data.idle_process_internal=p_idle_process_internal;
+
+ if (data.idle_process_internal)
+ add_to_group("idle_process_internal",false);
+ else
+ remove_from_group("idle_process_internal");
+
+ data.idle_process_internal=p_idle_process_internal;
+ _change_notify("idle_process_internal");
}
-bool Node::is_processing() const {
+bool Node::is_processing_internal() const {
- return data.idle_process;
+ return data.idle_process_internal;
}
@@ -2813,10 +2882,14 @@ bool Node::is_displayed_folded() const {
return data.display_folded;
}
+void Node::request_ready() {
+ data.ready_first=true;
+}
+
void Node::_bind_methods() {
- _GLOBAL_DEF("node/name_num_separator",0);
- Globals::get_singleton()->set_custom_property_info("node/name_num_separator",PropertyInfo(Variant::INT,"node/name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
+ _GLOBAL_DEF("editor/node_name_num_separator",0);
+ GlobalConfig::get_singleton()->set_custom_property_info("editor/node_name_num_separator",PropertyInfo(Variant::INT,"editor/node_name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
ClassDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
@@ -2858,8 +2931,8 @@ void Node::_bind_methods() {
ClassDB::bind_method(_MD("set_fixed_process","enable"),&Node::set_fixed_process);
ClassDB::bind_method(_MD("get_fixed_process_delta_time"),&Node::get_fixed_process_delta_time);
ClassDB::bind_method(_MD("is_fixed_processing"),&Node::is_fixed_processing);
- ClassDB::bind_method(_MD("set_process","enable"),&Node::set_process);
ClassDB::bind_method(_MD("get_process_delta_time"),&Node::get_process_delta_time);
+ ClassDB::bind_method(_MD("set_process","enable"),&Node::set_process);
ClassDB::bind_method(_MD("is_processing"),&Node::is_processing);
ClassDB::bind_method(_MD("set_process_input","enable"),&Node::set_process_input);
ClassDB::bind_method(_MD("is_processing_input"),&Node::is_processing_input);
@@ -2875,6 +2948,12 @@ void Node::_bind_methods() {
ClassDB::bind_method(_MD("set_display_folded","fold"),&Node::set_display_folded);
ClassDB::bind_method(_MD("is_displayed_folded"),&Node::is_displayed_folded);
+ ClassDB::bind_method(_MD("set_process_internal","enable"),&Node::set_process_internal);
+ ClassDB::bind_method(_MD("is_processing_internal"),&Node::is_processing_internal);
+
+ ClassDB::bind_method(_MD("set_fixed_process_internal","enable"),&Node::set_fixed_process_internal);
+ ClassDB::bind_method(_MD("is_fixed_processing_internal"),&Node::is_fixed_processing_internal);
+
ClassDB::bind_method(_MD("get_tree:SceneTree"),&Node::get_tree);
ClassDB::bind_method(_MD("duplicate:Node","use_instancing"),&Node::duplicate,DEFVAL(false));
@@ -2888,6 +2967,8 @@ void Node::_bind_methods() {
ClassDB::bind_method(_MD("queue_free"),&Node::queue_delete);
+ ClassDB::bind_method(_MD("request_ready"),&Node::request_ready);
+
ClassDB::bind_method(_MD("set_network_mode","mode"),&Node::set_network_mode);
ClassDB::bind_method(_MD("get_network_mode"),&Node::get_network_mode);
@@ -2946,6 +3027,9 @@ void Node::_bind_methods() {
BIND_CONSTANT( NOTIFICATION_DRAG_BEGIN );
BIND_CONSTANT( NOTIFICATION_DRAG_END );
BIND_CONSTANT( NOTIFICATION_PATH_CHANGED);
+ BIND_CONSTANT( NOTIFICATION_TRANSLATION_CHANGED );
+ BIND_CONSTANT( NOTIFICATION_INTERNAL_PROCESS );
+ BIND_CONSTANT( NOTIFICATION_INTERNAL_FIXED_PROCESS );
BIND_CONSTANT( NETWORK_MODE_INHERIT );
@@ -2989,7 +3073,7 @@ void Node::_bind_methods() {
String Node::_get_name_num_separator() {
- switch(Globals::get_singleton()->get("node/name_num_separator").operator int()) {
+ switch(GlobalConfig::get_singleton()->get("node/name_num_separator").operator int()) {
case 0: return "";
case 1: return " ";
case 2: return "_";
@@ -3008,6 +3092,8 @@ Node::Node() {
data.tree=NULL;
data.fixed_process=false;
data.idle_process=false;
+ data.fixed_process_internal=false;
+ data.idle_process_internal=false;
data.inside_tree=false;
data.ready_notified=false;
@@ -3026,6 +3112,7 @@ Node::Node() {
data.viewport=NULL;
data.use_placeholder=false;
data.display_folded=false;
+ data.ready_first=true;
}