Showing the changes to libraries/script-engine/src/ScriptManagerScriptingInterface.h (1 of 3 files). Show all
Unified · Split
| @@ -16,7 +16,7 @@ · 15 unmodified lines | |||
| 16 | #include "ScriptManager.h" | 16 | #include "ScriptManager.h" |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | /**jsdoc | 19 | /*@jsdoc |
| 20 | * The <code>Script</code> API provides facilities for working with scripts. | 20 | * The <code>Script</code> API provides facilities for working with scripts. |
| 21 | * | 21 | * |
| 22 | * @namespace Script | 22 | * @namespace Script |
| @@ -64,7 +64,7 @@ public: · 41 unmodified lines | |||
| 64 | virtual ~ScriptManagerScriptingInterface() { | 64 | virtual ~ScriptManagerScriptingInterface() { |
| 65 | 65 | ||
| 66 | } | 66 | } |
| 67 | /**jsdoc | 67 | /*@jsdoc |
| 68 | * Stops and unloads the current script. | 68 | * Stops and unloads the current script. |
| 69 | * <p><strong>Warning:</strong> If an assignment client script, the script gets restarted after stopping.</p> | 69 | * <p><strong>Warning:</strong> If an assignment client script, the script gets restarted after stopping.</p> |
| 70 | * @function Script.stop | 70 | * @function Script.stop |
| @@ -83,7 +83,7 @@ public: · 12 unmodified lines | |||
| 83 | // NOTE - this is intended to be a public interface for Agent scripts, and local scripts, but not for EntityScripts | 83 | // NOTE - this is intended to be a public interface for Agent scripts, and local scripts, but not for EntityScripts |
| 84 | Q_INVOKABLE void stop(bool marshal = false) { _manager->stop(marshal); } | 84 | Q_INVOKABLE void stop(bool marshal = false) { _manager->stop(marshal); } |
| 85 | 85 | ||
| 86 | /**jsdoc | 86 | /*@jsdoc |
| 87 | * Gets the context that the script is running in: Interface/avatar, client entity, server entity, or assignment client. | 87 | * Gets the context that the script is running in: Interface/avatar, client entity, server entity, or assignment client. |
| 88 | * @function Script.getContext | 88 | * @function Script.getContext |
| 89 | * @returns {string} The context that the script is running in: | 89 | * @returns {string} The context that the script is running in: |
| @@ -97,7 +97,7 @@ public: · 7 unmodified lines | |||
| 97 | Q_INVOKABLE QString getContext() const { return _manager->getContext(); } | 97 | Q_INVOKABLE QString getContext() const { return _manager->getContext(); } |
| 98 | 98 | ||
| 99 | 99 | ||
| 100 | /**jsdoc | 100 | /*@jsdoc |
| 101 | * Checks whether the script is running as an Interface or avatar script. | 101 | * Checks whether the script is running as an Interface or avatar script. |
| 102 | * @function Script.isClientScript | 102 | * @function Script.isClientScript |
| 103 | * @returns {boolean} <code>true</code> if the script is running as an Interface or avatar script, <code>false</code> if it | 103 | * @returns {boolean} <code>true</code> if the script is running as an Interface or avatar script, <code>false</code> if it |
| @@ -105,7 +105,7 @@ public: · 1 unmodified line | |||
| 105 | */ | 105 | */ |
| 106 | Q_INVOKABLE bool isClientScript() const { return _manager->isClientScript(); } | 106 | Q_INVOKABLE bool isClientScript() const { return _manager->isClientScript(); } |
| 107 | 107 | ||
| 108 | /**jsdoc | 108 | /*@jsdoc |
| 109 | * Checks whether the application was compiled as a debug build. | 109 | * Checks whether the application was compiled as a debug build. |
| 110 | * @function Script.isDebugMode | 110 | * @function Script.isDebugMode |
| 111 | * @returns {boolean} <code>true</code> if the application was compiled as a debug build, <code>false</code> if it was | 111 | * @returns {boolean} <code>true</code> if the application was compiled as a debug build, <code>false</code> if it was |
| @@ -113,21 +113,21 @@ public: · 1 unmodified line | |||
| 113 | */ | 113 | */ |
| 114 | Q_INVOKABLE bool isDebugMode() const { return _manager->isDebugMode(); } | 114 | Q_INVOKABLE bool isDebugMode() const { return _manager->isDebugMode(); } |
| 115 | 115 | ||
| 116 | /**jsdoc | 116 | /*@jsdoc |
| 117 | * Checks whether the script is running as a client entity script. | 117 | * Checks whether the script is running as a client entity script. |
| 118 | * @function Script.isEntityClientScript | 118 | * @function Script.isEntityClientScript |
| 119 | * @returns {boolean} <code>true</code> if the script is running as a client entity script, <code>false</code> if it isn't. | 119 | * @returns {boolean} <code>true</code> if the script is running as a client entity script, <code>false</code> if it isn't. |
| 120 | */ | 120 | */ |
| 121 | Q_INVOKABLE bool isEntityClientScript() const { return _manager->isEntityClientScript(); } | 121 | Q_INVOKABLE bool isEntityClientScript() const { return _manager->isEntityClientScript(); } |
| 122 | 122 | ||
| 123 | /**jsdoc | 123 | /*@jsdoc |
| 124 | * Checks whether the script is running as a server entity script. | 124 | * Checks whether the script is running as a server entity script. |
| 125 | * @function Script.isEntityServerScript | 125 | * @function Script.isEntityServerScript |
| 126 | * @returns {boolean} <code>true</code> if the script is running as a server entity script, <code>false</code> if it isn't. | 126 | * @returns {boolean} <code>true</code> if the script is running as a server entity script, <code>false</code> if it isn't. |
| 127 | */ | 127 | */ |
| 128 | Q_INVOKABLE bool isEntityServerScript() const { return _manager->isEntityServerScript(); } | 128 | Q_INVOKABLE bool isEntityServerScript() const { return _manager->isEntityServerScript(); } |
| 129 | 129 | ||
| 130 | /**jsdoc | 130 | /*@jsdoc |
| 131 | * Checks whether the script is running as an assignment client script. | 131 | * Checks whether the script is running as an assignment client script. |
| 132 | * @function Script.isAgentScript | 132 | * @function Script.isAgentScript |
| 133 | * @returns {boolean} <code>true</code> if the script is running as an assignment client script, <code>false</code> if it | 133 | * @returns {boolean} <code>true</code> if the script is running as an assignment client script, <code>false</code> if it |
| @@ -147,7 +147,7 @@ public: · 13 unmodified lines | |||
| 147 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 147 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 148 | // NOTE - these are intended to be public interfaces available to scripts | 148 | // NOTE - these are intended to be public interfaces available to scripts |
| 149 | 149 | ||
| 150 | /**jsdoc | 150 | /*@jsdoc |
| 151 | * @function Script.formatExecption | 151 | * @function Script.formatExecption |
| 152 | * @param {object} exception - Exception. | 152 | * @param {object} exception - Exception. |
| 153 | * @param {boolean} inludeExtendeDetails - Include extended details. | 153 | * @param {boolean} inludeExtendeDetails - Include extended details. |
| @@ -156,7 +156,7 @@ public: · 2 unmodified lines | |||
| 156 | */ | 156 | */ |
| 157 | Q_INVOKABLE QString formatException(const ScriptValue& exception, bool includeExtendedDetails) { return _manager->formatException(exception, includeExtendedDetails); } | 157 | Q_INVOKABLE QString formatException(const ScriptValue& exception, bool includeExtendedDetails) { return _manager->formatException(exception, includeExtendedDetails); } |
| 158 | 158 | ||
| 159 | /**jsdoc | 159 | /*@jsdoc |
| 160 | * Adds a function to the list of functions called when a particular event occurs on a particular entity. | 160 | * Adds a function to the list of functions called when a particular event occurs on a particular entity. |
| 161 | * <p>See also, the {@link Entities} API.</p> | 161 | * <p>See also, the {@link Entities} API.</p> |
| 162 | * @function Script.addEventHandler | 162 | * @function Script.addEventHandler |
| @@ -180,7 +180,7 @@ public: · 17 unmodified lines | |||
| 180 | */ | 180 | */ |
| 181 | Q_INVOKABLE void addEventHandler(const EntityItemID& entityID, const QString& eventName, const ScriptValue& handler) { _manager->addEventHandler(entityID, eventName, handler); } | 181 | Q_INVOKABLE void addEventHandler(const EntityItemID& entityID, const QString& eventName, const ScriptValue& handler) { _manager->addEventHandler(entityID, eventName, handler); } |
| 182 | 182 | ||
| 183 | /**jsdoc | 183 | /*@jsdoc |
| 184 | * Removes a function from the list of functions called when an entity event occurs on a particular entity. | 184 | * Removes a function from the list of functions called when an entity event occurs on a particular entity. |
| 185 | * <p>See also, the {@link Entities} API.</p> | 185 | * <p>See also, the {@link Entities} API.</p> |
| 186 | * @function Script.removeEventHandler | 186 | * @function Script.removeEventHandler |
| @@ -190,7 +190,7 @@ public: · 3 unmodified lines | |||
| 190 | */ | 190 | */ |
| 191 | Q_INVOKABLE void removeEventHandler(const EntityItemID& entityID, const QString& eventName, const ScriptValue& handler) { _manager->removeEventHandler(entityID, eventName, handler); } | 191 | Q_INVOKABLE void removeEventHandler(const EntityItemID& entityID, const QString& eventName, const ScriptValue& handler) { _manager->removeEventHandler(entityID, eventName, handler); } |
| 192 | 192 | ||
| 193 | /**jsdoc | 193 | /*@jsdoc |
| 194 | * Starts running another script in Interface, if it isn't already running. The script is not automatically loaded next | 194 | * Starts running another script in Interface, if it isn't already running. The script is not automatically loaded next |
| 195 | * time Interface starts. | 195 | * time Interface starts. |
| 196 | * <p class="availableIn"><strong>Supported Script Types:</strong> Interface Scripts • Avatar Scripts</p> | 196 | * <p class="availableIn"><strong>Supported Script Types:</strong> Interface Scripts • Avatar Scripts</p> |
| @@ -212,7 +212,7 @@ public: · 15 unmodified lines | |||
| 212 | */ | 212 | */ |
| 213 | Q_INVOKABLE void load(const QString& loadfile) { _manager->load(loadfile); } | 213 | Q_INVOKABLE void load(const QString& loadfile) { _manager->load(loadfile); } |
| 214 | 214 | ||
| 215 | /**jsdoc | 215 | /*@jsdoc |
| 216 | * Includes JavaScript from other files in the current script. If a callback is specified, the files are loaded and | 216 | * Includes JavaScript from other files in the current script. If a callback is specified, the files are loaded and |
| 217 | * included asynchronously, otherwise they are included synchronously (i.e., script execution blocks while the files are | 217 | * included asynchronously, otherwise they are included synchronously (i.e., script execution blocks while the files are |
| 218 | * included). | 218 | * included). |
| @@ -224,7 +224,7 @@ public: · 5 unmodified lines | |||
| 224 | */ | 224 | */ |
| 225 | Q_INVOKABLE void include(const QStringList& includeFiles, const ScriptValue& callback = ScriptValue()) { _manager->include(includeFiles, callback);}; | 225 | Q_INVOKABLE void include(const QStringList& includeFiles, const ScriptValue& callback = ScriptValue()) { _manager->include(includeFiles, callback);}; |
| 226 | 226 | ||
| 227 | /**jsdoc | 227 | /*@jsdoc |
| 228 | * Includes JavaScript from another file in the current script. If a callback is specified, the file is loaded and included | 228 | * Includes JavaScript from another file in the current script. If a callback is specified, the file is loaded and included |
| 229 | * asynchronously, otherwise it is included synchronously (i.e., script execution blocks while the file is included). | 229 | * asynchronously, otherwise it is included synchronously (i.e., script execution blocks while the file is included). |
| 230 | * @function Script.include | 230 | * @function Script.include |
| @@ -252,7 +252,7 @@ public: · 21 unmodified lines | |||
| 252 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 252 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 253 | // MODULE related methods | 253 | // MODULE related methods |
| 254 | 254 | ||
| 255 | /**jsdoc | 255 | /*@jsdoc |
| 256 | * Provides access to methods or objects provided in an external JavaScript or JSON file. | 256 | * Provides access to methods or objects provided in an external JavaScript or JSON file. |
| 257 | * See {@link https://docs.overte.org/script/js-tips.html} for further details. | 257 | * See {@link https://docs.overte.org/script/js-tips.html} for further details. |
| 258 | * @function Script.require | 258 | * @function Script.require |
| @@ -263,14 +263,14 @@ public: · 4 unmodified lines | |||
| 263 | */ | 263 | */ |
| 264 | Q_INVOKABLE ScriptValue require(const QString& moduleId) { return _manager->require(moduleId); } | 264 | Q_INVOKABLE ScriptValue require(const QString& moduleId) { return _manager->require(moduleId); } |
| 265 | 265 | ||
| 266 | /**jsdoc | 266 | /*@jsdoc |
| 267 | * @function Script.resetModuleCache | 267 | * @function Script.resetModuleCache |
| 268 | * @param {boolean} [deleteScriptCache=false] - Delete script cache. | 268 | * @param {boolean} [deleteScriptCache=false] - Delete script cache. |
| 269 | * @deprecated This function is deprecated and will be removed. | 269 | * @deprecated This function is deprecated and will be removed. |
| 270 | */ | 270 | */ |
| 271 | Q_INVOKABLE void resetModuleCache(bool deleteScriptCache = false) { _manager->resetModuleCache(deleteScriptCache);} | 271 | Q_INVOKABLE void resetModuleCache(bool deleteScriptCache = false) { _manager->resetModuleCache(deleteScriptCache);} |
| 272 | 272 | ||
| 273 | /**jsdoc | 273 | /*@jsdoc |
| 274 | * Calls a function repeatedly, at a set interval. | 274 | * Calls a function repeatedly, at a set interval. |
| 275 | * @function Script.setInterval | 275 | * @function Script.setInterval |
| 276 | * @param {function} function - The function to call. This can be either the name of a function or an in-line definition. | 276 | * @param {function} function - The function to call. This can be either the name of a function or an in-line definition. |
| @@ -283,7 +283,7 @@ public: · 6 unmodified lines | |||
| 283 | */ | 283 | */ |
| 284 | Q_INVOKABLE QTimer* setInterval(const ScriptValue& function, int intervalMS) { return _manager->setInterval(function, intervalMS); } | 284 | Q_INVOKABLE QTimer* setInterval(const ScriptValue& function, int intervalMS) { return _manager->setInterval(function, intervalMS); } |
| 285 | 285 | ||
| 286 | /**jsdoc | 286 | /*@jsdoc |
| 287 | * Calls a function once, after a delay. | 287 | * Calls a function once, after a delay. |
| 288 | * @function Script.setTimeout | 288 | * @function Script.setTimeout |
| 289 | * @param {function} function - The function to call. This can be either the name of a function or an in-line definition. | 289 | * @param {function} function - The function to call. This can be either the name of a function or an in-line definition. |
| @@ -296,7 +296,7 @@ public: · 6 unmodified lines | |||
| 296 | */ | 296 | */ |
| 297 | Q_INVOKABLE QTimer* setTimeout(const ScriptValue& function, int timeoutMS) { return _manager->setTimeout(function, timeoutMS); }; | 297 | Q_INVOKABLE QTimer* setTimeout(const ScriptValue& function, int timeoutMS) { return _manager->setTimeout(function, timeoutMS); }; |
| 298 | 298 | ||
| 299 | /**jsdoc | 299 | /*@jsdoc |
| 300 | * Stops an interval timer set by {@link Script.setInterval|setInterval}. | 300 | * Stops an interval timer set by {@link Script.setInterval|setInterval}. |
| 301 | * @function Script.clearInterval | 301 | * @function Script.clearInterval |
| 302 | * @param {object} timer - The interval timer to stop. | 302 | * @param {object} timer - The interval timer to stop. |
| @@ -317,7 +317,7 @@ public: · 14 unmodified lines | |||
| 317 | // Overloaded version is needed in case the timer has expired | 317 | // Overloaded version is needed in case the timer has expired |
| 318 | Q_INVOKABLE void clearInterval(QVariantMap timer) { ; } | 318 | Q_INVOKABLE void clearInterval(QVariantMap timer) { ; } |
| 319 | 319 | ||
| 320 | /**jsdoc | 320 | /*@jsdoc |
| 321 | * Stops a timeout timer set by {@link Script.setTimeout|setTimeout}. | 321 | * Stops a timeout timer set by {@link Script.setTimeout|setTimeout}. |
| 322 | * @function Script.clearTimeout | 322 | * @function Script.clearTimeout |
| 323 | * @param {object} timer - The timeout timer to stop. | 323 | * @param {object} timer - The timeout timer to stop. |
| @@ -335,7 +335,7 @@ public: · 11 unmodified lines | |||
| 335 | // Overloaded version is needed in case the timer has expired | 335 | // Overloaded version is needed in case the timer has expired |
| 336 | Q_INVOKABLE void clearTimeout(QVariantMap timer) { ; } | 336 | Q_INVOKABLE void clearTimeout(QVariantMap timer) { ; } |
| 337 | 337 | ||
| 338 | /**jsdoc | 338 | /*@jsdoc |
| 339 | * Prints a message to the program log and emits {@link Script.printedMessage}. | 339 | * Prints a message to the program log and emits {@link Script.printedMessage}. |
| 340 | * <p>Alternatively, you can use {@link print} or one of the {@link console} API methods.</p> | 340 | * <p>Alternatively, you can use {@link print} or one of the {@link console} API methods.</p> |
| 341 | * @function Script.print | 341 | * @function Script.print |
| @@ -343,7 +343,7 @@ public: · 1 unmodified line | |||
| 343 | */ | 343 | */ |
| 344 | Q_INVOKABLE void print(const QString& message) { _manager->print(message); } | 344 | Q_INVOKABLE void print(const QString& message) { _manager->print(message); } |
| 345 | 345 | ||
| 346 | /**jsdoc | 346 | /*@jsdoc |
| 347 | * Resolves a relative path to an absolute path. The relative path is relative to the script's location. | 347 | * Resolves a relative path to an absolute path. The relative path is relative to the script's location. |
| 348 | * @function Script.resolvePath | 348 | * @function Script.resolvePath |
| 349 | * @param {string} path - The relative path to resolve. | 349 | * @param {string} path - The relative path to resolve. |
| @@ -357,14 +357,14 @@ public: · 7 unmodified lines | |||
| 357 | */ | 357 | */ |
| 358 | Q_INVOKABLE QUrl resolvePath(const QString& path) const { return _manager->resolvePath(path);} | 358 | Q_INVOKABLE QUrl resolvePath(const QString& path) const { return _manager->resolvePath(path);} |
| 359 | 359 | ||
| 360 | /**jsdoc | 360 | /*@jsdoc |
| 361 | * Gets the path to the resources directory for QML files. | 361 | * Gets the path to the resources directory for QML files. |
| 362 | * @function Script.resourcesPath | 362 | * @function Script.resourcesPath |
| 363 | * @returns {string} The path to the resources directory for QML files. | 363 | * @returns {string} The path to the resources directory for QML files. |
| 364 | */ | 364 | */ |
| 365 | Q_INVOKABLE QUrl resourcesPath() const { return _manager->resourcesPath(); } | 365 | Q_INVOKABLE QUrl resourcesPath() const { return _manager->resourcesPath(); } |
| 366 | 366 | ||
| 367 | /**jsdoc | 367 | /*@jsdoc |
| 368 | * Starts timing a section of code in order to send usage data about it to Vircadia. Shouldn't be used outside of the | 368 | * Starts timing a section of code in order to send usage data about it to Vircadia. Shouldn't be used outside of the |
| 369 | * standard scripts. | 369 | * standard scripts. |
| 370 | * @function Script.beginProfileRange | 370 | * @function Script.beginProfileRange |
| @@ -372,7 +372,7 @@ public: · 1 unmodified line | |||
| 372 | */ | 372 | */ |
| 373 | Q_INVOKABLE void beginProfileRange(const QString& label) const { _manager->beginProfileRange(label); } | 373 | Q_INVOKABLE void beginProfileRange(const QString& label) const { _manager->beginProfileRange(label); } |
| 374 | 374 | ||
| 375 | /**jsdoc | 375 | /*@jsdoc |
| 376 | * Finishes timing a section of code in order to send usage data about it to Vircadia. Shouldn't be used outside of | 376 | * Finishes timing a section of code in order to send usage data about it to Vircadia. Shouldn't be used outside of |
| 377 | * the standard scripts. | 377 | * the standard scripts. |
| 378 | * @function Script.endProfileRange | 378 | * @function Script.endProfileRange |
| @@ -383,7 +383,7 @@ public: · 4 unmodified lines | |||
| 383 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 383 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 384 | // Entity Script Related methods | 384 | // Entity Script Related methods |
| 385 | 385 | ||
| 386 | /**jsdoc | 386 | /*@jsdoc |
| 387 | * Checks whether an entity has an entity script running. | 387 | * Checks whether an entity has an entity script running. |
| 388 | * @function Script.isEntityScriptRunning | 388 | * @function Script.isEntityScriptRunning |
| 389 | * @param {Uuid} entityID - The ID of the entity. | 389 | * @param {Uuid} entityID - The ID of the entity. |
| @@ -391,14 +391,14 @@ public: · 1 unmodified line | |||
| 391 | */ | 391 | */ |
| 392 | Q_INVOKABLE bool isEntityScriptRunning(const EntityItemID& entityID) { return _manager->isEntityScriptRunning(entityID); } | 392 | Q_INVOKABLE bool isEntityScriptRunning(const EntityItemID& entityID) { return _manager->isEntityScriptRunning(entityID); } |
| 393 | 393 | ||
| 394 | /**jsdoc | 394 | /*@jsdoc |
| 395 | * Manually runs the JavaScript garbage collector which reclaims memory by disposing of objects that are no longer | 395 | * Manually runs the JavaScript garbage collector which reclaims memory by disposing of objects that are no longer |
| 396 | * reachable. | 396 | * reachable. |
| 397 | * @function Script.requestGarbageCollection | 397 | * @function Script.requestGarbageCollection |
| 398 | */ | 398 | */ |
| 399 | Q_INVOKABLE void requestGarbageCollection() { _manager->requestGarbageCollection(); } | 399 | Q_INVOKABLE void requestGarbageCollection() { _manager->requestGarbageCollection(); } |
| 400 | 400 | ||
| 401 | /**jsdoc | 401 | /*@jsdoc |
| 402 | * Prints out current backtrace to the log. | 402 | * Prints out current backtrace to the log. |
| 403 | * @function Script.logBacktrace | 403 | * @function Script.logBacktrace |
| 404 | * @param {string} title - Title added to the printed out backtrace. | 404 | * @param {string} title - Title added to the printed out backtrace. |
| @@ -414,7 +414,7 @@ public: · 9 unmodified lines | |||
| 414 | */ | 414 | */ |
| 415 | Q_INVOKABLE void loadEntityScript(const EntityItemID& entityID, const QString& entityScript, bool forceRedownload) { _manager->loadEntityScript(entityID, entityScript, forceRedownload); } | 415 | Q_INVOKABLE void loadEntityScript(const EntityItemID& entityID, const QString& entityScript, bool forceRedownload) { _manager->loadEntityScript(entityID, entityScript, forceRedownload); } |
| 416 | 416 | ||
| 417 | /**jsdoc | 417 | /*@jsdoc |
| 418 | * @function Script.unloadEntityScript | 418 | * @function Script.unloadEntityScript |
| 419 | * @param {Uuid} entityID - Entity ID. | 419 | * @param {Uuid} entityID - Entity ID. |
| 420 | * @param {boolean} [shouldRemoveFromMap=false] - Should remove from map. | 420 | * @param {boolean} [shouldRemoveFromMap=false] - Should remove from map. |
| @@ -422,14 +422,14 @@ public: · 1 unmodified line | |||
| 422 | */ | 422 | */ |
| 423 | Q_INVOKABLE void unloadEntityScript(const EntityItemID& entityID, bool shouldRemoveFromMap = false) { _manager->unloadEntityScript(entityID, shouldRemoveFromMap); } | 423 | Q_INVOKABLE void unloadEntityScript(const EntityItemID& entityID, bool shouldRemoveFromMap = false) { _manager->unloadEntityScript(entityID, shouldRemoveFromMap); } |
| 424 | 424 | ||
| 425 | /**jsdoc | 425 | /*@jsdoc |
| 426 | * @function Script.unloadAllEntityScripts | 426 | * @function Script.unloadAllEntityScripts |
| 427 | * @param {boolean} [blockingCall=false] - Wait for completion if call moved to another thread. | 427 | * @param {boolean} [blockingCall=false] - Wait for completion if call moved to another thread. |
| 428 | * @deprecated This function is deprecated and will be removed. | 428 | * @deprecated This function is deprecated and will be removed. |
| 429 | */ | 429 | */ |
| 430 | Q_INVOKABLE void unloadAllEntityScripts(bool blockingCall = false) { _manager->unloadAllEntityScripts(blockingCall); } | 430 | Q_INVOKABLE void unloadAllEntityScripts(bool blockingCall = false) { _manager->unloadAllEntityScripts(blockingCall); } |
| 431 | 431 | ||
| 432 | /**jsdoc | 432 | /*@jsdoc |
| 433 | * Calls a method in an entity script. | 433 | * Calls a method in an entity script. |
| 434 | * @function Script.callEntityScriptMethod | 434 | * @function Script.callEntityScriptMethod |
| 435 | * @param {Uuid} entityID - The ID of the entity running the entity script. | 435 | * @param {Uuid} entityID - The ID of the entity running the entity script. |
| @@ -441,7 +441,7 @@ public: · 5 unmodified lines | |||
| 441 | const QStringList& params = QStringList(), | 441 | const QStringList& params = QStringList(), |
| 442 | const QUuid& remoteCallerID = QUuid()) { _manager->callEntityScriptMethod(entityID, methodName, params, remoteCallerID); } | 442 | const QUuid& remoteCallerID = QUuid()) { _manager->callEntityScriptMethod(entityID, methodName, params, remoteCallerID); } |
| 443 | 443 | ||
| 444 | /**jsdoc | 444 | /*@jsdoc |
| 445 | * Calls a method in an entity script. | 445 | * Calls a method in an entity script. |
| 446 | * @function Script.callEntityScriptMethod | 446 | * @function Script.callEntityScriptMethod |
| 447 | * @param {Uuid} entityID - Entity ID. | 447 | * @param {Uuid} entityID - Entity ID. |
| @@ -451,7 +451,7 @@ public: · 3 unmodified lines | |||
| 451 | */ | 451 | */ |
| 452 | Q_INVOKABLE void callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const PointerEvent& event) { _manager->callEntityScriptMethod(entityID, methodName, event); } | 452 | Q_INVOKABLE void callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const PointerEvent& event) { _manager->callEntityScriptMethod(entityID, methodName, event); } |
| 453 | 453 | ||
| 454 | /**jsdoc | 454 | /*@jsdoc |
| 455 | * Calls a method in an entity script. | 455 | * Calls a method in an entity script. |
| 456 | * @function Script.callEntityScriptMethod | 456 | * @function Script.callEntityScriptMethod |
| 457 | * @param {Uuid} entityID - Entity ID. | 457 | * @param {Uuid} entityID - Entity ID. |
| @@ -462,14 +462,14 @@ public: · 4 unmodified lines | |||
| 462 | */ | 462 | */ |
| 463 | Q_INVOKABLE void callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const EntityItemID& otherID, const Collision& collision) { _manager->callEntityScriptMethod(entityID, methodName, otherID, collision);} | 463 | Q_INVOKABLE void callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const EntityItemID& otherID, const Collision& collision) { _manager->callEntityScriptMethod(entityID, methodName, otherID, collision);} |
| 464 | 464 | ||
| 465 | /**jsdoc | 465 | /*@jsdoc |
| 466 | * @function Script.generateUUID | 466 | * @function Script.generateUUID |
| 467 | * @returns {Uuid} A new UUID. | 467 | * @returns {Uuid} A new UUID. |
| 468 | * @deprecated This function is deprecated and will be removed. Use {@link Uuid(0).generate|Uuid.generate} instead. | 468 | * @deprecated This function is deprecated and will be removed. Use {@link Uuid(0).generate|Uuid.generate} instead. |
| 469 | */ | 469 | */ |
| 470 | Q_INVOKABLE QUuid generateUUID() { return QUuid::createUuid(); } | 470 | Q_INVOKABLE QUuid generateUUID() { return QUuid::createUuid(); } |
| 471 | 471 | ||
| 472 | /**jsdoc | 472 | /*@jsdoc |
| 473 | * Gets the URL for an asset in an external resource bucket. (The location where the bucket is hosted may change over time | 473 | * Gets the URL for an asset in an external resource bucket. (The location where the bucket is hosted may change over time |
| 474 | * but this method will return the asset's current URL.) | 474 | * but this method will return the asset's current URL.) |
| 475 | * @function Script.getExternalPath | 475 | * @function Script.getExternalPath |
| @@ -486,7 +486,7 @@ public: · 10 unmodified lines | |||
| 486 | */ | 486 | */ |
| 487 | Q_INVOKABLE QString getExternalPath(ExternalResource::Bucket bucket, const QString& path) { return _manager->getExternalPath(bucket, path); } | 487 | Q_INVOKABLE QString getExternalPath(ExternalResource::Bucket bucket, const QString& path) { return _manager->getExternalPath(bucket, path); } |
| 488 | 488 | ||
| 489 | /**jsdoc | 489 | /*@jsdoc |
| 490 | * <p>Object containing memory usage statistics data.</p> | 490 | * <p>Object containing memory usage statistics data.</p> |
| 491 | * <table> | 491 | * <table> |
| 492 | * <thead> | 492 | * <thead> |
| @@ -503,26 +503,26 @@ public: · 10 unmodified lines | |||
| 503 | * @typedef {object} Script.MemoryUsageData | 503 | * @typedef {object} Script.MemoryUsageData |
| 504 | */ | 504 | */ |
| 505 | 505 | ||
| 506 | /**jsdoc | 506 | /*@jsdoc |
| 507 | * Returns memory usage statistics data. | 507 | * Returns memory usage statistics data. |
| 508 | * @function Script.getMemoryUsageStatistics | 508 | * @function Script.getMemoryUsageStatistics |
| 509 | * @Returns {Script.MemoryUsageData} Object containing statistics about memory usage. | 509 | * @Returns {Script.MemoryUsageData} Object containing statistics about memory usage. |
| 510 | */ | 510 | */ |
| 511 | Q_INVOKABLE QVariantMap getMemoryUsageStatistics(); | 511 | Q_INVOKABLE QVariantMap getMemoryUsageStatistics(); |
| 512 | 512 | ||
| 513 | /**jsdoc | 513 | /*@jsdoc |
| 514 | * Start collecting object statistics that can later be reported with Script.dumpHeapObjectStatistics(). | 514 | * Start collecting object statistics that can later be reported with Script.dumpHeapObjectStatistics(). |
| 515 | * @function Script.dumpHeapObjectStatistics | 515 | * @function Script.dumpHeapObjectStatistics |
| 516 | */ | 516 | */ |
| 517 | Q_INVOKABLE void startCollectingObjectStatistics(); | 517 | Q_INVOKABLE void startCollectingObjectStatistics(); |
| 518 | 518 | ||
| 519 | /**jsdoc | 519 | /*@jsdoc |
| 520 | * Prints heap statistics to a file. Collecting needs to first be started with Script.dumpHeapObjectStatistics(). | 520 | * Prints heap statistics to a file. Collecting needs to first be started with Script.dumpHeapObjectStatistics(). |
| 521 | * @function Script.dumpHeapObjectStatistics | 521 | * @function Script.dumpHeapObjectStatistics |
| 522 | */ | 522 | */ |
| 523 | Q_INVOKABLE void dumpHeapObjectStatistics(); | 523 | Q_INVOKABLE void dumpHeapObjectStatistics(); |
| 524 | 524 | ||
| 525 | /**jsdoc | 525 | /*@jsdoc |
| 526 | * Create test object for garbage collector debugging. | 526 | * Create test object for garbage collector debugging. |
| 527 | * @function Script.createGarbageCollectorDebuggingObject() | 527 | * @function Script.createGarbageCollectorDebuggingObject() |
| 528 | * @Returns Test object. | 528 | * @Returns Test object. |
| @@ -531,7 +531,7 @@ public: · 2 unmodified lines | |||
| 531 | 531 | ||
| 532 | signals: | 532 | signals: |
| 533 | 533 | ||
| 534 | /**jsdoc | 534 | /*@jsdoc |
| 535 | * @function Script.scriptLoaded | 535 | * @function Script.scriptLoaded |
| 536 | * @param {string} filename - File name. | 536 | * @param {string} filename - File name. |
| 537 | * @returns {Signal} | 537 | * @returns {Signal} |
| @@ -539,7 +539,7 @@ signals: · 1 unmodified line | |||
| 539 | */ | 539 | */ |
| 540 | void scriptLoaded(const QString& scriptFilename); | 540 | void scriptLoaded(const QString& scriptFilename); |
| 541 | 541 | ||
| 542 | /**jsdoc | 542 | /*@jsdoc |
| 543 | * @function Script.errorLoadingScript | 543 | * @function Script.errorLoadingScript |
| 544 | * @param {string} filename - File name. | 544 | * @param {string} filename - File name. |
| 545 | * @returns {Signal} | 545 | * @returns {Signal} |
| @@ -547,7 +547,7 @@ signals: · 1 unmodified line | |||
| 547 | */ | 547 | */ |
| 548 | void errorLoadingScript(const QString& scriptFilename); | 548 | void errorLoadingScript(const QString& scriptFilename); |
| 549 | 549 | ||
| 550 | /**jsdoc | 550 | /*@jsdoc |
| 551 | * Triggered frequently at a system-determined interval. | 551 | * Triggered frequently at a system-determined interval. |
| 552 | * @function Script.update | 552 | * @function Script.update |
| 553 | * @param {number} deltaTime - The time since the last update, in s. | 553 | * @param {number} deltaTime - The time since the last update, in s. |
| @@ -559,7 +559,7 @@ signals: · 5 unmodified lines | |||
| 559 | */ | 559 | */ |
| 560 | void update(float deltaTime); | 560 | void update(float deltaTime); |
| 561 | 561 | ||
| 562 | /**jsdoc | 562 | /*@jsdoc |
| 563 | * Triggered when the script is stopping. | 563 | * Triggered when the script is stopping. |
| 564 | * @function Script.scriptEnding | 564 | * @function Script.scriptEnding |
| 565 | * @returns {Signal} | 565 | * @returns {Signal} |
| @@ -577,7 +577,7 @@ signals: · 11 unmodified lines | |||
| 577 | */ | 577 | */ |
| 578 | void scriptEnding(); | 578 | void scriptEnding(); |
| 579 | 579 | ||
| 580 | /**jsdoc | 580 | /*@jsdoc |
| 581 | * @function Script.finished | 581 | * @function Script.finished |
| 582 | * @param {string} filename - File name. | 582 | * @param {string} filename - File name. |
| 583 | * @param {object} engine - Engine. | 583 | * @param {object} engine - Engine. |
| @@ -586,7 +586,7 @@ signals: · 2 unmodified lines | |||
| 586 | */ | 586 | */ |
| 587 | void finished(const QString& fileNameString, ScriptManagerPointer); | 587 | void finished(const QString& fileNameString, ScriptManagerPointer); |
| 588 | 588 | ||
| 589 | /**jsdoc | 589 | /*@jsdoc |
| 590 | * Triggered when the script prints a message to the program log via {@link print}, {@link Script.print}, | 590 | * Triggered when the script prints a message to the program log via {@link print}, {@link Script.print}, |
| 591 | * {@link console.log}, {@link console.debug}, {@link console.group}, {@link console.groupEnd}, {@link console.time}, or | 591 | * {@link console.log}, {@link console.debug}, {@link console.group}, {@link console.groupEnd}, {@link console.time}, or |
| 592 | * {@link console.timeEnd}. | 592 | * {@link console.timeEnd}. |
| @@ -597,7 +597,7 @@ signals: · 4 unmodified lines | |||
| 597 | */ | 597 | */ |
| 598 | void printedMessage(const QString& message, const QString& scriptName); | 598 | void printedMessage(const QString& message, const QString& scriptName); |
| 599 | 599 | ||
| 600 | /**jsdoc | 600 | /*@jsdoc |
| 601 | * Triggered when the script generates an error, {@link console.error} or {@link console.exception} is called, or | 601 | * Triggered when the script generates an error, {@link console.error} or {@link console.exception} is called, or |
| 602 | * {@link console.assert} is called and fails. | 602 | * {@link console.assert} is called and fails. |
| 603 | * @function Script.errorMessage | 603 | * @function Script.errorMessage |
| @@ -607,7 +607,7 @@ signals: · 3 unmodified lines | |||
| 607 | */ | 607 | */ |
| 608 | void errorMessage(const QString& message, const QString& scriptName); | 608 | void errorMessage(const QString& message, const QString& scriptName); |
| 609 | 609 | ||
| 610 | /**jsdoc | 610 | /*@jsdoc |
| 611 | * Triggered when the script generates a warning or {@link console.warn} is called. | 611 | * Triggered when the script generates a warning or {@link console.warn} is called. |
| 612 | * @function Script.warningMessage | 612 | * @function Script.warningMessage |
| 613 | * @param {string} message - The warning message. | 613 | * @param {string} message - The warning message. |
| @@ -616,7 +616,7 @@ signals: · 2 unmodified lines | |||
| 616 | */ | 616 | */ |
| 617 | void warningMessage(const QString& message, const QString& scriptName); | 617 | void warningMessage(const QString& message, const QString& scriptName); |
| 618 | 618 | ||
| 619 | /**jsdoc | 619 | /*@jsdoc |
| 620 | * Triggered when the script generates an information message or {@link console.info} is called. | 620 | * Triggered when the script generates an information message or {@link console.info} is called. |
| 621 | * @function Script.infoMessage | 621 | * @function Script.infoMessage |
| 622 | * @param {string} message - The information message. | 622 | * @param {string} message - The information message. |
| @@ -625,21 +625,21 @@ signals: · 2 unmodified lines | |||
| 625 | */ | 625 | */ |
| 626 | void infoMessage(const QString& message, const QString& scriptName); | 626 | void infoMessage(const QString& message, const QString& scriptName); |
| 627 | 627 | ||
| 628 | /**jsdoc | 628 | /*@jsdoc |
| 629 | * Triggered when the running state of the script changes, e.g., from running to stopping. | 629 | * Triggered when the running state of the script changes, e.g., from running to stopping. |
| 630 | * @function Script.runningStateChanged | 630 | * @function Script.runningStateChanged |
| 631 | * @returns {Signal} | 631 | * @returns {Signal} |
| 632 | */ | 632 | */ |
| 633 | void runningStateChanged(); | 633 | void runningStateChanged(); |
| 634 | 634 | ||
| 635 | /**jsdoc | 635 | /*@jsdoc |
| 636 | * @function Script.clearDebugWindow | 636 | * @function Script.clearDebugWindow |
| 637 | * @returns {Signal} | 637 | * @returns {Signal} |
| 638 | * @deprecated This signal is deprecated and will be removed. | 638 | * @deprecated This signal is deprecated and will be removed. |
| 639 | */ | 639 | */ |
| 640 | void clearDebugWindow(); | 640 | void clearDebugWindow(); |
| 641 | 641 | ||
| 642 | /**jsdoc | 642 | /*@jsdoc |
| 643 | * @function Script.loadScript | 643 | * @function Script.loadScript |
| 644 | * @param {string} scriptName - Script name. | 644 | * @param {string} scriptName - Script name. |
| 645 | * @param {boolean} isUserLoaded - Is user loaded. | 645 | * @param {boolean} isUserLoaded - Is user loaded. |
| @@ -648,7 +648,7 @@ signals: · 2 unmodified lines | |||
| 648 | */ | 648 | */ |
| 649 | void loadScript(const QString& scriptName, bool isUserLoaded); | 649 | void loadScript(const QString& scriptName, bool isUserLoaded); |
| 650 | 650 | ||
| 651 | /**jsdoc | 651 | /*@jsdoc |
| 652 | * @function Script.reloadScript | 652 | * @function Script.reloadScript |
| 653 | * @param {string} scriptName - Script name. | 653 | * @param {string} scriptName - Script name. |
| 654 | * @param {boolean} isUserLoaded - Is user loaded. | 654 | * @param {boolean} isUserLoaded - Is user loaded. |
| @@ -657,14 +657,14 @@ signals: · 2 unmodified lines | |||
| 657 | */ | 657 | */ |
| 658 | void reloadScript(const QString& scriptName, bool isUserLoaded); | 658 | void reloadScript(const QString& scriptName, bool isUserLoaded); |
| 659 | 659 | ||
| 660 | /**jsdoc | 660 | /*@jsdoc |
| 661 | * Triggered when the script has stopped. | 661 | * Triggered when the script has stopped. |
| 662 | * @function Script.doneRunning | 662 | * @function Script.doneRunning |
| 663 | * @returns {Signal} | 663 | * @returns {Signal} |
| 664 | */ | 664 | */ |
| 665 | void doneRunning(); | 665 | void doneRunning(); |
| 666 | 666 | ||
| 667 | /**jsdoc | 667 | /*@jsdoc |
| 668 | * @function Script.entityScriptDetailsUpdated | 668 | * @function Script.entityScriptDetailsUpdated |
| 669 | * @returns {Signal} | 669 | * @returns {Signal} |
| 670 | * @deprecated This signal is deprecated and will be removed. | 670 | * @deprecated This signal is deprecated and will be removed. |
| @@ -673,7 +673,7 @@ signals: · 2 unmodified lines | |||
| 673 | // script is updated (goes from RUNNING to ERROR_RUNNING_SCRIPT, for example) | 673 | // script is updated (goes from RUNNING to ERROR_RUNNING_SCRIPT, for example) |
| 674 | void entityScriptDetailsUpdated(); | 674 | void entityScriptDetailsUpdated(); |
| 675 | 675 | ||
| 676 | /**jsdoc | 676 | /*@jsdoc |
| 677 | * Triggered when the script starts for the user. See also, {@link Entities.preload}. | 677 | * Triggered when the script starts for the user. See also, {@link Entities.preload}. |
| 678 | * <p class="availableIn"><strong>Supported Script Types:</strong> Client Entity Scripts • Server Entity Scripts</p> | 678 | * <p class="availableIn"><strong>Supported Script Types:</strong> Client Entity Scripts • Server Entity Scripts</p> |
| 679 | * @function Script.entityScriptPreloadFinished | 679 | * @function Script.entityScriptPreloadFinished |
| @@ -701,7 +701,7 @@ signals: · 21 unmodified lines | |||
| 701 | // Emitted when an entity script has finished running preload | 701 | // Emitted when an entity script has finished running preload |
| 702 | void entityScriptPreloadFinished(const EntityItemID& entityID); | 702 | void entityScriptPreloadFinished(const EntityItemID& entityID); |
| 703 | 703 | ||
| 704 | /**jsdoc | 704 | /*@jsdoc |
| 705 | * Triggered when a script generates an unhandled exception. | 705 | * Triggered when a script generates an unhandled exception. |
| 706 | * @function Script.unhandledException | 706 | * @function Script.unhandledException |
| 707 | * @param {object} exception - The details of the exception. | 707 | * @param {object} exception - The details of the exception. |
| @@ -716,7 +716,7 @@ signals: · 8 unmodified lines | |||
| 716 | 716 | ||
| 717 | 717 | ||
| 718 | protected: | 718 | protected: |
| 719 | /**jsdoc | 719 | /*@jsdoc |
| 720 | * @function Script.executeOnScriptThread | 720 | * @function Script.executeOnScriptThread |
| 721 | * @param {function} function - Function. | 721 | * @param {function} function - Function. |
| 722 | * @param {ConnectionType} [type=2] - Connection type. | 722 | * @param {ConnectionType} [type=2] - Connection type. |
| @@ -728,7 +728,7 @@ protected: · 5 unmodified lines | |||
| 728 | // | 728 | // |
| 729 | // Q_INVOKABLE void executeOnScriptThread(std::function<void()> function, const Qt::ConnectionType& type = Qt::QueuedConnection ) { _manager->executeOnScriptThread(function, type);} | 729 | // Q_INVOKABLE void executeOnScriptThread(std::function<void()> function, const Qt::ConnectionType& type = Qt::QueuedConnection ) { _manager->executeOnScriptThread(function, type);} |
| 730 | 730 | ||
| 731 | /**jsdoc | 731 | /*@jsdoc |
| 732 | * @function Script._requireResolve | 732 | * @function Script._requireResolve |
| 733 | * @param {string} module - Module. | 733 | * @param {string} module - Module. |
| 734 | * @param {string} [relativeTo=""] - Relative to. | 734 | * @param {string} [relativeTo=""] - Relative to. |
| @@ -739,7 +739,7 @@ protected: · 4 unmodified lines | |||
| 739 | // then inside of init() we just have to do "Script.require.resolve = Script._requireResolve;" | 739 | // then inside of init() we just have to do "Script.require.resolve = Script._requireResolve;" |
| 740 | Q_INVOKABLE QString _requireResolve(const QString& moduleId, const QString& relativeTo = QString()) { return _manager->_requireResolve(moduleId, relativeTo); } | 740 | Q_INVOKABLE QString _requireResolve(const QString& moduleId, const QString& relativeTo = QString()) { return _manager->_requireResolve(moduleId, relativeTo); } |
| 741 | 741 | ||
| 742 | /**jsdoc | 742 | /*@jsdoc |
| 743 | * @function Script.entityScriptContentAvailable | 743 | * @function Script.entityScriptContentAvailable |
| 744 | * @param {Uuid} entityID - Entity ID. | 744 | * @param {Uuid} entityID - Entity ID. |
| 745 | * @param {string} scriptOrURL - Path. | 745 | * @param {string} scriptOrURL - Path. |
| @@ -759,4 +759,4 @@ private slots: · 13 unmodified lines | |||
| 759 | private: | 759 | private: |
| 760 | 760 | ||
| 761 | ScriptManager *_manager; | 761 | ScriptManager *_manager; |
| 762 | }; | 762 | }; |