diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/tile_map.cpp | 1 | ||||
-rw-r--r-- | scene/3d/proximity_group_3d.cpp | 1 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 8 | ||||
-rw-r--r-- | scene/gui/menu_button.cpp | 45 | ||||
-rw-r--r-- | scene/gui/menu_button.h | 2 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 20 | ||||
-rw-r--r-- | scene/main/scene_tree.h | 20 | ||||
-rw-r--r-- | scene/main/timer.cpp | 8 | ||||
-rw-r--r-- | scene/main/timer.h | 10 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 2 | ||||
-rw-r--r-- | scene/register_scene_types.cpp | 1 |
11 files changed, 71 insertions, 47 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 3932f3dc78..e9efa1cf84 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -795,6 +795,7 @@ void TileMap::_set_tile_data(const Vector<int> &p_data) { const int *r = p_data.ptr(); int offset = (format >= FORMAT_2) ? 3 : 2; + ERR_FAIL_COND_MSG(c % offset != 0, "Corrupted tile data."); clear(); diff --git a/scene/3d/proximity_group_3d.cpp b/scene/3d/proximity_group_3d.cpp index 037110eaa1..c8c61a9f00 100644 --- a/scene/3d/proximity_group_3d.cpp +++ b/scene/3d/proximity_group_3d.cpp @@ -128,6 +128,7 @@ void ProximityGroup3D::broadcast(String p_method, Variant p_parameters) { void ProximityGroup3D::_proximity_group_broadcast(String p_method, Variant p_parameters) { if (dispatch_mode == MODE_PROXY) { + ERR_FAIL_COND(!is_inside_tree()); get_parent()->call(p_method, p_parameters); } else { emit_signal(SNAME("broadcast"), p_method, p_parameters); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index b31c3d57f9..a57e986877 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -46,8 +46,8 @@ void Tween::start_tweeners() { ERR_FAIL_MSG("Tween without commands, aborting."); } - for (Ref<Tweener> E : tweeners.write[current_step]) { - E->start(); + for (Ref<Tweener> &tweener : tweeners.write[current_step]) { + tweener->start(); } } @@ -253,11 +253,11 @@ bool Tween::step(float p_delta) { float step_delta = rem_delta; step_active = false; - for (Ref<Tweener> E : tweeners.write[current_step]) { + for (Ref<Tweener> &tweener : tweeners.write[current_step]) { // Modified inside Tweener.step(). float temp_delta = rem_delta; // Turns to true if any Tweener returns true (i.e. is still not finished). - step_active = E->step(temp_delta) || step_active; + step_active = tweener->step(temp_delta) || step_active; step_delta = MIN(temp_delta, rem_delta); } diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 73034dee5a..cf1f41d0fc 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -57,7 +57,32 @@ void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) { void MenuButton::_popup_visibility_changed(bool p_visible) { set_pressed(p_visible); - set_process_internal(p_visible); + + if (!p_visible) { + set_process_internal(false); + return; + } + + if (switch_on_hover) { + Window *window = Object::cast_to<Window>(get_viewport()); + if (window) { + mouse_pos_adjusted = window->get_position(); + + if (window->is_embedded()) { + Window *window_parent = Object::cast_to<Window>(window->get_parent()->get_viewport()); + while (window_parent) { + if (!window_parent->is_embedded()) { + mouse_pos_adjusted += window_parent->get_position(); + break; + } + + window_parent = Object::cast_to<Window>(window_parent->get_parent()->get_viewport()); + } + } + + set_process_internal(true); + } + } } void MenuButton::pressed() { @@ -106,17 +131,13 @@ void MenuButton::_notification(int p_what) { } } break; case NOTIFICATION_INTERNAL_PROCESS: { - if (switch_on_hover) { - Window *window = Object::cast_to<Window>(get_viewport()); - if (window) { - Vector2i mouse_pos = DisplayServer::get_singleton()->mouse_get_position() - window->get_position(); - MenuButton *menu_btn_other = Object::cast_to<MenuButton>(window->gui_find_control(mouse_pos)); - if (menu_btn_other && menu_btn_other != this && menu_btn_other->is_switch_on_hover() && !menu_btn_other->is_disabled() && - (get_parent()->is_ancestor_of(menu_btn_other) || menu_btn_other->get_parent()->is_ancestor_of(popup))) { - popup->hide(); - menu_btn_other->pressed(); - } - } + Vector2i mouse_pos = DisplayServer::get_singleton()->mouse_get_position() - mouse_pos_adjusted; + MenuButton *menu_btn_other = Object::cast_to<MenuButton>(get_viewport()->gui_find_control(mouse_pos)); + + if (menu_btn_other && menu_btn_other != this && menu_btn_other->is_switch_on_hover() && !menu_btn_other->is_disabled() && + (get_parent()->is_ancestor_of(menu_btn_other) || menu_btn_other->get_parent()->is_ancestor_of(popup))) { + popup->hide(); + menu_btn_other->pressed(); } } break; } diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h index 301769b008..cc2ca117c4 100644 --- a/scene/gui/menu_button.h +++ b/scene/gui/menu_button.h @@ -42,6 +42,8 @@ class MenuButton : public Button { bool disable_shortcuts = false; PopupMenu *popup; + Vector2i mouse_pos_adjusted; + Array _get_items() const; void _set_items(const Array &p_items); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index adba7f1a31..dcbbebbc55 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -66,11 +66,11 @@ void SceneTreeTimer::_bind_methods() { ADD_SIGNAL(MethodInfo("timeout")); } -void SceneTreeTimer::set_time_left(float p_time) { +void SceneTreeTimer::set_time_left(double p_time) { time_left = p_time; } -float SceneTreeTimer::get_time_left() const { +double SceneTreeTimer::get_time_left() const { return time_left; } @@ -403,7 +403,7 @@ void SceneTree::initialize() { MainLoop::initialize(); } -bool SceneTree::physics_process(float p_time) { +bool SceneTree::physics_process(double p_time) { root_lock++; current_frame++; @@ -432,7 +432,7 @@ bool SceneTree::physics_process(float p_time) { return _quit; } -bool SceneTree::process(float p_time) { +bool SceneTree::process(double p_time) { root_lock++; MainLoop::process(p_time); @@ -474,7 +474,7 @@ bool SceneTree::process(float p_time) { continue; } - float time_left = E->get()->get_time_left(); + double time_left = E->get()->get_time_left(); if (E->get()->is_ignore_time_scale()) { time_left -= Engine::get_singleton()->get_process_step(); } else { @@ -571,8 +571,8 @@ void SceneTree::finalize() { } // cleanup timers - for (Ref<SceneTreeTimer> E : timers) { - E->release_connections(); + for (Ref<SceneTreeTimer> &timer : timers) { + timer->release_connections(); } timers.clear(); } @@ -1124,7 +1124,7 @@ void SceneTree::add_current_scene(Node *p_current) { root->add_child(p_current); } -Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_always) { +Ref<SceneTreeTimer> SceneTree::create_timer(double p_delay_sec, bool p_process_always) { Ref<SceneTreeTimer> stt; stt.instantiate(); stt->set_process_always(p_process_always); @@ -1146,8 +1146,8 @@ Array SceneTree::get_processed_tweens() { ret.resize(tweens.size()); int i = 0; - for (Ref<Tween> E : tweens) { - ret[i] = E; + for (const Ref<Tween> &tween : tweens) { + ret[i] = tween; i++; } diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index c3d59663d6..cfb95bd6b5 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -52,7 +52,7 @@ class Tween; class SceneTreeTimer : public RefCounted { GDCLASS(SceneTreeTimer, RefCounted); - float time_left = 0.0; + double time_left = 0.0; bool process_always = true; bool ignore_time_scale = false; @@ -60,8 +60,8 @@ protected: static void _bind_methods(); public: - void set_time_left(float p_time); - float get_time_left() const; + void set_time_left(double p_time); + double get_time_left() const; void set_process_always(bool p_process_always); bool is_process_always(); @@ -91,8 +91,8 @@ private: Window *root = nullptr; uint64_t tree_version = 1; - float physics_process_time = 1.0; - float process_time = 1.0; + double physics_process_time = 1.0; + double process_time = 1.0; bool accept_quit = true; bool quit_on_go_back = true; @@ -237,8 +237,8 @@ public: virtual void initialize() override; - virtual bool physics_process(float p_time) override; - virtual bool process(float p_time) override; + virtual bool physics_process(double p_time) override; + virtual bool process(double p_time) override; virtual void finalize() override; @@ -247,8 +247,8 @@ public: void quit(int p_exit_code = EXIT_SUCCESS); - _FORCE_INLINE_ float get_physics_process_time() const { return physics_process_time; } - _FORCE_INLINE_ float get_process_time() const { return process_time; } + _FORCE_INLINE_ double get_physics_process_time() const { return physics_process_time; } + _FORCE_INLINE_ double get_process_time() const { return process_time; } #ifdef TOOLS_ENABLED bool is_node_being_edited(const Node *p_node) const; @@ -317,7 +317,7 @@ public: Error change_scene_to(const Ref<PackedScene> &p_scene); Error reload_current_scene(); - Ref<SceneTreeTimer> create_timer(float p_delay_sec, bool p_process_always = true); + Ref<SceneTreeTimer> create_timer(double p_delay_sec, bool p_process_always = true); Ref<Tween> create_tween(); Array get_processed_tweens(); diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index ef8245076f..b5a2a30b3b 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -81,12 +81,12 @@ void Timer::_notification(int p_what) { } } -void Timer::set_wait_time(float p_time) { +void Timer::set_wait_time(double p_time) { ERR_FAIL_COND_MSG(p_time <= 0, "Time should be greater than zero."); wait_time = p_time; } -float Timer::get_wait_time() const { +double Timer::get_wait_time() const { return wait_time; } @@ -106,7 +106,7 @@ bool Timer::has_autostart() const { return autostart; } -void Timer::start(float p_time) { +void Timer::start(double p_time) { ERR_FAIL_COND_MSG(!is_inside_tree(), "Timer was not added to the SceneTree. Either add it or set autostart to true."); if (p_time > 0) { @@ -139,7 +139,7 @@ bool Timer::is_stopped() const { return get_time_left() <= 0; } -float Timer::get_time_left() const { +double Timer::get_time_left() const { return time_left > 0 ? time_left : 0; } diff --git a/scene/main/timer.h b/scene/main/timer.h index 3d9e21d7fc..2b9faddcb9 100644 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -36,7 +36,7 @@ class Timer : public Node { GDCLASS(Timer, Node); - float wait_time = 1.0; + double wait_time = 1.0; bool one_shot = false; bool autostart = false; bool processing = false; @@ -54,8 +54,8 @@ public: TIMER_PROCESS_IDLE, }; - void set_wait_time(float p_time); - float get_wait_time() const; + void set_wait_time(double p_time); + double get_wait_time() const; void set_one_shot(bool p_one_shot); bool is_one_shot() const; @@ -63,7 +63,7 @@ public: void set_autostart(bool p_start); bool has_autostart() const; - void start(float p_time = -1); + void start(double p_time = -1); void stop(); void set_paused(bool p_paused); @@ -71,7 +71,7 @@ public: bool is_stopped() const; - float get_time_left() const; + double get_time_left() const; void set_timer_process_callback(TimerProcessCallback p_callback); TimerProcessCallback get_timer_process_callback() const; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 4231072ed9..27e42db1bd 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -573,7 +573,7 @@ void Viewport::_process_picking() { // if no mouse event exists, create a motion one. This is necessary because objects or camera may have moved. // while this extra event is sent, it is checked if both camera and last object and last ID did not move. If nothing changed, the event is discarded to avoid flooding with unnecessary motion events every frame bool has_mouse_event = false; - for (Ref<InputEvent> m : physics_picking_events) { + for (const Ref<InputEvent> &m : physics_picking_events) { if (m.is_valid()) { has_mouse_event = true; break; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 439fe649a1..8ede8e9a0b 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -909,7 +909,6 @@ void register_scene_types() { ClassDB::add_compatibility_class("Generic6DOFJoint", "Generic6DOFJoint3D"); ClassDB::add_compatibility_class("HeightMapShape", "HeightMapShape3D"); ClassDB::add_compatibility_class("HingeJoint", "HingeJoint3D"); - ClassDB::add_compatibility_class("ImmediateGeometry", "ImmediateGeometry3D"); ClassDB::add_compatibility_class("Joint", "Joint3D"); ClassDB::add_compatibility_class("KinematicBody", "CharacterBody3D"); ClassDB::add_compatibility_class("KinematicBody2D", "CharacterBody2D"); |