Showing the changes to libraries/script-engine/src/ScriptEngine.h (1 of 6 files). Show all
Unified · Split
| @@ -40,6 +40,12 @@ const unsigned int SCRIPT_DATA_CALLBACK_USECS = floor(((1.0f / 60.0f) * 1000 * 1 · 39 unmodified lines | |||
| 40 | 40 | ||
| 41 | typedef QHash<QString, QScriptValueList> RegisteredEventHandlers; | 41 | typedef QHash<QString, QScriptValueList> RegisteredEventHandlers; |
| 42 | 42 | ||
| 43 | class EntityScriptDetails { | ||
| 44 | public: | ||
| 45 | QString scriptText; | ||
| 46 | QScriptValue scriptObject; | ||
| 47 | }; | ||
| 48 | |||
| 43 | class ScriptEngine : public QScriptEngine, public ScriptUser { | 49 | class ScriptEngine : public QScriptEngine, public ScriptUser { |
| 44 | Q_OBJECT | 50 | Q_OBJECT |
| 45 | public: | 51 | public: |
| @@ -100,6 +106,13 @@ public: · 54 unmodified lines | |||
| 100 | Q_INVOKABLE void print(const QString& message); | 106 | Q_INVOKABLE void print(const QString& message); |
| 101 | Q_INVOKABLE QUrl resolvePath(const QString& path) const; | 107 | Q_INVOKABLE QUrl resolvePath(const QString& path) const; |
| 102 | 108 | ||
| 109 | // Entity Script Related methods | ||
| 110 | Q_INVOKABLE void loadEntityScript(const EntityItemID& entityID, const QString& entityScript, bool forceRedownload = false); // will call the preload method once loaded | ||
| 111 | Q_INVOKABLE void unloadEntityScript(const EntityItemID& entityID); // will call unload method | ||
| 112 | Q_INVOKABLE void callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName); | ||
| 113 | Q_INVOKABLE void callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const MouseEvent& event); | ||
| 114 | Q_INVOKABLE void callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const EntityItemID& otherID, const Collision& collision); | ||
| 115 | |||
| 103 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 116 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 104 | // NOTE - this is intended to be a public interface for Agent scripts, and local scripts, but not for EntityScripts | 117 | // NOTE - this is intended to be a public interface for Agent scripts, and local scripts, but not for EntityScripts |
| 105 | Q_INVOKABLE void stop(); | 118 | Q_INVOKABLE void stop(); |
| @@ -149,6 +162,9 @@ protected: · 43 unmodified lines | |||
| 149 | QSet<QUrl> _includedURLs; | 162 | QSet<QUrl> _includedURLs; |
| 150 | bool _wantSignals = true; | 163 | bool _wantSignals = true; |
| 151 | 164 | ||
| 165 | QHash<EntityItemID, EntityScriptDetails> _entityScripts; | ||
| 166 | |||
| 167 | |||
| 152 | private: | 168 | private: |
| 153 | void init(); | 169 | void init(); |
| 154 | QString getFilename() const; | 170 | QString getFilename() const; |