Condition tutorial on active HMD
Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all
Unified · Split
| @@ -1465,46 +1465,53 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1464 unmodified lines | |||
| 1465 | const auto testScript = property(hifi::properties::TEST).toUrl(); | 1465 | const auto testScript = property(hifi::properties::TEST).toUrl(); |
| 1466 | scriptEngines->loadScript(testScript, false); | 1466 | scriptEngines->loadScript(testScript, false); |
| 1467 | } else { | 1467 | } else { |
| 1468 | // Get sandbox content set version, if available | 1468 | enum HandControllerType { |
| 1469 | Vive, | ||
| 1470 | Oculus | ||
| 1471 | }; | ||
| 1472 | static const std::map<HandControllerType, int> MIN_CONTENT_VERSION = { | ||
| 1473 | { Vive, 1 }, | ||
| 1474 | { Oculus, 27 } | ||
| 1475 | }; | ||
| 1476 | |||
| 1477 | // Get sandbox content set version | ||
| 1469 | auto acDirPath = PathUtils::getAppDataPath() + "../../" + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; | 1478 | auto acDirPath = PathUtils::getAppDataPath() + "../../" + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; |
| 1470 | auto contentVersionPath = acDirPath + "content-version.txt"; | 1479 | auto contentVersionPath = acDirPath + "content-version.txt"; |
| 1471 | qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; | 1480 | qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; |
| 1472 | auto contentVersion = 0; | 1481 | int contentVersion = 0; |
| 1473 | QFile contentVersionFile(contentVersionPath); | 1482 | QFile contentVersionFile(contentVersionPath); |
| 1474 | if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { | 1483 | if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
| 1475 | QString line = contentVersionFile.readAll(); | 1484 | QString line = contentVersionFile.readAll(); |
| 1476 | // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure | 1485 | contentVersion = line.toInt(); // returns 0 if conversion fails |
| 1477 | contentVersion = line.toInt(); | ||
| 1478 | } | 1486 | } |
| 1479 | qCDebug(interfaceapp) << "Server content version: " << contentVersion; | ||
| 1480 | 1487 | ||
| 1481 | static const int MIN_VIVE_CONTENT_VERSION = 1; | 1488 | // Get controller availability |
| 1482 | static const int MIN_OCULUS_TOUCH_CONTENT_VERSION = 27; | ||
| 1483 | |||
| 1484 | bool hasSufficientTutorialContent = false; | ||
| 1485 | bool hasHandControllers = false; | 1489 | bool hasHandControllers = false; |
| 1486 | 1490 | HandControllerType handControllerType = Vive; | |
| 1487 | // Only specific hand controllers are currently supported, so only send users to the tutorial | ||
| 1488 | // if they have one of those hand controllers. | ||
| 1489 | if (PluginUtils::isViveControllerAvailable()) { | 1491 | if (PluginUtils::isViveControllerAvailable()) { |
| 1490 | hasHandControllers = true; | 1492 | hasHandControllers = true; |
| 1491 | hasSufficientTutorialContent = contentVersion >= MIN_VIVE_CONTENT_VERSION; | 1493 | handControllerType = Vive; |
| 1492 | } else if (PluginUtils::isOculusTouchControllerAvailable()) { | 1494 | } else if (PluginUtils::isOculusTouchControllerAvailable()) { |
| 1493 | hasHandControllers = true; | 1495 | hasHandControllers = true; |
| 1494 | hasSufficientTutorialContent = contentVersion >= MIN_OCULUS_TOUCH_CONTENT_VERSION; | 1496 | handControllerType = Oculus; |
| 1495 | } | 1497 | } |
| 1496 | 1498 | ||
| 1497 | Setting::Handle<bool> firstRun { Settings::firstRun, true }; | 1499 | // Check tutorial content versioning |
| 1500 | bool hasTutorialContent = contentVersion >= MIN_CONTENT_VERSION.at(handControllerType); | ||
| 1501 | |||
| 1502 | // Check HMD use (may be technically available without being in use) | ||
| 1503 | bool hasHMD = PluginUtils::isHMDAvailable(); | ||
| 1504 | bool isUsingHMD = hasHMD && hasHandControllers && _displayPlugin->isHmd(); | ||
| 1498 | 1505 | ||
| 1499 | bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable() && hasHandControllers; | ||
| 1500 | Setting::Handle<bool> tutorialComplete { "tutorialComplete", false }; | 1506 | Setting::Handle<bool> tutorialComplete { "tutorialComplete", false }; |
| 1507 | Setting::Handle<bool> firstRun { Settings::firstRun, true }; | ||
| 1501 | 1508 | ||
| 1502 | bool shouldGoToTutorial = hasHMDAndHandControllers && hasSufficientTutorialContent && !tutorialComplete.get(); | 1509 | bool isTutorialComplete = tutorialComplete.get(); |
| 1510 | bool shouldGoToTutorial = isUsingHMD && hasTutorialContent && !isTutorialComplete; | ||
| 1503 | 1511 | ||
| 1504 | qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName(); | 1512 | qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMD; |
| 1505 | qCDebug(interfaceapp) << "Has sufficient tutorial content (" << contentVersion << ") : " << hasSufficientTutorialContent; | 1513 | qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << |
| 1506 | qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get(); | 1514 | ", complete:" << isTutorialComplete << ", should go:" << shouldGoToTutorial; |
| 1507 | qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial; | ||
| 1508 | 1515 | ||
| 1509 | // when --url in command line, teleport to location | 1516 | // when --url in command line, teleport to location |
| 1510 | const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; | 1517 | const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; |
| @@ -1541,7 +1548,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 30 unmodified lines | |||
| 1541 | 1548 | ||
| 1542 | // If this is a first run we short-circuit the address passed in | 1549 | // If this is a first run we short-circuit the address passed in |
| 1543 | if (isFirstRun) { | 1550 | if (isFirstRun) { |
| 1544 | if (hasHMDAndHandControllers) { | 1551 | if (isUsingHMD) { |
| 1545 | if (sandboxIsRunning) { | 1552 | if (sandboxIsRunning) { |
| 1546 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; | 1553 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| 1547 | DependencyManager::get<AddressManager>()->goToLocalSandbox(); | 1554 | DependencyManager::get<AddressManager>()->goToLocalSandbox(); |