Showing the changes to interface/src/Application.cpp (1 of 6 files). Show all
Unified · Split
| @@ -131,6 +131,7 @@ · 130 unmodified lines | |||
| 131 | #include "LODManager.h" | 131 | #include "LODManager.h" |
| 132 | #include "ModelPackager.h" | 132 | #include "ModelPackager.h" |
| 133 | #include "networking/HFWebEngineProfile.h" | 133 | #include "networking/HFWebEngineProfile.h" |
| 134 | #include "scripting/TestScriptingInterface.h" | ||
| 134 | #include "scripting/AccountScriptingInterface.h" | 135 | #include "scripting/AccountScriptingInterface.h" |
| 135 | #include "scripting/AssetMappingsScriptingInterface.h" | 136 | #include "scripting/AssetMappingsScriptingInterface.h" |
| 136 | #include "scripting/AudioDeviceScriptingInterface.h" | 137 | #include "scripting/AudioDeviceScriptingInterface.h" |
| @@ -541,6 +542,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 404 unmodified lines | |||
| 541 | setProperty(hifi::properties::STEAM, SteamClient::isRunning()); | 542 | setProperty(hifi::properties::STEAM, SteamClient::isRunning()); |
| 542 | setProperty(hifi::properties::CRASHED, _previousSessionCrashed); | 543 | setProperty(hifi::properties::CRASHED, _previousSessionCrashed); |
| 543 | 544 | ||
| 545 | { | ||
| 546 | const QString TEST_SCRIPT = "--testScript"; | ||
| 547 | const QStringList args = arguments(); | ||
| 548 | for (int i = 0; i < args.size() - 1; ++i) { | ||
| 549 | if (args.at(i) == TEST_SCRIPT) { | ||
| 550 | QString testScriptPath = args.at(i + 1); | ||
| 551 | if (QFileInfo(testScriptPath).exists()) { | ||
| 552 | setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); | ||
| 553 | } | ||
| 554 | } | ||
| 555 | } | ||
| 556 | } | ||
| 557 | |||
| 558 | |||
| 544 | _runningMarker.startRunningMarker(); | 559 | _runningMarker.startRunningMarker(); |
| 545 | 560 | ||
| 546 | PluginContainer* pluginContainer = dynamic_cast<PluginContainer*>(this); // set the container for any plugins that care | 561 | PluginContainer* pluginContainer = dynamic_cast<PluginContainer*>(this); // set the container for any plugins that care |
| @@ -1329,90 +1344,96 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 782 unmodified lines | |||
| 1329 | return entityServerNode && !isPhysicsEnabled(); | 1344 | return entityServerNode && !isPhysicsEnabled(); |
| 1330 | }); | 1345 | }); |
| 1331 | 1346 | ||
| 1347 | QVariant testProperty = property(hifi::properties::TEST); | ||
| 1348 | qDebug() << testProperty; | ||
| 1349 | if (testProperty.isValid()) { | ||
| 1350 | auto scriptEngines = DependencyManager::get<ScriptEngines>(); | ||
| 1351 | const auto testScript = property(hifi::properties::TEST).toUrl(); | ||
| 1352 | scriptEngines->loadScript(testScript, false); | ||
| 1353 | } else { | ||
| 1354 | // Get sandbox content set version, if available | ||
| 1355 | auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; | ||
| 1356 | auto contentVersionPath = acDirPath + "content-version.txt"; | ||
| 1357 | qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; | ||
| 1358 | auto contentVersion = 0; | ||
| 1359 | QFile contentVersionFile(contentVersionPath); | ||
| 1360 | if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||
| 1361 | QString line = contentVersionFile.readAll(); | ||
| 1362 | // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure | ||
| 1363 | contentVersion = line.toInt(); | ||
| 1364 | } | ||
| 1365 | qCDebug(interfaceapp) << "Server content version: " << contentVersion; | ||
| 1332 | 1366 | ||
| 1367 | bool hasTutorialContent = contentVersion >= 1; | ||
| 1333 | 1368 | ||
| 1334 | // Get sandbox content set version, if available | 1369 | Setting::Handle<bool> firstRun { Settings::firstRun, true }; |
| 1335 | auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; | 1370 | bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable(); |
| 1336 | auto contentVersionPath = acDirPath + "content-version.txt"; | 1371 | Setting::Handle<bool> tutorialComplete { "tutorialComplete", false }; |
| 1337 | qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; | 1372 | |
| 1338 | auto contentVersion = 0; | 1373 | bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get(); |
| 1339 | QFile contentVersionFile(contentVersionPath); | 1374 | |
| 1340 | if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { | 1375 | qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName(); |
| 1341 | QString line = contentVersionFile.readAll(); | 1376 | qCDebug(interfaceapp) << "Has tutorial content: " << hasTutorialContent; |
| 1342 | // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure | 1377 | qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get(); |
| 1343 | contentVersion = line.toInt(); | 1378 | qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial; |
| 1344 | } | 1379 | |
| 1345 | qCDebug(interfaceapp) << "Server content version: " << contentVersion; | 1380 | // when --url in command line, teleport to location |
| 1346 | 1381 | const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; | |
| 1347 | bool hasTutorialContent = contentVersion >= 1; | 1382 | int urlIndex = arguments().indexOf(HIFI_URL_COMMAND_LINE_KEY); |
| 1348 | 1383 | QString addressLookupString; | |
| 1349 | Setting::Handle<bool> firstRun { Settings::firstRun, true }; | 1384 | if (urlIndex != -1) { |
| 1350 | bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable(); | 1385 | addressLookupString = arguments().value(urlIndex + 1); |
| 1351 | Setting::Handle<bool> tutorialComplete { "tutorialComplete", false }; | 1386 | } |
| 1352 | |||
| 1353 | bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get(); | ||
| 1354 | |||
| 1355 | qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName(); | ||
| 1356 | qCDebug(interfaceapp) << "Has tutorial content: " << hasTutorialContent; | ||
| 1357 | qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get(); | ||
| 1358 | qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial; | ||
| 1359 | |||
| 1360 | // when --url in command line, teleport to location | ||
| 1361 | const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; | ||
| 1362 | int urlIndex = arguments().indexOf(HIFI_URL_COMMAND_LINE_KEY); | ||
| 1363 | QString addressLookupString; | ||
| 1364 | if (urlIndex != -1) { | ||
| 1365 | addressLookupString = arguments().value(urlIndex + 1); | ||
| 1366 | } | ||
| 1367 | 1387 | ||
| 1368 | const QString TUTORIAL_PATH = "/tutorial_begin"; | 1388 | const QString TUTORIAL_PATH = "/tutorial_begin"; |
| 1369 | 1389 | ||
| 1370 | if (shouldGoToTutorial) { | 1390 | if (shouldGoToTutorial) { |
| 1371 | if(sandboxIsRunning) { | 1391 | if (sandboxIsRunning) { |
| 1372 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | 1392 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| 1373 | DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH); | 1393 | DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH); |
| 1374 | } else { | ||
| 1375 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | ||
| 1376 | if (firstRun.get()) { | ||
| 1377 | showHelp(); | ||
| 1378 | } | ||
| 1379 | if (addressLookupString.isEmpty()) { | ||
| 1380 | DependencyManager::get<AddressManager>()->goToEntry(); | ||
| 1381 | } else { | 1394 | } else { |
| 1382 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | 1395 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; |
| 1396 | if (firstRun.get()) { | ||
| 1397 | showHelp(); | ||
| 1398 | } | ||
| 1399 | if (addressLookupString.isEmpty()) { | ||
| 1400 | DependencyManager::get<AddressManager>()->goToEntry(); | ||
| 1401 | } else { | ||
| 1402 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | ||
| 1403 | } | ||
| 1383 | } | 1404 | } |
| 1384 | } | 1405 | } else { |
| 1385 | } else { | ||
| 1386 | 1406 | ||
| 1387 | bool isFirstRun = firstRun.get(); | 1407 | bool isFirstRun = firstRun.get(); |
| 1388 | 1408 | ||
| 1389 | if (isFirstRun) { | 1409 | if (isFirstRun) { |
| 1390 | showHelp(); | 1410 | showHelp(); |
| 1391 | } | 1411 | } |
| 1392 | 1412 | ||
| 1393 | // If this is a first run we short-circuit the address passed in | 1413 | // If this is a first run we short-circuit the address passed in |
| 1394 | if (isFirstRun) { | 1414 | if (isFirstRun) { |
| 1395 | if (hasHMDAndHandControllers) { | 1415 | if (hasHMDAndHandControllers) { |
| 1396 | if(sandboxIsRunning) { | 1416 | if (sandboxIsRunning) { |
| 1397 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | 1417 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| 1398 | DependencyManager::get<AddressManager>()->goToLocalSandbox(); | 1418 | DependencyManager::get<AddressManager>()->goToLocalSandbox(); |
| 1419 | } else { | ||
| 1420 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | ||
| 1421 | DependencyManager::get<AddressManager>()->goToEntry(); | ||
| 1422 | } | ||
| 1399 | } else { | 1423 | } else { |
| 1400 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | ||
| 1401 | DependencyManager::get<AddressManager>()->goToEntry(); | 1424 | DependencyManager::get<AddressManager>()->goToEntry(); |
| 1402 | } | 1425 | } |
| 1403 | } else { | 1426 | } else { |
| 1404 | DependencyManager::get<AddressManager>()->goToEntry(); | 1427 | qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString); |
| 1428 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | ||
| 1405 | } | 1429 | } |
| 1406 | } else { | ||
| 1407 | qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString); | ||
| 1408 | DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | ||
| 1409 | } | 1430 | } |
| 1410 | } | ||
| 1411 | 1431 | ||
| 1412 | _connectionMonitor.init(); | 1432 | _connectionMonitor.init(); |
| 1413 | 1433 | ||
| 1414 | // After all of the constructor is completed, then set firstRun to false. | 1434 | // After all of the constructor is completed, then set firstRun to false. |
| 1415 | firstRun.set(false); | 1435 | firstRun.set(false); |
| 1436 | } | ||
| 1416 | } | 1437 | } |
| 1417 | 1438 | ||
| 1418 | void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { | 1439 | void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { |
| @@ -5056,6 +5077,11 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 3637 unmodified lines | |||
| 5056 | // AvatarManager has some custom types | 5077 | // AvatarManager has some custom types |
| 5057 | AvatarManager::registerMetaTypes(scriptEngine); | 5078 | AvatarManager::registerMetaTypes(scriptEngine); |
| 5058 | 5079 | ||
| 5080 | if (property(hifi::properties::TEST).isValid()) { | ||
| 5081 | scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance()); | ||
| 5082 | } | ||
| 5083 | |||
| 5084 | scriptEngine->registerGlobalObject("Overlays", &_overlays); | ||
| 5059 | scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this)); | 5085 | scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this)); |
| 5060 | 5086 | ||
| 5061 | // hook our avatar and avatar hash map object into this script engine | 5087 | // hook our avatar and avatar hash map object into this script engine |