mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 20:56:52 +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...
|
// start the script on a new thread...
|
||||||
_scriptEngine = new ScriptEngine(script);
|
_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);
|
QThread* workerThread = new QThread(this);
|
||||||
|
|
||||||
connect(workerThread, SIGNAL(started()), _scriptEngine, SLOT(run()));
|
connect(workerThread, SIGNAL(started()), _scriptEngine, SLOT(run()));
|
||||||
|
|
||||||
connect(_scriptEngine, SIGNAL(finished()), this, SLOT(assignmentCompleted()));
|
//connect(_scriptEngine, SIGNAL(finished()), this, SLOT(assignmentCompleted()));
|
||||||
connect(_scriptEngine, SIGNAL(finished()), workerThread, SLOT(quit()));
|
//connect(_scriptEngine, SIGNAL(finished()), workerThread, SLOT(quit()));
|
||||||
connect(_scriptEngine, SIGNAL(finished()), _scriptEngine, SLOT(deleteLater()));
|
//connect(_scriptEngine, SIGNAL(finished()), _scriptEngine, SLOT(deleteLater()));
|
||||||
connect(_scriptEngine, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
|
//connect(_scriptEngine, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
|
||||||
|
|
||||||
_scriptEngine->moveToThread(workerThread);
|
_scriptEngine->moveToThread(workerThread);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ ScriptEngine::ScriptEngine(QString scriptContents) {
|
||||||
void ScriptEngine::run() {
|
void ScriptEngine::run() {
|
||||||
QScriptEngine engine;
|
QScriptEngine engine;
|
||||||
|
|
||||||
|
_voxelScriptingInterface.init();
|
||||||
|
_particleScriptingInterface.init();
|
||||||
|
|
||||||
// register meta-type for glm::vec3 conversions
|
// register meta-type for glm::vec3 conversions
|
||||||
registerMetaTypes(&engine);
|
registerMetaTypes(&engine);
|
||||||
|
|
||||||
|
@ -76,7 +79,28 @@ void ScriptEngine::run() {
|
||||||
|
|
||||||
QCoreApplication::processEvents();
|
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) {
|
if (willSendVisualDataCallBack) {
|
||||||
qDebug() << "willSendVisualDataCallback thisFrame:" << thisFrame << "\n";
|
qDebug() << "willSendVisualDataCallback thisFrame:" << thisFrame << "\n";
|
||||||
|
|
|
@ -23,6 +23,12 @@ class ScriptEngine : public QObject {
|
||||||
public:
|
public:
|
||||||
ScriptEngine(QString scriptContents);
|
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:
|
public slots:
|
||||||
void run();
|
void run();
|
||||||
void stop() {
|
void stop() {
|
||||||
|
|
Loading…
Reference in a new issue