diff options
-rw-r--r-- | core/object.cpp | 20 | ||||
-rw-r--r-- | core/object.h | 1 | ||||
-rw-r--r-- | doc/classes/Object.xml | 11 | ||||
-rw-r--r-- | scene/resources/space_2d.cpp | 66 | ||||
-rw-r--r-- | scene/resources/space_2d.h | 56 |
5 files changed, 31 insertions, 123 deletions
diff --git a/core/object.cpp b/core/object.cpp index 140ee811fe..188c0ee5c2 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1324,6 +1324,25 @@ Array Object::_get_incoming_connections() const { return ret; } +bool Object::has_signal(const StringName &p_name) const { + if (!script.is_null()) { + Ref<Script> scr = script; + if (scr.is_valid() && scr->has_script_signal(p_name)) { + return true; + } + } + + if (ClassDB::has_signal(get_class_name(), p_name)) { + return true; + } + + if (_has_user_signal(p_name)) { + return true; + } + + return false; +} + void Object::get_signal_list(List<MethodInfo> *p_signals) const { if (!script.is_null()) { @@ -1696,6 +1715,7 @@ void Object::_bind_methods() { ClassDB::bind_method(D_METHOD("has_method", "method"), &Object::has_method); + ClassDB::bind_method(D_METHOD("has_signal", "signal"), &Object::has_signal); ClassDB::bind_method(D_METHOD("get_signal_list"), &Object::_get_signal_list); ClassDB::bind_method(D_METHOD("get_signal_connection_list", "signal"), &Object::_get_signal_connection_list); ClassDB::bind_method(D_METHOD("get_incoming_connections"), &Object::_get_incoming_connections); diff --git a/core/object.h b/core/object.h index 59d3f06cfe..9bdcf0d3d8 100644 --- a/core/object.h +++ b/core/object.h @@ -694,6 +694,7 @@ public: void add_user_signal(const MethodInfo &p_signal); Error emit_signal(const StringName &p_name, VARIANT_ARG_LIST); Error emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount); + bool has_signal(const StringName &p_name) const; void get_signal_list(List<MethodInfo> *p_signals) const; void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const; void get_all_signal_connections(List<Connection> *p_connections) const; diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index a3faccae1a..33f5fc0f35 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -311,13 +311,22 @@ Returns [code]true[/code] if the object contains the given [code]method[/code]. </description> </method> + <method name="has_signal" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="signal" type="String"> + </argument> + <description> + Returns [code]true[/code] if the given [code]signal[/code] exists. + </description> + </method> <method name="has_user_signal" qualifiers="const"> <return type="bool"> </return> <argument index="0" name="signal" type="StringName"> </argument> <description> - Returns [code]true[/code] if the given user-defined [code]signal[/code] exists. + Returns [code]true[/code] if the given user-defined [code]signal[/code] exists. Only signals added using [method add_user_signal] are taken into account. </description> </method> <method name="is_blocking_signals" qualifiers="const"> diff --git a/scene/resources/space_2d.cpp b/scene/resources/space_2d.cpp deleted file mode 100644 index 376e926548..0000000000 --- a/scene/resources/space_2d.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************/ -/* space_2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "space_2d.h" - -RID Space2D::get_rid() const { - - return space; -} - -void Space2D::set_active(bool p_active) { - - active = p_active; - Physics2DServer::get_singleton()->space_set_active(space, active); -} - -bool Space2D::is_active() const { - - return active; -} - -void Space2D::_bind_methods() { - - ClassDB::bind_method(D_METHOD("set_active", "active"), &Space2D::set_active); - ClassDB::bind_method(D_METHOD("is_active"), &Space2D::is_active); - - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "is_active"); -} - -Space2D::Space2D() { - - active = false; - space = Physics2DServer::get_singleton()->space_create(); -} - -Space2D::~Space2D() { - - Physics2DServer::get_singleton()->free(space); -} diff --git a/scene/resources/space_2d.h b/scene/resources/space_2d.h deleted file mode 100644 index ff88c40348..0000000000 --- a/scene/resources/space_2d.h +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************/ -/* space_2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef SPACE_2D_H -#define SPACE_2D_H - -#include "core/resource.h" -#include "servers/physics_2d_server.h" - -class Space2D : public Resource { - - GDCLASS(Space2D, Resource); - bool active; - RID space; - -protected: - static void _bind_methods(); - -public: - void set_active(bool p_active); - bool is_active() const; - - virtual RID get_rid() const; - - Space2D(); - ~Space2D(); -}; - -#endif // SPACE_2D_H |