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");
|
||||
|
||||
#ifdef __FCEU_QSCRIPT_ENABLE__
|
||||
QtScriptManager::getInstance()->frameFinishedUpdate();
|
||||
#endif
|
||||
//#ifdef __FCEU_QSCRIPT_ENABLE__
|
||||
// QtScriptManager::getInstance()->frameFinishedUpdate();
|
||||
//#endif
|
||||
|
||||
transferVideoBuffer();
|
||||
}
|
||||
|
|
|
@ -240,6 +240,8 @@ int QtScriptInstance::configEngine()
|
|||
|
||||
engine->globalObject().setProperty("gui", guiObject);
|
||||
|
||||
QtScriptManager::getInstance()->removeFrameFinishedConnection(this);
|
||||
|
||||
onFrameFinishCallback = QJSValue();
|
||||
onScriptStopCallback = QJSValue();
|
||||
|
||||
|
@ -277,6 +279,10 @@ int QtScriptInstance::loadScriptFile( QString filepath )
|
|||
onFrameFinishCallback = engine->globalObject().property("onFrameFinish");
|
||||
onScriptStopCallback = engine->globalObject().property("onScriptStop");
|
||||
|
||||
if (onFrameFinishCallback.isCallable())
|
||||
{
|
||||
QtScriptManager::getInstance()->addFrameFinishedConnection(this);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//----------------------------------------------------
|
||||
|
@ -513,12 +519,45 @@ void QtScriptManager::removeScriptInstance(QtScriptInstance* script)
|
|||
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()
|
||||
{
|
||||
FCEU_WRAPPER_LOCK();
|
||||
for (auto script : scriptList)
|
||||
for (auto script : frameFinishConnectList)
|
||||
{
|
||||
script->onFrameFinish();
|
||||
}
|
||||
|
|
|
@ -113,12 +113,17 @@ public:
|
|||
|
||||
void addScriptInstance(QtScriptInstance* script);
|
||||
void removeScriptInstance(QtScriptInstance* script);
|
||||
void addFrameFinishedConnection(QtScriptInstance* script);
|
||||
void removeFrameFinishedConnection(QtScriptInstance* script);
|
||||
private:
|
||||
static QtScriptManager* _instance;
|
||||
|
||||
QList<QtScriptInstance*> scriptList;
|
||||
QList<QtScriptInstance*> frameFinishConnectList;
|
||||
FCEU::timeStampRecord lastFrameUpdate;
|
||||
|
||||
int frameFinishedConnectCount = 0;
|
||||
|
||||
public slots:
|
||||
void frameFinishedUpdate();
|
||||
};
|
||||
|
|
|
@ -1481,12 +1481,12 @@ int fceuWrapperUpdate( void )
|
|||
|
||||
hexEditorUpdateMemoryValues();
|
||||
|
||||
fceuWrapperUnLock();
|
||||
|
||||
if ( consoleWindow )
|
||||
{
|
||||
consoleWindow->emulatorThread->signalFrameFinished();
|
||||
}
|
||||
fceuWrapperUnLock();
|
||||
|
||||
emulatorHasMutex = 0;
|
||||
|
||||
#ifdef __FCEU_PROFILER_ENABLE__
|
||||
|
|
Loading…
Reference in New Issue