Showing the changes to interface/src/Application.cpp (1 of 89 files). Show all
Unified · Split
| @@ -131,6 +131,7 @@ · 130 unmodified lines | ||
| 131 | 131 | #include "LODManager.h" |
| 132 | 132 | #include "ModelPackager.h" |
| 133 | 133 | #include "networking/HFWebEngineProfile.h" |
| 134 | +#include "scripting/TestScriptingInterface.h" | |
| 134 | 135 | #include "scripting/AccountScriptingInterface.h" |
| 135 | 136 | #include "scripting/AssetMappingsScriptingInterface.h" |
| 136 | 137 | #include "scripting/AudioDeviceScriptingInterface.h" |
| @@ -168,6 +169,8 @@ · 31 unmodified lines | ||
| 168 | 169 | // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU |
| 169 | 170 | // FIXME seems to be broken. |
| 170 | 171 | #if defined(Q_OS_WIN) |
| 172 | +#include <VersionHelpers.h> | |
| 173 | + | |
| 171 | 174 | extern "C" { |
| 172 | 175 | _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; |
| 173 | 176 | } |
| @@ -418,6 +421,16 @@ bool setupEssentials(int& argc, char** argv) { · 244 unmodified lines | ||
| 418 | 421 | |
| 419 | 422 | Setting::preInit(); |
| 420 | 423 | |
| 424 | +#if defined(Q_OS_WIN) | |
| 425 | + // Select appropriate audio DLL | |
| 426 | + QString audioDLLPath = QCoreApplication::applicationDirPath(); | |
| 427 | + if (IsWindows8OrGreater()) { | |
| 428 | + audioDLLPath += "/audioWin8"; | |
| 429 | + } else { | |
| 430 | + audioDLLPath += "/audioWin7"; | |
| 431 | + } | |
| 432 | + QCoreApplication::addLibraryPath(audioDLLPath); | |
| 433 | +#endif | |
| 421 | 434 | |
| 422 | 435 | static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset"; |
| 423 | 436 | bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET); |
| @@ -541,6 +554,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 117 unmodified lines | ||
| 541 | 554 | setProperty(hifi::properties::STEAM, SteamClient::isRunning()); |
| 542 | 555 | setProperty(hifi::properties::CRASHED, _previousSessionCrashed); |
| 543 | 556 | |
| 557 | + { | |
| 558 | + const QString TEST_SCRIPT = "--testScript"; | |
| 559 | + const QStringList args = arguments(); | |
| 560 | + for (int i = 0; i < args.size() - 1; ++i) { | |
| 561 | + if (args.at(i) == TEST_SCRIPT) { | |
| 562 | + QString testScriptPath = args.at(i + 1); | |
| 563 | + if (QFileInfo(testScriptPath).exists()) { | |
| 564 | + setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); | |
| 565 | + } | |
| 566 | + } | |
| 567 | + } | |
| 568 | + } | |
| 569 | + | |
| 570 | + | |
| 544 | 571 | _runningMarker.startRunningMarker(); |
| 545 | 572 | |
| 546 | 573 | PluginContainer* pluginContainer = dynamic_cast<PluginContainer*>(this); // set the container for any plugins that care |
| @@ -591,8 +618,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 44 unmodified lines | ||
| 591 | 618 | qCDebug(interfaceapp) << "[VERSION] We will use DEVELOPMENT global services."; |
| 592 | 619 | #endif |
| 593 | 620 | |
| 594 | − | |
| 595 | − bool wantsSandboxRunning = shouldRunServer(); | |
| 621 | + | |
| 622 | + static const QString NO_UPDATER_ARG = "--no-updater"; | |
| 623 | + static const bool noUpdater = arguments().indexOf(NO_UPDATER_ARG) != -1; | |
| 624 | + static const bool wantsSandboxRunning = shouldRunServer(); | |
| 596 | 625 | static bool determinedSandboxState = false; |
| 597 | 626 | static bool sandboxIsRunning = false; |
| 598 | 627 | SandboxUtils sandboxUtils; |
| @@ -602,11 +631,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 3 unmodified lines | ||
| 602 | 631 | qCDebug(interfaceapp) << "Home sandbox appears to be running....."; |
| 603 | 632 | determinedSandboxState = true; |
| 604 | 633 | sandboxIsRunning = true; |
| 605 | − }, [&, wantsSandboxRunning]() { | |
| 634 | + }, [&]() { | |
| 606 | 635 | qCDebug(interfaceapp) << "Home sandbox does not appear to be running...."; |
| 607 | 636 | if (wantsSandboxRunning) { |
| 608 | 637 | QString contentPath = getRunServerPath(); |
| 609 | − bool noUpdater = SteamClient::isRunning(); | |
| 610 | 638 | SandboxUtils::runLocalSandbox(contentPath, true, RUNNING_MARKER_FILENAME, noUpdater); |
| 611 | 639 | sandboxIsRunning = true; |
| 612 | 640 | } |
| @@ -1128,7 +1156,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 515 unmodified lines | ||
| 1128 | 1156 | #endif |
| 1129 | 1157 | |
| 1130 | 1158 | // If launched from Steam, let it handle updates |
| 1131 | − if (!SteamClient::isRunning()) { | |
| 1159 | + if (!noUpdater) { | |
| 1132 | 1160 | auto applicationUpdater = DependencyManager::get<AutoUpdater>(); |
| 1133 | 1161 | connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog); |
| 1134 | 1162 | applicationUpdater->checkForUpdate(); |
| @@ -1328,90 +1356,96 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 193 unmodified lines | ||
| 1328 | 1356 | return entityServerNode && !isPhysicsEnabled(); |
| 1329 | 1357 | }); |
| 1330 | 1358 | |
| 1359 | + QVariant testProperty = property(hifi::properties::TEST); | |
| 1360 | + qDebug() << testProperty; | |
| 1361 | + if (testProperty.isValid()) { | |
| 1362 | + auto scriptEngines = DependencyManager::get<ScriptEngines>(); | |
| 1363 | + const auto testScript = property(hifi::properties::TEST).toUrl(); | |
| 1364 | + scriptEngines->loadScript(testScript, false); | |
| 1365 | + } else { | |
| 1366 | + // Get sandbox content set version, if available | |
| 1367 | + auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; | |
| 1368 | + auto contentVersionPath = acDirPath + "content-version.txt"; | |
| 1369 | + qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; | |
| 1370 | + auto contentVersion = 0; | |
| 1371 | + QFile contentVersionFile(contentVersionPath); | |
| 1372 | + if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { | |
| 1373 | + QString line = contentVersionFile.readAll(); | |
| 1374 | + // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure | |
| 1375 | + contentVersion = line.toInt(); | |
| 1376 | + } | |
| 1377 | + qCDebug(interfaceapp) << "Server content version: " << contentVersion; | |
| 1331 | 1378 | |
| 1379 | + bool hasTutorialContent = contentVersion >= 1; | |
| 1332 | 1380 | |
| 1333 | − // Get sandbox content set version, if available | |
| 1334 | − auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; | |
| 1335 | − auto contentVersionPath = acDirPath + "content-version.txt"; | |
| 1336 | − qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; | |
| 1337 | − auto contentVersion = 0; | |
| 1338 | − QFile contentVersionFile(contentVersionPath); | |
| 1339 | − if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { | |
| 1340 | − QString line = contentVersionFile.readAll(); | |
| 1341 | − // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure | |
| 1342 | − contentVersion = line.toInt(); | |
| 1343 | − } | |
| 1344 | − qCDebug(interfaceapp) << "Server content version: " << contentVersion; | |
| 1345 | − | |
| 1346 | − bool hasTutorialContent = contentVersion >= 1; | |
| 1347 | − | |
| 1348 | − Setting::Handle<bool> firstRun { Settings::firstRun, true }; | |
| 1349 | − bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable(); | |
| 1350 | − Setting::Handle<bool> tutorialComplete { "tutorialComplete", false }; | |
| 1351 | − | |
| 1352 | − bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get(); | |
| 1353 | − | |
| 1354 | − qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName(); | |
| 1355 | − qCDebug(interfaceapp) << "Has tutorial content: " << hasTutorialContent; | |
| 1356 | − qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get(); | |
| 1357 | − qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial; | |
| 1358 | − | |
| 1359 | − // when --url in command line, teleport to location | |
| 1360 | − const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; | |
| 1361 | − int urlIndex = arguments().indexOf(HIFI_URL_COMMAND_LINE_KEY); | |
| 1362 | − QString addressLookupString; | |
| 1363 | − if (urlIndex != -1) { | |
| 1364 | − addressLookupString = arguments().value(urlIndex + 1); | |
| 1365 | − } | |
| 1381 | + Setting::Handle<bool> firstRun { Settings::firstRun, true }; | |
| 1382 | + bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable(); | |
| 1383 | + Setting::Handle<bool> tutorialComplete { "tutorialComplete", false }; | |
| 1384 | + | |
| 1385 | + bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get(); | |
| 1386 | + | |
| 1387 | + qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName(); | |
| 1388 | + qCDebug(interfaceapp) << "Has tutorial content: " << hasTutorialContent; | |
| 1389 | + qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get(); | |
| 1390 | + qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial; | |
| 1391 | + | |
| 1392 | + // when --url in command line, teleport to location | |
| 1393 | + const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; | |
| 1394 | + int urlIndex = arguments().indexOf(HIFI_URL_COMMAND_LINE_KEY); | |
| 1395 | + QString addressLookupString; | |
| 1396 | + if (urlIndex != -1) { | |
| 1397 | + addressLookupString = arguments().value(urlIndex + 1); | |
| 1398 | + } | |
| 1366 | 1399 | |
| 1367 | − const QString TUTORIAL_PATH = "/tutorial_begin"; | |
| 1400 | + const QString TUTORIAL_PATH = "/tutorial_begin"; | |
| 1368 | 1401 | |
| 1369 | − if (shouldGoToTutorial) { | |
| 1370 | − if(sandboxIsRunning) { | |
| 1371 | − qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | |
| 1372 | − DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH); | |
| 1373 | − } else { | |
| 1374 | − qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | |
| 1375 | − if (firstRun.get()) { | |
| 1376 | − showHelp(); | |
| 1377 | − } | |
| 1378 | − if (addressLookupString.isEmpty()) { | |
| 1379 | − DependencyManager::get<AddressManager>()->goToEntry(); | |
| 1402 | + if (shouldGoToTutorial) { | |
| 1403 | + if (sandboxIsRunning) { | |
| 1404 | + qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | |
| 1405 | + DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH); | |
| 1380 | 1406 | } else { |
| 1381 | − DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | |
| 1407 | + qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | |
| 1408 | + if (firstRun.get()) { | |
| 1409 | + showHelp(); | |
| 1410 | + } | |
| 1411 | + if (addressLookupString.isEmpty()) { | |
| 1412 | + DependencyManager::get<AddressManager>()->goToEntry(); | |
| 1413 | + } else { | |
| 1414 | + DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | |
| 1415 | + } | |
| 1382 | 1416 | } |
| 1383 | − } | |
| 1384 | − } else { | |
| 1417 | + } else { | |
| 1385 | 1418 | |
| 1386 | − bool isFirstRun = firstRun.get(); | |
| 1419 | + bool isFirstRun = firstRun.get(); | |
| 1387 | 1420 | |
| 1388 | − if (isFirstRun) { | |
| 1389 | − showHelp(); | |
| 1390 | − } | |
| 1421 | + if (isFirstRun) { | |
| 1422 | + showHelp(); | |
| 1423 | + } | |
| 1391 | 1424 | |
| 1392 | − // If this is a first run we short-circuit the address passed in | |
| 1393 | − if (isFirstRun) { | |
| 1394 | − if (hasHMDAndHandControllers) { | |
| 1395 | − if(sandboxIsRunning) { | |
| 1396 | − qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | |
| 1397 | − DependencyManager::get<AddressManager>()->goToLocalSandbox(); | |
| 1425 | + // If this is a first run we short-circuit the address passed in | |
| 1426 | + if (isFirstRun) { | |
| 1427 | + if (hasHMDAndHandControllers) { | |
| 1428 | + if (sandboxIsRunning) { | |
| 1429 | + qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | |
| 1430 | + DependencyManager::get<AddressManager>()->goToLocalSandbox(); | |
| 1431 | + } else { | |
| 1432 | + qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | |
| 1433 | + DependencyManager::get<AddressManager>()->goToEntry(); | |
| 1434 | + } | |
| 1398 | 1435 | } else { |
| 1399 | − qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; | |
| 1400 | 1436 | DependencyManager::get<AddressManager>()->goToEntry(); |
| 1401 | 1437 | } |
| 1402 | 1438 | } else { |
| 1403 | − DependencyManager::get<AddressManager>()->goToEntry(); | |
| 1439 | + qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString); | |
| 1440 | + DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | |
| 1404 | 1441 | } |
| 1405 | − } else { | |
| 1406 | − qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString); | |
| 1407 | − DependencyManager::get<AddressManager>()->loadSettings(addressLookupString); | |
| 1408 | 1442 | } |
| 1409 | − } | |
| 1410 | 1443 | |
| 1411 | − _connectionMonitor.init(); | |
| 1444 | + _connectionMonitor.init(); | |
| 1412 | 1445 | |
| 1413 | − // After all of the constructor is completed, then set firstRun to false. | |
| 1414 | − firstRun.set(false); | |
| 1446 | + // After all of the constructor is completed, then set firstRun to false. | |
| 1447 | + firstRun.set(false); | |
| 1448 | + } | |
| 1415 | 1449 | } |
| 1416 | 1450 | |
| 1417 | 1451 | void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) { |
| @@ -2519,6 +2553,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 1101 unmodified lines | ||
| 2519 | 2553 | Menu::getInstance()->triggerOption(MenuOption::DefaultSkybox); |
| 2520 | 2554 | break; |
| 2521 | 2555 | |
| 2556 | + case Qt::Key_N: | |
| 2557 | + if (!isOption && !isShifted && isMeta) { | |
| 2558 | + DependencyManager::get<NodeList>()->toggleIgnoreRadius(); | |
| 2559 | + } | |
| 2560 | + break; | |
| 2561 | + | |
| 2522 | 2562 | case Qt::Key_S: |
| 2523 | 2563 | if (isShifted && isMeta && !isOption) { |
| 2524 | 2564 | Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings); |
| @@ -4755,7 +4795,7 @@ void Application::resetSensors(bool andReload) { · 2230 unmodified lines | ||
| 4755 | 4795 | DependencyManager::get<EyeTracker>()->reset(); |
| 4756 | 4796 | getActiveDisplayPlugin()->resetSensors(); |
| 4757 | 4797 | _overlayConductor.centerUI(); |
| 4758 | − getMyAvatar()->reset(andReload); | |
| 4798 | + getMyAvatar()->reset(true, andReload); | |
| 4759 | 4799 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection); |
| 4760 | 4800 | } |
| 4761 | 4801 | |
| @@ -5060,6 +5100,11 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 298 unmodified lines | ||
| 5060 | 5100 | // AvatarManager has some custom types |
| 5061 | 5101 | AvatarManager::registerMetaTypes(scriptEngine); |
| 5062 | 5102 | |
| 5103 | + if (property(hifi::properties::TEST).isValid()) { | |
| 5104 | + scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance()); | |
| 5105 | + } | |
| 5106 | + | |
| 5107 | + scriptEngine->registerGlobalObject("Overlays", &_overlays); | |
| 5063 | 5108 | scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this)); |
| 5064 | 5109 | |
| 5065 | 5110 | // hook our avatar and avatar hash map object into this script engine |
| @@ -5740,6 +5785,7 @@ void Application::updateDisplayMode() { · 674 unmodified lines | ||
| 5740 | 5785 | QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) { |
| 5741 | 5786 | resizeGL(); |
| 5742 | 5787 | }); |
| 5788 | + QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset); | |
| 5743 | 5789 | first = false; |
| 5744 | 5790 | } |
| 5745 | 5791 | |