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