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
131131 #include "LODManager.h"
132132 #include "ModelPackager.h"
133133 #include "networking/HFWebEngineProfile.h"
134+#include "scripting/TestScriptingInterface.h"
134135 #include "scripting/AccountScriptingInterface.h"
135136 #include "scripting/AssetMappingsScriptingInterface.h"
136137 #include "scripting/AudioDeviceScriptingInterface.h"
@@ -168,6 +169,8 @@ · 31 unmodified lines
168169 // On Windows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
169170 // FIXME seems to be broken.
170171 #if defined(Q_OS_WIN)
172+#include <VersionHelpers.h>
173+
171174 extern "C" {
172175 _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
173176 }
@@ -418,6 +421,16 @@ bool setupEssentials(int& argc, char** argv) { · 244 unmodified lines
418421
419422 Setting::preInit();
420423
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
421434
422435 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
423436 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
541554 setProperty(hifi::properties::STEAM, SteamClient::isRunning());
542555 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
543556
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+
544571 _runningMarker.startRunningMarker();
545572
546573 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
591618 qCDebug(interfaceapp) << "[VERSION] We will use DEVELOPMENT global services.";
592619 #endif
593620
594−
595− bool wantsSandboxRunning = shouldRunServer();
621+
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();
596625 static bool determinedSandboxState = false;
597626 static bool sandboxIsRunning = false;
598627 SandboxUtils sandboxUtils;
@@ -602,11 +631,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 3 unmodified lines
602631 qCDebug(interfaceapp) << "Home sandbox appears to be running.....";
603632 determinedSandboxState = true;
604633 sandboxIsRunning = true;
605− }, [&, wantsSandboxRunning]() {
634+ }, [&]() {
606635 qCDebug(interfaceapp) << "Home sandbox does not appear to be running....";
607636 if (wantsSandboxRunning) {
608637 QString contentPath = getRunServerPath();
609− bool noUpdater = SteamClient::isRunning();
610638 SandboxUtils::runLocalSandbox(contentPath, true, RUNNING_MARKER_FILENAME, noUpdater);
611639 sandboxIsRunning = true;
612640 }
@@ -1128,7 +1156,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 515 unmodified lines
11281156 #endif
11291157
11301158 // If launched from Steam, let it handle updates
1131− if (!SteamClient::isRunning()) {
1159+ if (!noUpdater) {
11321160 auto applicationUpdater = DependencyManager::get<AutoUpdater>();
11331161 connect(applicationUpdater.data(), &AutoUpdater::newVersionIsAvailable, dialogsManager.data(), &DialogsManager::showUpdateDialog);
11341162 applicationUpdater->checkForUpdate();
@@ -1328,90 +1356,96 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 193 unmodified lines
13281356 return entityServerNode && !isPhysicsEnabled();
13291357 });
13301358
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;
13311378
1379+ bool hasTutorialContent = contentVersion >= 1;
13321380
1333− // Get sandbox content set version, if available
1334− auto acDirPath = PathUtils::getRootDataDirectory() + BuildInfo::MODIFIED_ORGANIZATION + "/assignment-client/";
1335− auto contentVersionPath = acDirPath + "content-version.txt";
1336− qCDebug(interfaceapp) << "Checking " << contentVersionPath << " for content version";
1337− auto contentVersion = 0;
1338− QFile contentVersionFile(contentVersionPath);
1339− if (contentVersionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
1340− QString line = contentVersionFile.readAll();
1341− // toInt() returns 0 if the conversion fails, so we don't need to specifically check for failure
1342− contentVersion = line.toInt();
1343− }
1344− qCDebug(interfaceapp) << "Server content version: " << contentVersion;
1345−
1346− bool hasTutorialContent = contentVersion >= 1;
1347−
1348− Setting::Handle<bool> firstRun { Settings::firstRun, true };
1349− bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable();
1350− Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };
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− }
1381+ Setting::Handle<bool> firstRun { Settings::firstRun, true };
1382+ bool hasHMDAndHandControllers = PluginUtils::isHMDAvailable("OpenVR (Vive)") && PluginUtils::isHandControllerAvailable();
1383+ Setting::Handle<bool> tutorialComplete { "tutorialComplete", false };
1384+
1385+ bool shouldGoToTutorial = hasHMDAndHandControllers && hasTutorialContent && !tutorialComplete.get();
1386+
1387+ qCDebug(interfaceapp) << "Has HMD + Hand Controllers: " << hasHMDAndHandControllers << ", current plugin: " << _displayPlugin->getName();
1388+ qCDebug(interfaceapp) << "Has tutorial content: " << hasTutorialContent;
1389+ qCDebug(interfaceapp) << "Tutorial complete: " << tutorialComplete.get();
1390+ qCDebug(interfaceapp) << "Should go to tutorial: " << shouldGoToTutorial;
1391+
1392+ // when --url in command line, teleport to location
1393+ const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
1394+ int urlIndex = arguments().indexOf(HIFI_URL_COMMAND_LINE_KEY);
1395+ QString addressLookupString;
1396+ if (urlIndex != -1) {
1397+ addressLookupString = arguments().value(urlIndex + 1);
1398+ }
13661399
1367− const QString TUTORIAL_PATH = "/tutorial_begin";
1400+ const QString TUTORIAL_PATH = "/tutorial_begin";
13681401
1369− if (shouldGoToTutorial) {
1370− if(sandboxIsRunning) {
1371− qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
1372− 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();
1402+ if (shouldGoToTutorial) {
1403+ if (sandboxIsRunning) {
1404+ qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
1405+ DependencyManager::get<AddressManager>()->goToLocalSandbox(TUTORIAL_PATH);
13801406 } 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+ }
13821416 }
1383− }
1384− } else {
1417+ } else {
13851418
1386− bool isFirstRun = firstRun.get();
1419+ bool isFirstRun = firstRun.get();
13871420
1388− if (isFirstRun) {
1389− showHelp();
1390− }
1421+ if (isFirstRun) {
1422+ showHelp();
1423+ }
13911424
1392− // If this is a first run we short-circuit the address passed in
1393− if (isFirstRun) {
1394− if (hasHMDAndHandControllers) {
1395− if(sandboxIsRunning) {
1396− qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
1397− DependencyManager::get<AddressManager>()->goToLocalSandbox();
1425+ // If this is a first run we short-circuit the address passed in
1426+ if (isFirstRun) {
1427+ if (hasHMDAndHandControllers) {
1428+ if (sandboxIsRunning) {
1429+ qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home.";
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+ }
13981435 } else {
1399− qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry.";
14001436 DependencyManager::get<AddressManager>()->goToEntry();
14011437 }
14021438 } 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);
14041441 }
1405− } else {
1406− qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString);
1407− DependencyManager::get<AddressManager>()->loadSettings(addressLookupString);
14081442 }
1409− }
14101443
1411− _connectionMonitor.init();
1444+ _connectionMonitor.init();
14121445
1413− // After all of the constructor is completed, then set firstRun to false.
1414− firstRun.set(false);
1446+ // After all of the constructor is completed, then set firstRun to false.
1447+ firstRun.set(false);
1448+ }
14151449 }
14161450
14171451 void Application::domainConnectionRefused(const QString& reasonMessage, int reasonCodeInt, const QString& extraInfo) {
@@ -2519,6 +2553,12 @@ void Application::keyPressEvent(QKeyEvent* event) { · 1101 unmodified lines
25192553 Menu::getInstance()->triggerOption(MenuOption::DefaultSkybox);
25202554 break;
25212555
2556+ case Qt::Key_N:
2557+ if (!isOption && !isShifted && isMeta) {
2558+ DependencyManager::get<NodeList>()->toggleIgnoreRadius();
2559+ }
2560+ break;
2561+
25222562 case Qt::Key_S:
25232563 if (isShifted && isMeta && !isOption) {
25242564 Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
@@ -4755,7 +4795,7 @@ void Application::resetSensors(bool andReload) { · 2230 unmodified lines
47554795 DependencyManager::get<EyeTracker>()->reset();
47564796 getActiveDisplayPlugin()->resetSensors();
47574797 _overlayConductor.centerUI();
4758− getMyAvatar()->reset(andReload);
4798+ getMyAvatar()->reset(true, andReload);
47594799 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);
47604800 }
47614801
@@ -5060,6 +5100,11 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 298 unmodified lines
50605100 // AvatarManager has some custom types
50615101 AvatarManager::registerMetaTypes(scriptEngine);
50625102
5103+ if (property(hifi::properties::TEST).isValid()) {
5104+ scriptEngine->registerGlobalObject("Test", TestScriptingInterface::getInstance());
5105+ }
5106+
5107+ scriptEngine->registerGlobalObject("Overlays", &_overlays);
50635108 scriptEngine->registerGlobalObject("Rates", new RatesScriptingInterface(this));
50645109
50655110 // hook our avatar and avatar hash map object into this script engine
@@ -5740,6 +5785,7 @@ void Application::updateDisplayMode() { · 674 unmodified lines
57405785 QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {
57415786 resizeGL();
57425787 });
5788+ QObject::connect(displayPlugin.get(), &DisplayPlugin::resetSensorsRequested, this, &Application::requestReset);
57435789 first = false;
57445790 }
57455791

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