History

Merge branch 'master' into 20280

David Rowe committed 11 years ago

Commit 3c7cdc12 parents 44083dd e73a000209 files · +7380 −4838Browse files

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

Unified · Split

interface/src/Application.cpp+172−170
@@ -38,8 +38,8 @@ · 37 unmodified lines
3838 #include <QObject>
3939 #include <QWheelEvent>
4040 #include <QScreen>
41−#include <QSettings>
4241 #include <QShortcut>
42+#include <QSystemTrayIcon>
4343 #include <QTimer>
4444 #include <QUrl>
4545 #include <QWindow>
@@ -73,13 +73,16 @@ · 27 unmodified lines
7373 #include <PhysicsEngine.h>
7474 #include <ProgramObject.h>
7575 #include <ResourceCache.h>
76+#include <Settings.h>
7677 #include <SoundCache.h>
7778 #include <TextRenderer.h>
7879 #include <UserActivityLogger.h>
7980 #include <UUID.h>
8081
8182 #include "Application.h"
83+#include "Audio.h"
8284 #include "InterfaceVersion.h"
85+#include "LODManager.h"
8386 #include "Menu.h"
8487 #include "ModelUploader.h"
8588 #include "Util.h"
@@ -100,7 +103,6 @@ · 14 unmodified lines
100103 #include "gpu/Batch.h"
101104 #include "gpu/GLBackend.h"
102105
103−
104106 #include "scripting/AccountScriptingInterface.h"
105107 #include "scripting/AudioDeviceScriptingInterface.h"
106108 #include "scripting/ClipboardScriptingInterface.h"
@@ -112,9 +114,16 @@ · 5 unmodified lines
112114 #include "scripting/WindowScriptingInterface.h"
113115 #include "scripting/WebWindowClass.h"
114116
117+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
118+#include "SpeechRecognizer.h"
119+#endif
120+
115121 #include "ui/DataWebDialog.h"
122+#include "ui/DialogsManager.h"
116123 #include "ui/InfoView.h"
124+#include "ui/LoginDialog.h"
117125 #include "ui/Snapshot.h"
126+#include "ui/StandAloneJSConsole.h"
118127 #include "ui/Stats.h"
119128
120129
@@ -137,6 +146,12 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 16 unmodified lines
137146
138147 const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
139148
149+namespace SettingHandles {
150+ const SettingHandle<bool> firstRun("firstRun", true);
151+ const SettingHandle<QString> lastScriptLocation("LastScriptLocation");
152+ const SettingHandle<QString> scriptsLocation("scriptsLocation");
153+}
154+
140155 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
141156 QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
142157
@@ -153,6 +168,16 @@ bool setupEssentials(int& argc, char** argv) { · 10 unmodified lines
153168 listenPort = atoi(portStr);
154169 }
155170
171+ // read the ApplicationInfo.ini file for Name/Version/Domain information
172+ QSettings::setDefaultFormat(QSettings::IniFormat);
173+ QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
174+ // set the associated application properties
175+ applicationInfo.beginGroup("INFO");
176+ QApplication::setApplicationName(applicationInfo.value("name").toString());
177+ QApplication::setApplicationVersion(BUILD_VERSION);
178+ QApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
179+ QApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
180+
156181 DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
157182
158183 // Set dependencies
@@ -173,6 +198,12 @@ bool setupEssentials(int& argc, char** argv) { · 14 unmodified lines
173198 auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>();
174199 auto modelBlender = DependencyManager::set<ModelBlender>();
175200 auto audioToolBox = DependencyManager::set<AudioToolBox>();
201+ auto lodManager = DependencyManager::set<LODManager>();
202+ auto jsConsole = DependencyManager::set<StandAloneJSConsole>();
203+ auto dialogsManager = DependencyManager::set<DialogsManager>();
204+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
205+ auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
206+#endif
176207
177208 return true;
178209 }
@@ -210,8 +241,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 31 unmodified lines
210241 _mousePressed(false),
211242 _enableProcessOctreeThread(true),
212243 _octreeProcessor(),
213− _packetsPerSecond(0),
214− _bytesPerSecond(0),
244+ _inPacketsPerSecond(0),
245+ _outPacketsPerSecond(0),
246+ _inBytesPerSecond(0),
247+ _outBytesPerSecond(0),
215248 _nodeBoundsDisplay(this),
216249 _previousScriptLocation(),
217250 _applicationOverlay(),
@@ -224,35 +257,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 6 unmodified lines
224257 _aboutToQuit(false),
225258 _notifiedPacketVersionMismatchThisDomain(false)
226259 {
227− auto glCanvas = DependencyManager::get<GLCanvas>();
228− auto nodeList = DependencyManager::get<NodeList>();
229− Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
260+ _logger = new FileLogger(this); // After setting organization name in order to get correct directory
261+ qInstallMessageHandler(messageHandler);
230262
263+ QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
264+ _window->setWindowTitle("Interface");
231265
232− // read the ApplicationInfo.ini file for Name/Version/Domain information
233− QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
234−
235− // set the associated application properties
236− applicationInfo.beginGroup("INFO");
237−
238− setApplicationName(applicationInfo.value("name").toString());
239− setApplicationVersion(BUILD_VERSION);
240− setOrganizationName(applicationInfo.value("organizationName").toString());
241− setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
242−
243− _logger = new FileLogger(this); // After setting organization name in order to get correct directory
244−
245− QSettings::setDefaultFormat(QSettings::IniFormat);
266+ Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
267+
268+ auto glCanvas = DependencyManager::get<GLCanvas>();
269+ auto nodeList = DependencyManager::get<NodeList>();
246270
247271 _myAvatar = _avatarManager.getMyAvatar();
248272
249273 _applicationStartupTime = startup_time;
250274
251− QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf");
252− _window->setWindowTitle("Interface");
253−
254− qInstallMessageHandler(messageHandler);
255−
256275 qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
257276
258277 _bookmarks = new Bookmarks(); // Before setting up the menu
@@ -281,6 +300,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 22 unmodified lines
281300 auto audioIO = DependencyManager::get<Audio>();
282301 audioIO->moveToThread(audioThread);
283302 connect(audioThread, &QThread::started, audioIO.data(), &Audio::start);
303+ connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled()));
284304
285305 audioThread->start();
286306
@@ -292,7 +312,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 5 unmodified lines
292312 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle()));
293313 connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails()));
294314 connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived);
295− connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag);
315+ connect(&domainHandler, &DomainHandler::hostnameChanged,
316+ DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
296317
297318 // update our location every 5 seconds in the data-server, assuming that we are authenticated with one
298319 const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000;
@@ -319,7 +340,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 20 unmodified lines
319340
320341 connect(&accountManager, &AccountManager::balanceChanged, this, &Application::updateWindowTitle);
321342
322− connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain);
343+ auto dialogsManager = DependencyManager::get<DialogsManager>();
344+ connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog);
323345 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
324346
325347 // once we have a profile in account manager make sure we generate a new keypair
@@ -340,9 +362,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 14 unmodified lines
340362
341363 connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
342364
343− _settings = new QSettings(this);
344− _numChangedSettings = 0;
345−
346365 #ifdef _WIN32
347366 WSADATA WsaData;
348367 int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData);
@@ -383,7 +402,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 34 unmodified lines
383402
384403 _window->setCentralWidget(glCanvas.data());
385404
386− restoreSizeAndPosition();
405+ _window->restoreGeometry();
387406
388407 _window->setVisible(true);
389408 glCanvas->setFocusPolicy(Qt::StrongFocus);
@@ -417,23 +436,31 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines
417436 connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
418437
419438 // check first run...
420− QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
421− if (firstRunValue.isValid() && firstRunValue.toBool()) {
439+ bool firstRun = SettingHandles::firstRun.get();
440+ if (firstRun) {
422441 qDebug() << "This is a first run...";
423442 // clear the scripts, and set out script to our default scripts
424443 clearScriptsBeforeRunning();
425444 loadScript(DEFAULT_SCRIPTS_JS_URL);
426445
427− QMutexLocker locker(&_settingsMutex);
428− _settings->setValue("firstRun",QVariant(false));
446+ SettingHandles::firstRun.set(false);
429447 } else {
430448 // do this as late as possible so that all required subsystems are initialized
431449 loadScripts();
432450
433− QMutexLocker locker(&_settingsMutex);
434− _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
451+ _previousScriptLocation = SettingHandles::lastScriptLocation.get();
435452 }
436−
453+
454+ loadSettings();
455+ int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
456+ connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
457+ connect(&_settingsThread, SIGNAL(started), &_settingsTimer, SLOT(start));
458+ connect(&_settingsThread, &QThread::finished, &_settingsTimer, &QTimer::deleteLater);
459+ _settingsTimer.moveToThread(&_settingsThread);
460+ _settingsTimer.setSingleShot(false);
461+ _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL);
462+ _settingsThread.start();
463+
437464 _trayIcon->show();
438465
439466 // set the local loopback interface for local sounds from audio scripts
@@ -454,12 +481,12 @@ void Application::aboutToQuit() { · 14 unmodified lines
454481 }
455482
456483 Application::~Application() {
484+ saveSettings();
457485
458486 _entities.getTree()->setSimulation(NULL);
459487 qInstallMessageHandler(NULL);
460488
461− saveSettings();
462− storeSizeAndPosition();
489+ _window->saveGeometry();
463490
464491 int DELAY_TIME = 1000;
465492 UserActivityLogger::getInstance().close(DELAY_TIME);
@@ -496,45 +523,6 @@ Application::~Application() { · 30 unmodified lines
496523 DependencyManager::destroy<GLCanvas>();
497524 }
498525
499−void Application::saveSettings() {
500− Menu::getInstance()->saveSettings();
501− _rearMirrorTools->saveSettings(_settings);
502−
503− _settings->sync();
504− _numChangedSettings = 0;
505−}
506−
507−
508−void Application::restoreSizeAndPosition() {
509− QRect available = desktop()->availableGeometry();
510−
511− QMutexLocker locker(&_settingsMutex);
512− _settings->beginGroup("Window");
513−
514− int x = (int)loadSetting(_settings, "x", 0);
515− int y = (int)loadSetting(_settings, "y", 0);
516− _window->move(x, y);
517−
518− int width = (int)loadSetting(_settings, "width", available.width());
519− int height = (int)loadSetting(_settings, "height", available.height());
520− _window->resize(width, height);
521−
522− _settings->endGroup();
523−}
524−
525−void Application::storeSizeAndPosition() {
526− QMutexLocker locker(&_settingsMutex);
527− _settings->beginGroup("Window");
528−
529− _settings->setValue("width", _window->rect().width());
530− _settings->setValue("height", _window->rect().height());
531−
532− _settings->setValue("x", _window->pos().x());
533− _settings->setValue("y", _window->pos().y());
534−
535− _settings->endGroup();
536−}
537−
538526 void Application::initializeGL() {
539527 qDebug( "Created Display Window.");
540528
@@ -657,7 +645,7 @@ void Application::paintGL() { · 116 unmodified lines
657645 _myCamera.update(1.0f / _fps);
658646 }
659647
660− if (Menu::getInstance()->getShadowsEnabled()) {
648+ if (getShadowsEnabled()) {
661649 updateShadowMap();
662650 }
663651
@@ -713,6 +701,24 @@ void Application::paintGL() { · 49 unmodified lines
713701 _frameCount++;
714702 }
715703
704+void Application::runTests() {
705+ runTimingTests();
706+}
707+
708+void Application::audioMuteToggled() {
709+ QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio);
710+ Q_CHECK_PTR(muteAction);
711+ muteAction->setChecked(DependencyManager::get<Audio>()->isMuted());
712+}
713+
714+void Application::aboutApp() {
715+ InfoView::forcedShow(INFO_HELP_PATH);
716+}
717+
718+void Application::showEditEntitiesHelp() {
719+ InfoView::forcedShow(INFO_EDIT_ENTITIES_PATH);
720+}
721+
716722 void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
717723 if (OculusManager::isConnected()) {
718724 OculusManager::configureCamera(camera, width, height);
@@ -720,7 +726,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 1 unmodified line
720726 TV3DManager::configureCamera(camera, width, height);
721727 } else {
722728 camera.setAspectRatio((float)width / height);
723− camera.setFieldOfView(Menu::getInstance()->getFieldOfView());
729+ camera.setFieldOfView(_viewFrustum.getFieldOfView());
724730 }
725731 }
726732
@@ -773,19 +779,20 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 46 unmodified lines
773779 int nReceivingNodes = DependencyManager::get<NodeList>()->broadcastToNodes(packet, NodeSet() << type);
774780
775781 // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
776− BandwidthMeter::ChannelIndex channel;
782+ double bandwidth_amount = nReceivingNodes * packet.size();
777783 switch (type) {
778784 case NodeType::Agent:
779785 case NodeType::AvatarMixer:
780− channel = BandwidthMeter::AVATARS;
786+ _bandwidthRecorder.avatarsChannel->output.updateValue(bandwidth_amount);
787+ _bandwidthRecorder.totalChannel->input.updateValue(bandwidth_amount);
781788 break;
782789 case NodeType::EntityServer:
783− channel = BandwidthMeter::OCTREE;
790+ _bandwidthRecorder.octreeChannel->output.updateValue(bandwidth_amount);
791+ _bandwidthRecorder.totalChannel->output.updateValue(bandwidth_amount);
784792 break;
785793 default:
786794 continue;
787795 }
788− _bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * packet.size());
789796 }
790797 }
791798
@@ -1260,7 +1267,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 468 unmodified lines
12601267 int horizontalOffset = MIRROR_VIEW_WIDTH;
12611268 Stats::getInstance()->checkClick(getMouseX(), getMouseY(),
12621269 getMouseDragStartedX(), getMouseDragStartedY(), horizontalOffset);
1263− checkBandwidthMeterClick();
12641270 }
12651271
12661272 // fire an action end event
@@ -1388,8 +1394,10 @@ void Application::timer() { · 121 unmodified lines
13881394
13891395 _fps = (float)_frameCount / diffTime;
13901396
1391− _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / diffTime;
1392− _bytesPerSecond = (float) _datagramProcessor.getByteCount() / diffTime;
1397+ _inPacketsPerSecond = (float) _datagramProcessor.getInPacketCount() / diffTime;
1398+ _outPacketsPerSecond = (float) _datagramProcessor.getOutPacketCount() / diffTime;
1399+ _inBytesPerSecond = (float) _datagramProcessor.getInByteCount() / diffTime;
1400+ _outBytesPerSecond = (float) _datagramProcessor.getOutByteCount() / diffTime;
13931401 _frameCount = 0;
13941402
13951403 _datagramProcessor.resetCounters();
@@ -1443,31 +1451,10 @@ void Application::idle() { · 47 unmodified lines
14431451
14441452 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
14451453 idleTimer->start(2);
1446−
1447− if (_numChangedSettings > 0) {
1448− saveSettings();
1449− }
14501454 }
14511455 }
14521456 }
14531457
1454−void Application::checkBandwidthMeterClick() {
1455− // ... to be called upon button release
1456− auto glCanvas = DependencyManager::get<GLCanvas>();
1457− if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
1458− Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
1459− Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) &&
1460− glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(),
1461− getMouseY() - getMouseDragStartedY())))
1462− <= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH
1463− && _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), glCanvas->width(), glCanvas->height())) {
1464−
1465− // The bandwidth meter is visible, the click didn't get dragged too far and
1466− // we actually hit the bandwidth meter
1467− Menu::getInstance()->bandwidthDetails();
1468− }
1469−}
1470−
14711458 void Application::setFullscreen(bool fullscreen) {
14721459 if (Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen) != fullscreen) {
14731460 Menu::getInstance()->getActionForOption(MenuOption::Fullscreen)->setChecked(fullscreen);
@@ -1602,6 +1589,20 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa · 128 unmodified lines
16021589 return true;
16031590 }
16041591
1592+void Application::loadSettings() {
1593+ DependencyManager::get<Audio>()->loadSettings();
1594+ DependencyManager::get<LODManager>()->loadSettings();
1595+ Menu::getInstance()->loadSettings();
1596+ _myAvatar->loadData();
1597+}
1598+
1599+void Application::saveSettings() {
1600+ DependencyManager::get<Audio>()->saveSettings();
1601+ DependencyManager::get<LODManager>()->saveSettings();
1602+ Menu::getInstance()->saveSettings();
1603+ _myAvatar->saveData();
1604+}
1605+
16051606 bool Application::importEntities(const QString& filename) {
16061607 _entityClipboard.eraseAllOctreeElements();
16071608 bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
@@ -1652,8 +1653,6 @@ void Application::init() { · 44 unmodified lines
16521653
16531654 _timerStart.start();
16541655 _lastTimeUpdated.start();
1655−
1656− Menu::getInstance()->loadSettings();
16571656
16581657 // when --url in command line, teleport to location
16591658 const QString HIFI_URL_COMMAND_LINE_KEY = "--url";
@@ -1671,11 +1670,11 @@ void Application::init() { · 11 unmodified lines
16711670 if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseEnabled)) {
16721671 // on OS X we only setup sixense if the user wants it on - this allows running without the hid_init crash
16731672 // if hydra support is temporarily not required
1674− Menu::getInstance()->toggleSixense(true);
1673+ SixenseManager::getInstance().toggleSixense(true);
16751674 }
16761675 #else
16771676 // setup sixense
1678− Menu::getInstance()->toggleSixense(true);
1677+ SixenseManager::getInstance().toggleSixense(true);
16791678 #endif
16801679
16811680 // initialize our face trackers after loading the menu settings
@@ -1714,16 +1713,13 @@ void Application::init() { · 32 unmodified lines
17141713 _metavoxels.init();
17151714
17161715 auto glCanvas = DependencyManager::get<GLCanvas>();
1717− _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings);
1716+ _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect);
17181717
17191718 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
17201719 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
17211720 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
17221721 connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
17231722
1724− // save settings when avatar changes
1725− connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
1726−
17271723 // make sure our texture cache knows about window size changes
17281724 DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data());
17291725
@@ -1765,9 +1761,9 @@ void Application::updateLOD() { · 35 unmodified lines
17651761 PerformanceTimer perfTimer("LOD");
17661762 // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode
17671763 if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) {
1768− Menu::getInstance()->autoAdjustLOD(_fps);
1764+ DependencyManager::get<LODManager>()->autoAdjustLOD(_fps);
17691765 } else {
1770− Menu::getInstance()->resetLODAdjust();
1766+ DependencyManager::get<LODManager>()->resetLODAdjust();
17711767 }
17721768 }
17731769
@@ -1884,7 +1880,7 @@ void Application::updateMyAvatarLookAtPosition() { · 110 unmodified lines
18841880 // deflect using Faceshift gaze data
18851881 glm::vec3 origin = _myAvatar->getHead()->getEyePosition();
18861882 float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f;
1887− float deflection = Menu::getInstance()->getFaceshiftEyeDeflection();
1883+ float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection();
18881884 if (isLookingAtSomeone) {
18891885 deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT;
18901886 }
@@ -1956,14 +1952,15 @@ void Application::updateDialogs(float deltaTime) { · 65 unmodified lines
19561952 PerformanceTimer perfTimer("updateDialogs");
19571953 bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
19581954 PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
1959−
1955+ auto dialogsManager = DependencyManager::get<DialogsManager>();
1956+
19601957 // Update bandwidth dialog, if any
1961− BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog();
1958+ BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog();
19621959 if (bandwidthDialog) {
19631960 bandwidthDialog->update();
19641961 }
19651962
1966− OctreeStatsDialog* octreeStatsDialog = Menu::getInstance()->getOctreeStatsDialog();
1963+ QPointer<OctreeStatsDialog> octreeStatsDialog = dialogsManager->getOctreeStatsDialog();
19671964 if (octreeStatsDialog) {
19681965 octreeStatsDialog->update();
19691966 }
@@ -2234,8 +2231,9 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 264 unmodified lines
22342231 _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip());
22352232 _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip());
22362233 _octreeQuery.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition());
2237− _octreeQuery.setOctreeSizeScale(Menu::getInstance()->getOctreeSizeScale());
2238− _octreeQuery.setBoundaryLevelAdjust(Menu::getInstance()->getBoundaryLevelAdjust());
2234+ auto lodManager = DependencyManager::get<LODManager>();
2235+ _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale());
2236+ _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust());
22392237
22402238 unsigned char queryPacket[MAX_PACKET_SIZE];
22412239
@@ -2287,7 +2285,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 45 unmodified lines
22872285 int perServerPPS = 0;
22882286 const int SMALL_BUDGET = 10;
22892287 int perUnknownServer = SMALL_BUDGET;
2290− int totalPPS = Menu::getInstance()->getMaxOctreePacketsPerSecond();
2288+ int totalPPS = _octreeQuery.getMaxOctreePacketsPerSecond();
22912289
22922290 // determine PPS based on number of servers
22932291 if (inViewServers >= 1) {
@@ -2390,7 +2388,8 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 96 unmodified lines
23902388 nodeList->writeUnverifiedDatagram(reinterpret_cast<const char*>(queryPacket), packetLength, node);
23912389
23922390 // Feed number of bytes to corresponding channel of the bandwidth meter
2393− _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(packetLength);
2391+ _bandwidthRecorder.octreeChannel->output.updateValue(packetLength);
2392+ _bandwidthRecorder.totalChannel->output.updateValue(packetLength);
23942393 }
23952394 });
23962395 }
@@ -2408,7 +2407,7 @@ QRect Application::getDesirableApplicationGeometry() { · 11 unmodified lines
24082407
24092408 // If our parent window is on the HMD, then don't use it's geometry, instead use
24102409 // the "main screen" geometry.
2411− HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog();
2410+ HMDToolsDialog* hmdTools = DependencyManager::get<DialogsManager>()->getHMDToolsDialog();
24122411 if (hmdTools && hmdTools->hasHMDScreen()) {
24132412 QScreen* hmdScreen = hmdTools->getHMDScreen();
24142413 QWindow* appWindow = getWindow()->windowHandle();
@@ -2633,15 +2632,15 @@ void Application::setupWorldLight() { · 218 unmodified lines
26332632 }
26342633
26352634 bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
2636− return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera);
2635+ return DependencyManager::get<LODManager>()->shouldRenderMesh(largestDimension, distanceToCamera);
26372636 }
26382637
26392638 float Application::getSizeScale() const {
2640− return Menu::getInstance()->getOctreeSizeScale();
2639+ return DependencyManager::get<LODManager>()->getOctreeSizeScale();
26412640 }
26422641
26432642 int Application::getBoundaryLevelAdjust() const {
2644− return Menu::getInstance()->getBoundaryLevelAdjust();
2643+ return DependencyManager::get<LODManager>()->getBoundaryLevelAdjust();
26452644 }
26462645
26472646 PickRay Application::computePickRay(float x, float y) {
@@ -2791,8 +2790,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 143 unmodified lines
27912790 if (!selfAvatarOnly) {
27922791 // draw a red sphere
27932792 float originSphereRadius = 0.05f;
2794− glColor3f(1,0,0);
2795− DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15);
2793+ DependencyManager::get<GeometryCache>()->renderSphere(originSphereRadius, 15, 15, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));
27962794
27972795 // also, metavoxels
27982796 if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) {
@@ -2937,8 +2935,10 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 138 unmodified lines
29372935 }
29382936 }
29392937
2940−bool Application::getShadowsEnabled() {
2941− return Menu::getInstance()->getShadowsEnabled();
2938+bool Application::getShadowsEnabled() {
2939+ Menu* menubar = Menu::getInstance();
2940+ return menubar->isOptionChecked(MenuOption::SimpleShadows) ||
2941+ menubar->isOptionChecked(MenuOption::CascadedShadows);
29422942 }
29432943
29442944 bool Application::getCascadeShadowsEnabled() {
@@ -2983,7 +2983,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines
29832983 _mirrorCamera.setPosition(_myAvatar->getPosition() +
29842984 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
29852985
2986− } else if (_rearMirrorTools->getZoomLevel() == BODY) {
2986+ } else if (SettingHandles::rearViewZoomLevel.get() == BODY) {
29872987 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
29882988 _mirrorCamera.setPosition(_myAvatar->getChestPosition() +
29892989 _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
@@ -3377,48 +3377,49 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin · 387 unmodified lines
33773377 }
33783378
33793379 void Application::packetSent(quint64 length) {
3380− _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length);
3380+ _bandwidthRecorder.octreeChannel->output.updateValue(length);
3381+ _bandwidthRecorder.totalChannel->output.updateValue(length);
33813382 }
33823383
3384+const QString SETTINGS_KEY = "Settings";
3385+
33833386 void Application::loadScripts() {
33843387 // loads all saved scripts
3385− int size = lockSettings()->beginReadArray("Settings");
3386− unlockSettings();
3388+ Settings settings;
3389+ int size = settings.beginReadArray(SETTINGS_KEY);
33873390 for (int i = 0; i < size; ++i){
3388− lockSettings()->setArrayIndex(i);
3389− QString string = _settings->value("script").toString();
3390− unlockSettings();
3391+ settings.setArrayIndex(i);
3392+ QString string = settings.value("script").toString();
33913393 if (!string.isEmpty()) {
33923394 loadScript(string);
33933395 }
33943396 }
3395−
3396− QMutexLocker locker(&_settingsMutex);
3397− _settings->endArray();
3397+ settings.endArray();
33983398 }
33993399
34003400 void Application::clearScriptsBeforeRunning() {
3401− // clears all scripts from the settings
3402− QMutexLocker locker(&_settingsMutex);
3403− _settings->remove("Settings");
3401+ // clears all scripts from the settingsSettings settings;
3402+ Settings settings;
3403+ settings.beginWriteArray(SETTINGS_KEY);
3404+ settings.remove("");
34043405 }
34053406
34063407 void Application::saveScripts() {
34073408 // Saves all currently running user-loaded scripts
3408− QMutexLocker locker(&_settingsMutex);
3409− _settings->beginWriteArray("Settings");
3410−
3409+ Settings settings;
3410+ settings.beginWriteArray(SETTINGS_KEY);
3411+ settings.remove("");
3412+
34113413 QStringList runningScripts = getRunningScripts();
34123414 int i = 0;
3413− for (QStringList::const_iterator it = runningScripts.begin(); it != runningScripts.end(); it += 1) {
3415+ for (auto it = runningScripts.begin(); it != runningScripts.end(); ++it) {
34143416 if (getScriptEngine(*it)->isUserLoaded()) {
3415− _settings->setArrayIndex(i);
3416− _settings->setValue("script", *it);
3417− i += 1;
3417+ settings.setArrayIndex(i);
3418+ settings.setValue("script", *it);
3419+ ++i;
34183420 }
34193421 }
3420−
3421− _settings->endArray();
3422+ settings.endArray();
34223423 }
34233424
34243425 QScriptValue joystickToScriptValue(QScriptEngine *engine, Joystick* const &in) {
@@ -3445,7 +3446,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 20 unmodified lines
34453446 scriptEngine->registerGlobalObject("Camera", &_myCamera);
34463447
34473448 #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
3448− scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer());
3449+ scriptEngine->registerGlobalObject("SpeechRecognizer", DependencyManager::get<SpeechRecognizer>().data());
34493450 #endif
34503451
34513452 ClipboardScriptingInterface* clipboardScriptable = new ClipboardScriptingInterface();
@@ -3545,7 +3546,6 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 93 unmodified lines
35453546 if (activateMainWindow && !loadScriptFromEditor) {
35463547 _window->activateWindow();
35473548 }
3548− bumpSettings();
35493549
35503550 return scriptEngine;
35513551 }
@@ -3573,7 +3573,6 @@ void Application::scriptFinished(const QString& scriptName) { · 21 unmodified lines
35733573 _scriptEnginesHash.erase(it);
35743574 _runningScriptsWidget->scriptStopped(scriptName);
35753575 _runningScriptsWidget->setRunningScripts(getRunningScripts());
3576− bumpSettings();
35773576 }
35783577 }
35793578
@@ -3669,7 +3668,6 @@ void Application::openUrl(const QUrl& url) { · 89 unmodified lines
36693668 }
36703669
36713670 void Application::updateMyAvatarTransform() {
3672− bumpSettings();
36733671 const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters
36743672 glm::vec3 avatarPosition = _myAvatar->getPosition();
36753673 glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset();
@@ -3686,7 +3684,6 @@ void Application::updateMyAvatarTransform() { · 10 unmodified lines
36863684 }
36873685
36883686 void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) {
3689−
36903687 // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed
36913688 const QString VOXEL_SETTINGS_KEY = "voxels";
36923689 const QString PER_VOXEL_COST_KEY = "per-voxel-credits";
@@ -3729,9 +3726,7 @@ QString Application::getPreviousScriptLocation() { · 36 unmodified lines
37293726
37303727 void Application::setPreviousScriptLocation(const QString& previousScriptLocation) {
37313728 _previousScriptLocation = previousScriptLocation;
3732− QMutexLocker locker(&_settingsMutex);
3733− _settings->setValue("LastScriptLocation", _previousScriptLocation);
3734− bumpSettings();
3729+ SettingHandles::lastScriptLocation.set(_previousScriptLocation);
37353730 }
37363731
37373732 void Application::loadDialog() {
@@ -3747,7 +3742,6 @@ void Application::loadDialog() { · 9 unmodified lines
37473742 }
37483743
37493744 void Application::loadScriptURLDialog() {
3750−
37513745 QInputDialog scriptURLDialog(Application::getInstance()->getWindow());
37523746 scriptURLDialog.setWindowTitle("Open and Run Script URL");
37533747 scriptURLDialog.setLabelText("Script:");
@@ -3765,11 +3759,16 @@ void Application::loadScriptURLDialog() { · 11 unmodified lines
37653759 }
37663760 loadScript(newScript);
37673761 }
3768−
3769− sendFakeEnterEvent();
37703762 }
37713763
3764+QString Application::getScriptsLocation() const {
3765+ return SettingHandles::scriptsLocation.get();
3766+}
37723767
3768+void Application::setScriptsLocation(const QString& scriptsLocation) {
3769+ SettingHandles::scriptsLocation.set(scriptsLocation);
3770+ emit scriptLocationChanged(scriptsLocation);
3771+}
37733772
37743773 void Application::toggleLogDialog() {
37753774 if (! _logDialog) {
@@ -3789,6 +3788,7 @@ void Application::initAvatarAndViewFrustum() { · 13 unmodified lines
37893788
37903789 void Application::checkVersion() {
37913790 QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL)));
3791+ latestVersionRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
37923792 latestVersionRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
37933793 QNetworkReply* reply = NetworkAccessManager::getInstance().get(latestVersionRequest);
37943794 connect(reply, SIGNAL(finished()), SLOT(parseVersionXml()));
@@ -3871,7 +3871,8 @@ void Application::takeSnapshot() { · 76 unmodified lines
38713871 _snapshotShareDialog->show();
38723872 }
38733873
3874−void Application::setVSyncEnabled(bool vsyncOn) {
3874+void Application::setVSyncEnabled() {
3875+ bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn);
38753876 #if defined(Q_OS_WIN)
38763877 if (wglewGetExtension("WGL_EXT_swap_control")) {
38773878 wglSwapIntervalEXT(vsyncOn);
@@ -3895,6 +3896,7 @@ void Application::setVSyncEnabled(bool vsyncOn) { · 17 unmodified lines
38953896 #else
38963897 qDebug("V-Sync is FORCED ON on this system\n");
38973898 #endif
3899+ vsyncOn = true; // Turns off unused variable warning
38983900 }
38993901
39003902 bool Application::isVSyncOn() const {

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