Add Ability to Pass Parameters When Calling Methods on Entities
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 7 files). Show all
Unified · Split
| @@ -18,6 +18,7 @@ · 17 unmodified lines | |||
| 18 | #include <QtNetwork/QNetworkReply> | 18 | #include <QtNetwork/QNetworkReply> |
| 19 | #include <QtScript/QScriptEngine> | 19 | #include <QtScript/QScriptEngine> |
| 20 | #include <QtScript/QScriptValue> | 20 | #include <QtScript/QScriptValue> |
| 21 | #include <QtCore/QStringList> | ||
| 21 | 22 | ||
| 22 | #include <AudioConstants.h> | 23 | #include <AudioConstants.h> |
| 23 | #include <AudioEffectOptions.h> | 24 | #include <AudioEffectOptions.h> |
| @@ -1170,8 +1171,7 @@ void ScriptEngine::refreshFileScript(const EntityItemID& entityID) { · 1146 unmodified lines | |||
| 1170 | recurseGuard = false; | 1171 | recurseGuard = false; |
| 1171 | } | 1172 | } |
| 1172 | 1173 | ||
| 1173 | 1174 | void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const QStringList& params) { | |
| 1174 | void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName) { | ||
| 1175 | if (QThread::currentThread() != thread()) { | 1175 | if (QThread::currentThread() != thread()) { |
| 1176 | #ifdef THREAD_DEBUGGING | 1176 | #ifdef THREAD_DEBUGGING |
| 1177 | qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " | 1177 | qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| @@ -1180,7 +1180,8 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 2 unmodified lines | |||
| 1180 | 1180 | ||
| 1181 | QMetaObject::invokeMethod(this, "callEntityScriptMethod", | 1181 | QMetaObject::invokeMethod(this, "callEntityScriptMethod", |
| 1182 | Q_ARG(const EntityItemID&, entityID), | 1182 | Q_ARG(const EntityItemID&, entityID), |
| 1183 | Q_ARG(const QString&, methodName)); | 1183 | Q_ARG(const QString&, methodName), |
| 1184 | Q_ARG(const QStringList&, params)); | ||
| 1184 | return; | 1185 | return; |
| 1185 | } | 1186 | } |
| 1186 | #ifdef THREAD_DEBUGGING | 1187 | #ifdef THREAD_DEBUGGING |
| @@ -1195,6 +1196,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 8 unmodified lines | |||
| 1195 | if (entityScript.property(methodName).isFunction()) { | 1196 | if (entityScript.property(methodName).isFunction()) { |
| 1196 | QScriptValueList args; | 1197 | QScriptValueList args; |
| 1197 | args << entityID.toScriptValue(this); | 1198 | args << entityID.toScriptValue(this); |
| 1199 | args << qScriptValueFromSequence(this, params); | ||
| 1198 | entityScript.property(methodName).call(entityScript, args); | 1200 | entityScript.property(methodName).call(entityScript, args); |
| 1199 | } | 1201 | } |
| 1200 | 1202 | ||