diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-08-20 12:55:46 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-20 12:55:46 -0300 |
commit | 541fdffc0ab2115238fe9cedbf1c088b15f11fdf (patch) | |
tree | 187c5d0278e5075907fef8a86b4d00d6a0b7161a /scene/main | |
parent | 831e21e89ba0275b43b6a351e538256b8ce715a3 (diff) | |
parent | 90b8a5b71ef79e0339826507c4b290f0c51b7cd2 (diff) | |
download | redot-engine-541fdffc0ab2115238fe9cedbf1c088b15f11fdf.tar.gz |
Merge pull request #10319 from neikeq/pr-engine-editor-hint
Adds Engine::is_editor_hint() method
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/scene_tree.cpp | 24 | ||||
-rw-r--r-- | scene/main/scene_tree.h | 9 | ||||
-rwxr-xr-x | scene/main/timer.cpp | 4 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 4 |
4 files changed, 10 insertions, 31 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 2e67a1feaf..8c0733e8b2 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -382,7 +382,7 @@ bool SceneTree::is_input_handled() { void SceneTree::input_event(const Ref<InputEvent> &p_event) { - if (is_editor_hint() && (p_event->cast_to<InputEventJoypadButton>() || p_event->cast_to<InputEventJoypadMotion>())) + if (Engine::get_singleton()->is_editor_hint() && (p_event->cast_to<InputEventJoypadButton>() || p_event->cast_to<InputEventJoypadMotion>())) return; //avoid joy input on editor root_lock++; @@ -541,7 +541,7 @@ bool SceneTree::idle(float p_time) { #ifdef TOOLS_ENABLED - if (is_editor_hint()) { + if (Engine::get_singleton()->is_editor_hint()) { //simple hack to reload fallback environment if it changed from editor String env_path = ProjectSettings::get_singleton()->get("rendering/environment/default_environment"); env_path = env_path.strip_edges(); //user may have added a space or two @@ -616,7 +616,7 @@ void SceneTree::_notification(int p_notification) { get_root()->propagate_notification(p_notification); } break; case NOTIFICATION_TRANSLATION_CHANGED: { - if (!is_editor_hint()) { + if (!Engine::get_singleton()->is_editor_hint()) { get_root()->propagate_notification(Node::NOTIFICATION_TRANSLATION_CHANGED); } } break; @@ -642,19 +642,10 @@ void SceneTree::set_quit_on_go_back(bool p_enable) { } #ifdef TOOLS_ENABLED -void SceneTree::set_editor_hint(bool p_enabled) { - - editor_hint = p_enabled; -} bool SceneTree::is_node_being_edited(const Node *p_node) const { - return editor_hint && edited_scene_root && edited_scene_root->is_a_parent_of(p_node); -} - -bool SceneTree::is_editor_hint() const { - - return editor_hint; + return Engine::get_singleton()->is_editor_hint() && edited_scene_root && edited_scene_root->is_a_parent_of(p_node); } #endif @@ -2114,8 +2105,6 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("set_auto_accept_quit", "enabled"), &SceneTree::set_auto_accept_quit); - ClassDB::bind_method(D_METHOD("set_editor_hint", "enable"), &SceneTree::set_editor_hint); - ClassDB::bind_method(D_METHOD("is_editor_hint"), &SceneTree::is_editor_hint); ClassDB::bind_method(D_METHOD("set_debug_collisions_hint", "enable"), &SceneTree::set_debug_collisions_hint); ClassDB::bind_method(D_METHOD("is_debugging_collisions_hint"), &SceneTree::is_debugging_collisions_hint); ClassDB::bind_method(D_METHOD("set_debug_navigation_hint", "enable"), &SceneTree::set_debug_navigation_hint); @@ -2240,9 +2229,6 @@ SceneTree::SceneTree() { accept_quit = true; quit_on_go_back = true; initialized = false; -#ifdef TOOLS_ENABLED - editor_hint = false; -#endif #ifdef DEBUG_ENABLED debug_collisions_hint = false; debug_navigation_hint = false; @@ -2312,7 +2298,7 @@ SceneTree::SceneTree() { if (env.is_valid()) { root->get_world()->set_fallback_environment(env); } else { - if (is_editor_hint()) { + if (Engine::get_singleton()->is_editor_hint()) { //file was erased, clear the field. ProjectSettings::get_singleton()->set("rendering/environment/default_environment", ""); } else { diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index 3543ebee90..5563bd33be 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -111,9 +111,6 @@ private: bool quit_on_go_back; uint32_t last_id; -#ifdef TOOLS_ENABLED - bool editor_hint; -#endif #ifdef DEBUG_ENABLED bool debug_collisions_hint; bool debug_navigation_hint; @@ -363,14 +360,8 @@ public: _FORCE_INLINE_ float get_idle_process_time() const { return idle_process_time; } #ifdef TOOLS_ENABLED - void set_editor_hint(bool p_enabled); - - bool is_editor_hint() const; bool is_node_being_edited(const Node *p_node) const; #else - void set_editor_hint(bool p_enabled) {} - - bool is_editor_hint() const { return false; } bool is_node_being_edited(const Node *p_node) const { return false; } #endif diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index a61d1100e6..06801ee49d 100755 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -29,6 +29,8 @@ /*************************************************************************/ #include "timer.h" +#include "engine.h" + void Timer::_notification(int p_what) { switch (p_what) { @@ -37,7 +39,7 @@ void Timer::_notification(int p_what) { if (autostart) { #ifdef TOOLS_ENABLED - if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) + if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) break; #endif start(); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index a22d897669..7148cda5c4 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1354,7 +1354,7 @@ void Viewport::_vp_input(const Ref<InputEvent> &p_ev) { return; #ifdef TOOLS_ENABLED - if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { + if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { return; } #endif @@ -1374,7 +1374,7 @@ void Viewport::_vp_unhandled_input(const Ref<InputEvent> &p_ev) { if (disable_input) return; #ifdef TOOLS_ENABLED - if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { + if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { return; } #endif |