mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:09:24 +02:00
Merge pull request #22 from birarda/entity-script-server
fix for RecordingScriptingInterface, default scripts, local audio injector
This commit is contained in:
commit
4914ad9014
5 changed files with 41 additions and 38 deletions
|
@ -376,6 +376,9 @@ void Agent::executeScript() {
|
||||||
|
|
||||||
_scriptEngine->registerGlobalObject("EntityViewer", &_entityViewer);
|
_scriptEngine->registerGlobalObject("EntityViewer", &_entityViewer);
|
||||||
|
|
||||||
|
auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>();
|
||||||
|
_scriptEngine->registerGlobalObject("Recording", recordingInterface.data());
|
||||||
|
|
||||||
// we need to make sure that init has been called for our EntityScriptingInterface
|
// we need to make sure that init has been called for our EntityScriptingInterface
|
||||||
// so that it actually has a jurisdiction listener when we ask it for it next
|
// so that it actually has a jurisdiction listener when we ask it for it next
|
||||||
entityScriptingInterface->init();
|
entityScriptingInterface->init();
|
||||||
|
|
|
@ -5485,6 +5485,9 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
scriptEngine->registerGlobalObject("Controller", scriptingInterface.data());
|
scriptEngine->registerGlobalObject("Controller", scriptingInterface.data());
|
||||||
UserInputMapper::registerControllerTypes(scriptEngine);
|
UserInputMapper::registerControllerTypes(scriptEngine);
|
||||||
|
|
||||||
|
auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>();
|
||||||
|
_scriptEngine->registerGlobalObject("Recording", recordingInterface.data());
|
||||||
|
|
||||||
// connect this script engines printedMessage signal to the global ScriptEngines these various messages
|
// connect this script engines printedMessage signal to the global ScriptEngines these various messages
|
||||||
connect(scriptEngine, &ScriptEngine::printedMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onPrintedMessage);
|
connect(scriptEngine, &ScriptEngine::printedMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onPrintedMessage);
|
||||||
connect(scriptEngine, &ScriptEngine::errorMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onErrorMessage);
|
connect(scriptEngine, &ScriptEngine::errorMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onErrorMessage);
|
||||||
|
|
|
@ -180,9 +180,6 @@ bool AudioInjector::injectLocally() {
|
||||||
} else {
|
} else {
|
||||||
qCDebug(audio) << "AudioInjector::injectLocally called without any data in Sound QByteArray";
|
qCDebug(audio) << "AudioInjector::injectLocally called without any data in Sound QByteArray";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
qCDebug(audio) << "AudioInjector::injectLocally cannot inject locally with no local audio interface present.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|
|
@ -562,9 +562,6 @@ void ScriptEngine::init() {
|
||||||
// constants
|
// constants
|
||||||
globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE)));
|
globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE)));
|
||||||
|
|
||||||
auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>();
|
|
||||||
registerGlobalObject("Recording", recordingInterface.data());
|
|
||||||
|
|
||||||
registerGlobalObject("Assets", &_assetScriptingInterface);
|
registerGlobalObject("Assets", &_assetScriptingInterface);
|
||||||
registerGlobalObject("Resources", DependencyManager::get<ResourceScriptingInterface>().data());
|
registerGlobalObject("Resources", DependencyManager::get<ResourceScriptingInterface>().data());
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,39 +156,42 @@ void ScriptsModel::reloadDefaultFiles() {
|
||||||
void ScriptsModel::requestDefaultFiles(QString marker) {
|
void ScriptsModel::requestDefaultFiles(QString marker) {
|
||||||
QUrl url(defaultScriptsLocation());
|
QUrl url(defaultScriptsLocation());
|
||||||
|
|
||||||
if (url.isLocalFile()) {
|
// targets that don't have a scripts folder in the appropriate location will have an empty URL here
|
||||||
// if the url indicates a local directory, use QDirIterator
|
if (!url.isEmpty()) {
|
||||||
QString localDir = expandScriptUrl(url).toLocalFile();
|
if (url.isLocalFile()) {
|
||||||
int localDirPartCount = localDir.split("/").size();
|
// if the url indicates a local directory, use QDirIterator
|
||||||
if (localDir.endsWith("/")) {
|
QString localDir = expandScriptUrl(url).toLocalFile();
|
||||||
localDirPartCount--;
|
int localDirPartCount = localDir.split("/").size();
|
||||||
}
|
if (localDir.endsWith("/")) {
|
||||||
#ifdef Q_OS_WIN
|
localDirPartCount--;
|
||||||
localDirPartCount++; // one for the drive letter
|
}
|
||||||
#endif
|
#ifdef Q_OS_WIN
|
||||||
QDirIterator it(localDir, QStringList() << "*.js", QDir::Files, QDirIterator::Subdirectories);
|
localDirPartCount++; // one for the drive letter
|
||||||
while (it.hasNext()) {
|
#endif
|
||||||
QUrl jsFullPath = QUrl::fromLocalFile(it.next());
|
QDirIterator it(localDir, QStringList() << "*.js", QDir::Files, QDirIterator::Subdirectories);
|
||||||
QString jsPartialPath = jsFullPath.path().split("/").mid(localDirPartCount).join("/");
|
while (it.hasNext()) {
|
||||||
jsFullPath = normalizeScriptURL(jsFullPath);
|
QUrl jsFullPath = QUrl::fromLocalFile(it.next());
|
||||||
_treeNodes.append(new TreeNodeScript(jsPartialPath, jsFullPath.toString(), SCRIPT_ORIGIN_DEFAULT));
|
QString jsPartialPath = jsFullPath.path().split("/").mid(localDirPartCount).join("/");
|
||||||
}
|
jsFullPath = normalizeScriptURL(jsFullPath);
|
||||||
_loadingScripts = false;
|
_treeNodes.append(new TreeNodeScript(jsPartialPath, jsFullPath.toString(), SCRIPT_ORIGIN_DEFAULT));
|
||||||
} else {
|
}
|
||||||
// the url indicates http(s), use QNetworkRequest
|
_loadingScripts = false;
|
||||||
QUrlQuery query;
|
} else {
|
||||||
query.addQueryItem(PREFIX_PARAMETER_NAME, ".");
|
// the url indicates http(s), use QNetworkRequest
|
||||||
if (!marker.isEmpty()) {
|
QUrlQuery query;
|
||||||
query.addQueryItem(MARKER_PARAMETER_NAME, marker);
|
query.addQueryItem(PREFIX_PARAMETER_NAME, ".");
|
||||||
}
|
if (!marker.isEmpty()) {
|
||||||
url.setQuery(query);
|
query.addQueryItem(MARKER_PARAMETER_NAME, marker);
|
||||||
|
}
|
||||||
|
url.setQuery(query);
|
||||||
|
|
||||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||||
QNetworkReply* reply = networkAccessManager.get(request);
|
QNetworkReply* reply = networkAccessManager.get(request);
|
||||||
connect(reply, SIGNAL(finished()), SLOT(downloadFinished()));
|
connect(reply, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue