diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/camera.cpp | 18 | ||||
-rw-r--r-- | scene/3d/camera.h | 3 | ||||
-rw-r--r-- | scene/3d/visual_instance.cpp | 16 | ||||
-rw-r--r-- | scene/3d/visual_instance.h | 3 | ||||
-rw-r--r-- | scene/gui/control.cpp | 4 | ||||
-rw-r--r-- | scene/gui/popup_menu.cpp | 19 | ||||
-rw-r--r-- | scene/gui/popup_menu.h | 4 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 15 | ||||
-rw-r--r-- | scene/gui/tabs.h | 5 | ||||
-rw-r--r-- | scene/main/node.cpp | 13 | ||||
-rw-r--r-- | scene/main/node.h | 1 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 2 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 8 | ||||
-rw-r--r-- | scene/scene_string_names.cpp | 2 | ||||
-rw-r--r-- | scene/scene_string_names.h | 2 |
16 files changed, 113 insertions, 4 deletions
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 9a2046991b..0fe427d5fc 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -468,6 +468,10 @@ void Camera::_bind_methods() { ClassDB::bind_method(D_METHOD("get_keep_aspect_mode"), &Camera::get_keep_aspect_mode); ClassDB::bind_method(D_METHOD("set_doppler_tracking", "mode"), &Camera::set_doppler_tracking); ClassDB::bind_method(D_METHOD("get_doppler_tracking"), &Camera::get_doppler_tracking); + + ClassDB::bind_method(D_METHOD("set_cull_mask_bit", "layer", "enable"), &Camera::set_cull_mask_bit); + ClassDB::bind_method(D_METHOD("get_cull_mask_bit", "layer"), &Camera::get_cull_mask_bit); + //ClassDB::bind_method(D_METHOD("_camera_make_current"),&Camera::_camera_make_current ); ADD_PROPERTY(PropertyInfo(Variant::INT, "keep_aspect", PROPERTY_HINT_ENUM, "Keep Width,Keep Height"), "set_keep_aspect_mode", "get_keep_aspect_mode"); @@ -550,6 +554,20 @@ uint32_t Camera::get_cull_mask() const { return layers; } +void Camera::set_cull_mask_bit(int p_layer, bool p_enable) { + ERR_FAIL_INDEX(p_layer, 32); + if (p_enable) { + set_cull_mask(layers | (1 << p_layer)); + } else { + set_cull_mask(layers & (~(1 << p_layer))); + } +} + +bool Camera::get_cull_mask_bit(int p_layer) const { + ERR_FAIL_INDEX_V(p_layer, 32, false); + return (layers & (1 << p_layer)); +} + Vector<Plane> Camera::get_frustum() const { ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>()); diff --git a/scene/3d/camera.h b/scene/3d/camera.h index 1b506e0c4f..97705d8ae0 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -142,6 +142,9 @@ public: void set_cull_mask(uint32_t p_layers); uint32_t get_cull_mask() const; + void set_cull_mask_bit(int p_layer, bool p_enable); + bool get_cull_mask_bit(int p_layer) const; + virtual Vector<Plane> get_frustum() const; void set_environment(const Ref<Environment> &p_environment); diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index 00541a7d8a..767518dc83 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -105,12 +105,28 @@ uint32_t VisualInstance::get_layer_mask() const { return layers; } +void VisualInstance::set_layer_mask_bit(int p_layer, bool p_enable) { + ERR_FAIL_INDEX(p_layer, 32); + if (p_enable) { + set_layer_mask(layers | (1 << p_layer)); + } else { + set_layer_mask(layers & (~(1 << p_layer))); + } +} + +bool VisualInstance::get_layer_mask_bit(int p_layer) const { + ERR_FAIL_INDEX_V(p_layer, 32, false); + return (layers & (1 << p_layer)); +} + void VisualInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"), &VisualInstance::_get_visual_instance_rid); ClassDB::bind_method(D_METHOD("set_base", "base"), &VisualInstance::set_base); ClassDB::bind_method(D_METHOD("set_layer_mask", "mask"), &VisualInstance::set_layer_mask); ClassDB::bind_method(D_METHOD("get_layer_mask"), &VisualInstance::get_layer_mask); + ClassDB::bind_method(D_METHOD("set_layer_mask_bit", "layer", "enabled"), &VisualInstance::set_layer_mask_bit); + ClassDB::bind_method(D_METHOD("get_layer_mask_bit", "layer"), &VisualInstance::get_layer_mask_bit); ClassDB::bind_method(D_METHOD("get_transformed_aabb"), &VisualInstance::get_transformed_aabb); diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h index 8458a343b2..9249bc04ce 100644 --- a/scene/3d/visual_instance.h +++ b/scene/3d/visual_instance.h @@ -73,6 +73,9 @@ public: void set_layer_mask(uint32_t p_mask); uint32_t get_layer_mask() const; + void set_layer_mask_bit(int p_layer, bool p_enable); + bool get_layer_mask_bit(int p_layer) const; + VisualInstance(); ~VisualInstance(); }; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 12aeed1520..18f06eca31 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -663,6 +663,9 @@ void Control::_notification(int p_notification) { bool Control::clips_input() const { + if (get_script_instance()) { + return get_script_instance()->call(SceneStringNames::get_singleton()->_clips_input); + } return false; } bool Control::has_point(const Point2 &p_point) const { @@ -2828,6 +2831,7 @@ void Control::_bind_methods() { BIND_VMETHOD(MethodInfo(Variant::BOOL, "can_drop_data", PropertyInfo(Variant::VECTOR2, "position"), PropertyInfo(Variant::NIL, "data"))); BIND_VMETHOD(MethodInfo("drop_data", PropertyInfo(Variant::VECTOR2, "position"), PropertyInfo(Variant::NIL, "data"))); BIND_VMETHOD(MethodInfo(Variant::OBJECT, "_make_custom_tooltip", PropertyInfo(Variant::STRING, "for_text"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_clips_input")); ADD_GROUP("Anchor", "anchor_"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "anchor_left", PROPERTY_HINT_RANGE, "0,1,0.01"), "_set_anchor", "get_anchor", MARGIN_LEFT); diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index cd4ece0950..ab762e19ee 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -530,6 +530,11 @@ void PopupMenu::_notification(int p_what) { } } break; + case MainLoop::NOTIFICATION_WM_FOCUS_OUT: { + + if (hide_on_window_lose_focus) + hide(); + } break; case NOTIFICATION_MOUSE_ENTER: { grab_focus(); @@ -1249,6 +1254,16 @@ float PopupMenu::get_submenu_popup_delay() const { return submenu_timer->get_wait_time(); } +void PopupMenu::set_hide_on_window_lose_focus(bool p_enabled) { + + hide_on_window_lose_focus = p_enabled; +} + +bool PopupMenu::is_hide_on_window_lose_focus() const { + + return hide_on_window_lose_focus; +} + String PopupMenu::get_tooltip(const Point2 &p_pos) const { int over = _get_mouse_over(p_pos); @@ -1353,6 +1368,10 @@ void PopupMenu::_bind_methods() { ClassDB::bind_method(D_METHOD("set_submenu_popup_delay", "seconds"), &PopupMenu::set_submenu_popup_delay); ClassDB::bind_method(D_METHOD("get_submenu_popup_delay"), &PopupMenu::get_submenu_popup_delay); + + ClassDB::bind_method(D_METHOD("set_hide_on_window_lose_focus", "enable"), &PopupMenu::set_hide_on_window_lose_focus); + ClassDB::bind_method(D_METHOD("is_hide_on_window_lose_focus"), &PopupMenu::is_hide_on_window_lose_focus); + ClassDB::bind_method(D_METHOD("_submenu_timeout"), &PopupMenu::_submenu_timeout); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items"); diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index 8ec51c7d3a..a06a17c9fe 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -101,6 +101,7 @@ class PopupMenu : public Popup { bool hide_on_item_selection; bool hide_on_checkable_item_selection; bool hide_on_multistate_item_selection; + bool hide_on_window_lose_focus; Vector2 moved; Array _get_items() const; @@ -207,6 +208,9 @@ public: virtual void popup(const Rect2 &p_bounds = Rect2()); + void set_hide_on_window_lose_focus(bool p_enabled); + bool is_hide_on_window_lose_focus() const; + PopupMenu(); ~PopupMenu(); }; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 50bd1d867c..2075f7ce70 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -189,7 +189,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { update(); } - if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { + if (mb->is_pressed() && (mb->get_button_index() == BUTTON_LEFT || (select_with_rmb && mb->get_button_index() == BUTTON_RIGHT))) { // clicks Point2 pos(mb->get_position().x, mb->get_position().y); @@ -920,6 +920,14 @@ int Tabs::get_tabs_rearrange_group() const { return tabs_rearrange_group; } +void Tabs::set_select_with_rmb(bool p_enabled) { + select_with_rmb = p_enabled; +} + +bool Tabs::get_select_with_rmb() const { + return select_with_rmb; +} + void Tabs::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &Tabs::_gui_input); @@ -950,6 +958,9 @@ void Tabs::_bind_methods() { ClassDB::bind_method(D_METHOD("set_tabs_rearrange_group", "group_id"), &Tabs::set_tabs_rearrange_group); ClassDB::bind_method(D_METHOD("get_tabs_rearrange_group"), &Tabs::get_tabs_rearrange_group); + ClassDB::bind_method(D_METHOD("set_select_with_rmb", "enabled"), &Tabs::set_select_with_rmb); + ClassDB::bind_method(D_METHOD("get_select_with_rmb"), &Tabs::get_select_with_rmb); + ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab"))); ADD_SIGNAL(MethodInfo("right_button_pressed", PropertyInfo(Variant::INT, "tab"))); ADD_SIGNAL(MethodInfo("tab_close", PropertyInfo(Variant::INT, "tab"))); @@ -988,6 +999,8 @@ Tabs::Tabs() { offset = 0; max_drawn_tab = 0; + select_with_rmb = false; + min_width = 0; scrolling_enabled = true; buttons_visible = false; diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index 3b38e7f2cb..e204f4364b 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -83,6 +83,8 @@ private: int rb_hover; bool rb_pressing; + bool select_with_rmb; + int cb_hover; bool cb_pressing; CloseButtonDisplayPolicy cb_displaypolicy; @@ -150,6 +152,9 @@ public: void set_tabs_rearrange_group(int p_group_id); int get_tabs_rearrange_group() const; + void set_select_with_rmb(bool p_enabled); + bool get_select_with_rmb() const; + void ensure_tab_visible(int p_idx); void set_min_width(int p_width); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index b7b26d1c55..68de7b3a0a 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -240,7 +240,7 @@ void Node::_propagate_enter_tree() { void Node::_propagate_exit_tree() { - //block while removing children +//block while removing children #ifdef DEBUG_ENABLED @@ -725,6 +725,17 @@ const Map<StringName, MultiplayerAPI::RPCMode>::Element *Node::get_node_rset_mod return data.rpc_properties.find(p_property); } +bool Node::can_process_notification(int p_what) const { + switch (p_what) { + case NOTIFICATION_PHYSICS_PROCESS: return data.physics_process; + case NOTIFICATION_PROCESS: return data.idle_process; + case NOTIFICATION_INTERNAL_PROCESS: return data.idle_process_internal; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: return data.physics_process_internal; + } + + return true; +} + bool Node::can_process() const { ERR_FAIL_COND_V(!is_inside_tree(), false); diff --git a/scene/main/node.h b/scene/main/node.h index 4b8f584ba7..9ee0340678 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -364,6 +364,7 @@ public: void set_pause_mode(PauseMode p_mode); PauseMode get_pause_mode() const; bool can_process() const; + bool can_process_notification(int p_what) const; void request_ready(); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 1b2e87dd99..e99f785848 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -951,6 +951,8 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio if (!n->can_process()) continue; + if (!n->can_process_notification(p_notification)) + continue; n->notification(p_notification); //ERR_FAIL_COND(node_count != g.nodes.size()); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 573c401290..e43c2da02d 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1860,7 +1860,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (over != top && !top->is_a_parent_of(over)) { PopupMenu *popup_menu = Object::cast_to<PopupMenu>(top); - MenuButton *popup_menu_parent; + MenuButton *popup_menu_parent = NULL; MenuButton *menu_button = Object::cast_to<MenuButton>(over); if (popup_menu) diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index b95e0495d9..446b2b0e68 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -31,6 +31,7 @@ #include "packed_scene.h" #include "core/core_string_names.h" +#include "engine.h" #include "io/resource_loader.h" #include "project_settings.h" #include "scene/2d/node_2d.h" @@ -279,7 +280,12 @@ Node *SceneState::instance(GenEditState p_edit_state) const { stray_instances.push_back(node); //can't be added, go to stray list } } else { - node->_set_name_nocheck(snames[n.name]); + if (Engine::get_singleton()->is_editor_hint()) { + //validate name if using editor, to avoid broken + node->set_name(snames[n.name]); + } else { + node->_set_name_nocheck(snames[n.name]); + } } } diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index bf765385d0..661606c7ef 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -102,6 +102,8 @@ SceneStringNames::SceneStringNames() { _update_scroll = StaticCString::create("_update_scroll"); _update_xform = StaticCString::create("_update_xform"); + _clips_input = StaticCString::create("_clips_input"); + _proxgroup_add = StaticCString::create("_proxgroup_add"); _proxgroup_remove = StaticCString::create("_proxgroup_remove"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index b88cf7d8d7..817158f9f3 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -127,6 +127,8 @@ public: StringName _update_scroll; StringName _update_xform; + StringName _clips_input; + StringName _proxgroup_add; StringName _proxgroup_remove; |