Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all
Unified · Split
| @@ -49,7 +49,7 @@ · 48 unmodified lines | ||
| 49 | 49 | #include <QXmlStreamReader> |
| 50 | 50 | #include <QXmlStreamAttributes> |
| 51 | 51 | #include <QMediaPlayer> |
| 52 | −#include <QMimeData> | |
| 52 | +#include <QMimeData> | |
| 53 | 53 | #include <QMessageBox> |
| 54 | 54 | |
| 55 | 55 | #include <AccountManager.h> |
| @@ -118,7 +118,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 62 unmodified lines | ||
| 118 | 118 | if (message.size() > 0) { |
| 119 | 119 | QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate); |
| 120 | 120 | QString formattedMessage = QString("[%1] %2\n").arg(dateString).arg(message); |
| 121 | − | |
| 121 | + | |
| 122 | 122 | fprintf(stdout, "%s", qPrintable(formattedMessage)); |
| 123 | 123 | Application::getInstance()->getLogger()->addMessage(qPrintable(formattedMessage)); |
| 124 | 124 | } |
| @@ -174,23 +174,23 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 49 unmodified lines | ||
| 174 | 174 | { |
| 175 | 175 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 176 | 176 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| 177 | − | |
| 177 | + | |
| 178 | 178 | // set the associated application properties |
| 179 | 179 | applicationInfo.beginGroup("INFO"); |
| 180 | − | |
| 180 | + | |
| 181 | 181 | qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); |
| 182 | − | |
| 182 | + | |
| 183 | 183 | setApplicationName(applicationInfo.value("name").toString()); |
| 184 | 184 | setApplicationVersion(BUILD_VERSION); |
| 185 | 185 | setOrganizationName(applicationInfo.value("organizationName").toString()); |
| 186 | 186 | setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); |
| 187 | − | |
| 187 | + | |
| 188 | 188 | QSettings::setDefaultFormat(QSettings::IniFormat); |
| 189 | − | |
| 189 | + | |
| 190 | 190 | _myAvatar = _avatarManager.getMyAvatar(); |
| 191 | 191 | |
| 192 | 192 | _applicationStartupTime = startup_time; |
| 193 | − | |
| 193 | + | |
| 194 | 194 | QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); |
| 195 | 195 | _window->setWindowTitle("Interface"); |
| 196 | 196 | |
| @@ -205,19 +205,19 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines | ||
| 205 | 205 | if (portStr) { |
| 206 | 206 | listenPort = atoi(portStr); |
| 207 | 207 | } |
| 208 | − | |
| 208 | + | |
| 209 | 209 | // start the nodeThread so its event loop is running |
| 210 | 210 | _nodeThread->start(); |
| 211 | − | |
| 211 | + | |
| 212 | 212 | // make sure the node thread is given highest priority |
| 213 | 213 | _nodeThread->setPriority(QThread::TimeCriticalPriority); |
| 214 | − | |
| 214 | + | |
| 215 | 215 | // put the NodeList and datagram processing on the node thread |
| 216 | 216 | NodeList* nodeList = NodeList::createInstance(NodeType::Agent, listenPort); |
| 217 | − | |
| 217 | + | |
| 218 | 218 | nodeList->moveToThread(_nodeThread); |
| 219 | 219 | _datagramProcessor.moveToThread(_nodeThread); |
| 220 | − | |
| 220 | + | |
| 221 | 221 | // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal |
| 222 | 222 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams())); |
| 223 | 223 | |
| @@ -239,20 +239,20 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 15 unmodified lines | ||
| 239 | 239 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); |
| 240 | 240 | connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle); |
| 241 | 241 | connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset); |
| 242 | − | |
| 242 | + | |
| 243 | 243 | // connect to appropriate slots on AccountManager |
| 244 | 244 | AccountManager& accountManager = AccountManager::getInstance(); |
| 245 | 245 | connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain); |
| 246 | 246 | connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); |
| 247 | − | |
| 247 | + | |
| 248 | 248 | // set the account manager's root URL and trigger a login request if we don't have the access token |
| 249 | 249 | accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL); |
| 250 | − | |
| 250 | + | |
| 251 | 251 | // once the event loop has started, check and signal for an access token |
| 252 | 252 | QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection); |
| 253 | 253 | |
| 254 | 254 | _settings = new QSettings(this); |
| 255 | − | |
| 255 | + | |
| 256 | 256 | // Check to see if the user passed in a command line option for loading a local |
| 257 | 257 | // Voxel File. |
| 258 | 258 | _voxelsFilename = getCmdOption(argc, constArgv, "-i"); |
| @@ -266,7 +266,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 7 unmodified lines | ||
| 266 | 266 | nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer |
| 267 | 267 | << NodeType::VoxelServer << NodeType::ParticleServer |
| 268 | 268 | << NodeType::MetavoxelServer); |
| 269 | − | |
| 269 | + | |
| 270 | 270 | // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender |
| 271 | 271 | connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent); |
| 272 | 272 | connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent); |
| @@ -276,7 +276,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines | ||
| 276 | 276 | connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); |
| 277 | 277 | silentNodeTimer->moveToThread(_nodeThread); |
| 278 | 278 | silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000); |
| 279 | − | |
| 279 | + | |
| 280 | 280 | // send the identity packet for our avatar each second to our avatar mixer |
| 281 | 281 | QTimer* identityPacketTimer = new QTimer(); |
| 282 | 282 | connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket); |
| @@ -324,14 +324,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 41 unmodified lines | ||
| 324 | 324 | |
| 325 | 325 | // Set the sixense filtering |
| 326 | 326 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 327 | − | |
| 327 | + | |
| 328 | 328 | checkVersion(); |
| 329 | − | |
| 329 | + | |
| 330 | 330 | _overlays.init(_glWidget); // do this before scripts load |
| 331 | − | |
| 331 | + | |
| 332 | 332 | LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); |
| 333 | 333 | LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); |
| 334 | 334 | |
| 335 | + _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget()); | |
| 336 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 337 | + connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); | |
| 338 | + | |
| 335 | 339 | // check first run... |
| 336 | 340 | QVariant firstRunValue = _settings->value("firstRun",QVariant(true)); |
| 337 | 341 | if (firstRunValue.isValid() && firstRunValue.toBool()) { |
| @@ -339,7 +343,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 1 unmodified line | ||
| 339 | 343 | // clear the scripts, and set out script to our default scripts |
| 340 | 344 | clearScriptsBeforeRunning(); |
| 341 | 345 | loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); |
| 342 | − | |
| 346 | + | |
| 343 | 347 | _settings->setValue("firstRun",QVariant(false)); |
| 344 | 348 | } else { |
| 345 | 349 | // do this as late as possible so that all required subsystems are inialized |
| @@ -350,31 +354,31 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines | ||
| 350 | 354 | Application::~Application() { |
| 351 | 355 | |
| 352 | 356 | qInstallMessageHandler(NULL); |
| 353 | − | |
| 357 | + | |
| 354 | 358 | // make sure we don't call the idle timer any more |
| 355 | 359 | delete idleTimer; |
| 356 | − | |
| 360 | + | |
| 357 | 361 | Menu::getInstance()->saveSettings(); |
| 358 | 362 | _rearMirrorTools->saveSettings(_settings); |
| 359 | − | |
| 363 | + | |
| 360 | 364 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 361 | 365 | if (_voxelImporter) { |
| 362 | 366 | _voxelImporter->saveSettings(_settings); |
| 363 | 367 | delete _voxelImporter; |
| 364 | 368 | } |
| 365 | 369 | _settings->sync(); |
| 366 | − | |
| 370 | + | |
| 367 | 371 | // let the avatar mixer know we're out |
| 368 | 372 | MyAvatar::sendKillAvatar(); |
| 369 | − | |
| 373 | + | |
| 370 | 374 | // ask the datagram processing thread to quit and wait until it is done |
| 371 | 375 | _nodeThread->quit(); |
| 372 | 376 | _nodeThread->wait(); |
| 373 | − | |
| 377 | + | |
| 374 | 378 | // ask the audio thread to quit and wait until it is done |
| 375 | 379 | _audio.thread()->quit(); |
| 376 | 380 | _audio.thread()->wait(); |
| 377 | − | |
| 381 | + | |
| 378 | 382 | _voxelProcessor.terminate(); |
| 379 | 383 | _voxelHideShowThread.terminate(); |
| 380 | 384 | _voxelEditSender.terminate(); |
| @@ -387,9 +391,9 @@ Application::~Application() { · 6 unmodified lines | ||
| 387 | 391 | Menu::getInstance()->deleteLater(); |
| 388 | 392 | |
| 389 | 393 | _myAvatar = NULL; |
| 390 | − | |
| 394 | + | |
| 391 | 395 | delete _glWidget; |
| 392 | − | |
| 396 | + | |
| 393 | 397 | AccountManager::getInstance().destroy(); |
| 394 | 398 | } |
| 395 | 399 | |
| @@ -581,7 +585,7 @@ void Application::paintGL() { · 185 unmodified lines | ||
| 581 | 585 | |
| 582 | 586 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 583 | 587 | renderRearViewMirror(_mirrorViewRect); |
| 584 | − | |
| 588 | + | |
| 585 | 589 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 586 | 590 | _rearMirrorTools->render(true); |
| 587 | 591 | } |
| @@ -654,10 +658,10 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 66 unmodified lines | ||
| 654 | 658 | if (type == NodeType::VoxelServer && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 655 | 659 | continue; |
| 656 | 660 | } |
| 657 | − | |
| 661 | + | |
| 658 | 662 | // Perform the broadcast for one type |
| 659 | 663 | int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(packet, NodeSet() << type); |
| 660 | − | |
| 664 | + | |
| 661 | 665 | // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) |
| 662 | 666 | BandwidthMeter::ChannelIndex channel; |
| 663 | 667 | switch (type) { |
| @@ -676,7 +680,7 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 12 unmodified lines | ||
| 676 | 680 | } |
| 677 | 681 | |
| 678 | 682 | bool Application::event(QEvent* event) { |
| 679 | − | |
| 683 | + | |
| 680 | 684 | // handle custom URL |
| 681 | 685 | if (event->type() == QEvent::FileOpen) { |
| 682 | 686 | QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event); |
| @@ -687,11 +691,11 @@ bool Application::event(QEvent* event) { · 4 unmodified lines | ||
| 687 | 691 | if (urlParts.count() > 1) { |
| 688 | 692 | // if url has 2 or more parts, the first one is domain name |
| 689 | 693 | Menu::getInstance()->goToDomain(urlParts[0]); |
| 690 | − | |
| 694 | + | |
| 691 | 695 | // location coordinates |
| 692 | 696 | Menu::getInstance()->goToDestination(urlParts[1]); |
| 693 | 697 | if (urlParts.count() > 2) { |
| 694 | − | |
| 698 | + | |
| 695 | 699 | // location orientation |
| 696 | 700 | Menu::getInstance()->goToOrientation(urlParts[2]); |
| 697 | 701 | } |
| @@ -701,7 +705,7 @@ bool Application::event(QEvent* event) { · 3 unmodified lines | ||
| 701 | 705 | Menu::getInstance()->goToDestination(urlParts[0]); |
| 702 | 706 | } |
| 703 | 707 | } |
| 704 | − | |
| 708 | + | |
| 705 | 709 | return false; |
| 706 | 710 | } |
| 707 | 711 | return QApplication::event(event); |
| @@ -712,7 +716,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 4 unmodified lines | ||
| 712 | 716 | _keysPressed.insert(event->key()); |
| 713 | 717 | |
| 714 | 718 | _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts |
| 715 | − | |
| 719 | + | |
| 716 | 720 | // if one of our scripts have asked to capture this event, then stop processing it |
| 717 | 721 | if (_controllerScriptingInterface.isKeyCaptured(event)) { |
| 718 | 722 | return; |
| @@ -1071,7 +1075,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 352 unmodified lines | ||
| 1071 | 1075 | checkBandwidthMeterClick(); |
| 1072 | 1076 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 1073 | 1077 | checkStatsClick(); |
| 1074 | − } | |
| 1078 | + } | |
| 1075 | 1079 | } |
| 1076 | 1080 | } |
| 1077 | 1081 | } |
| @@ -1120,7 +1124,7 @@ void Application::touchBeginEvent(QTouchEvent* event) { · 42 unmodified lines | ||
| 1120 | 1124 | if (_controllerScriptingInterface.isTouchCaptured()) { |
| 1121 | 1125 | return; |
| 1122 | 1126 | } |
| 1123 | − | |
| 1127 | + | |
| 1124 | 1128 | // put any application specific touch behavior below here.. |
| 1125 | 1129 | _lastTouchAvgX = _touchAvgX; |
| 1126 | 1130 | _lastTouchAvgY = _touchAvgY; |
| @@ -1163,13 +1167,13 @@ void Application::dropEvent(QDropEvent *event) { · 36 unmodified lines | ||
| 1163 | 1167 | break; |
| 1164 | 1168 | } |
| 1165 | 1169 | } |
| 1166 | − | |
| 1170 | + | |
| 1167 | 1171 | SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); |
| 1168 | 1172 | if (snapshotData) { |
| 1169 | 1173 | if (!snapshotData->getDomain().isEmpty()) { |
| 1170 | 1174 | Menu::getInstance()->goToDomain(snapshotData->getDomain()); |
| 1171 | 1175 | } |
| 1172 | − | |
| 1176 | + | |
| 1173 | 1177 | _myAvatar->setPosition(snapshotData->getLocation()); |
| 1174 | 1178 | _myAvatar->setOrientation(snapshotData->getOrientation()); |
| 1175 | 1179 | } else { |
| @@ -1197,19 +1201,19 @@ void Application::timer() { · 21 unmodified lines | ||
| 1197 | 1201 | } |
| 1198 | 1202 | |
| 1199 | 1203 | _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1200 | − | |
| 1204 | + | |
| 1201 | 1205 | _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1202 | 1206 | _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1203 | 1207 | _frameCount = 0; |
| 1204 | − | |
| 1208 | + | |
| 1205 | 1209 | _datagramProcessor.resetCounters(); |
| 1206 | 1210 | |
| 1207 | 1211 | gettimeofday(&_timerStart, NULL); |
| 1208 | 1212 | |
| 1209 | 1213 | // ask the node list to check in with the domain server |
| 1210 | 1214 | NodeList::getInstance()->sendDomainServerCheckIn(); |
| 1211 | − | |
| 1212 | − | |
| 1215 | + | |
| 1216 | + | |
| 1213 | 1217 | } |
| 1214 | 1218 | |
| 1215 | 1219 | void Application::idle() { |
| @@ -1246,11 +1250,11 @@ void Application::idle() { · 30 unmodified lines | ||
| 1246 | 1250 | _idleLoopMeasuredJitter = _idleLoopStdev.getStDev(); |
| 1247 | 1251 | _idleLoopStdev.reset(); |
| 1248 | 1252 | } |
| 1249 | − | |
| 1253 | + | |
| 1250 | 1254 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { |
| 1251 | 1255 | _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); |
| 1252 | 1256 | } |
| 1253 | − | |
| 1257 | + | |
| 1254 | 1258 | // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. |
| 1255 | 1259 | idleTimer->start(2); |
| 1256 | 1260 | } |
| @@ -1382,7 +1386,7 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 125 unmodified lines | ||
| 1382 | 1386 | tr("Sparse Voxel Octree Files (*.svo)")); |
| 1383 | 1387 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1384 | 1388 | const char* fileName = fileNameAscii.data(); |
| 1385 | − | |
| 1389 | + | |
| 1386 | 1390 | VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); |
| 1387 | 1391 | if (selectedNode) { |
| 1388 | 1392 | VoxelTree exportTree; |
| @@ -1396,12 +1400,12 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 7 unmodified lines | ||
| 1396 | 1400 | |
| 1397 | 1401 | void Application::importVoxels() { |
| 1398 | 1402 | _importSucceded = false; |
| 1399 | − | |
| 1403 | + | |
| 1400 | 1404 | if (!_voxelImporter) { |
| 1401 | 1405 | _voxelImporter = new VoxelImporter(_window); |
| 1402 | 1406 | _voxelImporter->loadSettings(_settings); |
| 1403 | 1407 | } |
| 1404 | − | |
| 1408 | + | |
| 1405 | 1409 | if (!_voxelImporter->exec()) { |
| 1406 | 1410 | qDebug() << "[DEBUG] Import succeeded." << endl; |
| 1407 | 1411 | _importSucceded = true; |
| @@ -1415,7 +1419,7 @@ void Application::importVoxels() { · 7 unmodified lines | ||
| 1415 | 1419 | |
| 1416 | 1420 | // restore the main window's active state |
| 1417 | 1421 | _window->activateWindow(); |
| 1418 | − | |
| 1422 | + | |
| 1419 | 1423 | emit importDone(); |
| 1420 | 1424 | } |
| 1421 | 1425 | |
| @@ -1471,7 +1475,7 @@ void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { · 49 unmodified lines | ||
| 1471 | 1475 | } |
| 1472 | 1476 | |
| 1473 | 1477 | pasteVoxelsToOctalCode(octalCodeDestination); |
| 1474 | − | |
| 1478 | + | |
| 1475 | 1479 | if (calculatedOctCode) { |
| 1476 | 1480 | delete[] calculatedOctCode; |
| 1477 | 1481 | } |
| @@ -1508,9 +1512,9 @@ void Application::init() { · 30 unmodified lines | ||
| 1508 | 1512 | |
| 1509 | 1513 | // Cleanup of the original shared tree |
| 1510 | 1514 | _sharedVoxelSystem.init(); |
| 1511 | − | |
| 1515 | + | |
| 1512 | 1516 | _voxelImporter = new VoxelImporter(_window); |
| 1513 | − | |
| 1517 | + | |
| 1514 | 1518 | _environment.init(); |
| 1515 | 1519 | |
| 1516 | 1520 | _glowEffect.init(); |
| @@ -1552,11 +1556,11 @@ void Application::init() { · 35 unmodified lines | ||
| 1552 | 1556 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); |
| 1553 | 1557 | } |
| 1554 | 1558 | qDebug("Loaded settings"); |
| 1555 | − | |
| 1559 | + | |
| 1556 | 1560 | // initialize Visage and Faceshift after loading the menu settings |
| 1557 | 1561 | _faceshift.init(); |
| 1558 | 1562 | _visage.init(); |
| 1559 | − | |
| 1563 | + | |
| 1560 | 1564 | // fire off an immediate domain-server check in now that settings are loaded |
| 1561 | 1565 | NodeList::getInstance()->sendDomainServerCheckIn(); |
| 1562 | 1566 | |
| @@ -1575,20 +1579,20 @@ void Application::init() { · 12 unmodified lines | ||
| 1575 | 1579 | _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_avatarManager); |
| 1576 | 1580 | |
| 1577 | 1581 | // connect the _particleCollisionSystem to our script engine's ParticleScriptingInterface |
| 1578 | − connect(&_particleCollisionSystem, | |
| 1582 | + connect(&_particleCollisionSystem, | |
| 1579 | 1583 | SIGNAL(particleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)), |
| 1580 | − ScriptEngine::getParticlesScriptingInterface(), | |
| 1584 | + ScriptEngine::getParticlesScriptingInterface(), | |
| 1581 | 1585 | SLOT(forwardParticleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&))); |
| 1582 | 1586 | |
| 1583 | − connect(&_particleCollisionSystem, | |
| 1587 | + connect(&_particleCollisionSystem, | |
| 1584 | 1588 | SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)), |
| 1585 | − ScriptEngine::getParticlesScriptingInterface(), | |
| 1589 | + ScriptEngine::getParticlesScriptingInterface(), | |
| 1586 | 1590 | SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&))); |
| 1587 | − | |
| 1591 | + | |
| 1588 | 1592 | _audio.init(_glWidget); |
| 1589 | 1593 | |
| 1590 | 1594 | _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); |
| 1591 | − | |
| 1595 | + | |
| 1592 | 1596 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); |
| 1593 | 1597 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1594 | 1598 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| @@ -1711,7 +1715,7 @@ void Application::updateMyAvatarLookAtPosition() { · 116 unmodified lines | ||
| 1711 | 1715 | float distance = TREE_SCALE; |
| 1712 | 1716 | if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) { |
| 1713 | 1717 | distance = glm::distance(_mouseRayOrigin, |
| 1714 | − static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); | |
| 1718 | + static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); | |
| 1715 | 1719 | } |
| 1716 | 1720 | const float FIXED_MIN_EYE_DISTANCE = 0.3f; |
| 1717 | 1721 | float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f : |
| @@ -1724,7 +1728,7 @@ void Application::updateMyAvatarLookAtPosition() { · 6 unmodified lines | ||
| 1724 | 1728 | eyePitch = _faceshift.getEstimatedEyePitch(); |
| 1725 | 1729 | eyeYaw = _faceshift.getEstimatedEyeYaw(); |
| 1726 | 1730 | trackerActive = true; |
| 1727 | − | |
| 1731 | + | |
| 1728 | 1732 | } else if (_visage.isActive()) { |
| 1729 | 1733 | eyePitch = _visage.getEstimatedEyePitch(); |
| 1730 | 1734 | eyeYaw = _visage.getEstimatedEyeYaw(); |
| @@ -1907,9 +1911,9 @@ void Application::update(float deltaTime) { · 176 unmodified lines | ||
| 1907 | 1911 | |
| 1908 | 1912 | _particles.update(); // update the particles... |
| 1909 | 1913 | _particleCollisionSystem.update(); // collide the particles... |
| 1910 | − | |
| 1914 | + | |
| 1911 | 1915 | _overlays.update(deltaTime); |
| 1912 | − | |
| 1916 | + | |
| 1913 | 1917 | // let external parties know we're updating |
| 1914 | 1918 | emit simulating(deltaTime); |
| 1915 | 1919 | } |
| @@ -1933,7 +1937,7 @@ void Application::updateMyAvatar(float deltaTime) { · 17 unmodified lines | ||
| 1933 | 1937 | // actually need to calculate the view frustum planes to send these details |
| 1934 | 1938 | // to the server. |
| 1935 | 1939 | loadViewFrustum(_myCamera, _viewFrustum); |
| 1936 | − | |
| 1940 | + | |
| 1937 | 1941 | // Update my voxel servers with my current voxel query... |
| 1938 | 1942 | quint64 now = usecTimestampNow(); |
| 1939 | 1943 | quint64 sinceLastQuery = now - _lastQueriedTime; |
| @@ -2209,7 +2213,7 @@ void Application::updateShadowMap() { · 269 unmodified lines | ||
| 2209 | 2213 | } |
| 2210 | 2214 | center = inverseRotation * center; |
| 2211 | 2215 | glm::vec3 minima(center.x - radius, center.y - radius, center.z - radius); |
| 2212 | − glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius); | |
| 2216 | + glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius); | |
| 2213 | 2217 | |
| 2214 | 2218 | // stretch out our extents in z so that we get all of the avatars |
| 2215 | 2219 | minima.z -= _viewFrustum.getFarClip() * 0.5f; |
| @@ -2230,7 +2234,7 @@ void Application::updateShadowMap() { · 14 unmodified lines | ||
| 2230 | 2234 | _shadowViewFrustum.setEyeOffsetPosition(glm::vec3()); |
| 2231 | 2235 | _shadowViewFrustum.setEyeOffsetOrientation(glm::quat()); |
| 2232 | 2236 | _shadowViewFrustum.calculate(); |
| 2233 | − | |
| 2237 | + | |
| 2234 | 2238 | glMatrixMode(GL_PROJECTION); |
| 2235 | 2239 | glPushMatrix(); |
| 2236 | 2240 | glLoadIdentity(); |
| @@ -2285,19 +2289,19 @@ void Application::setupWorldLight() { · 48 unmodified lines | ||
| 2285 | 2289 | |
| 2286 | 2290 | QImage Application::renderAvatarBillboard() { |
| 2287 | 2291 | _textureCache.getPrimaryFramebufferObject()->bind(); |
| 2288 | − | |
| 2292 | + | |
| 2289 | 2293 | glDisable(GL_BLEND); |
| 2290 | 2294 | |
| 2291 | 2295 | const int BILLBOARD_SIZE = 64; |
| 2292 | 2296 | renderRearViewMirror(QRect(0, _glWidget->height() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true); |
| 2293 | − | |
| 2297 | + | |
| 2294 | 2298 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 2295 | 2299 | glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); |
| 2296 | − | |
| 2300 | + | |
| 2297 | 2301 | glEnable(GL_BLEND); |
| 2298 | − | |
| 2302 | + | |
| 2299 | 2303 | _textureCache.getPrimaryFramebufferObject()->release(); |
| 2300 | − | |
| 2304 | + | |
| 2301 | 2305 | return image; |
| 2302 | 2306 | } |
| 2303 | 2307 | |
| @@ -2398,7 +2402,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 94 unmodified lines | ||
| 2398 | 2402 | "Application::displaySide() ... metavoxels..."); |
| 2399 | 2403 | _metavoxels.render(); |
| 2400 | 2404 | } |
| 2401 | − | |
| 2405 | + | |
| 2402 | 2406 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { |
| 2403 | 2407 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2404 | 2408 | "Application::displaySide() ... bucky balls..."); |
| @@ -2411,7 +2415,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 6 unmodified lines | ||
| 2411 | 2415 | "Application::displaySide() ... particles..."); |
| 2412 | 2416 | _particles.render(); |
| 2413 | 2417 | } |
| 2414 | − | |
| 2418 | + | |
| 2415 | 2419 | // render the ambient occlusion effect if enabled |
| 2416 | 2420 | if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) { |
| 2417 | 2421 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| @@ -2455,7 +2459,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 37 unmodified lines | ||
| 2455 | 2459 | |
| 2456 | 2460 | // give external parties a change to hook in |
| 2457 | 2461 | emit renderingInWorldInterface(); |
| 2458 | − | |
| 2462 | + | |
| 2459 | 2463 | // render JS/scriptable overlays |
| 2460 | 2464 | _overlays.render3D(); |
| 2461 | 2465 | } |
| @@ -2536,8 +2540,8 @@ void Application::displayOverlay() { · 74 unmodified lines | ||
| 2536 | 2540 | char frameTimer[10]; |
| 2537 | 2541 | quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); |
| 2538 | 2542 | sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); |
| 2539 | − int timerBottom = | |
| 2540 | − (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && | |
| 2543 | + int timerBottom = | |
| 2544 | + (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && | |
| 2541 | 2545 | Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) |
| 2542 | 2546 | ? 80 : 20; |
| 2543 | 2547 | drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0.f, frameTimer, WHITE_TEXT); |
| @@ -2552,7 +2556,7 @@ void Application::displayOverlay() { · 8 unmodified lines | ||
| 2552 | 2556 | void Application::displayStatsBackground(unsigned int rgba, int x, int y, int width, int height) { |
| 2553 | 2557 | glBegin(GL_QUADS); |
| 2554 | 2558 | glColor4f(((rgba >> 24) & 0xff) / 255.0f, |
| 2555 | − ((rgba >> 16) & 0xff) / 255.0f, | |
| 2559 | + ((rgba >> 16) & 0xff) / 255.0f, | |
| 2556 | 2560 | ((rgba >> 8) & 0xff) / 255.0f, |
| 2557 | 2561 | (rgba & 0xff) / 255.0f); |
| 2558 | 2562 | glVertex3f(x, y, 0); |
| @@ -2560,7 +2564,7 @@ void Application::displayStatsBackground(unsigned int rgba, int x, int y, int wi · 1 unmodified line | ||
| 2560 | 2564 | glVertex3f(x + width, y + height, 0); |
| 2561 | 2565 | glVertex3f(x , y + height, 0); |
| 2562 | 2566 | glEnd(); |
| 2563 | − glColor4f(1, 1, 1, 1); | |
| 2567 | + glColor4f(1, 1, 1, 1); | |
| 2564 | 2568 | } |
| 2565 | 2569 | |
| 2566 | 2570 | // display expanded or contracted stats |
| @@ -2654,12 +2658,12 @@ void Application::displayStats() { · 87 unmodified lines | ||
| 2654 | 2658 | (float) (_audio.getNetworkBufferLengthSamplesPerChannel() + (float) _audio.getJitterBufferSamples()) / |
| 2655 | 2659 | (float)_audio.getNetworkSampleRate() * 1000.f); |
| 2656 | 2660 | drawText(30, _glWidget->height() - 22, 0.10f, 0.f, 2.f, audioJitter, WHITE_TEXT); |
| 2657 | − | |
| 2658 | − | |
| 2661 | + | |
| 2662 | + | |
| 2659 | 2663 | char audioPing[30]; |
| 2660 | 2664 | sprintf(audioPing, "Audio ping: %d", pingAudio); |
| 2661 | − | |
| 2662 | − | |
| 2665 | + | |
| 2666 | + | |
| 2663 | 2667 | char avatarPing[30]; |
| 2664 | 2668 | sprintf(avatarPing, "Avatar ping: %d", pingAvatar); |
| 2665 | 2669 | char voxelAvgPing[30]; |
| @@ -2697,7 +2701,7 @@ void Application::displayStats() { · 31 unmodified lines | ||
| 2697 | 2701 | } else { |
| 2698 | 2702 | // longhand way |
| 2699 | 2703 | sprintf(avatarPosition, "Position: %.1f, %.1f, %.1f", avatarPos.x, avatarPos.y, avatarPos.z); |
| 2700 | − } | |
| 2704 | + } | |
| 2701 | 2705 | char avatarVelocity[30]; |
| 2702 | 2706 | sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar->getVelocity())); |
| 2703 | 2707 | char avatarBodyYaw[30]; |
| @@ -2723,7 +2727,7 @@ void Application::displayStats() { · 19 unmodified lines | ||
| 2723 | 2727 | |
| 2724 | 2728 | verticalOffset += STATS_PELS_PER_LINE; |
| 2725 | 2729 | drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarMixerStats, WHITE_TEXT); |
| 2726 | − | |
| 2730 | + | |
| 2727 | 2731 | stringstream downloadStats; |
| 2728 | 2732 | downloadStats << "Downloads: "; |
| 2729 | 2733 | foreach (Resource* resource, ResourceCache::getLoadingRequests()) { |
| @@ -2731,7 +2735,7 @@ void Application::displayStats() { · 1 unmodified line | ||
| 2731 | 2735 | downloadStats << roundf(resource->getProgress() * MAXIMUM_PERCENTAGE) << "% "; |
| 2732 | 2736 | } |
| 2733 | 2737 | downloadStats << "(" << ResourceCache::getPendingRequestCount() << " pending)"; |
| 2734 | − | |
| 2738 | + | |
| 2735 | 2739 | verticalOffset += STATS_PELS_PER_LINE; |
| 2736 | 2740 | drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, downloadStats.str().c_str(), WHITE_TEXT); |
| 2737 | 2741 | } |
| @@ -2751,7 +2755,7 @@ void Application::displayStats() { · 13 unmodified lines | ||
| 2751 | 2755 | drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); |
| 2752 | 2756 | |
| 2753 | 2757 | voxelStats.str(""); |
| 2754 | − voxelStats << | |
| 2758 | + voxelStats << | |
| 2755 | 2759 | "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB / " << |
| 2756 | 2760 | "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB"; |
| 2757 | 2761 | if (_voxels.hasVoxelMemoryUsageGPU()) { |
| @@ -2803,7 +2807,7 @@ void Application::displayStats() { · 45 unmodified lines | ||
| 2803 | 2807 | totalNodes += stats.getTotalElements(); |
| 2804 | 2808 | if (_statsExpanded) { |
| 2805 | 2809 | totalInternal += stats.getTotalInternal(); |
| 2806 | − totalLeaves += stats.getTotalLeaves(); | |
| 2810 | + totalLeaves += stats.getTotalLeaves(); | |
| 2807 | 2811 | } |
| 2808 | 2812 | } |
| 2809 | 2813 | if (_statsExpanded) { |
| @@ -2827,7 +2831,7 @@ void Application::displayStats() { · 17 unmodified lines | ||
| 2827 | 2831 | QString packetsString = locale.toString((int)voxelPacketsToProcess); |
| 2828 | 2832 | QString maxString = locale.toString((int)_recentMaxPackets); |
| 2829 | 2833 | voxelStats << "Voxel Packets to Process: " << qPrintable(packetsString) |
| 2830 | − << " [Recent Max: " << qPrintable(maxString) << "]"; | |
| 2834 | + << " [Recent Max: " << qPrintable(maxString) << "]"; | |
| 2831 | 2835 | verticalOffset += STATS_PELS_PER_LINE; |
| 2832 | 2836 | drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT); |
| 2833 | 2837 | } |
| @@ -2989,12 +2993,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 155 unmodified lines | ||
| 2989 | 2993 | _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees |
| 2990 | 2994 | _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 2991 | 2995 | _mirrorCamera.setTargetPosition(_myAvatar->getPosition()); |
| 2992 | − | |
| 2996 | + | |
| 2993 | 2997 | } else if (_rearMirrorTools->getZoomLevel() == BODY) { |
| 2994 | 2998 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 2995 | 2999 | _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); |
| 2996 | 3000 | _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition()); |
| 2997 | − | |
| 3001 | + | |
| 2998 | 3002 | } else { // HEAD zoom level |
| 2999 | 3003 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 3000 | 3004 | _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); |
| @@ -3009,7 +3013,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 8 unmodified lines | ||
| 3009 | 3013 | } |
| 3010 | 3014 | } |
| 3011 | 3015 | _mirrorCamera.setAspectRatio((float)region.width() / region.height()); |
| 3012 | − | |
| 3016 | + | |
| 3013 | 3017 | _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); |
| 3014 | 3018 | _mirrorCamera.update(1.0f/_fps); |
| 3015 | 3019 | |
| @@ -3054,7 +3058,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines | ||
| 3054 | 3058 | if (!billboard) { |
| 3055 | 3059 | _rearMirrorTools->render(false); |
| 3056 | 3060 | } |
| 3057 | − | |
| 3061 | + | |
| 3058 | 3062 | // reset Viewport and projection matrix |
| 3059 | 3063 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); |
| 3060 | 3064 | glDisable(GL_SCISSOR_TEST); |
| @@ -3274,14 +3278,14 @@ void Application::setMenuShortcutsEnabled(bool enabled) { · 213 unmodified lines | ||
| 3274 | 3278 | } |
| 3275 | 3279 | |
| 3276 | 3280 | void Application::updateWindowTitle(){ |
| 3277 | − | |
| 3281 | + | |
| 3278 | 3282 | QString buildVersion = " (build " + applicationVersion() + ")"; |
| 3279 | 3283 | NodeList* nodeList = NodeList::getInstance(); |
| 3280 | − | |
| 3284 | + | |
| 3281 | 3285 | QString username = AccountManager::getInstance().getUsername(); |
| 3282 | 3286 | QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString() |
| 3283 | 3287 | + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion; |
| 3284 | − | |
| 3288 | + | |
| 3285 | 3289 | qDebug("Application title set to: %s", title.toStdString().c_str()); |
| 3286 | 3290 | _window->setWindowTitle(title); |
| 3287 | 3291 | } |
| @@ -3296,7 +3300,7 @@ void Application::domainChanged(const QString& domainHostname) { · 8 unmodified lines | ||
| 3296 | 3300 | _voxelServerJurisdictions.clear(); |
| 3297 | 3301 | _octreeServerSceneStats.clear(); |
| 3298 | 3302 | _particleServerJurisdictions.clear(); |
| 3299 | − | |
| 3303 | + | |
| 3300 | 3304 | // reset the particle renderer |
| 3301 | 3305 | _particles.clear(); |
| 3302 | 3306 | |
| @@ -3306,12 +3310,12 @@ void Application::domainChanged(const QString& domainHostname) { · 3 unmodified lines | ||
| 3306 | 3310 | |
| 3307 | 3311 | void Application::connectedToDomain(const QString& hostname) { |
| 3308 | 3312 | AccountManager& accountManager = AccountManager::getInstance(); |
| 3309 | − | |
| 3313 | + | |
| 3310 | 3314 | if (accountManager.isLoggedIn()) { |
| 3311 | 3315 | // update our domain-server with the data-server we're logged in with |
| 3312 | − | |
| 3316 | + | |
| 3313 | 3317 | QString domainPutJsonString = "{\"address\":{\"domain\":\"" + hostname + "\"}}"; |
| 3314 | − | |
| 3318 | + | |
| 3315 | 3319 | accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation, |
| 3316 | 3320 | JSONCallbackParameters(), domainPutJsonString.toUtf8()); |
| 3317 | 3321 | } |
| @@ -3476,13 +3480,13 @@ void Application::loadScripts() { · 158 unmodified lines | ||
| 3476 | 3480 | // loads all saved scripts |
| 3477 | 3481 | QSettings* settings = new QSettings(this); |
| 3478 | 3482 | int size = settings->beginReadArray("Settings"); |
| 3479 | − | |
| 3483 | + | |
| 3480 | 3484 | for (int i = 0; i < size; ++i){ |
| 3481 | 3485 | settings->setArrayIndex(i); |
| 3482 | 3486 | QString string = settings->value("script").toString(); |
| 3483 | 3487 | loadScript(string); |
| 3484 | 3488 | } |
| 3485 | − | |
| 3489 | + | |
| 3486 | 3490 | settings->endArray(); |
| 3487 | 3491 | } |
| 3488 | 3492 | |
| @@ -3497,42 +3501,72 @@ void Application::saveScripts() { · 8 unmodified lines | ||
| 3497 | 3501 | // saves all current running scripts |
| 3498 | 3502 | QSettings* settings = new QSettings(this); |
| 3499 | 3503 | settings->beginWriteArray("Settings"); |
| 3500 | − for (int i = 0; i < _activeScripts.size(); ++i){ | |
| 3504 | + for (int i = 0; i < getRunningScripts().size(); ++i){ | |
| 3501 | 3505 | settings->setArrayIndex(i); |
| 3502 | − settings->setValue("script", _activeScripts.at(i)); | |
| 3506 | + settings->setValue("script", getRunningScripts().at(i)); | |
| 3503 | 3507 | } |
| 3504 | − | |
| 3508 | + | |
| 3505 | 3509 | settings->endArray(); |
| 3506 | 3510 | } |
| 3507 | 3511 | |
| 3508 | 3512 | void Application::stopAllScripts() { |
| 3509 | 3513 | // stops all current running scripts |
| 3510 | − QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions(); | |
| 3511 | − foreach (QAction* scriptAction, scriptActions) { | |
| 3512 | − scriptAction->activate(QAction::Trigger); | |
| 3513 | − qDebug() << "stopping script..." << scriptAction->text(); | |
| 3514 | + for (int i = 0; i < _scriptEnginesHash.size(); ++i) { | |
| 3515 | + _scriptEnginesHash.values().at(i)->stop(); | |
| 3516 | + qDebug() << "stopping script..." << getRunningScripts().at(i); | |
| 3514 | 3517 | } |
| 3515 | − _activeScripts.clear(); | |
| 3518 | + _scriptEnginesHash.clear(); | |
| 3519 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3520 | +} | |
| 3521 | + | |
| 3522 | +void Application::stopScript(const QString &scriptName) | |
| 3523 | +{ | |
| 3524 | + _scriptEnginesHash.value(scriptName)->stop(); | |
| 3525 | + qDebug() << "stopping script..." << scriptName; | |
| 3526 | + _scriptEnginesHash.remove(scriptName); | |
| 3527 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3516 | 3528 | } |
| 3517 | 3529 | |
| 3518 | 3530 | void Application::reloadAllScripts() { |
| 3519 | 3531 | // remember all the current scripts so we can reload them |
| 3520 | − QStringList reloadList = _activeScripts; | |
| 3532 | + QStringList reloadList = getRunningScripts(); | |
| 3521 | 3533 | // reloads all current running scripts |
| 3522 | − QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions(); | |
| 3523 | − foreach (QAction* scriptAction, scriptActions) { | |
| 3524 | − scriptAction->activate(QAction::Trigger); | |
| 3525 | − qDebug() << "stopping script..." << scriptAction->text(); | |
| 3526 | − } | |
| 3534 | + stopAllScripts(); | |
| 3527 | 3535 | |
| 3528 | − // NOTE: we don't need to clear the _activeScripts list because that is handled on script shutdown. | |
| 3529 | − | |
| 3530 | 3536 | foreach (QString scriptName, reloadList){ |
| 3531 | 3537 | qDebug() << "reloading script..." << scriptName; |
| 3532 | 3538 | loadScript(scriptName); |
| 3533 | 3539 | } |
| 3534 | 3540 | } |
| 3535 | 3541 | |
| 3542 | +void Application::toggleRunningScriptsWidget() | |
| 3543 | +{ | |
| 3544 | + if (!_runningScriptsWidget->toggleViewAction()->isChecked()) { | |
| 3545 | + _runningScriptsWidget->move(_window->geometry().topLeft().x(), _window->geometry().topLeft().y()); | |
| 3546 | + _runningScriptsWidget->resize(0, _window->height()); | |
| 3547 | + _runningScriptsWidget->toggleViewAction()->trigger(); | |
| 3548 | + _runningScriptsWidget->grabKeyboard(); | |
| 3549 | + | |
| 3550 | + QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); | |
| 3551 | + slideAnimation->setStartValue(_runningScriptsWidget->geometry()); | |
| 3552 | + slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), | |
| 3553 | + 310, _runningScriptsWidget->height())); | |
| 3554 | + slideAnimation->setDuration(250); | |
| 3555 | + slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); | |
| 3556 | + } else { | |
| 3557 | + _runningScriptsWidget->releaseKeyboard(); | |
| 3558 | + | |
| 3559 | + QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); | |
| 3560 | + slideAnimation->setStartValue(_runningScriptsWidget->geometry()); | |
| 3561 | + slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), | |
| 3562 | + 0, _runningScriptsWidget->height())); | |
| 3563 | + slideAnimation->setDuration(250); | |
| 3564 | + slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); | |
| 3565 | + | |
| 3566 | + QTimer::singleShot(260, _runningScriptsWidget->toggleViewAction(), SLOT(trigger())); | |
| 3567 | + } | |
| 3568 | +} | |
| 3569 | + | |
| 3536 | 3570 | void Application::uploadFST() { |
| 3537 | 3571 | FstReader reader; |
| 3538 | 3572 | if (reader.zip()) { |
| @@ -3540,29 +3574,17 @@ void Application::uploadFST() { · 1 unmodified line | ||
| 3540 | 3574 | } |
| 3541 | 3575 | } |
| 3542 | 3576 | |
| 3543 | −void Application::removeScriptName(const QString& fileNameString) { | |
| 3544 | − _activeScripts.removeOne(fileNameString); | |
| 3545 | −} | |
| 3546 | − | |
| 3547 | −void Application::cleanupScriptMenuItem(const QString& scriptMenuName) { | |
| 3548 | − Menu::getInstance()->removeAction(Menu::getInstance()->getActiveScriptsMenu(), scriptMenuName); | |
| 3549 | −} | |
| 3550 | − | |
| 3551 | 3577 | void Application::loadScript(const QString& scriptName) { |
| 3552 | 3578 | |
| 3553 | 3579 | // start the script on a new thread... |
| 3554 | − bool wantMenuItems = true; // tells the ScriptEngine object to add menu items for itself | |
| 3555 | − ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), wantMenuItems, &_controllerScriptingInterface); | |
| 3580 | + ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), &_controllerScriptingInterface); | |
| 3581 | + _scriptEnginesHash.insert(scriptName, scriptEngine); | |
| 3556 | 3582 | |
| 3557 | 3583 | if (!scriptEngine->hasScript()) { |
| 3558 | 3584 | qDebug() << "Application::loadScript(), script failed to load..."; |
| 3559 | 3585 | return; |
| 3560 | 3586 | } |
| 3561 | − _activeScripts.append(scriptName); | |
| 3562 | − | |
| 3563 | − // add a stop menu item | |
| 3564 | − Menu::getInstance()->addActionToQMenuAndActionHash(Menu::getInstance()->getActiveScriptsMenu(), | |
| 3565 | − scriptEngine->getScriptMenuName(), 0, scriptEngine, SLOT(stop())); | |
| 3587 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3566 | 3588 | |
| 3567 | 3589 | // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so |
| 3568 | 3590 | // we can use the same ones from the application. |
| @@ -3570,7 +3592,7 @@ void Application::loadScript(const QString& scriptName) { · 1 unmodified line | ||
| 3570 | 3592 | scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree()); |
| 3571 | 3593 | scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender); |
| 3572 | 3594 | scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree()); |
| 3573 | − | |
| 3595 | + | |
| 3574 | 3596 | // hook our avatar object into this script engine |
| 3575 | 3597 | scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features |
| 3576 | 3598 | |
| @@ -3595,8 +3617,6 @@ void Application::loadScript(const QString& scriptName) { · 18 unmodified lines | ||
| 3595 | 3617 | // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue |
| 3596 | 3618 | connect(scriptEngine, SIGNAL(finished(const QString&)), scriptEngine, SLOT(deleteLater())); |
| 3597 | 3619 | connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); |
| 3598 | − connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(removeScriptName(const QString&))); | |
| 3599 | − connect(scriptEngine, SIGNAL(cleanupMenuItem(const QString&)), this, SLOT(cleanupScriptMenuItem(const QString&))); | |
| 3600 | 3620 | |
| 3601 | 3621 | // when the application is about to quit, stop our script engine so it unwinds properly |
| 3602 | 3622 | connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop())); |
| @@ -3620,12 +3640,12 @@ void Application::loadDialog() { · 17 unmodified lines | ||
| 3620 | 3640 | suggestedName = _previousScriptLocation; |
| 3621 | 3641 | } |
| 3622 | 3642 | |
| 3623 | − QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, | |
| 3643 | + QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, | |
| 3624 | 3644 | tr("JavaScript Files (*.js)")); |
| 3625 | 3645 | if (!fileNameString.isEmpty()) { |
| 3626 | 3646 | _previousScriptLocation = fileNameString; |
| 3627 | 3647 | } |
| 3628 | − | |
| 3648 | + | |
| 3629 | 3649 | loadScript(fileNameString); |
| 3630 | 3650 | } |
| 3631 | 3651 | |
| @@ -3636,7 +3656,7 @@ void Application::loadScriptURLDialog() { · 4 unmodified lines | ||
| 3636 | 3656 | scriptURLDialog.setLabelText("Script:"); |
| 3637 | 3657 | scriptURLDialog.setWindowFlags(Qt::Sheet); |
| 3638 | 3658 | const float DIALOG_RATIO_OF_WINDOW = 0.30f; |
| 3639 | − scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, | |
| 3659 | + scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, | |
| 3640 | 3660 | scriptURLDialog.size().height()); |
| 3641 | 3661 | |
| 3642 | 3662 | int dialogReturn = scriptURLDialog.exec(); |
| @@ -3674,29 +3694,29 @@ void Application::checkVersion() { · 31 unmodified lines | ||
| 3674 | 3694 | } |
| 3675 | 3695 | |
| 3676 | 3696 | void Application::parseVersionXml() { |
| 3677 | − | |
| 3697 | + | |
| 3678 | 3698 | #ifdef Q_OS_WIN32 |
| 3679 | 3699 | QString operatingSystem("win"); |
| 3680 | 3700 | #endif |
| 3681 | − | |
| 3701 | + | |
| 3682 | 3702 | #ifdef Q_OS_MAC |
| 3683 | 3703 | QString operatingSystem("mac"); |
| 3684 | 3704 | #endif |
| 3685 | − | |
| 3705 | + | |
| 3686 | 3706 | #ifdef Q_OS_LINUX |
| 3687 | 3707 | QString operatingSystem("ubuntu"); |
| 3688 | 3708 | #endif |
| 3689 | − | |
| 3709 | + | |
| 3690 | 3710 | QString releaseDate; |
| 3691 | 3711 | QString releaseNotes; |
| 3692 | 3712 | QString latestVersion; |
| 3693 | 3713 | QUrl downloadUrl; |
| 3694 | 3714 | QObject* sender = QObject::sender(); |
| 3695 | − | |
| 3715 | + | |
| 3696 | 3716 | QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender)); |
| 3697 | 3717 | while (!xml.atEnd() && !xml.hasError()) { |
| 3698 | 3718 | QXmlStreamReader::TokenType token = xml.readNext(); |
| 3699 | − | |
| 3719 | + | |
| 3700 | 3720 | if (token == QXmlStreamReader::StartElement) { |
| 3701 | 3721 | if (xml.name() == "ReleaseDate") { |
| 3702 | 3722 | xml.readNext(); |