Qt JS engine in work.
This commit is contained in:
parent
ecda95ed70
commit
e51a748a05
|
@ -4597,9 +4597,9 @@ void consoleWin_t::emuFrameFinish(void)
|
||||||
|
|
||||||
//printf("EMU Frame Finish\n");
|
//printf("EMU Frame Finish\n");
|
||||||
|
|
||||||
#ifdef __FCEU_QSCRIPT_ENABLE__
|
//#ifdef __FCEU_QSCRIPT_ENABLE__
|
||||||
QtScriptManager::getInstance()->frameFinishedUpdate();
|
// QtScriptManager::getInstance()->frameFinishedUpdate();
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
transferVideoBuffer();
|
transferVideoBuffer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,8 @@ int QtScriptInstance::configEngine()
|
||||||
|
|
||||||
engine->globalObject().setProperty("gui", guiObject);
|
engine->globalObject().setProperty("gui", guiObject);
|
||||||
|
|
||||||
|
QtScriptManager::getInstance()->removeFrameFinishedConnection(this);
|
||||||
|
|
||||||
onFrameFinishCallback = QJSValue();
|
onFrameFinishCallback = QJSValue();
|
||||||
onScriptStopCallback = QJSValue();
|
onScriptStopCallback = QJSValue();
|
||||||
|
|
||||||
|
@ -277,6 +279,10 @@ int QtScriptInstance::loadScriptFile( QString filepath )
|
||||||
onFrameFinishCallback = engine->globalObject().property("onFrameFinish");
|
onFrameFinishCallback = engine->globalObject().property("onFrameFinish");
|
||||||
onScriptStopCallback = engine->globalObject().property("onScriptStop");
|
onScriptStopCallback = engine->globalObject().property("onScriptStop");
|
||||||
|
|
||||||
|
if (onFrameFinishCallback.isCallable())
|
||||||
|
{
|
||||||
|
QtScriptManager::getInstance()->addFrameFinishedConnection(this);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
@ -513,12 +519,45 @@ void QtScriptManager::removeScriptInstance(QtScriptInstance* script)
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeFrameFinishedConnection(script);
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void QtScriptManager::addFrameFinishedConnection(QtScriptInstance* script)
|
||||||
|
{
|
||||||
|
if (frameFinishConnectList.size() == 0)
|
||||||
|
{
|
||||||
|
connect(consoleWindow->emulatorThread, SIGNAL(frameFinished(void)), this, SLOT(frameFinishedUpdate(void)), Qt::BlockingQueuedConnection);
|
||||||
|
}
|
||||||
|
frameFinishConnectList.push_back(script);
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void QtScriptManager::removeFrameFinishedConnection(QtScriptInstance* script)
|
||||||
|
{
|
||||||
|
auto it = frameFinishConnectList.begin();
|
||||||
|
|
||||||
|
while (it != frameFinishConnectList.end())
|
||||||
|
{
|
||||||
|
if (*it == script)
|
||||||
|
{
|
||||||
|
it = frameFinishConnectList.erase(it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frameFinishConnectList.size() == 0)
|
||||||
|
{
|
||||||
|
consoleWindow->emulatorThread->disconnect( SIGNAL(frameFinished(void)), this, SLOT(frameFinishedUpdate(void)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void QtScriptManager::frameFinishedUpdate()
|
void QtScriptManager::frameFinishedUpdate()
|
||||||
{
|
{
|
||||||
FCEU_WRAPPER_LOCK();
|
FCEU_WRAPPER_LOCK();
|
||||||
for (auto script : scriptList)
|
for (auto script : frameFinishConnectList)
|
||||||
{
|
{
|
||||||
script->onFrameFinish();
|
script->onFrameFinish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,12 +113,17 @@ public:
|
||||||
|
|
||||||
void addScriptInstance(QtScriptInstance* script);
|
void addScriptInstance(QtScriptInstance* script);
|
||||||
void removeScriptInstance(QtScriptInstance* script);
|
void removeScriptInstance(QtScriptInstance* script);
|
||||||
|
void addFrameFinishedConnection(QtScriptInstance* script);
|
||||||
|
void removeFrameFinishedConnection(QtScriptInstance* script);
|
||||||
private:
|
private:
|
||||||
static QtScriptManager* _instance;
|
static QtScriptManager* _instance;
|
||||||
|
|
||||||
QList<QtScriptInstance*> scriptList;
|
QList<QtScriptInstance*> scriptList;
|
||||||
|
QList<QtScriptInstance*> frameFinishConnectList;
|
||||||
FCEU::timeStampRecord lastFrameUpdate;
|
FCEU::timeStampRecord lastFrameUpdate;
|
||||||
|
|
||||||
|
int frameFinishedConnectCount = 0;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void frameFinishedUpdate();
|
void frameFinishedUpdate();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1481,12 +1481,12 @@ int fceuWrapperUpdate( void )
|
||||||
|
|
||||||
hexEditorUpdateMemoryValues();
|
hexEditorUpdateMemoryValues();
|
||||||
|
|
||||||
|
fceuWrapperUnLock();
|
||||||
|
|
||||||
if ( consoleWindow )
|
if ( consoleWindow )
|
||||||
{
|
{
|
||||||
consoleWindow->emulatorThread->signalFrameFinished();
|
consoleWindow->emulatorThread->signalFrameFinished();
|
||||||
}
|
}
|
||||||
fceuWrapperUnLock();
|
|
||||||
|
|
||||||
emulatorHasMutex = 0;
|
emulatorHasMutex = 0;
|
||||||
|
|
||||||
#ifdef __FCEU_PROFILER_ENABLE__
|
#ifdef __FCEU_PROFILER_ENABLE__
|
||||||
|
|
Loading…
Reference in New Issue