Showing the changes to interface/src/Application.cpp (1 of 114 files). Show all
Unified · Split
| @@ -38,8 +38,8 @@ · 37 unmodified lines | |||
| 38 | #include <QObject> | 38 | #include <QObject> |
| 39 | #include <QWheelEvent> | 39 | #include <QWheelEvent> |
| 40 | #include <QScreen> | 40 | #include <QScreen> |
| 41 | #include <QSettings> | ||
| 42 | #include <QShortcut> | 41 | #include <QShortcut> |
| 42 | #include <QSystemTrayIcon> | ||
| 43 | #include <QTimer> | 43 | #include <QTimer> |
| 44 | #include <QUrl> | 44 | #include <QUrl> |
| 45 | #include <QWindow> | 45 | #include <QWindow> |
| @@ -73,13 +73,16 @@ · 27 unmodified lines | |||
| 73 | #include <PhysicsEngine.h> | 73 | #include <PhysicsEngine.h> |
| 74 | #include <ProgramObject.h> | 74 | #include <ProgramObject.h> |
| 75 | #include <ResourceCache.h> | 75 | #include <ResourceCache.h> |
| 76 | #include <Settings.h> | ||
| 76 | #include <SoundCache.h> | 77 | #include <SoundCache.h> |
| 77 | #include <TextRenderer.h> | 78 | #include <TextRenderer.h> |
| 78 | #include <UserActivityLogger.h> | 79 | #include <UserActivityLogger.h> |
| 79 | #include <UUID.h> | 80 | #include <UUID.h> |
| 80 | 81 | ||
| 81 | #include "Application.h" | 82 | #include "Application.h" |
| 83 | #include "Audio.h" | ||
| 82 | #include "InterfaceVersion.h" | 84 | #include "InterfaceVersion.h" |
| 85 | #include "LODManager.h" | ||
| 83 | #include "Menu.h" | 86 | #include "Menu.h" |
| 84 | #include "ModelUploader.h" | 87 | #include "ModelUploader.h" |
| 85 | #include "Util.h" | 88 | #include "Util.h" |
| @@ -100,7 +103,6 @@ · 14 unmodified lines | |||
| 100 | #include "gpu/Batch.h" | 103 | #include "gpu/Batch.h" |
| 101 | #include "gpu/GLBackend.h" | 104 | #include "gpu/GLBackend.h" |
| 102 | 105 | ||
| 103 | |||
| 104 | #include "scripting/AccountScriptingInterface.h" | 106 | #include "scripting/AccountScriptingInterface.h" |
| 105 | #include "scripting/AudioDeviceScriptingInterface.h" | 107 | #include "scripting/AudioDeviceScriptingInterface.h" |
| 106 | #include "scripting/ClipboardScriptingInterface.h" | 108 | #include "scripting/ClipboardScriptingInterface.h" |
| @@ -113,9 +115,16 @@ · 6 unmodified lines | |||
| 113 | #include "scripting/WindowScriptingInterface.h" | 115 | #include "scripting/WindowScriptingInterface.h" |
| 114 | #include "scripting/WebWindowClass.h" | 116 | #include "scripting/WebWindowClass.h" |
| 115 | 117 | ||
| 118 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) | ||
| 119 | #include "SpeechRecognizer.h" | ||
| 120 | #endif | ||
| 121 | |||
| 116 | #include "ui/DataWebDialog.h" | 122 | #include "ui/DataWebDialog.h" |
| 123 | #include "ui/DialogsManager.h" | ||
| 117 | #include "ui/InfoView.h" | 124 | #include "ui/InfoView.h" |
| 125 | #include "ui/LoginDialog.h" | ||
| 118 | #include "ui/Snapshot.h" | 126 | #include "ui/Snapshot.h" |
| 127 | #include "ui/StandAloneJSConsole.h" | ||
| 119 | #include "ui/Stats.h" | 128 | #include "ui/Stats.h" |
| 120 | 129 | ||
| 121 | 130 | ||
| @@ -138,6 +147,12 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D · 16 unmodified lines | |||
| 138 | 147 | ||
| 139 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; | 148 | const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js"; |
| 140 | 149 | ||
| 150 | namespace SettingHandles { | ||
| 151 | const SettingHandle<bool> firstRun("firstRun", true); | ||
| 152 | const SettingHandle<QString> lastScriptLocation("LastScriptLocation"); | ||
| 153 | const SettingHandle<QString> scriptsLocation("scriptsLocation"); | ||
| 154 | } | ||
| 155 | |||
| 141 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { | 156 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { |
| 142 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); | 157 | QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message); |
| 143 | 158 | ||
| @@ -154,6 +169,16 @@ bool setupEssentials(int& argc, char** argv) { · 10 unmodified lines | |||
| 154 | listenPort = atoi(portStr); | 169 | listenPort = atoi(portStr); |
| 155 | } | 170 | } |
| 156 | 171 | ||
| 172 | // read the ApplicationInfo.ini file for Name/Version/Domain information | ||
| 173 | QSettings::setDefaultFormat(QSettings::IniFormat); | ||
| 174 | QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | ||
| 175 | // set the associated application properties | ||
| 176 | applicationInfo.beginGroup("INFO"); | ||
| 177 | QApplication::setApplicationName(applicationInfo.value("name").toString()); | ||
| 178 | QApplication::setApplicationVersion(BUILD_VERSION); | ||
| 179 | QApplication::setOrganizationName(applicationInfo.value("organizationName").toString()); | ||
| 180 | QApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); | ||
| 181 | |||
| 157 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); | 182 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); |
| 158 | 183 | ||
| 159 | // Set dependencies | 184 | // Set dependencies |
| @@ -174,6 +199,12 @@ bool setupEssentials(int& argc, char** argv) { · 14 unmodified lines | |||
| 174 | auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>(); | 199 | auto ddeFaceTracker = DependencyManager::set<DdeFaceTracker>(); |
| 175 | auto modelBlender = DependencyManager::set<ModelBlender>(); | 200 | auto modelBlender = DependencyManager::set<ModelBlender>(); |
| 176 | auto audioToolBox = DependencyManager::set<AudioToolBox>(); | 201 | auto audioToolBox = DependencyManager::set<AudioToolBox>(); |
| 202 | auto lodManager = DependencyManager::set<LODManager>(); | ||
| 203 | auto jsConsole = DependencyManager::set<StandAloneJSConsole>(); | ||
| 204 | auto dialogsManager = DependencyManager::set<DialogsManager>(); | ||
| 205 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) | ||
| 206 | auto speechRecognizer = DependencyManager::set<SpeechRecognizer>(); | ||
| 207 | #endif | ||
| 177 | 208 | ||
| 178 | return true; | 209 | return true; |
| 179 | } | 210 | } |
| @@ -224,35 +255,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 44 unmodified lines | |||
| 224 | _isVSyncOn(true), | 255 | _isVSyncOn(true), |
| 225 | _aboutToQuit(false) | 256 | _aboutToQuit(false) |
| 226 | { | 257 | { |
| 227 | auto glCanvas = DependencyManager::get<GLCanvas>(); | 258 | _logger = new FileLogger(this); // After setting organization name in order to get correct directory |
| 228 | auto nodeList = DependencyManager::get<NodeList>(); | 259 | qInstallMessageHandler(messageHandler); |
| 229 | Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us | ||
| 230 | 260 | ||
| 261 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); | ||
| 262 | _window->setWindowTitle("Interface"); | ||
| 231 | 263 | ||
| 232 | // read the ApplicationInfo.ini file for Name/Version/Domain information | 264 | Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us |
| 233 | QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); | 265 | |
| 234 | 266 | auto glCanvas = DependencyManager::get<GLCanvas>(); | |
| 235 | // set the associated application properties | 267 | auto nodeList = DependencyManager::get<NodeList>(); |
| 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); | ||
| 246 | 268 | ||
| 247 | _myAvatar = _avatarManager.getMyAvatar(); | 269 | _myAvatar = _avatarManager.getMyAvatar(); |
| 248 | 270 | ||
| 249 | _applicationStartupTime = startup_time; | 271 | _applicationStartupTime = startup_time; |
| 250 | 272 | ||
| 251 | QFontDatabase::addApplicationFont(PathUtils::resourcesPath() + "styles/Inconsolata.otf"); | ||
| 252 | _window->setWindowTitle("Interface"); | ||
| 253 | |||
| 254 | qInstallMessageHandler(messageHandler); | ||
| 255 | |||
| 256 | qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); | 273 | qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); |
| 257 | 274 | ||
| 258 | _bookmarks = new Bookmarks(); // Before setting up the menu | 275 | _bookmarks = new Bookmarks(); // Before setting up the menu |
| @@ -281,6 +298,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 22 unmodified lines | |||
| 281 | auto audioIO = DependencyManager::get<Audio>(); | 298 | auto audioIO = DependencyManager::get<Audio>(); |
| 282 | audioIO->moveToThread(audioThread); | 299 | audioIO->moveToThread(audioThread); |
| 283 | connect(audioThread, &QThread::started, audioIO.data(), &Audio::start); | 300 | connect(audioThread, &QThread::started, audioIO.data(), &Audio::start); |
| 301 | connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled())); | ||
| 284 | 302 | ||
| 285 | audioThread->start(); | 303 | audioThread->start(); |
| 286 | 304 | ||
| @@ -292,7 +310,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 5 unmodified lines | |||
| 292 | connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle())); | 310 | connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(updateWindowTitle())); |
| 293 | connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails())); | 311 | connect(&domainHandler, SIGNAL(disconnectedFromDomain()), SLOT(clearDomainOctreeDetails())); |
| 294 | connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived); | 312 | connect(&domainHandler, &DomainHandler::settingsReceived, this, &Application::domainSettingsReceived); |
| 295 | connect(&domainHandler, &DomainHandler::hostnameChanged, Menu::getInstance(), &Menu::clearLoginDialogDisplayedFlag); | 313 | connect(&domainHandler, &DomainHandler::hostnameChanged, |
| 314 | DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress); | ||
| 296 | 315 | ||
| 297 | // update our location every 5 seconds in the data-server, assuming that we are authenticated with one | 316 | // update our location every 5 seconds in the data-server, assuming that we are authenticated with one |
| 298 | const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000; | 317 | const qint64 DATA_SERVER_LOCATION_CHANGE_UPDATE_MSECS = 5 * 1000; |
| @@ -318,7 +337,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 19 unmodified lines | |||
| 318 | 337 | ||
| 319 | connect(&accountManager, &AccountManager::balanceChanged, this, &Application::updateWindowTitle); | 338 | connect(&accountManager, &AccountManager::balanceChanged, this, &Application::updateWindowTitle); |
| 320 | 339 | ||
| 321 | connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain); | 340 | auto dialogsManager = DependencyManager::get<DialogsManager>(); |
| 341 | connect(&accountManager, &AccountManager::authRequired, dialogsManager.data(), &DialogsManager::showLoginDialog); | ||
| 322 | connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); | 342 | connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); |
| 323 | 343 | ||
| 324 | // once we have a profile in account manager make sure we generate a new keypair | 344 | // once we have a profile in account manager make sure we generate a new keypair |
| @@ -339,9 +359,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 14 unmodified lines | |||
| 339 | 359 | ||
| 340 | connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle); | 360 | connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle); |
| 341 | 361 | ||
| 342 | _settings = new QSettings(this); | ||
| 343 | _numChangedSettings = 0; | ||
| 344 | |||
| 345 | #ifdef _WIN32 | 362 | #ifdef _WIN32 |
| 346 | WSADATA WsaData; | 363 | WSADATA WsaData; |
| 347 | int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData); | 364 | int wsaresult = WSAStartup(MAKEWORD(2,2), &WsaData); |
| @@ -382,7 +399,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 34 unmodified lines | |||
| 382 | 399 | ||
| 383 | _window->setCentralWidget(glCanvas.data()); | 400 | _window->setCentralWidget(glCanvas.data()); |
| 384 | 401 | ||
| 385 | restoreSizeAndPosition(); | 402 | _window->restoreGeometry(); |
| 386 | 403 | ||
| 387 | _window->setVisible(true); | 404 | _window->setVisible(true); |
| 388 | glCanvas->setFocusPolicy(Qt::StrongFocus); | 405 | glCanvas->setFocusPolicy(Qt::StrongFocus); |
| @@ -416,23 +433,31 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 27 unmodified lines | |||
| 416 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); | 433 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); |
| 417 | 434 | ||
| 418 | // check first run... | 435 | // check first run... |
| 419 | QVariant firstRunValue = _settings->value("firstRun",QVariant(true)); | 436 | bool firstRun = SettingHandles::firstRun.get(); |
| 420 | if (firstRunValue.isValid() && firstRunValue.toBool()) { | 437 | if (firstRun) { |
| 421 | qDebug() << "This is a first run..."; | 438 | qDebug() << "This is a first run..."; |
| 422 | // clear the scripts, and set out script to our default scripts | 439 | // clear the scripts, and set out script to our default scripts |
| 423 | clearScriptsBeforeRunning(); | 440 | clearScriptsBeforeRunning(); |
| 424 | loadScript(DEFAULT_SCRIPTS_JS_URL); | 441 | loadScript(DEFAULT_SCRIPTS_JS_URL); |
| 425 | 442 | ||
| 426 | QMutexLocker locker(&_settingsMutex); | 443 | SettingHandles::firstRun.set(false); |
| 427 | _settings->setValue("firstRun",QVariant(false)); | ||
| 428 | } else { | 444 | } else { |
| 429 | // do this as late as possible so that all required subsystems are initialized | 445 | // do this as late as possible so that all required subsystems are initialized |
| 430 | loadScripts(); | 446 | loadScripts(); |
| 431 | 447 | ||
| 432 | QMutexLocker locker(&_settingsMutex); | 448 | _previousScriptLocation = SettingHandles::lastScriptLocation.get(); |
| 433 | _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); | ||
| 434 | } | 449 | } |
| 435 | 450 | ||
| 451 | loadSettings(); | ||
| 452 | int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now | ||
| 453 | connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings); | ||
| 454 | connect(&_settingsThread, SIGNAL(started), &_settingsTimer, SLOT(start)); | ||
| 455 | connect(&_settingsThread, &QThread::finished, &_settingsTimer, &QTimer::deleteLater); | ||
| 456 | _settingsTimer.moveToThread(&_settingsThread); | ||
| 457 | _settingsTimer.setSingleShot(false); | ||
| 458 | _settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL); | ||
| 459 | _settingsThread.start(); | ||
| 460 | |||
| 436 | _trayIcon->show(); | 461 | _trayIcon->show(); |
| 437 | 462 | ||
| 438 | // set the local loopback interface for local sounds from audio scripts | 463 | // set the local loopback interface for local sounds from audio scripts |
| @@ -453,12 +478,12 @@ void Application::aboutToQuit() { · 14 unmodified lines | |||
| 453 | } | 478 | } |
| 454 | 479 | ||
| 455 | Application::~Application() { | 480 | Application::~Application() { |
| 481 | saveSettings(); | ||
| 456 | 482 | ||
| 457 | _entities.getTree()->setSimulation(NULL); | 483 | _entities.getTree()->setSimulation(NULL); |
| 458 | qInstallMessageHandler(NULL); | 484 | qInstallMessageHandler(NULL); |
| 459 | 485 | ||
| 460 | saveSettings(); | 486 | _window->saveGeometry(); |
| 461 | storeSizeAndPosition(); | ||
| 462 | 487 | ||
| 463 | int DELAY_TIME = 1000; | 488 | int DELAY_TIME = 1000; |
| 464 | UserActivityLogger::getInstance().close(DELAY_TIME); | 489 | UserActivityLogger::getInstance().close(DELAY_TIME); |
| @@ -495,45 +520,6 @@ Application::~Application() { · 30 unmodified lines | |||
| 495 | DependencyManager::destroy<GLCanvas>(); | 520 | DependencyManager::destroy<GLCanvas>(); |
| 496 | } | 521 | } |
| 497 | 522 | ||
| 498 | void Application::saveSettings() { | ||
| 499 | Menu::getInstance()->saveSettings(); | ||
| 500 | _rearMirrorTools->saveSettings(_settings); | ||
| 501 | |||
| 502 | _settings->sync(); | ||
| 503 | _numChangedSettings = 0; | ||
| 504 | } | ||
| 505 | |||
| 506 | |||
| 507 | void Application::restoreSizeAndPosition() { | ||
| 508 | QRect available = desktop()->availableGeometry(); | ||
| 509 | |||
| 510 | QMutexLocker locker(&_settingsMutex); | ||
| 511 | _settings->beginGroup("Window"); | ||
| 512 | |||
| 513 | int x = (int)loadSetting(_settings, "x", 0); | ||
| 514 | int y = (int)loadSetting(_settings, "y", 0); | ||
| 515 | _window->move(x, y); | ||
| 516 | |||
| 517 | int width = (int)loadSetting(_settings, "width", available.width()); | ||
| 518 | int height = (int)loadSetting(_settings, "height", available.height()); | ||
| 519 | _window->resize(width, height); | ||
| 520 | |||
| 521 | _settings->endGroup(); | ||
| 522 | } | ||
| 523 | |||
| 524 | void Application::storeSizeAndPosition() { | ||
| 525 | QMutexLocker locker(&_settingsMutex); | ||
| 526 | _settings->beginGroup("Window"); | ||
| 527 | |||
| 528 | _settings->setValue("width", _window->rect().width()); | ||
| 529 | _settings->setValue("height", _window->rect().height()); | ||
| 530 | |||
| 531 | _settings->setValue("x", _window->pos().x()); | ||
| 532 | _settings->setValue("y", _window->pos().y()); | ||
| 533 | |||
| 534 | _settings->endGroup(); | ||
| 535 | } | ||
| 536 | |||
| 537 | void Application::initializeGL() { | 523 | void Application::initializeGL() { |
| 538 | qDebug( "Created Display Window."); | 524 | qDebug( "Created Display Window."); |
| 539 | 525 | ||
| @@ -655,7 +641,7 @@ void Application::paintGL() { · 115 unmodified lines | |||
| 655 | _myCamera.update(1.0f / _fps); | 641 | _myCamera.update(1.0f / _fps); |
| 656 | } | 642 | } |
| 657 | 643 | ||
| 658 | if (Menu::getInstance()->getShadowsEnabled()) { | 644 | if (getShadowsEnabled()) { |
| 659 | updateShadowMap(); | 645 | updateShadowMap(); |
| 660 | } | 646 | } |
| 661 | 647 | ||
| @@ -711,6 +697,24 @@ void Application::paintGL() { · 49 unmodified lines | |||
| 711 | _frameCount++; | 697 | _frameCount++; |
| 712 | } | 698 | } |
| 713 | 699 | ||
| 700 | void Application::runTests() { | ||
| 701 | runTimingTests(); | ||
| 702 | } | ||
| 703 | |||
| 704 | void Application::audioMuteToggled() { | ||
| 705 | QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteAudio); | ||
| 706 | Q_CHECK_PTR(muteAction); | ||
| 707 | muteAction->setChecked(DependencyManager::get<Audio>()->isMuted()); | ||
| 708 | } | ||
| 709 | |||
| 710 | void Application::aboutApp() { | ||
| 711 | InfoView::forcedShow(INFO_HELP_PATH); | ||
| 712 | } | ||
| 713 | |||
| 714 | void Application::showEditEntitiesHelp() { | ||
| 715 | InfoView::forcedShow(INFO_EDIT_ENTITIES_PATH); | ||
| 716 | } | ||
| 717 | |||
| 714 | void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) { | 718 | void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) { |
| 715 | if (OculusManager::isConnected()) { | 719 | if (OculusManager::isConnected()) { |
| 716 | OculusManager::configureCamera(camera, width, height); | 720 | OculusManager::configureCamera(camera, width, height); |
| @@ -718,7 +722,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) · 1 unmodified line | |||
| 718 | TV3DManager::configureCamera(camera, width, height); | 722 | TV3DManager::configureCamera(camera, width, height); |
| 719 | } else { | 723 | } else { |
| 720 | camera.setAspectRatio((float)width / height); | 724 | camera.setAspectRatio((float)width / height); |
| 721 | camera.setFieldOfView(Menu::getInstance()->getFieldOfView()); | 725 | camera.setFieldOfView(_viewFrustum.getFieldOfView()); |
| 722 | } | 726 | } |
| 723 | } | 727 | } |
| 724 | 728 | ||
| @@ -1441,10 +1445,6 @@ void Application::idle() { · 716 unmodified lines | |||
| 1441 | 1445 | ||
| 1442 | // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. | 1446 | // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. |
| 1443 | idleTimer->start(2); | 1447 | idleTimer->start(2); |
| 1444 | |||
| 1445 | if (_numChangedSettings > 0) { | ||
| 1446 | saveSettings(); | ||
| 1447 | } | ||
| 1448 | } | 1448 | } |
| 1449 | } | 1449 | } |
| 1450 | } | 1450 | } |
| @@ -1462,7 +1462,7 @@ void Application::checkBandwidthMeterClick() { · 11 unmodified lines | |||
| 1462 | 1462 | ||
| 1463 | // The bandwidth meter is visible, the click didn't get dragged too far and | 1463 | // The bandwidth meter is visible, the click didn't get dragged too far and |
| 1464 | // we actually hit the bandwidth meter | 1464 | // we actually hit the bandwidth meter |
| 1465 | Menu::getInstance()->bandwidthDetails(); | 1465 | DependencyManager::get<DialogsManager>()->bandwidthDetails(); |
| 1466 | } | 1466 | } |
| 1467 | } | 1467 | } |
| 1468 | 1468 | ||
| @@ -1600,6 +1600,20 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa · 131 unmodified lines | |||
| 1600 | return true; | 1600 | return true; |
| 1601 | } | 1601 | } |
| 1602 | 1602 | ||
| 1603 | void Application::loadSettings() { | ||
| 1604 | DependencyManager::get<Audio>()->loadSettings(); | ||
| 1605 | DependencyManager::get<LODManager>()->loadSettings(); | ||
| 1606 | Menu::getInstance()->loadSettings(); | ||
| 1607 | _myAvatar->loadData(); | ||
| 1608 | } | ||
| 1609 | |||
| 1610 | void Application::saveSettings() { | ||
| 1611 | DependencyManager::get<Audio>()->saveSettings(); | ||
| 1612 | DependencyManager::get<LODManager>()->saveSettings(); | ||
| 1613 | Menu::getInstance()->saveSettings(); | ||
| 1614 | _myAvatar->saveData(); | ||
| 1615 | } | ||
| 1616 | |||
| 1603 | bool Application::importEntities(const QString& filename) { | 1617 | bool Application::importEntities(const QString& filename) { |
| 1604 | _entityClipboard.eraseAllOctreeElements(); | 1618 | _entityClipboard.eraseAllOctreeElements(); |
| 1605 | bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData()); | 1619 | bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData()); |
| @@ -1650,8 +1664,6 @@ void Application::init() { · 44 unmodified lines | |||
| 1650 | 1664 | ||
| 1651 | _timerStart.start(); | 1665 | _timerStart.start(); |
| 1652 | _lastTimeUpdated.start(); | 1666 | _lastTimeUpdated.start(); |
| 1653 | |||
| 1654 | Menu::getInstance()->loadSettings(); | ||
| 1655 | 1667 | ||
| 1656 | // when --url in command line, teleport to location | 1668 | // when --url in command line, teleport to location |
| 1657 | const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; | 1669 | const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; |
| @@ -1669,11 +1681,11 @@ void Application::init() { · 11 unmodified lines | |||
| 1669 | if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseEnabled)) { | 1681 | if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseEnabled)) { |
| 1670 | // on OS X we only setup sixense if the user wants it on - this allows running without the hid_init crash | 1682 | // on OS X we only setup sixense if the user wants it on - this allows running without the hid_init crash |
| 1671 | // if hydra support is temporarily not required | 1683 | // if hydra support is temporarily not required |
| 1672 | Menu::getInstance()->toggleSixense(true); | 1684 | SixenseManager::getInstance().toggleSixense(true); |
| 1673 | } | 1685 | } |
| 1674 | #else | 1686 | #else |
| 1675 | // setup sixense | 1687 | // setup sixense |
| 1676 | Menu::getInstance()->toggleSixense(true); | 1688 | SixenseManager::getInstance().toggleSixense(true); |
| 1677 | #endif | 1689 | #endif |
| 1678 | 1690 | ||
| 1679 | // initialize our face trackers after loading the menu settings | 1691 | // initialize our face trackers after loading the menu settings |
| @@ -1712,16 +1724,13 @@ void Application::init() { · 32 unmodified lines | |||
| 1712 | _metavoxels.init(); | 1724 | _metavoxels.init(); |
| 1713 | 1725 | ||
| 1714 | auto glCanvas = DependencyManager::get<GLCanvas>(); | 1726 | auto glCanvas = DependencyManager::get<GLCanvas>(); |
| 1715 | _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect, _settings); | 1727 | _rearMirrorTools = new RearMirrorTools(glCanvas.data(), _mirrorViewRect); |
| 1716 | 1728 | ||
| 1717 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); | 1729 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); |
| 1718 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); | 1730 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1719 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); | 1731 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| 1720 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); | 1732 | connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors())); |
| 1721 | 1733 | ||
| 1722 | // save settings when avatar changes | ||
| 1723 | connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings); | ||
| 1724 | |||
| 1725 | // make sure our texture cache knows about window size changes | 1734 | // make sure our texture cache knows about window size changes |
| 1726 | DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data()); | 1735 | DependencyManager::get<TextureCache>()->associateWithWidget(glCanvas.data()); |
| 1727 | 1736 | ||
| @@ -1763,9 +1772,9 @@ void Application::updateLOD() { · 35 unmodified lines | |||
| 1763 | PerformanceTimer perfTimer("LOD"); | 1772 | PerformanceTimer perfTimer("LOD"); |
| 1764 | // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode | 1773 | // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode |
| 1765 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) { | 1774 | if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) { |
| 1766 | Menu::getInstance()->autoAdjustLOD(_fps); | 1775 | DependencyManager::get<LODManager>()->autoAdjustLOD(_fps); |
| 1767 | } else { | 1776 | } else { |
| 1768 | Menu::getInstance()->resetLODAdjust(); | 1777 | DependencyManager::get<LODManager>()->resetLODAdjust(); |
| 1769 | } | 1778 | } |
| 1770 | } | 1779 | } |
| 1771 | 1780 | ||
| @@ -1882,7 +1891,7 @@ void Application::updateMyAvatarLookAtPosition() { · 110 unmodified lines | |||
| 1882 | // deflect using Faceshift gaze data | 1891 | // deflect using Faceshift gaze data |
| 1883 | glm::vec3 origin = _myAvatar->getHead()->getEyePosition(); | 1892 | glm::vec3 origin = _myAvatar->getHead()->getEyePosition(); |
| 1884 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; | 1893 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| 1885 | float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); | 1894 | float deflection = DependencyManager::get<Faceshift>()->getEyeDeflection(); |
| 1886 | if (isLookingAtSomeone) { | 1895 | if (isLookingAtSomeone) { |
| 1887 | deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT; | 1896 | deflection *= GAZE_DEFLECTION_REDUCTION_DURING_EYE_CONTACT; |
| 1888 | } | 1897 | } |
| @@ -1954,14 +1963,15 @@ void Application::updateDialogs(float deltaTime) { · 65 unmodified lines | |||
| 1954 | PerformanceTimer perfTimer("updateDialogs"); | 1963 | PerformanceTimer perfTimer("updateDialogs"); |
| 1955 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | 1964 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1956 | PerformanceWarning warn(showWarnings, "Application::updateDialogs()"); | 1965 | PerformanceWarning warn(showWarnings, "Application::updateDialogs()"); |
| 1957 | 1966 | auto dialogsManager = DependencyManager::get<DialogsManager>(); | |
| 1967 | |||
| 1958 | // Update bandwidth dialog, if any | 1968 | // Update bandwidth dialog, if any |
| 1959 | BandwidthDialog* bandwidthDialog = Menu::getInstance()->getBandwidthDialog(); | 1969 | BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog(); |
| 1960 | if (bandwidthDialog) { | 1970 | if (bandwidthDialog) { |
| 1961 | bandwidthDialog->update(); | 1971 | bandwidthDialog->update(); |
| 1962 | } | 1972 | } |
| 1963 | 1973 | ||
| 1964 | OctreeStatsDialog* octreeStatsDialog = Menu::getInstance()->getOctreeStatsDialog(); | 1974 | QPointer<OctreeStatsDialog> octreeStatsDialog = dialogsManager->getOctreeStatsDialog(); |
| 1965 | if (octreeStatsDialog) { | 1975 | if (octreeStatsDialog) { |
| 1966 | octreeStatsDialog->update(); | 1976 | octreeStatsDialog->update(); |
| 1967 | } | 1977 | } |
| @@ -2232,8 +2242,9 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 264 unmodified lines | |||
| 2232 | _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip()); | 2242 | _octreeQuery.setCameraNearClip(_viewFrustum.getNearClip()); |
| 2233 | _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip()); | 2243 | _octreeQuery.setCameraFarClip(_viewFrustum.getFarClip()); |
| 2234 | _octreeQuery.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition()); | 2244 | _octreeQuery.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition()); |
| 2235 | _octreeQuery.setOctreeSizeScale(Menu::getInstance()->getOctreeSizeScale()); | 2245 | auto lodManager = DependencyManager::get<LODManager>(); |
| 2236 | _octreeQuery.setBoundaryLevelAdjust(Menu::getInstance()->getBoundaryLevelAdjust()); | 2246 | _octreeQuery.setOctreeSizeScale(lodManager->getOctreeSizeScale()); |
| 2247 | _octreeQuery.setBoundaryLevelAdjust(lodManager->getBoundaryLevelAdjust()); | ||
| 2237 | 2248 | ||
| 2238 | unsigned char queryPacket[MAX_PACKET_SIZE]; | 2249 | unsigned char queryPacket[MAX_PACKET_SIZE]; |
| 2239 | 2250 | ||
| @@ -2285,7 +2296,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 45 unmodified lines | |||
| 2285 | int perServerPPS = 0; | 2296 | int perServerPPS = 0; |
| 2286 | const int SMALL_BUDGET = 10; | 2297 | const int SMALL_BUDGET = 10; |
| 2287 | int perUnknownServer = SMALL_BUDGET; | 2298 | int perUnknownServer = SMALL_BUDGET; |
| 2288 | int totalPPS = Menu::getInstance()->getMaxOctreePacketsPerSecond(); | 2299 | int totalPPS = _octreeQuery.getMaxOctreePacketsPerSecond(); |
| 2289 | 2300 | ||
| 2290 | // determine PPS based on number of servers | 2301 | // determine PPS based on number of servers |
| 2291 | if (inViewServers >= 1) { | 2302 | if (inViewServers >= 1) { |
| @@ -2406,7 +2417,7 @@ QRect Application::getDesirableApplicationGeometry() { · 114 unmodified lines | |||
| 2406 | 2417 | ||
| 2407 | // If our parent window is on the HMD, then don't use it's geometry, instead use | 2418 | // If our parent window is on the HMD, then don't use it's geometry, instead use |
| 2408 | // the "main screen" geometry. | 2419 | // the "main screen" geometry. |
| 2409 | HMDToolsDialog* hmdTools = Menu::getInstance()->getHMDToolsDialog(); | 2420 | HMDToolsDialog* hmdTools = DependencyManager::get<DialogsManager>()->getHMDToolsDialog(); |
| 2410 | if (hmdTools && hmdTools->hasHMDScreen()) { | 2421 | if (hmdTools && hmdTools->hasHMDScreen()) { |
| 2411 | QScreen* hmdScreen = hmdTools->getHMDScreen(); | 2422 | QScreen* hmdScreen = hmdTools->getHMDScreen(); |
| 2412 | QWindow* appWindow = getWindow()->windowHandle(); | 2423 | QWindow* appWindow = getWindow()->windowHandle(); |
| @@ -2631,15 +2642,15 @@ void Application::setupWorldLight() { · 218 unmodified lines | |||
| 2631 | } | 2642 | } |
| 2632 | 2643 | ||
| 2633 | bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { | 2644 | bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) { |
| 2634 | return Menu::getInstance()->shouldRenderMesh(largestDimension, distanceToCamera); | 2645 | return DependencyManager::get<LODManager>()->shouldRenderMesh(largestDimension, distanceToCamera); |
| 2635 | } | 2646 | } |
| 2636 | 2647 | ||
| 2637 | float Application::getSizeScale() const { | 2648 | float Application::getSizeScale() const { |
| 2638 | return Menu::getInstance()->getOctreeSizeScale(); | 2649 | return DependencyManager::get<LODManager>()->getOctreeSizeScale(); |
| 2639 | } | 2650 | } |
| 2640 | 2651 | ||
| 2641 | int Application::getBoundaryLevelAdjust() const { | 2652 | int Application::getBoundaryLevelAdjust() const { |
| 2642 | return Menu::getInstance()->getBoundaryLevelAdjust(); | 2653 | return DependencyManager::get<LODManager>()->getBoundaryLevelAdjust(); |
| 2643 | } | 2654 | } |
| 2644 | 2655 | ||
| 2645 | PickRay Application::computePickRay(float x, float y) { | 2656 | PickRay Application::computePickRay(float x, float y) { |
| @@ -2935,8 +2946,10 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom · 289 unmodified lines | |||
| 2935 | } | 2946 | } |
| 2936 | } | 2947 | } |
| 2937 | 2948 | ||
| 2938 | bool Application::getShadowsEnabled() { | 2949 | bool Application::getShadowsEnabled() { |
| 2939 | return Menu::getInstance()->getShadowsEnabled(); | 2950 | Menu* menubar = Menu::getInstance(); |
| 2951 | return menubar->isOptionChecked(MenuOption::SimpleShadows) || | ||
| 2952 | menubar->isOptionChecked(MenuOption::CascadedShadows); | ||
| 2940 | } | 2953 | } |
| 2941 | 2954 | ||
| 2942 | bool Application::getCascadeShadowsEnabled() { | 2955 | bool Application::getCascadeShadowsEnabled() { |
| @@ -2981,7 +2994,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines | |||
| 2981 | _mirrorCamera.setPosition(_myAvatar->getPosition() + | 2994 | _mirrorCamera.setPosition(_myAvatar->getPosition() + |
| 2982 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); | 2995 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 2983 | 2996 | ||
| 2984 | } else if (_rearMirrorTools->getZoomLevel() == BODY) { | 2997 | } else if (SettingHandles::rearViewZoomLevel.get() == BODY) { |
| 2985 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees | 2998 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 2986 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + | 2999 | _mirrorCamera.setPosition(_myAvatar->getChestPosition() + |
| 2987 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); | 3000 | _myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); |
| @@ -3378,45 +3391,45 @@ void Application::packetSent(quint64 length) { · 390 unmodified lines | |||
| 3378 | _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length); | 3391 | _bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length); |
| 3379 | } | 3392 | } |
| 3380 | 3393 | ||
| 3394 | const QString SETTINGS_KEY = "Settings"; | ||
| 3395 | |||
| 3381 | void Application::loadScripts() { | 3396 | void Application::loadScripts() { |
| 3382 | // loads all saved scripts | 3397 | // loads all saved scripts |
| 3383 | int size = lockSettings()->beginReadArray("Settings"); | 3398 | Settings settings; |
| 3384 | unlockSettings(); | 3399 | int size = settings.beginReadArray(SETTINGS_KEY); |
| 3385 | for (int i = 0; i < size; ++i){ | 3400 | for (int i = 0; i < size; ++i){ |
| 3386 | lockSettings()->setArrayIndex(i); | 3401 | settings.setArrayIndex(i); |
| 3387 | QString string = _settings->value("script").toString(); | 3402 | QString string = settings.value("script").toString(); |
| 3388 | unlockSettings(); | ||
| 3389 | if (!string.isEmpty()) { | 3403 | if (!string.isEmpty()) { |
| 3390 | loadScript(string); | 3404 | loadScript(string); |
| 3391 | } | 3405 | } |
| 3392 | } | 3406 | } |
| 3393 | 3407 | settings.endArray(); | |
| 3394 | QMutexLocker locker(&_settingsMutex); | ||
| 3395 | _settings->endArray(); | ||
| 3396 | } | 3408 | } |
| 3397 | 3409 | ||
| 3398 | void Application::clearScriptsBeforeRunning() { | 3410 | void Application::clearScriptsBeforeRunning() { |
| 3399 | // clears all scripts from the settings | 3411 | // clears all scripts from the settings |
| 3400 | QMutexLocker locker(&_settingsMutex); | 3412 | SettingHandles::SettingHandle<QVariant>(SETTINGS_KEY).remove(); |
| 3401 | _settings->remove("Settings"); | ||
| 3402 | } | 3413 | } |
| 3403 | 3414 | ||
| 3404 | void Application::saveScripts() { | 3415 | void Application::saveScripts() { |
| 3405 | // Saves all currently running user-loaded scripts | ||
| 3406 | QMutexLocker locker(&_settingsMutex); | ||
| 3407 | _settings->beginWriteArray("Settings"); | ||
| 3408 | |||
| 3409 | QStringList runningScripts = getRunningScripts(); | 3416 | QStringList runningScripts = getRunningScripts(); |
| 3417 | if (runningScripts.isEmpty()) { | ||
| 3418 | return; | ||
| 3419 | } | ||
| 3420 | |||
| 3421 | // Saves all currently running user-loaded scripts | ||
| 3422 | Settings settings; | ||
| 3423 | settings.beginWriteArray(SETTINGS_KEY); | ||
| 3410 | int i = 0; | 3424 | int i = 0; |
| 3411 | for (QStringList::const_iterator it = runningScripts.begin(); it != runningScripts.end(); it += 1) { | 3425 | for (auto it = runningScripts.begin(); it != runningScripts.end(); ++it) { |
| 3412 | if (getScriptEngine(*it)->isUserLoaded()) { | 3426 | if (getScriptEngine(*it)->isUserLoaded()) { |
| 3413 | _settings->setArrayIndex(i); | 3427 | settings.setArrayIndex(i); |
| 3414 | _settings->setValue("script", *it); | 3428 | settings.setValue("script", *it); |
| 3415 | i += 1; | 3429 | ++i; |
| 3416 | } | 3430 | } |
| 3417 | } | 3431 | } |
| 3418 | 3432 | settings.endArray(); | |
| 3419 | _settings->endArray(); | ||
| 3420 | } | 3433 | } |
| 3421 | 3434 | ||
| 3422 | QScriptValue joystickToScriptValue(QScriptEngine *engine, Joystick* const &in) { | 3435 | QScriptValue joystickToScriptValue(QScriptEngine *engine, Joystick* const &in) { |
| @@ -3443,7 +3456,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 20 unmodified lines | |||
| 3443 | scriptEngine->registerGlobalObject("Camera", &_myCamera); | 3456 | scriptEngine->registerGlobalObject("Camera", &_myCamera); |
| 3444 | 3457 | ||
| 3445 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) | 3458 | #if defined(Q_OS_MAC) || defined(Q_OS_WIN) |
| 3446 | scriptEngine->registerGlobalObject("SpeechRecognizer", Menu::getInstance()->getSpeechRecognizer()); | 3459 | scriptEngine->registerGlobalObject("SpeechRecognizer", DependencyManager::get<SpeechRecognizer>().data()); |
| 3447 | #endif | 3460 | #endif |
| 3448 | 3461 | ||
| 3449 | ClipboardScriptingInterface* clipboardScriptable = new ClipboardScriptingInterface(); | 3462 | ClipboardScriptingInterface* clipboardScriptable = new ClipboardScriptingInterface(); |
| @@ -3545,7 +3558,6 @@ ScriptEngine* Application::loadScript(const QString& scriptFilename, bool isUser · 95 unmodified lines | |||
| 3545 | if (activateMainWindow && !loadScriptFromEditor) { | 3558 | if (activateMainWindow && !loadScriptFromEditor) { |
| 3546 | _window->activateWindow(); | 3559 | _window->activateWindow(); |
| 3547 | } | 3560 | } |
| 3548 | bumpSettings(); | ||
| 3549 | 3561 | ||
| 3550 | return scriptEngine; | 3562 | return scriptEngine; |
| 3551 | } | 3563 | } |
| @@ -3573,7 +3585,6 @@ void Application::scriptFinished(const QString& scriptName) { · 21 unmodified lines | |||
| 3573 | _scriptEnginesHash.erase(it); | 3585 | _scriptEnginesHash.erase(it); |
| 3574 | _runningScriptsWidget->scriptStopped(scriptName); | 3586 | _runningScriptsWidget->scriptStopped(scriptName); |
| 3575 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); | 3587 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); |
| 3576 | bumpSettings(); | ||
| 3577 | } | 3588 | } |
| 3578 | } | 3589 | } |
| 3579 | 3590 | ||
| @@ -3669,7 +3680,6 @@ void Application::openUrl(const QUrl& url) { · 89 unmodified lines | |||
| 3669 | } | 3680 | } |
| 3670 | 3681 | ||
| 3671 | void Application::updateMyAvatarTransform() { | 3682 | void Application::updateMyAvatarTransform() { |
| 3672 | bumpSettings(); | ||
| 3673 | const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters | 3683 | const float SIMULATION_OFFSET_QUANTIZATION = 16.0f; // meters |
| 3674 | glm::vec3 avatarPosition = _myAvatar->getPosition(); | 3684 | glm::vec3 avatarPosition = _myAvatar->getPosition(); |
| 3675 | glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset(); | 3685 | glm::vec3 physicsWorldOffset = _physicsEngine.getOriginOffset(); |
| @@ -3686,7 +3696,6 @@ void Application::updateMyAvatarTransform() { · 10 unmodified lines | |||
| 3686 | } | 3696 | } |
| 3687 | 3697 | ||
| 3688 | void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) { | 3698 | void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject) { |
| 3689 | |||
| 3690 | // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed | 3699 | // from the domain-handler, figure out the satoshi cost per voxel and per meter cubed |
| 3691 | const QString VOXEL_SETTINGS_KEY = "voxels"; | 3700 | const QString VOXEL_SETTINGS_KEY = "voxels"; |
| 3692 | const QString PER_VOXEL_COST_KEY = "per-voxel-credits"; | 3701 | const QString PER_VOXEL_COST_KEY = "per-voxel-credits"; |
| @@ -3729,9 +3738,7 @@ QString Application::getPreviousScriptLocation() { · 36 unmodified lines | |||
| 3729 | 3738 | ||
| 3730 | void Application::setPreviousScriptLocation(const QString& previousScriptLocation) { | 3739 | void Application::setPreviousScriptLocation(const QString& previousScriptLocation) { |
| 3731 | _previousScriptLocation = previousScriptLocation; | 3740 | _previousScriptLocation = previousScriptLocation; |
| 3732 | QMutexLocker locker(&_settingsMutex); | 3741 | SettingHandles::lastScriptLocation.set(_previousScriptLocation); |
| 3733 | _settings->setValue("LastScriptLocation", _previousScriptLocation); | ||
| 3734 | bumpSettings(); | ||
| 3735 | } | 3742 | } |
| 3736 | 3743 | ||
| 3737 | void Application::loadDialog() { | 3744 | void Application::loadDialog() { |
| @@ -3747,7 +3754,6 @@ void Application::loadDialog() { · 9 unmodified lines | |||
| 3747 | } | 3754 | } |
| 3748 | 3755 | ||
| 3749 | void Application::loadScriptURLDialog() { | 3756 | void Application::loadScriptURLDialog() { |
| 3750 | |||
| 3751 | QInputDialog scriptURLDialog(Application::getInstance()->getWindow()); | 3757 | QInputDialog scriptURLDialog(Application::getInstance()->getWindow()); |
| 3752 | scriptURLDialog.setWindowTitle("Open and Run Script URL"); | 3758 | scriptURLDialog.setWindowTitle("Open and Run Script URL"); |
| 3753 | scriptURLDialog.setLabelText("Script:"); | 3759 | scriptURLDialog.setLabelText("Script:"); |
| @@ -3765,11 +3771,16 @@ void Application::loadScriptURLDialog() { · 11 unmodified lines | |||
| 3765 | } | 3771 | } |
| 3766 | loadScript(newScript); | 3772 | loadScript(newScript); |
| 3767 | } | 3773 | } |
| 3768 | |||
| 3769 | sendFakeEnterEvent(); | ||
| 3770 | } | 3774 | } |
| 3771 | 3775 | ||
| 3776 | QString Application::getScriptsLocation() const { | ||
| 3777 | return SettingHandles::scriptsLocation.get(); | ||
| 3778 | } | ||
| 3772 | 3779 | ||
| 3780 | void Application::setScriptsLocation(const QString& scriptsLocation) { | ||
| 3781 | SettingHandles::scriptsLocation.set(scriptsLocation); | ||
| 3782 | emit scriptLocationChanged(scriptsLocation); | ||
| 3783 | } | ||
| 3773 | 3784 | ||
| 3774 | void Application::toggleLogDialog() { | 3785 | void Application::toggleLogDialog() { |
| 3775 | if (! _logDialog) { | 3786 | if (! _logDialog) { |
| @@ -3871,7 +3882,8 @@ void Application::takeSnapshot() { · 95 unmodified lines | |||
| 3871 | _snapshotShareDialog->show(); | 3882 | _snapshotShareDialog->show(); |
| 3872 | } | 3883 | } |
| 3873 | 3884 | ||
| 3874 | void Application::setVSyncEnabled(bool vsyncOn) { | 3885 | void Application::setVSyncEnabled() { |
| 3886 | bool vsyncOn = Menu::getInstance()->isOptionChecked(MenuOption::RenderTargetFramerateVSyncOn); | ||
| 3875 | #if defined(Q_OS_WIN) | 3887 | #if defined(Q_OS_WIN) |
| 3876 | if (wglewGetExtension("WGL_EXT_swap_control")) { | 3888 | if (wglewGetExtension("WGL_EXT_swap_control")) { |
| 3877 | wglSwapIntervalEXT(vsyncOn); | 3889 | wglSwapIntervalEXT(vsyncOn); |
| @@ -3895,6 +3907,7 @@ void Application::setVSyncEnabled(bool vsyncOn) { · 17 unmodified lines | |||
| 3895 | #else | 3907 | #else |
| 3896 | qDebug("V-Sync is FORCED ON on this system\n"); | 3908 | qDebug("V-Sync is FORCED ON on this system\n"); |
| 3897 | #endif | 3909 | #endif |
| 3910 | vsyncOn = true; // Turns off unused variable warning | ||
| 3898 | } | 3911 | } |
| 3899 | 3912 | ||
| 3900 | bool Application::isVSyncOn() const { | 3913 | bool Application::isVSyncOn() const { |