Added ability to pass command line arguments to JS scripts.
This commit is contained in:
parent
20a9c151be
commit
6248b0ee64
|
@ -1521,10 +1521,6 @@ void QtScriptInstance::print(const QString& msg)
|
||||||
{
|
{
|
||||||
dialog->logOutput(msg);
|
dialog->logOutput(msg);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug() << msg;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
bool QtScriptInstance::onEmulationThread()
|
bool QtScriptInstance::onEmulationThread()
|
||||||
|
@ -2422,7 +2418,7 @@ void QScriptDialog_t::openScriptFile(void)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "selected file path : " << filename.toUtf8();
|
//qDebug() << "selected file path : " << filename.toUtf8();
|
||||||
|
|
||||||
g_config->setOption("SDL.LastLoadJs", filename.toStdString().c_str());
|
g_config->setOption("SDL.LastLoadJs", filename.toStdString().c_str());
|
||||||
|
|
||||||
|
@ -2442,11 +2438,13 @@ void QScriptDialog_t::startScript(void)
|
||||||
FCEU_WRAPPER_UNLOCK();
|
FCEU_WRAPPER_UNLOCK();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO add option to pass options to script main.
|
// Pass command line arguments to script main.
|
||||||
QJSValue argArray = scriptInstance->getEngine()->newArray(4);
|
QStringList argStringList = scriptArgs->text().split(" ", Qt::SkipEmptyParts);
|
||||||
argArray.setProperty(0, "arg1");
|
QJSValue argArray = scriptInstance->getEngine()->newArray(argStringList.size());
|
||||||
argArray.setProperty(1, "arg2");
|
for (int i=0; i<argStringList.size(); i++)
|
||||||
argArray.setProperty(2, "arg3");
|
{
|
||||||
|
argArray.setProperty(i, argStringList[i]);
|
||||||
|
}
|
||||||
|
|
||||||
QJSValueList argList = { argArray };
|
QJSValueList argList = { argArray };
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue