History

Merge branch 'master' of github.com:highfidelity/hifi into tablet-ui

Seth Alves committed 9 years ago

Commit d97be522 parents 819e3dc 9155f1189 files · +23632 −1007Browse files

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

Unified · Split

interface/src/Application.cpp+119−73
@@ -131,6 +131,7 @@ · 130 unmodified lines
131#include "LODManager.h"131#include "LODManager.h"
132#include "ModelPackager.h"132#include "ModelPackager.h"
133#include "networking/HFWebEngineProfile.h"133#include "networking/HFWebEngineProfile.h"
134#include "scripting/TestScriptingInterface.h"
134#include "scripting/AccountScriptingInterface.h"135#include "scripting/AccountScriptingInterface.h"
135#include "scripting/AssetMappingsScriptingInterface.h"136#include "scripting/AssetMappingsScriptingInterface.h"
136#include "scripting/AudioDeviceScriptingInterface.h"137#include "scripting/AudioDeviceScriptingInterface.h"
@@ -168,6 +169,8 @@ · 31 unmodified lines
168// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU169// On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
169// FIXME seems to be broken.170// FIXME seems to be broken.
170#if defined(Q_OS_WIN)171#if defined(Q_OS_WIN)
172#include <VersionHelpers.h>
173
171extern "C" {174extern "C" {
172 _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;175 _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
173}176}
@@ -418,6 +421,16 @@ bool setupEssentials(int& argc, char** argv) { · 244 unmodified lines
418 421
419 Setting::preInit();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 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";435 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
423 bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);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 setProperty(hifi::properties::STEAM, SteamClient::isRunning());554 setProperty(hifi::properties::STEAM, SteamClient::isRunning());
542 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);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 _runningMarker.startRunningMarker();571 _runningMarker.startRunningMarker();
545 572
546 PluginContainer* pluginContainer = dynamic_cast<PluginContainer*>(this); // set the container for any plugins that care573 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 qCDebug(interfaceapp) << "[VERSION] We will use DEVELOPMENT global services.";618 qCDebug(interfaceapp) << "[VERSION] We will use DEVELOPMENT global services.";
592#endif619#endif
593 620
594 621
595 bool wantsSandboxRunning = shouldRunServer();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 static bool determinedSandboxState = false;625 static bool determinedSandboxState = false;
597 static bool sandboxIsRunning = false;626 static bool sandboxIsRunning = false;
598 SandboxUtils sandboxUtils;627 SandboxUtils sandboxUtils;
@@ -602,11 +631,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 3 unmodified lines
602 qCDebug(interfaceapp) << "Home sandbox appears to be running.....";631 qCDebug(interfaceapp) << "Home sandbox appears to be running.....";
603 determinedSandboxState = true;632 determinedSandboxState = true;
604 sandboxIsRunning = true;633 sandboxIsRunning = true;
605 }, [&, wantsSandboxRunning]() {634 }, [&]() {
606 qCDebug(interfaceapp) << "Home sandbox does not appear to be running....";635 qCDebug(interfaceapp) << "Home sandbox does not appear to be running....";
607 if (wantsSandboxRunning) {636 if (wantsSandboxRunning) {
608 QString contentPath = getRunServerPath();637 QString contentPath = getRunServerPath();
609 bool noUpdater = SteamClient::isRunning();
610 SandboxUtils::runLocalSandbox(contentPath, true, RUNNING_MARKER_FILENAME, noUpdater);638 SandboxUtils::runLocalSandbox(contentPath, true, RUNNING_MARKER_FILENAME, noUpdater);
611 sandboxIsRunning = true;639 sandboxIsRunning = true;
612 }640 }
@@ -1128,7 +1156,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 515 unmodified lines
1128#endif1156#endif
1129 1157
1130 // If launched from Steam, let it handle updates1158 // If launched from Steam, let it handle updates
1131 if (!SteamClient::isRunning()) {1159 if (!noUpdater) {
1132 auto applicationUpdater = DependencyManager::get<AutoUpdater>();1160 auto applicationUpdater = DependencyManager::get<AutoUpdater>();
1133 connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);1161 connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
1134 applicationUpdater->checkForUpdate();1162 applicationUpdater->checkForUpdate();
@@ -1328,90 +1356,96 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 193 unmodified lines
1328 return entityServerNode && !isPhysicsEnabled();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 available1381 Setting::Handle<bool> firstRun { Settings::firstRun, true };
1334 auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/";1382 bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable();
1335 auto contentVersionPath = acDirPath + "content-version.txt";1383 Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };
1336 qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version";1384
1337 auto contentVersion = 0;1385 bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get();
1338 QFile contentVersionFile(contentVersionPath);1386
1339 if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {1387 qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName();
1340 QString line = contentVersionFile.readAll();1388 qCDebug(interfaceapp) << "Has tutorial content: " << hasTutorialContent;
1341 // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure1389 qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get();
1342 contentVersion = line.toInt();1390 qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial;
1343 }1391
1344 qCDebug(interfaceapp) << "Server content version: " << contentVersion;1392 // when --url in command line, teleport to location
1345 1393 const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
1346 bool hasTutorialContent = contentVersion >= 1;1394 int urlIndex = arguments().indexOf(HIFI_URL_COMMAND_LINE_KEY);
1347 1395 QString addressLookupString;
1348 Setting::Handle<bool> firstRun { Settings::firstRun, true };1396 if (urlIndex != -1) {
1349 bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable();1397 addressLookupString = arguments().value(urlIndex + 1);
1350 Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };1398 }
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 }
1366 1399
1367 const QString TUTORIAL_PATH = "/tutorial_begin";1400 const QString TUTORIAL_PATH = "/tutorial_begin";
1368 1401
1369 if (shouldGoToTutorial) {1402 if (shouldGoToTutorial) {
1370 if(sandboxIsRunning) {1403 if (sandboxIsRunning) {
1371 qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";1404 qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
1372 DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH);1405 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();
1380 } else {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 }1417 } else {
1384 } else {
1385 1418
1386 bool isFirstRun = firstRun.get();1419 bool isFirstRun = firstRun.get();
1387 1420
1388 if (isFirstRun) {1421 if (isFirstRun) {
1389 showHelp();1422 showHelp();
1390 }1423 }
1391 1424
1392 // If this is a first run we short-circuit the address passed in1425 // If this is a first run we short-circuit the address passed in
1393 if (isFirstRun) {1426 if (isFirstRun) {
1394 if (hasHMDAndHandControllers) {1427 if (hasHMDAndHandControllers) {
1395 if(sandboxIsRunning) {1428 if (sandboxIsRunning) {
1396 qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";1429 qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
1397 DependencyManager::get<AddressManager>()->goToLocalSandbox();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 } else {1435 } else {
1399 qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry.";
1400 DependencyManager::get<AddressManager>()->goToEntry();1436 DependencyManager::get<AddressManager>()->goToEntry();
1401 }1437 }
1402 } else {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.1446 // After all of the constructor is completed, then set firstRun to false.
1414 firstRun.set(false);1447 firstRun.set(false);
1448 }
1415}1449}
1416 1450
1417void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {1451void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
@@ -2519,6 +2553,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 1101 unmodified lines
2519 Menu::getInstance()->triggerOption(MenuOption::DefaultSkybox);2553 Menu::getInstance()->triggerOption(MenuOption::DefaultSkybox);
2520 break;2554 break;
2521 2555
2556 case Qt::Key_N:
2557 if (!isOption && !isShifted && isMeta) {
2558 DependencyManager::get<NodeList>()->toggleIgnoreRadius();
2559 }
2560 break;
2561
2522 case Qt::Key_S:2562 case Qt::Key_S:
2523 if (isShifted && isMeta && !isOption) {2563 if (isShifted && isMeta && !isOption) {
2524 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);2564 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
@@ -4755,7 +4795,7 @@ void Application::resetSensors(bool andReload) { · 2230 unmodified lines
4755 DependencyManager::get<EyeTracker>()->reset();4795 DependencyManager::get<EyeTracker>()->reset();
4756 getActiveDisplayPlugin()->resetSensors();4796 getActiveDisplayPlugin()->resetSensors();
4757 _overlayConductor.centerUI();4797 _overlayConductor.centerUI();
4758 getMyAvatar()->reset(andReload);4798 getMyAvatar()->reset(true, andReload);
4759 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);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 // AvatarManager has some custom types5100 // AvatarManager has some custom types
5061 AvatarManager::registerMetaTypes(scriptEngine);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 scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));5108 scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
5064 5109
5065 // hook our avatar and avatar hash map object into this script engine5110 // hook our avatar and avatar hash map object into this script engine
@@ -5740,6 +5785,7 @@ void Application::updateDisplayMode() { · 674 unmodified lines
5740 QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {5785 QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {
5741 resizeGL();5786 resizeGL();
5742 });5787 });
5788 QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
5743 first = false;5789 first = false;
5744 }5790 }
5745 5791

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t