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 | 1465 | const auto testScript = property(hifi::properties::TEST).toUrl(); |
| 1466 | 1466 | scriptEngines->loadScript(testScript, false); |
| 1467 | 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 | 1478 | auto acDirPath = PathUtils::getAppDataPath() + "../../" + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; |
| 1470 | 1479 | auto contentVersionPath = acDirPath + "content-version.txt"; |
| 1471 | 1480 | qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; |
| 1472 | − auto contentVersion = 0; | |
| 1481 | + int contentVersion = 0; | |
| 1473 | 1482 | QFile contentVersionFile(contentVersionPath); |
| 1474 | 1483 | if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
| 1475 | 1484 | QString line = contentVersionFile.readAll(); |
| 1476 | − // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure | |
| 1477 | − contentVersion = line.toInt(); | |
| 1485 | + contentVersion = line.toInt(); // returns 0 if conversion fails | |
| 1478 | 1486 | } |
| 1479 | − qCDebug(interfaceapp) << "Server content version: " << contentVersion; | |
| 1480 | 1487 | |
| 1481 | − static const int MIN_VIVE_CONTENT_VERSION = 1; | |
| 1482 | − static const int MIN_OCULUS_TOUCH_CONTENT_VERSION = 27; | |
| 1483 | − | |
| 1484 | − bool hasSufficientTutorialContent = false; | |
| 1488 | + // Get controller availability | |
| 1485 | 1489 | bool hasHandControllers = false; |
| 1486 | − | |
| 1487 | − // Only specific hand controllers are currently supported, so only send users to the tutorial | |
| 1488 | − // if they have one of those hand controllers. | |
| 1490 | + HandControllerType handControllerType = Vive; | |
| 1489 | 1491 | if (PluginUtils::isViveControllerAvailable()) { |
| 1490 | 1492 | hasHandControllers = true; |
| 1491 | − hasSufficientTutorialContent = contentVersion >= MIN_VIVE_CONTENT_VERSION; | |
| 1493 | + handControllerType = Vive; | |
| 1492 | 1494 | } else if (PluginUtils::isOculusTouchControllerAvailable()) { |
| 1493 | 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 | 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(); | |
| 1505 | − qCDebug(interfaceapp) << "Has sufficient tutorial content (" << contentVersion << ") : " << hasSufficientTutorialContent; | |
| 1506 | − qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get(); | |
| 1507 | − qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial; | |
| 1512 | + qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMD; | |
| 1513 | + qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << | |
| 1514 | + ", complete:" << isTutorialComplete << ", should go:" << shouldGoToTutorial; | |
| 1508 | 1515 | |
| 1509 | 1516 | // when --url in command line, teleport to location |
| 1510 | 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 | 1549 | // If this is a first run we short-circuit the address passed in |
| 1543 | 1550 | if (isFirstRun) { |
| 1544 | − if (hasHMDAndHandControllers) { | |
| 1551 | + if (isUsingHMD) { | |
| 1545 | 1552 | if (sandboxIsRunning) { |
| 1546 | 1553 | qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; |
| 1547 | 1554 | DependencyManager::get<AddressManager>()->goToLocalSandbox(); |