History

Merge pull request #10240 from zzmp/fix/hmd-tutorial

Condition tutorial on active HMD

Ryan Huffman committed 9 years ago

Commit 8ba56a92 parents 11c21cc f432cfe2 files · +32 −25Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+29−22
@@ -1465,46 +1465,53 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1464 unmodified lines
14651465 const auto testScript = property(hifi::properties::TEST).toUrl();
14661466 scriptEngines->loadScript(testScript, false);
14671467 } 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
14691478 auto acDirPath = PathUtils::getAppDataPath() + "../../" + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/";
14701479 auto contentVersionPath = acDirPath + "content-version.txt";
14711480 qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version";
1472− auto contentVersion = 0;
1481+ int contentVersion = 0;
14731482 QFile contentVersionFile(contentVersionPath);
14741483 if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
14751484 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
14781486 }
1479− qCDebug(interfaceapp) << "Server content version: " << contentVersion;
14801487
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
14851489 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;
14891491 if (PluginUtils::isViveControllerAvailable()) {
14901492 hasHandControllers = true;
1491− hasSufficientTutorialContent = contentVersion >= MIN_VIVE_CONTENT_VERSION;
1493+ handControllerType = Vive;
14921494 } else if (PluginUtils::isOculusTouchControllerAvailable()) {
14931495 hasHandControllers = true;
1494− hasSufficientTutorialContent = contentVersion >= MIN_OCULUS_TOUCH_CONTENT_VERSION;
1496+ handControllerType = Oculus;
14951497 }
14961498
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();
14981505
1499− bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable() && hasHandControllers;
15001506 Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };
1507+ Setting::Handle<bool> firstRun { Settings::firstRun, true };
15011508
1502− bool shouldGoToTutorial = hasHMDAndHandControllers && hasSufficientTutorialContent && !tutorialComplete.get();
1509+ bool isTutorialComplete = tutorialComplete.get();
1510+ bool shouldGoToTutorial = isUsingHMD && hasTutorialContent && !isTutorialComplete;
15031511
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;
15081515
15091516 // when --url in command line, teleport to location
15101517 const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
@@ -1541,7 +1548,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 30 unmodified lines
15411548
15421549 // If this is a first run we short-circuit the address passed in
15431550 if (isFirstRun) {
1544− if (hasHMDAndHandControllers) {
1551+ if (isUsingHMD) {
15451552 if (sandboxIsRunning) {
15461553 qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
15471554 DependencyManager::get<AddressManager>()->goToLocalSandbox();