summaryrefslogtreecommitdiff
path: root/scene/main/viewport.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2021-09-09 19:19:10 -0300
committerGitHub <noreply@github.com>2021-09-09 19:19:10 -0300
commitd0a7eeaaffb0e79ccde9b794c383342d342744ce (patch)
tree6100e9cc98dbc2c376457bd6928c6cf70d96e2aa /scene/main/viewport.cpp
parent7c9cdea8365850aaf8101972c5853838759453bc (diff)
parentf2cb0a8d4b5226a0425d3a53caf23e353f231fed (diff)
Merge pull request #44844 from KoBeWi/hey_listen!_but_2d
Add Listener2D
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r--scene/main/viewport.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 8ec8c193fb..c5b0f47140 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -37,6 +37,7 @@
#include "core/templates/pair.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/collision_object_2d.h"
+#include "scene/2d/listener_2d.cpp"
#ifndef _3D_DISABLED
#include "scene/3d/camera_3d.h"
#include "scene/3d/collision_object_3d.h"
@@ -831,7 +832,6 @@ void Viewport::set_as_audio_listener_2d(bool p_enable) {
}
audio_listener_2d = p_enable;
-
_update_listener_2d();
}
@@ -839,6 +839,10 @@ bool Viewport::is_audio_listener_2d() const {
return audio_listener_2d;
}
+Listener2D *Viewport::get_listener_2d() const {
+ return listener_2d;
+}
+
void Viewport::enable_canvas_transform_override(bool p_enable) {
if (override_canvas_transform == p_enable) {
return;
@@ -903,6 +907,21 @@ void Viewport::_camera_2d_set(Camera2D *p_camera_2d) {
camera_2d = p_camera_2d;
}
+void Viewport::_listener_2d_set(Listener2D *p_listener) {
+ if (listener_2d == p_listener) {
+ return;
+ } else if (listener_2d) {
+ listener_2d->clear_current();
+ }
+ listener_2d = p_listener;
+}
+
+void Viewport::_listener_2d_remove(Listener2D *p_listener) {
+ if (listener_2d == p_listener) {
+ listener_2d = nullptr;
+ }
+}
+
void Viewport::_canvas_layer_add(CanvasLayer *p_canvas_layer) {
canvas_layers.insert(p_canvas_layer);
}