Showing the changes to interface/src/Application.cpp (1 of 29 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> |
| @@ -111,13 +111,11 @@ const float MIRROR_FIELD_OF_VIEW = 30.0f; · 55 unmodified lines | ||
| 111 | 111 | const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml"; |
| 112 | 112 | const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion"; |
| 113 | 113 | |
| 114 | −const QString CUSTOM_URL_SCHEME = "hifi:"; | |
| 115 | − | |
| 116 | 114 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) { |
| 117 | 115 | if (message.size() > 0) { |
| 118 | 116 | QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate); |
| 119 | 117 | QString formattedMessage = QString("[%1] %2\n").arg(dateString).arg(message); |
| 120 | − | |
| 118 | + | |
| 121 | 119 | fprintf(stdout, "%s", qPrintable(formattedMessage)); |
| 122 | 120 | Application::getInstance()->getLogger()->addMessage(qPrintable(formattedMessage)); |
| 123 | 121 | } |
| @@ -165,27 +163,28 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 41 unmodified lines | ||
| 165 | 163 | _voxelHideShowThread(&_voxels), |
| 166 | 164 | _packetsPerSecond(0), |
| 167 | 165 | _bytesPerSecond(0), |
| 166 | + _previousScriptLocation(), | |
| 168 | 167 | _logger(new FileLogger(this)) |
| 169 | 168 | { |
| 170 | 169 | // read the ApplicationInfo.ini file for Name/Version/Domain information |
| 171 | 170 | QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat); |
| 172 | − | |
| 171 | + | |
| 173 | 172 | // set the associated application properties |
| 174 | 173 | applicationInfo.beginGroup("INFO"); |
| 175 | − | |
| 174 | + | |
| 176 | 175 | qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion()); |
| 177 | − | |
| 176 | + | |
| 178 | 177 | setApplicationName(applicationInfo.value("name").toString()); |
| 179 | 178 | setApplicationVersion(BUILD_VERSION); |
| 180 | 179 | setOrganizationName(applicationInfo.value("organizationName").toString()); |
| 181 | 180 | setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); |
| 182 | − | |
| 181 | + | |
| 183 | 182 | QSettings::setDefaultFormat(QSettings::IniFormat); |
| 184 | − | |
| 183 | + | |
| 185 | 184 | _myAvatar = _avatarManager.getMyAvatar(); |
| 186 | 185 | |
| 187 | 186 | _applicationStartupTime = startup_time; |
| 188 | − | |
| 187 | + | |
| 189 | 188 | QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf"); |
| 190 | 189 | _window->setWindowTitle("Interface"); |
| 191 | 190 | |
| @@ -200,19 +199,19 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines | ||
| 200 | 199 | if (portStr) { |
| 201 | 200 | listenPort = atoi(portStr); |
| 202 | 201 | } |
| 203 | − | |
| 202 | + | |
| 204 | 203 | // start the nodeThread so its event loop is running |
| 205 | 204 | _nodeThread->start(); |
| 206 | − | |
| 205 | + | |
| 207 | 206 | // make sure the node thread is given highest priority |
| 208 | 207 | _nodeThread->setPriority(QThread::TimeCriticalPriority); |
| 209 | − | |
| 208 | + | |
| 210 | 209 | // put the NodeList and datagram processing on the node thread |
| 211 | 210 | NodeList* nodeList = NodeList::createInstance(NodeType::Agent, listenPort); |
| 212 | − | |
| 211 | + | |
| 213 | 212 | nodeList->moveToThread(_nodeThread); |
| 214 | 213 | _datagramProcessor.moveToThread(_nodeThread); |
| 215 | − | |
| 214 | + | |
| 216 | 215 | // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal |
| 217 | 216 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams())); |
| 218 | 217 | |
| @@ -234,20 +233,20 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 15 unmodified lines | ||
| 234 | 233 | connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); |
| 235 | 234 | connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle); |
| 236 | 235 | connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset); |
| 237 | − | |
| 236 | + | |
| 238 | 237 | // connect to appropriate slots on AccountManager |
| 239 | 238 | AccountManager& accountManager = AccountManager::getInstance(); |
| 240 | 239 | connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain); |
| 241 | 240 | connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle); |
| 242 | − | |
| 241 | + | |
| 243 | 242 | // set the account manager's root URL and trigger a login request if we don't have the access token |
| 244 | 243 | accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL); |
| 245 | − | |
| 244 | + | |
| 246 | 245 | // once the event loop has started, check and signal for an access token |
| 247 | 246 | QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection); |
| 248 | 247 | |
| 249 | 248 | _settings = new QSettings(this); |
| 250 | − | |
| 249 | + | |
| 251 | 250 | // Check to see if the user passed in a command line option for loading a local |
| 252 | 251 | // Voxel File. |
| 253 | 252 | _voxelsFilename = getCmdOption(argc, constArgv, "-i"); |
| @@ -261,7 +260,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 7 unmodified lines | ||
| 261 | 260 | nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer |
| 262 | 261 | << NodeType::VoxelServer << NodeType::ParticleServer |
| 263 | 262 | << NodeType::MetavoxelServer); |
| 264 | − | |
| 263 | + | |
| 265 | 264 | // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender |
| 266 | 265 | connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent); |
| 267 | 266 | connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent); |
| @@ -271,7 +270,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines | ||
| 271 | 270 | connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); |
| 272 | 271 | silentNodeTimer->moveToThread(_nodeThread); |
| 273 | 272 | silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000); |
| 274 | − | |
| 273 | + | |
| 275 | 274 | // send the identity packet for our avatar each second to our avatar mixer |
| 276 | 275 | QTimer* identityPacketTimer = new QTimer(); |
| 277 | 276 | connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket); |
| @@ -319,14 +318,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 41 unmodified lines | ||
| 319 | 318 | |
| 320 | 319 | // Set the sixense filtering |
| 321 | 320 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 322 | − | |
| 321 | + | |
| 323 | 322 | checkVersion(); |
| 324 | − | |
| 323 | + | |
| 325 | 324 | _overlays.init(_glWidget); // do this before scripts load |
| 326 | − | |
| 325 | + | |
| 327 | 326 | LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree()); |
| 328 | 327 | LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard); |
| 329 | 328 | |
| 329 | + _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget()); | |
| 330 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 331 | + connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); | |
| 332 | + | |
| 330 | 333 | // check first run... |
| 331 | 334 | QVariant firstRunValue = _settings->value("firstRun",QVariant(true)); |
| 332 | 335 | if (firstRunValue.isValid() && firstRunValue.toBool()) { |
| @@ -334,7 +337,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 1 unmodified line | ||
| 334 | 337 | // clear the scripts, and set out script to our default scripts |
| 335 | 338 | clearScriptsBeforeRunning(); |
| 336 | 339 | loadScript("http://public.highfidelity.io/scripts/defaultScripts.js"); |
| 337 | − | |
| 340 | + | |
| 338 | 341 | _settings->setValue("firstRun",QVariant(false)); |
| 339 | 342 | } else { |
| 340 | 343 | // do this as late as possible so that all required subsystems are inialized |
| @@ -345,34 +348,34 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines | ||
| 345 | 348 | Application::~Application() { |
| 346 | 349 | |
| 347 | 350 | qInstallMessageHandler(NULL); |
| 348 | − | |
| 351 | + | |
| 349 | 352 | // make sure we don't call the idle timer any more |
| 350 | 353 | delete idleTimer; |
| 351 | − | |
| 354 | + | |
| 352 | 355 | Menu::getInstance()->saveSettings(); |
| 353 | 356 | _rearMirrorTools->saveSettings(_settings); |
| 354 | − | |
| 357 | + | |
| 355 | 358 | _sharedVoxelSystem.changeTree(new VoxelTree); |
| 356 | 359 | if (_voxelImporter) { |
| 357 | 360 | _voxelImporter->saveSettings(_settings); |
| 358 | 361 | delete _voxelImporter; |
| 359 | 362 | } |
| 360 | 363 | _settings->sync(); |
| 361 | − | |
| 364 | + | |
| 362 | 365 | // let the avatar mixer know we're out |
| 363 | 366 | MyAvatar::sendKillAvatar(); |
| 364 | − | |
| 367 | + | |
| 365 | 368 | // ask the datagram processing thread to quit and wait until it is done |
| 366 | 369 | _nodeThread->quit(); |
| 367 | 370 | _nodeThread->wait(); |
| 368 | − | |
| 371 | + | |
| 369 | 372 | // stop the audio process |
| 370 | 373 | QMetaObject::invokeMethod(&_audio, "stop"); |
| 371 | − | |
| 374 | + | |
| 372 | 375 | // ask the audio thread to quit and wait until it is done |
| 373 | 376 | _audio.thread()->quit(); |
| 374 | 377 | _audio.thread()->wait(); |
| 375 | − | |
| 378 | + | |
| 376 | 379 | _voxelProcessor.terminate(); |
| 377 | 380 | _voxelHideShowThread.terminate(); |
| 378 | 381 | _voxelEditSender.terminate(); |
| @@ -385,9 +388,9 @@ Application::~Application() { · 6 unmodified lines | ||
| 385 | 388 | Menu::getInstance()->deleteLater(); |
| 386 | 389 | |
| 387 | 390 | _myAvatar = NULL; |
| 388 | − | |
| 391 | + | |
| 389 | 392 | delete _glWidget; |
| 390 | − | |
| 393 | + | |
| 391 | 394 | AccountManager::getInstance().destroy(); |
| 392 | 395 | } |
| 393 | 396 | |
| @@ -579,7 +582,7 @@ void Application::paintGL() { · 185 unmodified lines | ||
| 579 | 582 | |
| 580 | 583 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 581 | 584 | renderRearViewMirror(_mirrorViewRect); |
| 582 | − | |
| 585 | + | |
| 583 | 586 | } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) { |
| 584 | 587 | _rearMirrorTools->render(true); |
| 585 | 588 | } |
| @@ -660,10 +663,10 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 74 unmodified lines | ||
| 660 | 663 | if (type == NodeType::VoxelServer && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { |
| 661 | 664 | continue; |
| 662 | 665 | } |
| 663 | − | |
| 666 | + | |
| 664 | 667 | // Perform the broadcast for one type |
| 665 | 668 | int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(packet, NodeSet() << type); |
| 666 | − | |
| 669 | + | |
| 667 | 670 | // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise) |
| 668 | 671 | BandwidthMeter::ChannelIndex channel; |
| 669 | 672 | switch (type) { |
| @@ -682,32 +685,15 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 12 unmodified lines | ||
| 682 | 685 | } |
| 683 | 686 | |
| 684 | 687 | bool Application::event(QEvent* event) { |
| 685 | − | |
| 688 | + | |
| 686 | 689 | // handle custom URL |
| 687 | 690 | if (event->type() == QEvent::FileOpen) { |
| 688 | 691 | QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event); |
| 689 | − if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) { | |
| 690 | − QString destination = fileEvent->url().toLocalFile().remove(CUSTOM_URL_SCHEME); | |
| 691 | − QStringList urlParts = destination.split('/', QString::SkipEmptyParts); | |
| 692 | − | |
| 693 | − if (urlParts.count() > 1) { | |
| 694 | − // if url has 2 or more parts, the first one is domain name | |
| 695 | − Menu::getInstance()->goToDomain(urlParts[0]); | |
| 696 | − | |
| 697 | − // location coordinates | |
| 698 | − Menu::getInstance()->goToDestination(urlParts[1]); | |
| 699 | − if (urlParts.count() > 2) { | |
| 700 | − | |
| 701 | − // location orientation | |
| 702 | − Menu::getInstance()->goToOrientation(urlParts[2]); | |
| 703 | − } | |
| 704 | − } else if (urlParts.count() == 1) { | |
| 705 | − | |
| 706 | − // location coordinates | |
| 707 | − Menu::getInstance()->goToDestination(urlParts[0]); | |
| 708 | − } | |
| 692 | + bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME); | |
| 693 | + if (isHifiSchemeURL) { | |
| 694 | + Menu::getInstance()->goTo(fileEvent->url().toString()); | |
| 709 | 695 | } |
| 710 | − | |
| 696 | + | |
| 711 | 697 | return false; |
| 712 | 698 | } |
| 713 | 699 | return QApplication::event(event); |
| @@ -718,7 +704,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 4 unmodified lines | ||
| 718 | 704 | _keysPressed.insert(event->key()); |
| 719 | 705 | |
| 720 | 706 | _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts |
| 721 | − | |
| 707 | + | |
| 722 | 708 | // if one of our scripts have asked to capture this event, then stop processing it |
| 723 | 709 | if (_controllerScriptingInterface.isKeyCaptured(event)) { |
| 724 | 710 | return; |
| @@ -1130,7 +1116,7 @@ void Application::touchBeginEvent(QTouchEvent* event) { · 405 unmodified lines | ||
| 1130 | 1116 | if (_controllerScriptingInterface.isTouchCaptured()) { |
| 1131 | 1117 | return; |
| 1132 | 1118 | } |
| 1133 | − | |
| 1119 | + | |
| 1134 | 1120 | // put any application specific touch behavior below here.. |
| 1135 | 1121 | _lastTouchAvgX = _touchAvgX; |
| 1136 | 1122 | _lastTouchAvgY = _touchAvgY; |
| @@ -1173,13 +1159,13 @@ void Application::dropEvent(QDropEvent *event) { · 36 unmodified lines | ||
| 1173 | 1159 | break; |
| 1174 | 1160 | } |
| 1175 | 1161 | } |
| 1176 | − | |
| 1162 | + | |
| 1177 | 1163 | SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath); |
| 1178 | 1164 | if (snapshotData) { |
| 1179 | 1165 | if (!snapshotData->getDomain().isEmpty()) { |
| 1180 | 1166 | Menu::getInstance()->goToDomain(snapshotData->getDomain()); |
| 1181 | 1167 | } |
| 1182 | − | |
| 1168 | + | |
| 1183 | 1169 | _myAvatar->setPosition(snapshotData->getLocation()); |
| 1184 | 1170 | _myAvatar->setOrientation(snapshotData->getOrientation()); |
| 1185 | 1171 | } else { |
| @@ -1207,19 +1193,19 @@ void Application::timer() { · 21 unmodified lines | ||
| 1207 | 1193 | } |
| 1208 | 1194 | |
| 1209 | 1195 | _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1210 | − | |
| 1196 | + | |
| 1211 | 1197 | _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1212 | 1198 | _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); |
| 1213 | 1199 | _frameCount = 0; |
| 1214 | − | |
| 1200 | + | |
| 1215 | 1201 | _datagramProcessor.resetCounters(); |
| 1216 | 1202 | |
| 1217 | 1203 | gettimeofday(&_timerStart, NULL); |
| 1218 | 1204 | |
| 1219 | 1205 | // ask the node list to check in with the domain server |
| 1220 | 1206 | NodeList::getInstance()->sendDomainServerCheckIn(); |
| 1221 | − | |
| 1222 | − | |
| 1207 | + | |
| 1208 | + | |
| 1223 | 1209 | } |
| 1224 | 1210 | |
| 1225 | 1211 | void Application::idle() { |
| @@ -1256,11 +1242,11 @@ void Application::idle() { · 30 unmodified lines | ||
| 1256 | 1242 | _idleLoopMeasuredJitter = _idleLoopStdev.getStDev(); |
| 1257 | 1243 | _idleLoopStdev.reset(); |
| 1258 | 1244 | } |
| 1259 | − | |
| 1245 | + | |
| 1260 | 1246 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { |
| 1261 | 1247 | _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); |
| 1262 | 1248 | } |
| 1263 | − | |
| 1249 | + | |
| 1264 | 1250 | // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. |
| 1265 | 1251 | idleTimer->start(2); |
| 1266 | 1252 | } |
| @@ -1392,7 +1378,7 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 125 unmodified lines | ||
| 1392 | 1378 | tr("Sparse Voxel Octree Files (*.svo)")); |
| 1393 | 1379 | QByteArray fileNameAscii = fileNameString.toLocal8Bit(); |
| 1394 | 1380 | const char* fileName = fileNameAscii.data(); |
| 1395 | − | |
| 1381 | + | |
| 1396 | 1382 | VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s); |
| 1397 | 1383 | if (selectedNode) { |
| 1398 | 1384 | VoxelTree exportTree; |
| @@ -1406,12 +1392,12 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 7 unmodified lines | ||
| 1406 | 1392 | |
| 1407 | 1393 | void Application::importVoxels() { |
| 1408 | 1394 | _importSucceded = false; |
| 1409 | − | |
| 1395 | + | |
| 1410 | 1396 | if (!_voxelImporter) { |
| 1411 | 1397 | _voxelImporter = new VoxelImporter(_window); |
| 1412 | 1398 | _voxelImporter->loadSettings(_settings); |
| 1413 | 1399 | } |
| 1414 | − | |
| 1400 | + | |
| 1415 | 1401 | if (!_voxelImporter->exec()) { |
| 1416 | 1402 | qDebug() << "[DEBUG] Import succeeded." << endl; |
| 1417 | 1403 | _importSucceded = true; |
| @@ -1425,7 +1411,7 @@ void Application::importVoxels() { · 7 unmodified lines | ||
| 1425 | 1411 | |
| 1426 | 1412 | // restore the main window's active state |
| 1427 | 1413 | _window->activateWindow(); |
| 1428 | − | |
| 1414 | + | |
| 1429 | 1415 | emit importDone(); |
| 1430 | 1416 | } |
| 1431 | 1417 | |
| @@ -1481,7 +1467,7 @@ void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { · 49 unmodified lines | ||
| 1481 | 1467 | } |
| 1482 | 1468 | |
| 1483 | 1469 | pasteVoxelsToOctalCode(octalCodeDestination); |
| 1484 | − | |
| 1470 | + | |
| 1485 | 1471 | if (calculatedOctCode) { |
| 1486 | 1472 | delete[] calculatedOctCode; |
| 1487 | 1473 | } |
| @@ -1518,9 +1504,9 @@ void Application::init() { · 30 unmodified lines | ||
| 1518 | 1504 | |
| 1519 | 1505 | // Cleanup of the original shared tree |
| 1520 | 1506 | _sharedVoxelSystem.init(); |
| 1521 | − | |
| 1507 | + | |
| 1522 | 1508 | _voxelImporter = new VoxelImporter(_window); |
| 1523 | − | |
| 1509 | + | |
| 1524 | 1510 | _environment.init(); |
| 1525 | 1511 | |
| 1526 | 1512 | _glowEffect.init(); |
| @@ -1562,11 +1548,11 @@ void Application::init() { · 35 unmodified lines | ||
| 1562 | 1548 | _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples()); |
| 1563 | 1549 | } |
| 1564 | 1550 | qDebug("Loaded settings"); |
| 1565 | − | |
| 1551 | + | |
| 1566 | 1552 | // initialize Visage and Faceshift after loading the menu settings |
| 1567 | 1553 | _faceshift.init(); |
| 1568 | 1554 | _visage.init(); |
| 1569 | − | |
| 1555 | + | |
| 1570 | 1556 | // fire off an immediate domain-server check in now that settings are loaded |
| 1571 | 1557 | NodeList::getInstance()->sendDomainServerCheckIn(); |
| 1572 | 1558 | |
| @@ -1585,20 +1571,20 @@ void Application::init() { · 12 unmodified lines | ||
| 1585 | 1571 | _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_avatarManager); |
| 1586 | 1572 | |
| 1587 | 1573 | // connect the _particleCollisionSystem to our script engine's ParticleScriptingInterface |
| 1588 | − connect(&_particleCollisionSystem, | |
| 1574 | + connect(&_particleCollisionSystem, | |
| 1589 | 1575 | SIGNAL(particleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)), |
| 1590 | − ScriptEngine::getParticlesScriptingInterface(), | |
| 1576 | + ScriptEngine::getParticlesScriptingInterface(), | |
| 1591 | 1577 | SLOT(forwardParticleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&))); |
| 1592 | 1578 | |
| 1593 | − connect(&_particleCollisionSystem, | |
| 1579 | + connect(&_particleCollisionSystem, | |
| 1594 | 1580 | SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)), |
| 1595 | − ScriptEngine::getParticlesScriptingInterface(), | |
| 1581 | + ScriptEngine::getParticlesScriptingInterface(), | |
| 1596 | 1582 | SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&))); |
| 1597 | − | |
| 1583 | + | |
| 1598 | 1584 | _audio.init(_glWidget); |
| 1599 | 1585 | |
| 1600 | 1586 | _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings); |
| 1601 | − | |
| 1587 | + | |
| 1602 | 1588 | connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView())); |
| 1603 | 1589 | connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView())); |
| 1604 | 1590 | connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView())); |
| @@ -1721,7 +1707,7 @@ void Application::updateMyAvatarLookAtPosition() { · 116 unmodified lines | ||
| 1721 | 1707 | float distance = TREE_SCALE; |
| 1722 | 1708 | if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) { |
| 1723 | 1709 | distance = glm::distance(_mouseRayOrigin, |
| 1724 | − static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); | |
| 1710 | + static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition()); | |
| 1725 | 1711 | } |
| 1726 | 1712 | const float FIXED_MIN_EYE_DISTANCE = 0.3f; |
| 1727 | 1713 | float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f : |
| @@ -1734,7 +1720,7 @@ void Application::updateMyAvatarLookAtPosition() { · 6 unmodified lines | ||
| 1734 | 1720 | eyePitch = _faceshift.getEstimatedEyePitch(); |
| 1735 | 1721 | eyeYaw = _faceshift.getEstimatedEyeYaw(); |
| 1736 | 1722 | trackerActive = true; |
| 1737 | − | |
| 1723 | + | |
| 1738 | 1724 | } else if (_visage.isActive()) { |
| 1739 | 1725 | eyePitch = _visage.getEstimatedEyePitch(); |
| 1740 | 1726 | eyeYaw = _visage.getEstimatedEyeYaw(); |
| @@ -1907,9 +1893,9 @@ void Application::update(float deltaTime) { · 166 unmodified lines | ||
| 1907 | 1893 | |
| 1908 | 1894 | _particles.update(); // update the particles... |
| 1909 | 1895 | _particleCollisionSystem.update(); // collide the particles... |
| 1910 | − | |
| 1896 | + | |
| 1911 | 1897 | _overlays.update(deltaTime); |
| 1912 | − | |
| 1898 | + | |
| 1913 | 1899 | // let external parties know we're updating |
| 1914 | 1900 | emit simulating(deltaTime); |
| 1915 | 1901 | } |
| @@ -1933,7 +1919,7 @@ void Application::updateMyAvatar(float deltaTime) { · 17 unmodified lines | ||
| 1933 | 1919 | // actually need to calculate the view frustum planes to send these details |
| 1934 | 1920 | // to the server. |
| 1935 | 1921 | loadViewFrustum(_myCamera, _viewFrustum); |
| 1936 | − | |
| 1922 | + | |
| 1937 | 1923 | // Update my voxel servers with my current voxel query... |
| 1938 | 1924 | quint64 now = usecTimestampNow(); |
| 1939 | 1925 | quint64 sinceLastQuery = now - _lastQueriedTime; |
| @@ -2209,7 +2195,7 @@ void Application::updateShadowMap() { · 269 unmodified lines | ||
| 2209 | 2195 | } |
| 2210 | 2196 | center = inverseRotation * center; |
| 2211 | 2197 | 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); | |
| 2198 | + glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius); | |
| 2213 | 2199 | |
| 2214 | 2200 | // stretch out our extents in z so that we get all of the avatars |
| 2215 | 2201 | minima.z -= _viewFrustum.getFarClip() * 0.5f; |
| @@ -2230,7 +2216,7 @@ void Application::updateShadowMap() { · 14 unmodified lines | ||
| 2230 | 2216 | _shadowViewFrustum.setEyeOffsetPosition(glm::vec3()); |
| 2231 | 2217 | _shadowViewFrustum.setEyeOffsetOrientation(glm::quat()); |
| 2232 | 2218 | _shadowViewFrustum.calculate(); |
| 2233 | − | |
| 2219 | + | |
| 2234 | 2220 | glMatrixMode(GL_PROJECTION); |
| 2235 | 2221 | glPushMatrix(); |
| 2236 | 2222 | glLoadIdentity(); |
| @@ -2285,19 +2271,19 @@ void Application::setupWorldLight() { · 48 unmodified lines | ||
| 2285 | 2271 | |
| 2286 | 2272 | QImage Application::renderAvatarBillboard() { |
| 2287 | 2273 | _textureCache.getPrimaryFramebufferObject()->bind(); |
| 2288 | − | |
| 2274 | + | |
| 2289 | 2275 | glDisable(GL_BLEND); |
| 2290 | 2276 | |
| 2291 | 2277 | const int BILLBOARD_SIZE = 64; |
| 2292 | 2278 | renderRearViewMirror(QRect(0, _glWidget->height() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true); |
| 2293 | − | |
| 2279 | + | |
| 2294 | 2280 | QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); |
| 2295 | 2281 | glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); |
| 2296 | − | |
| 2282 | + | |
| 2297 | 2283 | glEnable(GL_BLEND); |
| 2298 | − | |
| 2284 | + | |
| 2299 | 2285 | _textureCache.getPrimaryFramebufferObject()->release(); |
| 2300 | − | |
| 2286 | + | |
| 2301 | 2287 | return image; |
| 2302 | 2288 | } |
| 2303 | 2289 | |
| @@ -2398,7 +2384,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 94 unmodified lines | ||
| 2398 | 2384 | "Application::displaySide() ... metavoxels..."); |
| 2399 | 2385 | _metavoxels.render(); |
| 2400 | 2386 | } |
| 2401 | − | |
| 2387 | + | |
| 2402 | 2388 | if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { |
| 2403 | 2389 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| 2404 | 2390 | "Application::displaySide() ... bucky balls..."); |
| @@ -2411,7 +2397,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 6 unmodified lines | ||
| 2411 | 2397 | "Application::displaySide() ... particles..."); |
| 2412 | 2398 | _particles.render(); |
| 2413 | 2399 | } |
| 2414 | − | |
| 2400 | + | |
| 2415 | 2401 | // render the ambient occlusion effect if enabled |
| 2416 | 2402 | if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) { |
| 2417 | 2403 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), |
| @@ -2455,7 +2441,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 37 unmodified lines | ||
| 2455 | 2441 | |
| 2456 | 2442 | // give external parties a change to hook in |
| 2457 | 2443 | emit renderingInWorldInterface(); |
| 2458 | − | |
| 2444 | + | |
| 2459 | 2445 | // render JS/scriptable overlays |
| 2460 | 2446 | _overlays.render3D(); |
| 2461 | 2447 | } |
| @@ -2504,17 +2490,16 @@ void Application::displayOverlay() { · 42 unmodified lines | ||
| 2504 | 2490 | renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude()); |
| 2505 | 2491 | } |
| 2506 | 2492 | } |
| 2507 | − | |
| 2493 | + | |
| 2508 | 2494 | // Audio Scope |
| 2509 | 2495 | const int AUDIO_SCOPE_Y_OFFSET = 135; |
| 2510 | 2496 | if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { |
| 2511 | − _audio.renderMuteIcon(1, _glWidget->height() - 50); | |
| 2512 | 2497 | if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) { |
| 2513 | 2498 | int oscilloscopeTop = _glWidget->height() - AUDIO_SCOPE_Y_OFFSET; |
| 2514 | 2499 | _audioScope.render(MIRROR_VIEW_LEFT_PADDING, oscilloscopeTop); |
| 2515 | 2500 | } |
| 2516 | 2501 | } |
| 2517 | − | |
| 2502 | + | |
| 2518 | 2503 | // Audio VU Meter and Mute Icon |
| 2519 | 2504 | const int MUTE_ICON_SIZE = 24; |
| 2520 | 2505 | const int AUDIO_METER_INSET = 2; |
| @@ -2523,7 +2508,7 @@ void Application::displayOverlay() { · 2 unmodified lines | ||
| 2523 | 2508 | const int AUDIO_METER_HEIGHT = 8; |
| 2524 | 2509 | const int AUDIO_METER_Y_GAP = 8; |
| 2525 | 2510 | const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_INSET; |
| 2526 | − | |
| 2511 | + | |
| 2527 | 2512 | int audioMeterY; |
| 2528 | 2513 | if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) { |
| 2529 | 2514 | audioMeterY = MIRROR_VIEW_HEIGHT + AUDIO_METER_Y_GAP; |
| @@ -2531,8 +2516,8 @@ void Application::displayOverlay() { · 1 unmodified line | ||
| 2531 | 2516 | audioMeterY = AUDIO_METER_Y_GAP; |
| 2532 | 2517 | } |
| 2533 | 2518 | _audio.renderMuteIcon(MIRROR_VIEW_LEFT_PADDING, audioMeterY); |
| 2534 | − | |
| 2535 | − | |
| 2519 | + | |
| 2520 | + | |
| 2536 | 2521 | const float AUDIO_METER_BLUE[] = {0.0, 0.0, 1.0}; |
| 2537 | 2522 | const float AUDIO_METER_GREEN[] = {0.0, 1.0, 0.0}; |
| 2538 | 2523 | const float AUDIO_METER_RED[] = {1.0, 0.0, 0.0}; |
| @@ -2640,8 +2625,8 @@ void Application::displayOverlay() { · 101 unmodified lines | ||
| 2640 | 2625 | char frameTimer[10]; |
| 2641 | 2626 | quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); |
| 2642 | 2627 | sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000)); |
| 2643 | − int timerBottom = | |
| 2644 | − (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && | |
| 2628 | + int timerBottom = | |
| 2629 | + (Menu::getInstance()->isOptionChecked(MenuOption::Stats) && | |
| 2645 | 2630 | Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) |
| 2646 | 2631 | ? 80 : 20; |
| 2647 | 2632 | drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0.f, frameTimer, WHITE_TEXT); |
| @@ -2684,12 +2669,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 36 unmodified lines | ||
| 2684 | 2669 | _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees |
| 2685 | 2670 | _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale()); |
| 2686 | 2671 | _mirrorCamera.setTargetPosition(_myAvatar->getPosition()); |
| 2687 | − | |
| 2672 | + | |
| 2688 | 2673 | } else if (_rearMirrorTools->getZoomLevel() == BODY) { |
| 2689 | 2674 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 2690 | 2675 | _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale()); |
| 2691 | 2676 | _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition()); |
| 2692 | − | |
| 2677 | + | |
| 2693 | 2678 | } else { // HEAD zoom level |
| 2694 | 2679 | _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees |
| 2695 | 2680 | _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale()); |
| @@ -2704,7 +2689,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 8 unmodified lines | ||
| 2704 | 2689 | } |
| 2705 | 2690 | } |
| 2706 | 2691 | _mirrorCamera.setAspectRatio((float)region.width() / region.height()); |
| 2707 | − | |
| 2692 | + | |
| 2708 | 2693 | _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); |
| 2709 | 2694 | _mirrorCamera.update(1.0f/_fps); |
| 2710 | 2695 | |
| @@ -2749,7 +2734,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines | ||
| 2749 | 2734 | if (!billboard) { |
| 2750 | 2735 | _rearMirrorTools->render(false); |
| 2751 | 2736 | } |
| 2752 | − | |
| 2737 | + | |
| 2753 | 2738 | // reset Viewport and projection matrix |
| 2754 | 2739 | glViewport(0, 0, _glWidget->width(), _glWidget->height()); |
| 2755 | 2740 | glDisable(GL_SCISSOR_TEST); |
| @@ -2969,14 +2954,14 @@ void Application::setMenuShortcutsEnabled(bool enabled) { · 213 unmodified lines | ||
| 2969 | 2954 | } |
| 2970 | 2955 | |
| 2971 | 2956 | void Application::updateWindowTitle(){ |
| 2972 | − | |
| 2957 | + | |
| 2973 | 2958 | QString buildVersion = " (build " + applicationVersion() + ")"; |
| 2974 | 2959 | NodeList* nodeList = NodeList::getInstance(); |
| 2975 | − | |
| 2960 | + | |
| 2976 | 2961 | QString username = AccountManager::getInstance().getUsername(); |
| 2977 | 2962 | QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString() |
| 2978 | 2963 | + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion; |
| 2979 | − | |
| 2964 | + | |
| 2980 | 2965 | qDebug("Application title set to: %s", title.toStdString().c_str()); |
| 2981 | 2966 | _window->setWindowTitle(title); |
| 2982 | 2967 | } |
| @@ -2991,7 +2976,7 @@ void Application::domainChanged(const QString& domainHostname) { · 8 unmodified lines | ||
| 2991 | 2976 | _voxelServerJurisdictions.clear(); |
| 2992 | 2977 | _octreeServerSceneStats.clear(); |
| 2993 | 2978 | _particleServerJurisdictions.clear(); |
| 2994 | − | |
| 2979 | + | |
| 2995 | 2980 | // reset the particle renderer |
| 2996 | 2981 | _particles.clear(); |
| 2997 | 2982 | |
| @@ -3001,12 +2986,12 @@ void Application::domainChanged(const QString& domainHostname) { · 3 unmodified lines | ||
| 3001 | 2986 | |
| 3002 | 2987 | void Application::connectedToDomain(const QString& hostname) { |
| 3003 | 2988 | AccountManager& accountManager = AccountManager::getInstance(); |
| 3004 | − | |
| 2989 | + | |
| 3005 | 2990 | if (accountManager.isLoggedIn()) { |
| 3006 | 2991 | // update our domain-server with the data-server we're logged in with |
| 3007 | − | |
| 2992 | + | |
| 3008 | 2993 | QString domainPutJsonString = "{\"address\":{\"domain\":\"" + hostname + "\"}}"; |
| 3009 | − | |
| 2994 | + | |
| 3010 | 2995 | accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation, |
| 3011 | 2996 | JSONCallbackParameters(), domainPutJsonString.toUtf8()); |
| 3012 | 2997 | } |
| @@ -3171,13 +3156,13 @@ void Application::loadScripts() { · 158 unmodified lines | ||
| 3171 | 3156 | // loads all saved scripts |
| 3172 | 3157 | QSettings* settings = new QSettings(this); |
| 3173 | 3158 | int size = settings->beginReadArray("Settings"); |
| 3174 | − | |
| 3159 | + | |
| 3175 | 3160 | for (int i = 0; i < size; ++i){ |
| 3176 | 3161 | settings->setArrayIndex(i); |
| 3177 | 3162 | QString string = settings->value("script").toString(); |
| 3178 | 3163 | loadScript(string); |
| 3179 | 3164 | } |
| 3180 | − | |
| 3165 | + | |
| 3181 | 3166 | settings->endArray(); |
| 3182 | 3167 | } |
| 3183 | 3168 | |
| @@ -3192,42 +3177,72 @@ void Application::saveScripts() { · 8 unmodified lines | ||
| 3192 | 3177 | // saves all current running scripts |
| 3193 | 3178 | QSettings* settings = new QSettings(this); |
| 3194 | 3179 | settings->beginWriteArray("Settings"); |
| 3195 | − for (int i = 0; i < _activeScripts.size(); ++i){ | |
| 3180 | + for (int i = 0; i < getRunningScripts().size(); ++i){ | |
| 3196 | 3181 | settings->setArrayIndex(i); |
| 3197 | − settings->setValue("script", _activeScripts.at(i)); | |
| 3182 | + settings->setValue("script", getRunningScripts().at(i)); | |
| 3198 | 3183 | } |
| 3199 | − | |
| 3184 | + | |
| 3200 | 3185 | settings->endArray(); |
| 3201 | 3186 | } |
| 3202 | 3187 | |
| 3203 | 3188 | void Application::stopAllScripts() { |
| 3204 | 3189 | // stops all current running scripts |
| 3205 | − QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions(); | |
| 3206 | − foreach (QAction* scriptAction, scriptActions) { | |
| 3207 | − scriptAction->activate(QAction::Trigger); | |
| 3208 | − qDebug() << "stopping script..." << scriptAction->text(); | |
| 3190 | + for (int i = 0; i < _scriptEnginesHash.size(); ++i) { | |
| 3191 | + _scriptEnginesHash.values().at(i)->stop(); | |
| 3192 | + qDebug() << "stopping script..." << getRunningScripts().at(i); | |
| 3209 | 3193 | } |
| 3210 | − _activeScripts.clear(); | |
| 3194 | + _scriptEnginesHash.clear(); | |
| 3195 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3196 | +} | |
| 3197 | + | |
| 3198 | +void Application::stopScript(const QString &scriptName) | |
| 3199 | +{ | |
| 3200 | + _scriptEnginesHash.value(scriptName)->stop(); | |
| 3201 | + qDebug() << "stopping script..." << scriptName; | |
| 3202 | + _scriptEnginesHash.remove(scriptName); | |
| 3203 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3211 | 3204 | } |
| 3212 | 3205 | |
| 3213 | 3206 | void Application::reloadAllScripts() { |
| 3214 | 3207 | // remember all the current scripts so we can reload them |
| 3215 | − QStringList reloadList = _activeScripts; | |
| 3208 | + QStringList reloadList = getRunningScripts(); | |
| 3216 | 3209 | // reloads all current running scripts |
| 3217 | − QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions(); | |
| 3218 | − foreach (QAction* scriptAction, scriptActions) { | |
| 3219 | − scriptAction->activate(QAction::Trigger); | |
| 3220 | − qDebug() << "stopping script..." << scriptAction->text(); | |
| 3221 | − } | |
| 3210 | + stopAllScripts(); | |
| 3222 | 3211 | |
| 3223 | − // NOTE: we don't need to clear the _activeScripts list because that is handled on script shutdown. | |
| 3224 | − | |
| 3225 | 3212 | foreach (QString scriptName, reloadList){ |
| 3226 | 3213 | qDebug() << "reloading script..." << scriptName; |
| 3227 | 3214 | loadScript(scriptName); |
| 3228 | 3215 | } |
| 3229 | 3216 | } |
| 3230 | 3217 | |
| 3218 | +void Application::toggleRunningScriptsWidget() | |
| 3219 | +{ | |
| 3220 | + if (!_runningScriptsWidget->toggleViewAction()->isChecked()) { | |
| 3221 | + _runningScriptsWidget->move(_window->geometry().topLeft().x(), _window->geometry().topLeft().y()); | |
| 3222 | + _runningScriptsWidget->resize(0, _window->height()); | |
| 3223 | + _runningScriptsWidget->toggleViewAction()->trigger(); | |
| 3224 | + _runningScriptsWidget->grabKeyboard(); | |
| 3225 | + | |
| 3226 | + QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); | |
| 3227 | + slideAnimation->setStartValue(_runningScriptsWidget->geometry()); | |
| 3228 | + slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), | |
| 3229 | + 310, _runningScriptsWidget->height())); | |
| 3230 | + slideAnimation->setDuration(250); | |
| 3231 | + slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); | |
| 3232 | + } else { | |
| 3233 | + _runningScriptsWidget->releaseKeyboard(); | |
| 3234 | + | |
| 3235 | + QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget); | |
| 3236 | + slideAnimation->setStartValue(_runningScriptsWidget->geometry()); | |
| 3237 | + slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(), | |
| 3238 | + 0, _runningScriptsWidget->height())); | |
| 3239 | + slideAnimation->setDuration(250); | |
| 3240 | + slideAnimation->start(QAbstractAnimation::DeleteWhenStopped); | |
| 3241 | + | |
| 3242 | + QTimer::singleShot(260, _runningScriptsWidget->toggleViewAction(), SLOT(trigger())); | |
| 3243 | + } | |
| 3244 | +} | |
| 3245 | + | |
| 3231 | 3246 | void Application::uploadFST(bool isHead) { |
| 3232 | 3247 | FstReader reader(isHead); |
| 3233 | 3248 | if (reader.zip()) { |
| @@ -3243,29 +3258,17 @@ void Application::uploadSkeleton() { · 9 unmodified lines | ||
| 3243 | 3258 | uploadFST(false); |
| 3244 | 3259 | } |
| 3245 | 3260 | |
| 3246 | −void Application::removeScriptName(const QString& fileNameString) { | |
| 3247 | − _activeScripts.removeOne(fileNameString); | |
| 3248 | −} | |
| 3249 | − | |
| 3250 | −void Application::cleanupScriptMenuItem(const QString& scriptMenuName) { | |
| 3251 | − Menu::getInstance()->removeAction(Menu::getInstance()->getActiveScriptsMenu(), scriptMenuName); | |
| 3252 | −} | |
| 3253 | − | |
| 3254 | 3261 | void Application::loadScript(const QString& scriptName) { |
| 3255 | 3262 | |
| 3256 | 3263 | // start the script on a new thread... |
| 3257 | − bool wantMenuItems = true; // tells the ScriptEngine object to add menu items for itself | |
| 3258 | − ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), wantMenuItems, &_controllerScriptingInterface); | |
| 3264 | + ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), &_controllerScriptingInterface); | |
| 3265 | + _scriptEnginesHash.insert(scriptName, scriptEngine); | |
| 3259 | 3266 | |
| 3260 | 3267 | if (!scriptEngine->hasScript()) { |
| 3261 | 3268 | qDebug() << "Application::loadScript(), script failed to load..."; |
| 3262 | 3269 | return; |
| 3263 | 3270 | } |
| 3264 | − _activeScripts.append(scriptName); | |
| 3265 | − | |
| 3266 | − // add a stop menu item | |
| 3267 | − Menu::getInstance()->addActionToQMenuAndActionHash(Menu::getInstance()->getActiveScriptsMenu(), | |
| 3268 | − scriptEngine->getScriptMenuName(), 0, scriptEngine, SLOT(stop())); | |
| 3271 | + _runningScriptsWidget->setRunningScripts(getRunningScripts()); | |
| 3269 | 3272 | |
| 3270 | 3273 | // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so |
| 3271 | 3274 | // we can use the same ones from the application. |
| @@ -3273,7 +3276,7 @@ void Application::loadScript(const QString& scriptName) { · 1 unmodified line | ||
| 3273 | 3276 | scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree()); |
| 3274 | 3277 | scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender); |
| 3275 | 3278 | scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree()); |
| 3276 | − | |
| 3279 | + | |
| 3277 | 3280 | // hook our avatar object into this script engine |
| 3278 | 3281 | scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features |
| 3279 | 3282 | |
| @@ -3298,8 +3301,6 @@ void Application::loadScript(const QString& scriptName) { · 18 unmodified lines | ||
| 3298 | 3301 | // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue |
| 3299 | 3302 | connect(scriptEngine, SIGNAL(finished(const QString&)), scriptEngine, SLOT(deleteLater())); |
| 3300 | 3303 | connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); |
| 3301 | − connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(removeScriptName(const QString&))); | |
| 3302 | − connect(scriptEngine, SIGNAL(cleanupMenuItem(const QString&)), this, SLOT(cleanupScriptMenuItem(const QString&))); | |
| 3303 | 3304 | |
| 3304 | 3305 | // when the application is about to quit, stop our script engine so it unwinds properly |
| 3305 | 3306 | connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop())); |
| @@ -3323,12 +3324,12 @@ void Application::loadDialog() { · 17 unmodified lines | ||
| 3323 | 3324 | suggestedName = _previousScriptLocation; |
| 3324 | 3325 | } |
| 3325 | 3326 | |
| 3326 | − QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, | |
| 3327 | + QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName, | |
| 3327 | 3328 | tr("JavaScript Files (*.js)")); |
| 3328 | 3329 | if (!fileNameString.isEmpty()) { |
| 3329 | 3330 | _previousScriptLocation = fileNameString; |
| 3330 | 3331 | } |
| 3331 | − | |
| 3332 | + | |
| 3332 | 3333 | loadScript(fileNameString); |
| 3333 | 3334 | } |
| 3334 | 3335 | |
| @@ -3339,7 +3340,7 @@ void Application::loadScriptURLDialog() { · 4 unmodified lines | ||
| 3339 | 3340 | scriptURLDialog.setLabelText("Script:"); |
| 3340 | 3341 | scriptURLDialog.setWindowFlags(Qt::Sheet); |
| 3341 | 3342 | const float DIALOG_RATIO_OF_WINDOW = 0.30f; |
| 3342 | − scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, | |
| 3343 | + scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, | |
| 3343 | 3344 | scriptURLDialog.size().height()); |
| 3344 | 3345 | |
| 3345 | 3346 | int dialogReturn = scriptURLDialog.exec(); |
| @@ -3377,29 +3378,29 @@ void Application::checkVersion() { · 31 unmodified lines | ||
| 3377 | 3378 | } |
| 3378 | 3379 | |
| 3379 | 3380 | void Application::parseVersionXml() { |
| 3380 | − | |
| 3381 | + | |
| 3381 | 3382 | #ifdef Q_OS_WIN32 |
| 3382 | 3383 | QString operatingSystem("win"); |
| 3383 | 3384 | #endif |
| 3384 | − | |
| 3385 | + | |
| 3385 | 3386 | #ifdef Q_OS_MAC |
| 3386 | 3387 | QString operatingSystem("mac"); |
| 3387 | 3388 | #endif |
| 3388 | − | |
| 3389 | + | |
| 3389 | 3390 | #ifdef Q_OS_LINUX |
| 3390 | 3391 | QString operatingSystem("ubuntu"); |
| 3391 | 3392 | #endif |
| 3392 | − | |
| 3393 | + | |
| 3393 | 3394 | QString releaseDate; |
| 3394 | 3395 | QString releaseNotes; |
| 3395 | 3396 | QString latestVersion; |
| 3396 | 3397 | QUrl downloadUrl; |
| 3397 | 3398 | QObject* sender = QObject::sender(); |
| 3398 | − | |
| 3399 | + | |
| 3399 | 3400 | QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender)); |
| 3400 | 3401 | while (!xml.atEnd() && !xml.hasError()) { |
| 3401 | 3402 | QXmlStreamReader::TokenType token = xml.readNext(); |
| 3402 | − | |
| 3403 | + | |
| 3403 | 3404 | if (token == QXmlStreamReader::StartElement) { |
| 3404 | 3405 | if (xml.name() == "ReleaseDate") { |
| 3405 | 3406 | xml.readNext(); |