summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-06-24 13:29:23 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-06-24 13:29:45 -0300
commit48f1d02da4795ba9d485fe5fe2bea907be2fc467 (patch)
treeae248e1e863bb675026c2cfb8399ac8d23f33ed0 /core
parent199ad16bbc50d41aaeb76c276947156dafc81481 (diff)
added ability to define signals in script
closes #2175
Diffstat (limited to 'core')
-rw-r--r--core/object.cpp9
-rw-r--r--core/script_language.h4
2 files changed, 13 insertions, 0 deletions
diff --git a/core/object.cpp b/core/object.cpp
index cdb2c6517a..6bb7973cef 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1302,6 +1302,10 @@ Array Object::_get_signal_connection_list(const String& p_signal) const{
void Object::get_signal_list(List<MethodInfo> *p_signals ) const {
+ if (!script.is_null()) {
+ Ref<Script>(script)->get_script_signal_list(p_signals);
+ }
+
ObjectTypeDB::get_signal_list(get_type_name(),p_signals);
//find maybe usersignals?
const StringName *S=NULL;
@@ -1313,6 +1317,7 @@ void Object::get_signal_list(List<MethodInfo> *p_signals ) const {
p_signals->push_back(signal_map[*S].user);
}
}
+
}
@@ -1351,6 +1356,10 @@ Error Object::connect(const StringName& p_signal, Object *p_to_object, const Str
Signal *s = signal_map.getptr(p_signal);
if (!s) {
bool signal_is_valid = ObjectTypeDB::has_signal(get_type_name(),p_signal);
+ //check in script
+ if (!signal_is_valid && !script.is_null() && Ref<Script>(script)->has_script_signal(p_signal))
+ signal_is_valid=true;
+
if (!signal_is_valid) {
ERR_EXPLAIN("Attempt to connect nonexistent signal '"+p_signal+"' to method '"+p_to_method+"'");
ERR_FAIL_COND_V(!signal_is_valid,ERR_INVALID_PARAMETER);
diff --git a/core/script_language.h b/core/script_language.h
index 07ad571fda..c1b906e251 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -94,6 +94,10 @@ public:
virtual ScriptLanguage *get_language() const=0;
+ virtual bool has_script_signal(const StringName& p_signal) const=0;
+ virtual void get_script_signal_list(List<MethodInfo> *r_signals) const=0;
+
+
virtual void update_exports() {} //editor tool