From d093cc8bf86c048b90ac47183d7bf45d15f36e43 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 14 Jan 2017 10:03:53 -0300 Subject: Renamed call_group to call_group_flags, made call_group without flags the default --- scene/2d/camera_2d.cpp | 6 +-- scene/2d/canvas_item.cpp | 4 +- scene/3d/proximity_group.cpp | 2 +- scene/3d/spatial.cpp | 2 +- scene/main/scene_main_loop.cpp | 92 +++++++++++++++++++++++++++++++++--------- scene/main/scene_main_loop.h | 13 ++++-- scene/main/viewport.cpp | 6 +-- 7 files changed, 91 insertions(+), 34 deletions(-) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index b921db239d..adeaa34c3e 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -52,7 +52,7 @@ void Camera2D::_update_scroll() { if (viewport) { viewport->set_canvas_transform( xform ); } - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_camera_moved",xform); }; } @@ -375,7 +375,7 @@ void Camera2D::make_current() { if (!is_inside_tree()) { current=true; } else { - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",this); } } @@ -383,7 +383,7 @@ void Camera2D::clear_current() { current=false; if (is_inside_tree()) { - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL)); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,group_name,"_make_current",(Object*)(NULL)); } } diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 0a3e06602b..550b01c2f2 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -394,7 +394,7 @@ void CanvasItem::_enter_canvas() { else get_viewport()->gui_reset_canvas_sort_index(); - get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self"); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self"); } else { @@ -444,7 +444,7 @@ void CanvasItem::_notification(int p_what) { break; if (group!="") { - get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self"); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self"); } else { CanvasItem *p = get_parent_item(); ERR_FAIL_COND(!p); diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp index 5ef0d3f176..9f4b5c7a03 100644 --- a/scene/3d/proximity_group.cpp +++ b/scene/3d/proximity_group.cpp @@ -135,7 +135,7 @@ void ProximityGroup::broadcast(String p_name, Variant p_params) { E = groups.front(); while (E) { - get_tree()->call_group(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params); E = E->next(); }; diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 7c452f90af..788ef7f935 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -180,7 +180,7 @@ void Spatial::_notification(int p_what) { if (get_tree()->is_editor_hint()) { // get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); - get_tree()->call_group(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); + get_tree()->call_group_flags(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); if (!data.gizmo_disabled) { if (data.gizmo.is_valid()) diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp index 75af716f65..bc5f99b2f2 100644 --- a/scene/main/scene_main_loop.cpp +++ b/scene/main/scene_main_loop.cpp @@ -141,7 +141,7 @@ void SceneTree::_flush_ugc() { for(int i=0;iget().size();i++) v[i]=E->get()[i]; - call_group(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]); + call_group_flags(GROUP_CALL_REALTIME,E->key().group,E->key().call,v[0],v[1],v[2],v[3],v[4]); unique_group_calls.erase(E); } @@ -166,7 +166,7 @@ void SceneTree::_update_group_order(Group& g) { } -void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) { +void SceneTree::call_group_flags(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) { Map::Element *E=group_map.find(p_group); if (!E) @@ -216,7 +216,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const continue; if (p_call_flags&GROUP_CALL_REALTIME) { - if (p_call_flags&GROUP_CALL_MULIILEVEL) + if (p_call_flags&GROUP_CALL_MULTILEVEL) nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS); else nodes[i]->call(p_function,VARIANT_ARG_PASS); @@ -233,7 +233,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const continue; if (p_call_flags&GROUP_CALL_REALTIME) { - if (p_call_flags&GROUP_CALL_MULIILEVEL) + if (p_call_flags&GROUP_CALL_MULTILEVEL) nodes[i]->call_multilevel(p_function,VARIANT_ARG_PASS); else nodes[i]->call(p_function,VARIANT_ARG_PASS); @@ -248,7 +248,7 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const call_skip.clear(); } -void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int p_notification) { +void SceneTree::notify_group_flags(uint32_t p_call_flags,const StringName& p_group,int p_notification) { Map::Element *E=group_map.find(p_group); if (!E) @@ -298,7 +298,7 @@ void SceneTree::notify_group(uint32_t p_call_flags,const StringName& p_group,int call_skip.clear(); } -void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) { +void SceneTree::set_group_flags(uint32_t p_call_flags,const StringName& p_group,const String& p_name,const Variant& p_value) { Map::Element *E=group_map.find(p_group); if (!E) @@ -348,6 +348,23 @@ void SceneTree::set_group(uint32_t p_call_flags,const StringName& p_group,const call_skip.clear(); } + +void SceneTree::call_group(const StringName& p_group,const StringName& p_function,VARIANT_ARG_DECLARE) { + + call_group_flags(0,p_group,VARIANT_ARG_PASS); +} + +void SceneTree::notify_group(const StringName& p_group,int p_notification) { + + notify_group_flags(0,p_group,p_notification); +} + +void SceneTree::set_group(const StringName& p_group,const String& p_name,const Variant& p_value) { + + set_group_flags(0,p_group,p_name,p_value); +} + + void SceneTree::set_input_as_handled() { input_handled=true; @@ -357,7 +374,7 @@ void SceneTree::input_text( const String& p_text ) { root_lock++; - call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check + call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_input_text",p_text); //special one for GUI, as controls use their own process check root_lock--; @@ -452,7 +469,7 @@ void SceneTree::input_event( const InputEvent& p_event ) { //transform for the rest #else - call_group(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check + call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_input",ev); //special one for GUI, as controls use their own process check #endif if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote() && ev.type==InputEvent::KEY && ev.key.pressed && !ev.key.echo && ev.key.scancode==KEY_F8) { @@ -477,7 +494,7 @@ void SceneTree::input_event( const InputEvent& p_event ) { } #else - call_group(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check + call_group_flags(GROUP_CALL_REALTIME,"_viewports","_vp_unhandled_input",ev); //special one for GUI, as controls use their own process check #endif input_handled=true; @@ -528,7 +545,7 @@ bool SceneTree::iteration(float p_time) { _notify_group_pause("fixed_process",Node::NOTIFICATION_FIXED_PROCESS); _flush_ugc(); _flush_transform_notifications(); - call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds"); + call_group_flags(GROUP_CALL_REALTIME,"_viewports","update_worlds"); root_lock--; _flush_delete_queue(); @@ -573,7 +590,7 @@ bool SceneTree::idle(float p_time){ _flush_ugc(); _flush_transform_notifications(); //transforms after world update, to avoid unnecesary enter/exit notifications - call_group(GROUP_CALL_REALTIME,"_viewports","update_worlds"); + call_group_flags(GROUP_CALL_REALTIME,"_viewports","update_worlds"); root_lock--; @@ -667,7 +684,7 @@ void SceneTree::_notification(int p_notification) { } break; case NOTIFICATION_WM_UNFOCUS_REQUEST: { - notify_group(GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST); + notify_group_flags(GROUP_CALL_REALTIME|GROUP_CALL_MULTILEVEL,"input",NOTIFICATION_WM_UNFOCUS_REQUEST); } break; @@ -991,7 +1008,7 @@ uint32_t SceneTree::get_last_event_id() const { } -Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { +Variant SceneTree::_call_group_flags(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { r_error.error=Variant::CallError::CALL_OK; @@ -1011,11 +1028,33 @@ Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant:: v[i]=*p_args[i+3]; } - call_group(flags,group,method,v[0],v[1],v[2],v[3],v[4]); + call_group_flags(flags,group,method,v[0],v[1],v[2],v[3],v[4]); return Variant(); } +Variant SceneTree::_call_group(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { + + + r_error.error=Variant::CallError::CALL_OK; + + ERR_FAIL_COND_V(p_argcount<2,Variant()); + ERR_FAIL_COND_V(p_args[0]->get_type()!=Variant::STRING,Variant()); + ERR_FAIL_COND_V(p_args[1]->get_type()!=Variant::STRING,Variant()); + + StringName group = *p_args[0]; + StringName method = *p_args[1]; + Variant v[VARIANT_ARG_MAX]; + + for(int i=0;icall_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); get_tree()->set_input_as_handled(); @@ -1980,7 +1980,7 @@ void Viewport::_gui_input_event(InputEvent p_event) { }*/ - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); get_tree()->set_input_as_handled(); } @@ -2419,7 +2419,7 @@ void Viewport::_gui_control_grab_focus(Control* p_control) { if (gui.key_focus && gui.key_focus==p_control) return; - get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"_viewports","_gui_remove_focus"); + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME,"_viewports","_gui_remove_focus"); gui.key_focus=p_control; p_control->notification(Control::NOTIFICATION_FOCUS_ENTER); p_control->update(); -- cgit v1.2.3