Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 3 files). Show all
Unified · Split
| @@ -20,12 +20,20 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <UUID.h> |
| 21 | 21 | #include <VoxelConstants.h> |
| 22 | 22 | |
| 23 | +#include <Sound.h> | |
| 24 | + | |
| 23 | 25 | #include "ScriptEngine.h" |
| 24 | 26 | |
| 25 | 27 | int ScriptEngine::_scriptNumber = 1; |
| 26 | 28 | VoxelsScriptingInterface ScriptEngine::_voxelsScriptingInterface; |
| 27 | 29 | ParticlesScriptingInterface ScriptEngine::_particlesScriptingInterface; |
| 28 | 30 | |
| 31 | +static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* engine) { | |
| 32 | + QUrl soundURL = QUrl(context->argument(0).toString()); | |
| 33 | + QScriptValue soundScriptValue = engine->newQObject(new Sound(soundURL), QScriptEngine::ScriptOwnership); | |
| 34 | + | |
| 35 | + return soundScriptValue; | |
| 36 | +} | |
| 29 | 37 | |
| 30 | 38 | ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, |
| 31 | 39 | const char* scriptMenuName, AbstractMenuInterface* menu, |
| @@ -101,6 +109,10 @@ void ScriptEngine::run() { · 69 unmodified lines | ||
| 101 | 109 | QScriptValue particleScripterValue = engine.newQObject(&_particlesScriptingInterface); |
| 102 | 110 | engine.globalObject().setProperty("Particles", particleScripterValue); |
| 103 | 111 | |
| 112 | + QScriptValue soundConstructorValue = engine.newFunction(soundConstructor); | |
| 113 | + QScriptValue soundMetaObject = engine.newQMetaObject(&Sound::staticMetaObject, soundConstructorValue); | |
| 114 | + engine.globalObject().setProperty("Sound", soundMetaObject); | |
| 115 | + | |
| 104 | 116 | if (_controllerScriptingInterface) { |
| 105 | 117 | QScriptValue controllerScripterValue = engine.newQObject(_controllerScriptingInterface); |
| 106 | 118 | engine.globalObject().setProperty("Controller", controllerScripterValue); |