Showing the changes to interface/src/Application.cpp (1 of 98 files). Show all
Unified · Split
| @@ -152,6 +152,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 151 unmodified lines | ||
| 152 | 152 | _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), |
| 153 | 153 | _cameraPushback(0.0f), |
| 154 | 154 | _scaleMirror(1.0f), |
| 155 | + _rotateMirror(0.0f), | |
| 156 | + _raiseMirror(0.0f), | |
| 155 | 157 | _mouseX(0), |
| 156 | 158 | _mouseY(0), |
| 157 | 159 | _lastMouseMove(usecTimestampNow()), |
| @@ -685,11 +687,8 @@ void Application::resizeGL(int width, int height) { · 527 unmodified lines | ||
| 685 | 687 | glLoadIdentity(); |
| 686 | 688 | |
| 687 | 689 | // update Stats width |
| 688 | − int horizontalOffset = 0; | |
| 689 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 690 | − // mirror is enabled, let's set horizontal offset to give stats some margin | |
| 691 | − horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 692 | − } | |
| 690 | + // let's set horizontal offset to give stats some margin to mirror | |
| 691 | + int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 693 | 692 | Stats::getInstance()->resetWidth(width, horizontalOffset); |
| 694 | 693 | } |
| 695 | 694 | |
| @@ -1163,10 +1162,8 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 467 unmodified lines | ||
| 1163 | 1162 | _mousePressed = false; |
| 1164 | 1163 | checkBandwidthMeterClick(); |
| 1165 | 1164 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 1166 | − int horizontalOffset = 0; | |
| 1167 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 1168 | − horizontalOffset = MIRROR_VIEW_WIDTH; | |
| 1169 | − } | |
| 1165 | + // let's set horizontal offset to give stats some margin to mirror | |
| 1166 | + int horizontalOffset = MIRROR_VIEW_WIDTH; | |
| 1170 | 1167 | Stats::getInstance()->checkClick(_mouseX, _mouseY, _mouseDragStartedX, _mouseDragStartedY, horizontalOffset); |
| 1171 | 1168 | } |
| 1172 | 1169 | } |
| @@ -1218,10 +1215,6 @@ void Application::touchBeginEvent(QTouchEvent* event) { · 45 unmodified lines | ||
| 1218 | 1215 | return; |
| 1219 | 1216 | } |
| 1220 | 1217 | |
| 1221 | − // put any application specific touch behavior below here.. | |
| 1222 | − _lastTouchAvgX = _touchAvgX; | |
| 1223 | − _lastTouchAvgY = _touchAvgY; | |
| 1224 | − | |
| 1225 | 1218 | } |
| 1226 | 1219 | |
| 1227 | 1220 | void Application::touchEndEvent(QTouchEvent* event) { |
| @@ -1876,34 +1869,6 @@ void Application::updateMyAvatarLookAtPosition() { · 648 unmodified lines | ||
| 1876 | 1869 | _myAvatar->getHead()->setLookAtPosition(lookAtSpot); |
| 1877 | 1870 | } |
| 1878 | 1871 | |
| 1879 | −void Application::updateHandAndTouch(float deltaTime) { | |
| 1880 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1881 | − PerformanceWarning warn(showWarnings, "Application::updateHandAndTouch()"); | |
| 1882 | − | |
| 1883 | − // Update from Touch | |
| 1884 | − if (_isTouchPressed) { | |
| 1885 | − _lastTouchAvgX = _touchAvgX; | |
| 1886 | − _lastTouchAvgY = _touchAvgY; | |
| 1887 | − } | |
| 1888 | −} | |
| 1889 | − | |
| 1890 | −void Application::updateLeap(float deltaTime) { | |
| 1891 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1892 | − PerformanceWarning warn(showWarnings, "Application::updateLeap()"); | |
| 1893 | −} | |
| 1894 | − | |
| 1895 | −void Application::updateSixense(float deltaTime) { | |
| 1896 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1897 | − PerformanceWarning warn(showWarnings, "Application::updateSixense()"); | |
| 1898 | − | |
| 1899 | − _sixenseManager.update(deltaTime); | |
| 1900 | −} | |
| 1901 | − | |
| 1902 | −void Application::updateSerialDevices(float deltaTime) { | |
| 1903 | − bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); | |
| 1904 | − PerformanceWarning warn(showWarnings, "Application::updateSerialDevices()"); | |
| 1905 | −} | |
| 1906 | − | |
| 1907 | 1872 | void Application::updateThreads(float deltaTime) { |
| 1908 | 1873 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1909 | 1874 | PerformanceWarning warn(showWarnings, "Application::updateThreads()"); |
| @@ -2017,11 +1982,8 @@ void Application::update(float deltaTime) { · 107 unmodified lines | ||
| 2017 | 1982 | updateVisage(); |
| 2018 | 1983 | _myAvatar->updateLookAtTargetAvatar(); |
| 2019 | 1984 | updateMyAvatarLookAtPosition(); |
| 2020 | − | |
| 2021 | − updateHandAndTouch(deltaTime); // Update state for touch sensors | |
| 2022 | − updateLeap(deltaTime); // Leap finger-sensing device | |
| 2023 | − updateSixense(deltaTime); // Razer Hydra controllers | |
| 2024 | − updateSerialDevices(deltaTime); // Read serial port interface devices | |
| 1985 | + _sixenseManager.update(deltaTime); | |
| 1986 | + _prioVR.update(); | |
| 2025 | 1987 | updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes |
| 2026 | 1988 | updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... |
| 2027 | 1989 | _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them... |
| @@ -2770,11 +2732,8 @@ void Application::displayOverlay() { · 742 unmodified lines | ||
| 2770 | 2732 | glPointSize(1.0f); |
| 2771 | 2733 | |
| 2772 | 2734 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 2773 | − int horizontalOffset = 0; | |
| 2774 | − if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { | |
| 2775 | − // mirror is enabled, let's set horizontal offset to give stats some margin | |
| 2776 | − horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 2777 | − } | |
| 2735 | + // let's set horizontal offset to give stats some margin to mirror | |
| 2736 | + int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2; | |
| 2778 | 2737 | int voxelPacketsToProcess = _voxelProcessor.packetsToProcessCount(); |
| 2779 | 2738 | // Onscreen text about position, servers, etc |
| 2780 | 2739 | Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, _fps, _packetsPerSecond, _bytesPerSecond, voxelPacketsToProcess); |
| @@ -2798,6 +2757,9 @@ void Application::displayOverlay() { · 17 unmodified lines | ||
| 2798 | 2757 | } |
| 2799 | 2758 | _nodeBoundsDisplay.drawOverlay(); |
| 2800 | 2759 | |
| 2760 | + // give external parties a change to hook in | |
| 2761 | + emit renderingOverlay(); | |
| 2762 | + | |
| 2801 | 2763 | _overlays.render2D(); |
| 2802 | 2764 | |
| 2803 | 2765 | glPopMatrix(); |
| @@ -3106,6 +3068,8 @@ void Application::resetSensors() { · 302 unmodified lines | ||
| 3106 | 3068 | OculusManager::reset(); |
| 3107 | 3069 | } |
| 3108 | 3070 | |
| 3071 | + _prioVR.reset(); | |
| 3072 | + | |
| 3109 | 3073 | QCursor::setPos(_mouseX, _mouseY); |
| 3110 | 3074 | _myAvatar->reset(); |
| 3111 | 3075 | |
| @@ -3415,71 +3379,6 @@ void Application::saveScripts() { · 303 unmodified lines | ||
| 3415 | 3379 | _settings->endArray(); |
| 3416 | 3380 | } |
| 3417 | 3381 | |
| 3418 | −void Application::stopAllScripts() { | |
| 3419 | − // stops all current running scripts | |
| 3420 | − for (int i = 0; i < _scriptEnginesHash.size(); ++i) { | |
| 3421 | − _scriptEnginesHash.values().at(i)->stop(); | |
| 3422 | − qDebug() << "stopping script..." << getRunningScripts().at(i); | |
| 3423 | − } | |
| 3424 | − _scriptEnginesHash.clear(); | |
| 3425 | − _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3426 | − bumpSettings(); | |
| 3427 | −} | |
| 3428 | − | |
| 3429 | −void Application::stopScript(const QString &scriptName) { | |
| 3430 | − if (_scriptEnginesHash.contains(scriptName)) { | |
| 3431 | − _scriptEnginesHash.value(scriptName)->stop(); | |
| 3432 | − qDebug() << "stopping script..." << scriptName; | |
| 3433 | − _scriptEnginesHash.remove(scriptName); | |
| 3434 | − _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3435 | − bumpSettings(); | |
| 3436 | − } | |
| 3437 | −} | |
| 3438 | − | |
| 3439 | −void Application::reloadAllScripts() { | |
| 3440 | − // remember all the current scripts so we can reload them | |
| 3441 | − QStringList reloadList = getRunningScripts(); | |
| 3442 | − // reloads all current running scripts | |
| 3443 | − stopAllScripts(); | |
| 3444 | − | |
| 3445 | − foreach (QString scriptName, reloadList){ | |
| 3446 | − qDebug() << "reloading script..." << scriptName; | |
| 3447 | − loadScript(scriptName); | |
| 3448 | − } | |
| 3449 | −} | |
| 3450 | − | |
| 3451 | −void Application::manageRunningScriptsWidgetVisibility(bool shown) { | |
| 3452 | − if (_runningScriptsWidgetWasVisible && shown) { | |
| 3453 | − _runningScriptsWidget->show(); | |
| 3454 | − } else if (_runningScriptsWidgetWasVisible && !shown) { | |
| 3455 | − _runningScriptsWidget->hide(); | |
| 3456 | − } | |
| 3457 | −} | |
| 3458 | − | |
| 3459 | −void Application::toggleRunningScriptsWidget() { | |
| 3460 | − if (_runningScriptsWidgetWasVisible) { | |
| 3461 | − _runningScriptsWidget->hide(); | |
| 3462 | − _runningScriptsWidgetWasVisible = false; | |
| 3463 | − } else { | |
| 3464 | − _runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(), | |
| 3465 | − _window->size())); | |
| 3466 | − _runningScriptsWidget->show(); | |
| 3467 | − _runningScriptsWidgetWasVisible = true; | |
| 3468 | − } | |
| 3469 | −} | |
| 3470 | − | |
| 3471 | −void Application::uploadHead() { | |
| 3472 | − uploadModel(HEAD_MODEL); | |
| 3473 | −} | |
| 3474 | − | |
| 3475 | −void Application::uploadSkeleton() { | |
| 3476 | − uploadModel(SKELETON_MODEL); | |
| 3477 | −} | |
| 3478 | − | |
| 3479 | −void Application::uploadAttachment() { | |
| 3480 | − uploadModel(ATTACHMENT_MODEL); | |
| 3481 | −} | |
| 3482 | − | |
| 3483 | 3382 | ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScriptFromEditor) { |
| 3484 | 3383 | if(loadScriptFromEditor && _scriptEnginesHash.contains(scriptName) && !_scriptEnginesHash[scriptName]->isFinished()){ |
| 3485 | 3384 | return _scriptEnginesHash[scriptName]; |
| @@ -3517,6 +3416,8 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 31 unmodified lines | ||
| 3517 | 3416 | scriptEngine->registerGlobalObject("Clipboard", clipboardScriptable); |
| 3518 | 3417 | connect(scriptEngine, SIGNAL(finished(const QString&)), clipboardScriptable, SLOT(deleteLater())); |
| 3519 | 3418 | |
| 3419 | + connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(scriptFinished(const QString&))); | |
| 3420 | + | |
| 3520 | 3421 | scriptEngine->registerGlobalObject("Overlays", &_overlays); |
| 3521 | 3422 | |
| 3522 | 3423 | QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance()); |
| @@ -3559,6 +3460,69 @@ ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScript · 36 unmodified lines | ||
| 3559 | 3460 | return scriptEngine; |
| 3560 | 3461 | } |
| 3561 | 3462 | |
| 3463 | +void Application::scriptFinished(const QString& scriptName) { | |
| 3464 | + if (_scriptEnginesHash.remove(scriptName)) { | |
| 3465 | + _runningScriptsWidget->scriptStopped(scriptName); | |
| 3466 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3467 | + bumpSettings(); | |
| 3468 | + } | |
| 3469 | +} | |
| 3470 | + | |
| 3471 | +void Application::stopAllScripts(bool restart) { | |
| 3472 | + // stops all current running scripts | |
| 3473 | + for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); | |
| 3474 | + it != _scriptEnginesHash.constEnd(); it++) { | |
| 3475 | + if (restart) { | |
| 3476 | + connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&))); | |
| 3477 | + } | |
| 3478 | + it.value()->stop(); | |
| 3479 | + qDebug() << "stopping script..." << it.key(); | |
| 3480 | + } | |
| 3481 | +} | |
| 3482 | + | |
| 3483 | +void Application::stopScript(const QString &scriptName) { | |
| 3484 | + if (_scriptEnginesHash.contains(scriptName)) { | |
| 3485 | + _scriptEnginesHash.value(scriptName)->stop(); | |
| 3486 | + qDebug() << "stopping script..." << scriptName; | |
| 3487 | + } | |
| 3488 | +} | |
| 3489 | + | |
| 3490 | +void Application::reloadAllScripts() { | |
| 3491 | + stopAllScripts(true); | |
| 3492 | +} | |
| 3493 | + | |
| 3494 | +void Application::manageRunningScriptsWidgetVisibility(bool shown) { | |
| 3495 | + if (_runningScriptsWidgetWasVisible && shown) { | |
| 3496 | + _runningScriptsWidget->show(); | |
| 3497 | + } else if (_runningScriptsWidgetWasVisible && !shown) { | |
| 3498 | + _runningScriptsWidget->hide(); | |
| 3499 | + } | |
| 3500 | +} | |
| 3501 | + | |
| 3502 | +void Application::toggleRunningScriptsWidget() { | |
| 3503 | + if (_runningScriptsWidgetWasVisible) { | |
| 3504 | + _runningScriptsWidget->hide(); | |
| 3505 | + _runningScriptsWidgetWasVisible = false; | |
| 3506 | + } else { | |
| 3507 | + _runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(), | |
| 3508 | + _window->size())); | |
| 3509 | + _runningScriptsWidget->show(); | |
| 3510 | + _runningScriptsWidgetWasVisible = true; | |
| 3511 | + } | |
| 3512 | +} | |
| 3513 | + | |
| 3514 | +void Application::uploadHead() { | |
| 3515 | + uploadModel(HEAD_MODEL); | |
| 3516 | +} | |
| 3517 | + | |
| 3518 | +void Application::uploadSkeleton() { | |
| 3519 | + uploadModel(SKELETON_MODEL); | |
| 3520 | +} | |
| 3521 | + | |
| 3522 | +void Application::uploadAttachment() { | |
| 3523 | + uploadModel(ATTACHMENT_MODEL); | |
| 3524 | +} | |
| 3525 | + | |
| 3562 | 3526 | QString Application::getPreviousScriptLocation() { |
| 3563 | 3527 | QString suggestedName; |
| 3564 | 3528 | if (_previousScriptLocation.isEmpty()) { |
| @@ -3698,7 +3662,17 @@ void Application::takeSnapshot() { · 133 unmodified lines | ||
| 3698 | 3662 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 3699 | 3663 | player->play(); |
| 3700 | 3664 | |
| 3701 | − Snapshot::saveSnapshot(_glWidget, _myAvatar); | |
| 3665 | + QString fileName = Snapshot::saveSnapshot(_glWidget, _myAvatar); | |
| 3666 | + | |
| 3667 | + AccountManager& accountManager = AccountManager::getInstance(); | |
| 3668 | + if (!accountManager.isLoggedIn()) { | |
| 3669 | + return; | |
| 3670 | + } | |
| 3671 | + | |
| 3672 | + if (!_snapshotShareDialog) { | |
| 3673 | + _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); | |
| 3674 | + } | |
| 3675 | + _snapshotShareDialog->show(); | |
| 3702 | 3676 | } |
| 3703 | 3677 | |
| 3704 | 3678 | void Application::urlGoTo(int argc, const char * constArgv[]) { |