mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 09:33:36 +02:00
first cut at client scripts working
This commit is contained in:
parent
c2d5accbc9
commit
dacaade9ed
3 changed files with 43 additions and 5 deletions
|
@ -4426,14 +4426,22 @@ void Application::loadScript() {
|
|||
// start the script on a new thread...
|
||||
_scriptEngine = new ScriptEngine(script);
|
||||
|
||||
// setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
|
||||
// we can use the same ones from the application.
|
||||
_scriptEngine->getVoxelScriptingInterface()->setPacketSender(&_voxelEditSender);
|
||||
_scriptEngine->getParticleScriptingInterface()->setPacketSender(&_particleEditSender);
|
||||
|
||||
//_scriptEngine->getVoxelScriptingInterface()->setJurisdictionListener();
|
||||
//_scriptEngine->getParticleScriptingInterface()->setJurisdictionListener();
|
||||
|
||||
QThread* workerThread = new QThread(this);
|
||||
|
||||
connect(workerThread, SIGNAL(started()), _scriptEngine, SLOT(run()));
|
||||
|
||||
connect(_scriptEngine, SIGNAL(finished()), this, SLOT(assignmentCompleted()));
|
||||
connect(_scriptEngine, SIGNAL(finished()), workerThread, SLOT(quit()));
|
||||
connect(_scriptEngine, SIGNAL(finished()), _scriptEngine, SLOT(deleteLater()));
|
||||
connect(_scriptEngine, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
|
||||
//connect(_scriptEngine, SIGNAL(finished()), this, SLOT(assignmentCompleted()));
|
||||
//connect(_scriptEngine, SIGNAL(finished()), workerThread, SLOT(quit()));
|
||||
//connect(_scriptEngine, SIGNAL(finished()), _scriptEngine, SLOT(deleteLater()));
|
||||
//connect(_scriptEngine, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
|
||||
|
||||
_scriptEngine->moveToThread(workerThread);
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ ScriptEngine::ScriptEngine(QString scriptContents) {
|
|||
void ScriptEngine::run() {
|
||||
QScriptEngine engine;
|
||||
|
||||
_voxelScriptingInterface.init();
|
||||
_particleScriptingInterface.init();
|
||||
|
||||
// register meta-type for glm::vec3 conversions
|
||||
registerMetaTypes(&engine);
|
||||
|
||||
|
@ -76,7 +79,28 @@ void ScriptEngine::run() {
|
|||
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
bool willSendVisualDataCallBack = true;
|
||||
bool willSendVisualDataCallBack = false;
|
||||
if (_voxelScriptingInterface.getVoxelPacketSender()->serversExist()) {
|
||||
// allow the scripter's call back to setup visual data
|
||||
willSendVisualDataCallBack = true;
|
||||
|
||||
// release the queue of edit voxel messages.
|
||||
_voxelScriptingInterface.getVoxelPacketSender()->releaseQueuedMessages();
|
||||
|
||||
// since we're in non-threaded mode, call process so that the packets are sent
|
||||
//_voxelScriptingInterface.getVoxelPacketSender()->process();
|
||||
}
|
||||
|
||||
if (_particleScriptingInterface.getParticlePacketSender()->serversExist()) {
|
||||
// allow the scripter's call back to setup visual data
|
||||
willSendVisualDataCallBack = true;
|
||||
|
||||
// release the queue of edit voxel messages.
|
||||
_particleScriptingInterface.getParticlePacketSender()->releaseQueuedMessages();
|
||||
|
||||
// since we're in non-threaded mode, call process so that the packets are sent
|
||||
//_particleScriptingInterface.getParticlePacketSender()->process();
|
||||
}
|
||||
|
||||
if (willSendVisualDataCallBack) {
|
||||
qDebug() << "willSendVisualDataCallback thisFrame:" << thisFrame << "\n";
|
||||
|
|
|
@ -23,6 +23,12 @@ class ScriptEngine : public QObject {
|
|||
public:
|
||||
ScriptEngine(QString scriptContents);
|
||||
|
||||
/// Access the VoxelScriptingInterface in order to initialize it with a custom packet sender and jurisdiction listener
|
||||
VoxelScriptingInterface* getVoxelScriptingInterface() { return &_voxelScriptingInterface; }
|
||||
|
||||
/// Access the ParticleScriptingInterface in order to initialize it with a custom packet sender and jurisdiction listener
|
||||
ParticleScriptingInterface* getParticleScriptingInterface() { return &_particleScriptingInterface; }
|
||||
|
||||
public slots:
|
||||
void run();
|
||||
void stop() {
|
||||
|
|
Loading…
Reference in a new issue