check HMD usage for tutorial teleport

This commit is contained in:
Zach Pomerantz 2017-04-18 18:05:17 -04:00
parent e65079f826
commit a310acd37f

View file

@ -1458,46 +1458,53 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
const auto testScript = property(hifi::properties::TEST).toUrl(); const auto testScript = property(hifi::properties::TEST).toUrl();
scriptEngines->loadScript(testScript, false); scriptEngines->loadScript(testScript, false);
} else { } else {
// Get sandbox content set version, if available enum HandControllerType {
Vive,
Oculus
};
static const std::map<HandControllerType, int> MIN_CONTENT_VERSION = {
{ Vive, 1 },
{ Oculus, 27 }
};
// Get sandbox content set version
auto acDirPath = PathUtils::getAppDataPath() + "../../" + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/"; auto acDirPath = PathUtils::getAppDataPath() + "../../" + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/";
auto contentVersionPath = acDirPath + "content-version.txt"; auto contentVersionPath = acDirPath + "content-version.txt";
qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version"; qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version";
auto contentVersion = 0; int contentVersion = 0;
QFile contentVersionFile(contentVersionPath); QFile contentVersionFile(contentVersionPath);
if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) { if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString line = contentVersionFile.readAll(); QString line = contentVersionFile.readAll();
// toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure contentVersion = line.toInt(); // returns 0 if conversion fails
contentVersion = line.toInt();
} }
qCDebug(interfaceapp) << "Server content version: " << contentVersion;
static const int MIN_VIVE_CONTENT_VERSION = 1; // Get controller availability
static const int MIN_OCULUS_TOUCH_CONTENT_VERSION = 27;
bool hasSufficientTutorialContent = false;
bool hasHandControllers = false; bool hasHandControllers = false;
HandControllerType handControllerType = Vive;
// Only specific hand controllers are currently supported, so only send users to the tutorial
// if they have one of those hand controllers.
if (PluginUtils::isViveControllerAvailable()) { if (PluginUtils::isViveControllerAvailable()) {
hasHandControllers = true; hasHandControllers = true;
hasSufficientTutorialContent = contentVersion >= MIN_VIVE_CONTENT_VERSION; handControllerType = Vive;
} else if (PluginUtils::isOculusTouchControllerAvailable()) { } else if (PluginUtils::isOculusTouchControllerAvailable()) {
hasHandControllers = true; hasHandControllers = true;
hasSufficientTutorialContent = contentVersion >= MIN_OCULUS_TOUCH_CONTENT_VERSION; handControllerType = Oculus;
} }
// Check tutorial content versioning
bool hasTutorialContent = contentVersion >= MIN_CONTENT_VERSION.at(handControllerType);
// Check HMD use (may be technically available without being in use)
bool hasHMD = PluginUtils::isHMDAvailable();
bool isUsingHMD = hasHMD && hasHandControllers && _displayPlugin->isHmd();
Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };
Setting::Handle<bool> firstRun { Settings::firstRun, true }; Setting::Handle<bool> firstRun { Settings::firstRun, true };
bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable() && hasHandControllers; bool isTutorialComplete = tutorialComplete.get();
Setting::Handle<bool> tutorialComplete { "tutorialComplete", false }; bool shouldGoToTutorial = isUsingHMD && hasTutorialContent && !isTutorialComplete;
bool shouldGoToTutorial = hasHMDAndHandControllers && hasSufficientTutorialContent && !tutorialComplete.get(); qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMD;
qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent <<
qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName(); ", complete:" << isTutorialComplete << ", should go:" << shouldGoToTutorial;
qCDebug(interfaceapp) << "Has sufficient tutorial content (" << contentVersion << ") : " << hasSufficientTutorialContent;
qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get();
qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial;
// when --url in command line, teleport to location // when --url in command line, teleport to location
const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
@ -1534,7 +1541,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// If this is a first run we short-circuit the address passed in // If this is a first run we short-circuit the address passed in
if (isFirstRun) { if (isFirstRun) {
if (hasHMDAndHandControllers) { if (isUsingHMD) {
if (sandboxIsRunning) { if (sandboxIsRunning) {
qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
DependencyManager::get<AddressManager>()->goToLocalSandbox(); DependencyManager::get<AddressManager>()->goToLocalSandbox();