summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-10 10:52:12 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-10 10:52:12 +0100
commite3a87641bde07c1a2a8a9efdff8ad88856a14cd7 (patch)
tree3fdc163f6d6100c1481d1ff8c25d0bd072d7759d /scene/main
parent796690948f275039f205fab815fde03e4022edab (diff)
parentca8b762797cd725124f26c77f1a872cef269022b (diff)
Merge pull request #71147 from bruvzg/get_win
Add Node::get_window() method.
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/node.cpp10
-rw-r--r--scene/main/node.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 3544ec4c83..eb57ccfef1 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -39,6 +39,7 @@
#include "scene/animation/tween.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/main/multiplayer_api.h"
+#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
#include "viewport.h"
@@ -1467,6 +1468,14 @@ Node *Node::find_parent(const String &p_pattern) const {
return nullptr;
}
+Window *Node::get_window() const {
+ Viewport *vp = get_viewport();
+ if (vp) {
+ return vp->get_base_window();
+ }
+ return nullptr;
+}
+
bool Node::is_ancestor_of(const Node *p_node) const {
ERR_FAIL_NULL_V(p_node, false);
Node *p = p_node->data.parent;
@@ -2858,6 +2867,7 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_physics_process_internal", "enable"), &Node::set_physics_process_internal);
ClassDB::bind_method(D_METHOD("is_physics_processing_internal"), &Node::is_physics_processing_internal);
+ ClassDB::bind_method(D_METHOD("get_window"), &Node::get_window);
ClassDB::bind_method(D_METHOD("get_tree"), &Node::get_tree);
ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween);
diff --git a/scene/main/node.h b/scene/main/node.h
index 398465c3cd..dbdcca6170 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -37,6 +37,7 @@
#include "scene/main/scene_tree.h"
class Viewport;
+class Window;
class SceneState;
class Tween;
class PropertyTweener;
@@ -321,6 +322,8 @@ public:
Node *get_parent() const;
Node *find_parent(const String &p_pattern) const;
+ Window *get_window() const;
+
_FORCE_INLINE_ SceneTree *get_tree() const {
ERR_FAIL_COND_V(!data.tree, nullptr);
return data.tree;