Merge pull request #9195 from kubecz3k/obj-incoming-connections

Ability to get a list of signals that are targeting given object
This commit is contained in:
Rémi Verschelde 2017-06-27 00:06:42 +02:00 committed by GitHub
commit 6f0762ba5d
2 changed files with 17 additions and 0 deletions

View file

@ -1357,6 +1357,21 @@ Array Object::_get_signal_connection_list(const String &p_signal) const {
return ret;
}
Array Object::_get_incoming_connections() const {
Array ret;
int connections_amount = connections.size();
for (int idx_conn = 0; idx_conn < connections_amount; idx_conn++) {
Dictionary conn_data;
conn_data["source"] = connections[idx_conn].source;
conn_data["signal_name"] = connections[idx_conn].signal;
conn_data["method_name"] = connections[idx_conn].method;
ret.push_back(conn_data);
}
return ret;
}
void Object::get_signal_list(List<MethodInfo> *p_signals) const {
if (!script.is_null()) {
@ -1683,6 +1698,7 @@ void Object::_bind_methods() {
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);
ClassDB::bind_method(D_METHOD("connect", "signal", "target:Object", "method", "binds", "flags"), &Object::connect, DEFVAL(Array()), DEFVAL(0));
ClassDB::bind_method(D_METHOD("disconnect", "signal", "target:Object", "method"), &Object::disconnect);

View file

@ -443,6 +443,7 @@ private:
Variant _emit_signal(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
Array _get_signal_list() const;
Array _get_signal_connection_list(const String &p_signal) const;
Array _get_incoming_connections() const;
void _set_bind(const String &p_set, const Variant &p_value);
Variant _get_bind(const String &p_name) const;