|
@@ -1,5 +1,5 @@
|
|
|
/*************************************************************************/
|
|
|
-/* visibility_notifier_2d.cpp */
|
|
|
+/* visible_on_screen_notifier_2d.cpp */
|
|
|
/*************************************************************************/
|
|
|
/* This file is part of: */
|
|
|
/* GODOT ENGINE */
|
|
@@ -28,7 +28,7 @@
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
/*************************************************************************/
|
|
|
|
|
|
-#include "visibility_notifier_2d.h"
|
|
|
+#include "visible_on_screen_notifier_2d.h"
|
|
|
|
|
|
#include "core/config/engine.h"
|
|
|
#include "gpu_particles_2d.h"
|
|
@@ -39,16 +39,16 @@
|
|
|
#include "scene/scene_string_names.h"
|
|
|
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
-Rect2 VisibilityNotifier2D::_edit_get_rect() const {
|
|
|
+Rect2 VisibleOnScreenNotifier2D::_edit_get_rect() const {
|
|
|
return rect;
|
|
|
}
|
|
|
|
|
|
-bool VisibilityNotifier2D::_edit_use_rect() const {
|
|
|
+bool VisibleOnScreenNotifier2D::_edit_use_rect() const {
|
|
|
return true;
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-void VisibilityNotifier2D::_visibility_enter() {
|
|
|
+void VisibleOnScreenNotifier2D::_visibility_enter() {
|
|
|
if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) {
|
|
|
return;
|
|
|
}
|
|
@@ -57,7 +57,7 @@ void VisibilityNotifier2D::_visibility_enter() {
|
|
|
emit_signal(SceneStringNames::get_singleton()->screen_entered);
|
|
|
_screen_enter();
|
|
|
}
|
|
|
-void VisibilityNotifier2D::_visibility_exit() {
|
|
|
+void VisibleOnScreenNotifier2D::_visibility_exit() {
|
|
|
if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) {
|
|
|
return;
|
|
|
}
|
|
@@ -67,23 +67,23 @@ void VisibilityNotifier2D::_visibility_exit() {
|
|
|
_screen_exit();
|
|
|
}
|
|
|
|
|
|
-void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
|
|
|
+void VisibleOnScreenNotifier2D::set_rect(const Rect2 &p_rect) {
|
|
|
rect = p_rect;
|
|
|
if (is_inside_tree()) {
|
|
|
- RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibilityNotifier2D::_visibility_enter), callable_mp(this, &VisibilityNotifier2D::_visibility_exit));
|
|
|
+ RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_enter), callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_exit));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-Rect2 VisibilityNotifier2D::get_rect() const {
|
|
|
+Rect2 VisibleOnScreenNotifier2D::get_rect() const {
|
|
|
return rect;
|
|
|
}
|
|
|
|
|
|
-void VisibilityNotifier2D::_notification(int p_what) {
|
|
|
+void VisibleOnScreenNotifier2D::_notification(int p_what) {
|
|
|
switch (p_what) {
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
|
|
//get_world_2d()->
|
|
|
on_screen = false;
|
|
|
- RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibilityNotifier2D::_visibility_enter), callable_mp(this, &VisibilityNotifier2D::_visibility_exit));
|
|
|
+ RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_enter), callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_exit));
|
|
|
} break;
|
|
|
case NOTIFICATION_DRAW: {
|
|
|
if (Engine::get_singleton()->is_editor_hint()) {
|
|
@@ -97,14 +97,14 @@ void VisibilityNotifier2D::_notification(int p_what) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool VisibilityNotifier2D::is_on_screen() const {
|
|
|
+bool VisibleOnScreenNotifier2D::is_on_screen() const {
|
|
|
return on_screen;
|
|
|
}
|
|
|
|
|
|
-void VisibilityNotifier2D::_bind_methods() {
|
|
|
- ClassDB::bind_method(D_METHOD("set_rect", "rect"), &VisibilityNotifier2D::set_rect);
|
|
|
- ClassDB::bind_method(D_METHOD("get_rect"), &VisibilityNotifier2D::get_rect);
|
|
|
- ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier2D::is_on_screen);
|
|
|
+void VisibleOnScreenNotifier2D::_bind_methods() {
|
|
|
+ ClassDB::bind_method(D_METHOD("set_rect", "rect"), &VisibleOnScreenNotifier2D::set_rect);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_rect"), &VisibleOnScreenNotifier2D::get_rect);
|
|
|
+ ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibleOnScreenNotifier2D::is_on_screen);
|
|
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "rect"), "set_rect", "get_rect");
|
|
|
|
|
@@ -112,31 +112,31 @@ void VisibilityNotifier2D::_bind_methods() {
|
|
|
ADD_SIGNAL(MethodInfo("screen_exited"));
|
|
|
}
|
|
|
|
|
|
-VisibilityNotifier2D::VisibilityNotifier2D() {
|
|
|
+VisibleOnScreenNotifier2D::VisibleOnScreenNotifier2D() {
|
|
|
rect = Rect2(-10, -10, 20, 20);
|
|
|
}
|
|
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
|
-void VisibilityEnabler2D::_screen_enter() {
|
|
|
+void VisibleOnScreenEnabler2D::_screen_enter() {
|
|
|
_update_enable_mode(true);
|
|
|
}
|
|
|
|
|
|
-void VisibilityEnabler2D::_screen_exit() {
|
|
|
+void VisibleOnScreenEnabler2D::_screen_exit() {
|
|
|
_update_enable_mode(false);
|
|
|
}
|
|
|
|
|
|
-void VisibilityEnabler2D::set_enable_mode(EnableMode p_mode) {
|
|
|
+void VisibleOnScreenEnabler2D::set_enable_mode(EnableMode p_mode) {
|
|
|
enable_mode = p_mode;
|
|
|
if (is_inside_tree()) {
|
|
|
_update_enable_mode(is_on_screen());
|
|
|
}
|
|
|
}
|
|
|
-VisibilityEnabler2D::EnableMode VisibilityEnabler2D::get_enable_mode() {
|
|
|
+VisibleOnScreenEnabler2D::EnableMode VisibleOnScreenEnabler2D::get_enable_mode() {
|
|
|
return enable_mode;
|
|
|
}
|
|
|
|
|
|
-void VisibilityEnabler2D::set_enable_node_path(NodePath p_path) {
|
|
|
+void VisibleOnScreenEnabler2D::set_enable_node_path(NodePath p_path) {
|
|
|
if (enable_node_path == p_path) {
|
|
|
return;
|
|
|
}
|
|
@@ -150,11 +150,11 @@ void VisibilityEnabler2D::set_enable_node_path(NodePath p_path) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-NodePath VisibilityEnabler2D::get_enable_node_path() {
|
|
|
+NodePath VisibleOnScreenEnabler2D::get_enable_node_path() {
|
|
|
return enable_node_path;
|
|
|
}
|
|
|
|
|
|
-void VisibilityEnabler2D::_update_enable_mode(bool p_enable) {
|
|
|
+void VisibleOnScreenEnabler2D::_update_enable_mode(bool p_enable) {
|
|
|
Node *node = static_cast<Node *>(ObjectDB::get_instance(node_id));
|
|
|
if (node) {
|
|
|
if (p_enable) {
|
|
@@ -174,7 +174,7 @@ void VisibilityEnabler2D::_update_enable_mode(bool p_enable) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-void VisibilityEnabler2D::_notification(int p_what) {
|
|
|
+void VisibleOnScreenEnabler2D::_notification(int p_what) {
|
|
|
if (p_what == NOTIFICATION_ENTER_TREE) {
|
|
|
if (Engine::get_singleton()->is_editor_hint()) {
|
|
|
return;
|
|
@@ -193,12 +193,12 @@ void VisibilityEnabler2D::_notification(int p_what) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void VisibilityEnabler2D::_bind_methods() {
|
|
|
- ClassDB::bind_method(D_METHOD("set_enable_mode", "mode"), &VisibilityEnabler2D::set_enable_mode);
|
|
|
- ClassDB::bind_method(D_METHOD("get_enable_mode"), &VisibilityEnabler2D::get_enable_mode);
|
|
|
+void VisibleOnScreenEnabler2D::_bind_methods() {
|
|
|
+ ClassDB::bind_method(D_METHOD("set_enable_mode", "mode"), &VisibleOnScreenEnabler2D::set_enable_mode);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_enable_mode"), &VisibleOnScreenEnabler2D::get_enable_mode);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_enable_node_path", "path"), &VisibilityEnabler2D::set_enable_node_path);
|
|
|
- ClassDB::bind_method(D_METHOD("get_enable_node_path"), &VisibilityEnabler2D::get_enable_node_path);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_enable_node_path", "path"), &VisibleOnScreenEnabler2D::set_enable_node_path);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_enable_node_path"), &VisibleOnScreenEnabler2D::get_enable_node_path);
|
|
|
|
|
|
ADD_GROUP("Enabling", "enable_");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "enable_mode", PROPERTY_HINT_ENUM, "Inherit,Always,WhenPaused"), "set_enable_mode", "get_enable_mode");
|
|
@@ -209,5 +209,5 @@ void VisibilityEnabler2D::_bind_methods() {
|
|
|
BIND_ENUM_CONSTANT(ENABLE_MODE_WHEN_PAUSED);
|
|
|
}
|
|
|
|
|
|
-VisibilityEnabler2D::VisibilityEnabler2D() {
|
|
|
+VisibleOnScreenEnabler2D::VisibleOnScreenEnabler2D() {
|
|
|
}
|