History

Added the new Running Scripts widget

Mohammed Nafees committed 12 years ago

Commit d85d4fe1 parent 89cb1ad14 files · +920 −339Browse files

Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all

Unified · Split

interface/src/Application.cpp+170−150
@@ -49,7 +49,7 @@ · 48 unmodified lines
4949 #include <QXmlStreamReader>
5050 #include <QXmlStreamAttributes>
5151 #include <QMediaPlayer>
52−#include <QMimeData>
52+#include <QMimeData>
5353 #include <QMessageBox>
5454
5555 #include <AccountManager.h>
@@ -118,7 +118,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt · 62 unmodified lines
118118 if (message.size() > 0) {
119119 QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);
120120 QString formattedMessage = QString("[%1] %2\n").arg(dateString).arg(message);
121−
121+
122122 fprintf(stdout, "%s", qPrintable(formattedMessage));
123123 Application::getInstance()->getLogger()->addMessage(qPrintable(formattedMessage));
124124 }
@@ -174,23 +174,23 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 49 unmodified lines
174174 {
175175 // read the ApplicationInfo.ini file for Name/Version/Domain information
176176 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
177−
177+
178178 // set the associated application properties
179179 applicationInfo.beginGroup("INFO");
180−
180+
181181 qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
182−
182+
183183 setApplicationName(applicationInfo.value("name").toString());
184184 setApplicationVersion(BUILD_VERSION);
185185 setOrganizationName(applicationInfo.value("organizationName").toString());
186186 setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
187−
187+
188188 QSettings::setDefaultFormat(QSettings::IniFormat);
189−
189+
190190 _myAvatar = _avatarManager.getMyAvatar();
191191
192192 _applicationStartupTime = startup_time;
193−
193+
194194 QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf");
195195 _window->setWindowTitle("Interface");
196196
@@ -205,19 +205,19 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines
205205 if (portStr) {
206206 listenPort = atoi(portStr);
207207 }
208−
208+
209209 // start the nodeThread so its event loop is running
210210 _nodeThread->start();
211−
211+
212212 // make sure the node thread is given highest priority
213213 _nodeThread->setPriority(QThread::TimeCriticalPriority);
214−
214+
215215 // put the NodeList and datagram processing on the node thread
216216 NodeList* nodeList = NodeList::createInstance(NodeType::Agent, listenPort);
217−
217+
218218 nodeList->moveToThread(_nodeThread);
219219 _datagramProcessor.moveToThread(_nodeThread);
220−
220+
221221 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
222222 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));
223223
@@ -239,20 +239,20 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 15 unmodified lines
239239 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));
240240 connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle);
241241 connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset);
242−
242+
243243 // connect to appropriate slots on AccountManager
244244 AccountManager& accountManager = AccountManager::getInstance();
245245 connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain);
246246 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
247−
247+
248248 // set the account manager's root URL and trigger a login request if we don't have the access token
249249 accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL);
250−
250+
251251 // once the event loop has started, check and signal for an access token
252252 QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection);
253253
254254 _settings = new QSettings(this);
255−
255+
256256 // Check to see if the user passed in a command line option for loading a local
257257 // Voxel File.
258258 _voxelsFilename = getCmdOption(argc, constArgv, "-i");
@@ -266,7 +266,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 7 unmodified lines
266266 nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer
267267 << NodeType::VoxelServer << NodeType::ParticleServer
268268 << NodeType::MetavoxelServer);
269−
269+
270270 // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender
271271 connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);
272272 connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent);
@@ -276,7 +276,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines
276276 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
277277 silentNodeTimer->moveToThread(_nodeThread);
278278 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
279−
279+
280280 // send the identity packet for our avatar each second to our avatar mixer
281281 QTimer* identityPacketTimer = new QTimer();
282282 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
@@ -324,14 +324,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 41 unmodified lines
324324
325325 // Set the sixense filtering
326326 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
327−
327+
328328 checkVersion();
329−
329+
330330 _overlays.init(_glWidget); // do this before scripts load
331−
331+
332332 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
333333 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
334334
335+ _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget());
336+ _runningScriptsWidget->setRunningScripts(getRunningScripts());
337+ connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
338+
335339 // check first run...
336340 QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
337341 if (firstRunValue.isValid() && firstRunValue.toBool()) {
@@ -339,7 +343,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 1 unmodified line
339343 // clear the scripts, and set out script to our default scripts
340344 clearScriptsBeforeRunning();
341345 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");
342−
346+
343347 _settings->setValue("firstRun",QVariant(false));
344348 } else {
345349 // 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
350354 Application::~Application() {
351355
352356 qInstallMessageHandler(NULL);
353−
357+
354358 // make sure we don't call the idle timer any more
355359 delete idleTimer;
356−
360+
357361 Menu::getInstance()->saveSettings();
358362 _rearMirrorTools->saveSettings(_settings);
359−
363+
360364 _sharedVoxelSystem.changeTree(new VoxelTree);
361365 if (_voxelImporter) {
362366 _voxelImporter->saveSettings(_settings);
363367 delete _voxelImporter;
364368 }
365369 _settings->sync();
366−
370+
367371 // let the avatar mixer know we're out
368372 MyAvatar::sendKillAvatar();
369−
373+
370374 // ask the datagram processing thread to quit and wait until it is done
371375 _nodeThread->quit();
372376 _nodeThread->wait();
373−
377+
374378 // ask the audio thread to quit and wait until it is done
375379 _audio.thread()->quit();
376380 _audio.thread()->wait();
377−
381+
378382 _voxelProcessor.terminate();
379383 _voxelHideShowThread.terminate();
380384 _voxelEditSender.terminate();
@@ -387,9 +391,9 @@ Application::~Application() { · 6 unmodified lines
387391 Menu::getInstance()->deleteLater();
388392
389393 _myAvatar = NULL;
390−
394+
391395 delete _glWidget;
392−
396+
393397 AccountManager::getInstance().destroy();
394398 }
395399
@@ -581,7 +585,7 @@ void Application::paintGL() { · 185 unmodified lines
581585
582586 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
583587 renderRearViewMirror(_mirrorViewRect);
584−
588+
585589 } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
586590 _rearMirrorTools->render(true);
587591 }
@@ -654,10 +658,10 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 66 unmodified lines
654658 if (type == NodeType::VoxelServer && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
655659 continue;
656660 }
657−
661+
658662 // Perform the broadcast for one type
659663 int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(packet, NodeSet() << type);
660−
664+
661665 // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
662666 BandwidthMeter::ChannelIndex channel;
663667 switch (type) {
@@ -676,7 +680,7 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 12 unmodified lines
676680 }
677681
678682 bool Application::event(QEvent* event) {
679−
683+
680684 // handle custom URL
681685 if (event->type() == QEvent::FileOpen) {
682686 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
@@ -687,11 +691,11 @@ bool Application::event(QEvent* event) { · 4 unmodified lines
687691 if (urlParts.count() > 1) {
688692 // if url has 2 or more parts, the first one is domain name
689693 Menu::getInstance()->goToDomain(urlParts[0]);
690−
694+
691695 // location coordinates
692696 Menu::getInstance()->goToDestination(urlParts[1]);
693697 if (urlParts.count() > 2) {
694−
698+
695699 // location orientation
696700 Menu::getInstance()->goToOrientation(urlParts[2]);
697701 }
@@ -701,7 +705,7 @@ bool Application::event(QEvent* event) { · 3 unmodified lines
701705 Menu::getInstance()->goToDestination(urlParts[0]);
702706 }
703707 }
704−
708+
705709 return false;
706710 }
707711 return QApplication::event(event);
@@ -712,7 +716,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 4 unmodified lines
712716 _keysPressed.insert(event->key());
713717
714718 _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts
715−
719+
716720 // if one of our scripts have asked to capture this event, then stop processing it
717721 if (_controllerScriptingInterface.isKeyCaptured(event)) {
718722 return;
@@ -1071,7 +1075,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 352 unmodified lines
10711075 checkBandwidthMeterClick();
10721076 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
10731077 checkStatsClick();
1074− }
1078+ }
10751079 }
10761080 }
10771081 }
@@ -1120,7 +1124,7 @@ void Application::touchBeginEvent(QTouchEvent* event) { · 42 unmodified lines
11201124 if (_controllerScriptingInterface.isTouchCaptured()) {
11211125 return;
11221126 }
1123−
1127+
11241128 // put any application specific touch behavior below here..
11251129 _lastTouchAvgX = _touchAvgX;
11261130 _lastTouchAvgY = _touchAvgY;
@@ -1163,13 +1167,13 @@ void Application::dropEvent(QDropEvent *event) { · 36 unmodified lines
11631167 break;
11641168 }
11651169 }
1166−
1170+
11671171 SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
11681172 if (snapshotData) {
11691173 if (!snapshotData->getDomain().isEmpty()) {
11701174 Menu::getInstance()->goToDomain(snapshotData->getDomain());
11711175 }
1172−
1176+
11731177 _myAvatar->setPosition(snapshotData->getLocation());
11741178 _myAvatar->setOrientation(snapshotData->getOrientation());
11751179 } else {
@@ -1197,19 +1201,19 @@ void Application::timer() { · 21 unmodified lines
11971201 }
11981202
11991203 _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1200−
1204+
12011205 _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
12021206 _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
12031207 _frameCount = 0;
1204−
1208+
12051209 _datagramProcessor.resetCounters();
12061210
12071211 gettimeofday(&_timerStart, NULL);
12081212
12091213 // ask the node list to check in with the domain server
12101214 NodeList::getInstance()->sendDomainServerCheckIn();
1211−
1212−
1215+
1216+
12131217 }
12141218
12151219 void Application::idle() {
@@ -1246,11 +1250,11 @@ void Application::idle() { · 30 unmodified lines
12461250 _idleLoopMeasuredJitter = _idleLoopStdev.getStDev();
12471251 _idleLoopStdev.reset();
12481252 }
1249−
1253+
12501254 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
12511255 _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());
12521256 }
1253−
1257+
12541258 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
12551259 idleTimer->start(2);
12561260 }
@@ -1382,7 +1386,7 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 125 unmodified lines
13821386 tr("Sparse Voxel Octree Files (*.svo)"));
13831387 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
13841388 const char* fileName = fileNameAscii.data();
1385−
1389+
13861390 VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
13871391 if (selectedNode) {
13881392 VoxelTree exportTree;
@@ -1396,12 +1400,12 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 7 unmodified lines
13961400
13971401 void Application::importVoxels() {
13981402 _importSucceded = false;
1399−
1403+
14001404 if (!_voxelImporter) {
14011405 _voxelImporter = new VoxelImporter(_window);
14021406 _voxelImporter->loadSettings(_settings);
14031407 }
1404−
1408+
14051409 if (!_voxelImporter->exec()) {
14061410 qDebug() << "[DEBUG] Import succeeded." << endl;
14071411 _importSucceded = true;
@@ -1415,7 +1419,7 @@ void Application::importVoxels() { · 7 unmodified lines
14151419
14161420 // restore the main window's active state
14171421 _window->activateWindow();
1418−
1422+
14191423 emit importDone();
14201424 }
14211425
@@ -1471,7 +1475,7 @@ void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { · 49 unmodified lines
14711475 }
14721476
14731477 pasteVoxelsToOctalCode(octalCodeDestination);
1474−
1478+
14751479 if (calculatedOctCode) {
14761480 delete[] calculatedOctCode;
14771481 }
@@ -1508,9 +1512,9 @@ void Application::init() { · 30 unmodified lines
15081512
15091513 // Cleanup of the original shared tree
15101514 _sharedVoxelSystem.init();
1511−
1515+
15121516 _voxelImporter = new VoxelImporter(_window);
1513−
1517+
15141518 _environment.init();
15151519
15161520 _glowEffect.init();
@@ -1552,11 +1556,11 @@ void Application::init() { · 35 unmodified lines
15521556 _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples());
15531557 }
15541558 qDebug("Loaded settings");
1555−
1559+
15561560 // initialize Visage and Faceshift after loading the menu settings
15571561 _faceshift.init();
15581562 _visage.init();
1559−
1563+
15601564 // fire off an immediate domain-server check in now that settings are loaded
15611565 NodeList::getInstance()->sendDomainServerCheckIn();
15621566
@@ -1575,20 +1579,20 @@ void Application::init() { · 12 unmodified lines
15751579 _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_avatarManager);
15761580
15771581 // connect the _particleCollisionSystem to our script engine's ParticleScriptingInterface
1578− connect(&_particleCollisionSystem,
1582+ connect(&_particleCollisionSystem,
15791583 SIGNAL(particleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)),
1580− ScriptEngine::getParticlesScriptingInterface(),
1584+ ScriptEngine::getParticlesScriptingInterface(),
15811585 SLOT(forwardParticleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)));
15821586
1583− connect(&_particleCollisionSystem,
1587+ connect(&_particleCollisionSystem,
15841588 SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)),
1585− ScriptEngine::getParticlesScriptingInterface(),
1589+ ScriptEngine::getParticlesScriptingInterface(),
15861590 SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)));
1587−
1591+
15881592 _audio.init(_glWidget);
15891593
15901594 _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings);
1591−
1595+
15921596 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
15931597 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
15941598 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
@@ -1711,7 +1715,7 @@ void Application::updateMyAvatarLookAtPosition() { · 116 unmodified lines
17111715 float distance = TREE_SCALE;
17121716 if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) {
17131717 distance = glm::distance(_mouseRayOrigin,
1714− static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition());
1718+ static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition());
17151719 }
17161720 const float FIXED_MIN_EYE_DISTANCE = 0.3f;
17171721 float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f :
@@ -1724,7 +1728,7 @@ void Application::updateMyAvatarLookAtPosition() { · 6 unmodified lines
17241728 eyePitch = _faceshift.getEstimatedEyePitch();
17251729 eyeYaw = _faceshift.getEstimatedEyeYaw();
17261730 trackerActive = true;
1727−
1731+
17281732 } else if (_visage.isActive()) {
17291733 eyePitch = _visage.getEstimatedEyePitch();
17301734 eyeYaw = _visage.getEstimatedEyeYaw();
@@ -1907,9 +1911,9 @@ void Application::update(float deltaTime) { · 176 unmodified lines
19071911
19081912 _particles.update(); // update the particles...
19091913 _particleCollisionSystem.update(); // collide the particles...
1910−
1914+
19111915 _overlays.update(deltaTime);
1912−
1916+
19131917 // let external parties know we're updating
19141918 emit simulating(deltaTime);
19151919 }
@@ -1933,7 +1937,7 @@ void Application::updateMyAvatar(float deltaTime) { · 17 unmodified lines
19331937 // actually need to calculate the view frustum planes to send these details
19341938 // to the server.
19351939 loadViewFrustum(_myCamera, _viewFrustum);
1936−
1940+
19371941 // Update my voxel servers with my current voxel query...
19381942 quint64 now = usecTimestampNow();
19391943 quint64 sinceLastQuery = now - _lastQueriedTime;
@@ -2209,7 +2213,7 @@ void Application::updateShadowMap() { · 269 unmodified lines
22092213 }
22102214 center = inverseRotation * center;
22112215 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);
22132217
22142218 // stretch out our extents in z so that we get all of the avatars
22152219 minima.z -= _viewFrustum.getFarClip() * 0.5f;
@@ -2230,7 +2234,7 @@ void Application::updateShadowMap() { · 14 unmodified lines
22302234 _shadowViewFrustum.setEyeOffsetPosition(glm::vec3());
22312235 _shadowViewFrustum.setEyeOffsetOrientation(glm::quat());
22322236 _shadowViewFrustum.calculate();
2233−
2237+
22342238 glMatrixMode(GL_PROJECTION);
22352239 glPushMatrix();
22362240 glLoadIdentity();
@@ -2285,19 +2289,19 @@ void Application::setupWorldLight() { · 48 unmodified lines
22852289
22862290 QImage Application::renderAvatarBillboard() {
22872291 _textureCache.getPrimaryFramebufferObject()->bind();
2288−
2292+
22892293 glDisable(GL_BLEND);
22902294
22912295 const int BILLBOARD_SIZE = 64;
22922296 renderRearViewMirror(QRect(0, _glWidget->height() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true);
2293−
2297+
22942298 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
22952299 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
2296−
2300+
22972301 glEnable(GL_BLEND);
2298−
2302+
22992303 _textureCache.getPrimaryFramebufferObject()->release();
2300−
2304+
23012305 return image;
23022306 }
23032307
@@ -2398,7 +2402,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 94 unmodified lines
23982402 "Application::displaySide() ... metavoxels...");
23992403 _metavoxels.render();
24002404 }
2401−
2405+
24022406 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
24032407 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
24042408 "Application::displaySide() ... bucky balls...");
@@ -2411,7 +2415,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 6 unmodified lines
24112415 "Application::displaySide() ... particles...");
24122416 _particles.render();
24132417 }
2414−
2418+
24152419 // render the ambient occlusion effect if enabled
24162420 if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
24172421 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
@@ -2455,7 +2459,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 37 unmodified lines
24552459
24562460 // give external parties a change to hook in
24572461 emit renderingInWorldInterface();
2458−
2462+
24592463 // render JS/scriptable overlays
24602464 _overlays.render3D();
24612465 }
@@ -2536,8 +2540,8 @@ void Application::displayOverlay() { · 74 unmodified lines
25362540 char frameTimer[10];
25372541 quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
25382542 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
2539− int timerBottom =
2540− (Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
2543+ int timerBottom =
2544+ (Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
25412545 Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
25422546 ? 80 : 20;
25432547 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
25522556 void Application::displayStatsBackground(unsigned int rgba, int x, int y, int width, int height) {
25532557 glBegin(GL_QUADS);
25542558 glColor4f(((rgba >> 24) & 0xff) / 255.0f,
2555− ((rgba >> 16) & 0xff) / 255.0f,
2559+ ((rgba >> 16) & 0xff) / 255.0f,
25562560 ((rgba >> 8) & 0xff) / 255.0f,
25572561 (rgba & 0xff) / 255.0f);
25582562 glVertex3f(x, y, 0);
@@ -2560,7 +2564,7 @@ void Application::displayStatsBackground(unsigned int rgba, int x, int y, int wi · 1 unmodified line
25602564 glVertex3f(x + width, y + height, 0);
25612565 glVertex3f(x , y + height, 0);
25622566 glEnd();
2563− glColor4f(1, 1, 1, 1);
2567+ glColor4f(1, 1, 1, 1);
25642568 }
25652569
25662570 // display expanded or contracted stats
@@ -2654,12 +2658,12 @@ void Application::displayStats() { · 87 unmodified lines
26542658 (float) (_audio.getNetworkBufferLengthSamplesPerChannel() + (float) _audio.getJitterBufferSamples()) /
26552659 (float)_audio.getNetworkSampleRate() * 1000.f);
26562660 drawText(30, _glWidget->height() - 22, 0.10f, 0.f, 2.f, audioJitter, WHITE_TEXT);
2657−
2658−
2661+
2662+
26592663 char audioPing[30];
26602664 sprintf(audioPing, "Audio ping: %d", pingAudio);
2661−
2662−
2665+
2666+
26632667 char avatarPing[30];
26642668 sprintf(avatarPing, "Avatar ping: %d", pingAvatar);
26652669 char voxelAvgPing[30];
@@ -2697,7 +2701,7 @@ void Application::displayStats() { · 31 unmodified lines
26972701 } else {
26982702 // longhand way
26992703 sprintf(avatarPosition, "Position: %.1f, %.1f, %.1f", avatarPos.x, avatarPos.y, avatarPos.z);
2700− }
2704+ }
27012705 char avatarVelocity[30];
27022706 sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar->getVelocity()));
27032707 char avatarBodyYaw[30];
@@ -2723,7 +2727,7 @@ void Application::displayStats() { · 19 unmodified lines
27232727
27242728 verticalOffset += STATS_PELS_PER_LINE;
27252729 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, avatarMixerStats, WHITE_TEXT);
2726−
2730+
27272731 stringstream downloadStats;
27282732 downloadStats << "Downloads: ";
27292733 foreach (Resource* resource, ResourceCache::getLoadingRequests()) {
@@ -2731,7 +2735,7 @@ void Application::displayStats() { · 1 unmodified line
27312735 downloadStats << roundf(resource->getProgress() * MAXIMUM_PERCENTAGE) << "% ";
27322736 }
27332737 downloadStats << "(" << ResourceCache::getPendingRequestCount() << " pending)";
2734−
2738+
27352739 verticalOffset += STATS_PELS_PER_LINE;
27362740 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, downloadStats.str().c_str(), WHITE_TEXT);
27372741 }
@@ -2751,7 +2755,7 @@ void Application::displayStats() { · 13 unmodified lines
27512755 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
27522756
27532757 voxelStats.str("");
2754− voxelStats <<
2758+ voxelStats <<
27552759 "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB / " <<
27562760 "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB";
27572761 if (_voxels.hasVoxelMemoryUsageGPU()) {
@@ -2803,7 +2807,7 @@ void Application::displayStats() { · 45 unmodified lines
28032807 totalNodes += stats.getTotalElements();
28042808 if (_statsExpanded) {
28052809 totalInternal += stats.getTotalInternal();
2806− totalLeaves += stats.getTotalLeaves();
2810+ totalLeaves += stats.getTotalLeaves();
28072811 }
28082812 }
28092813 if (_statsExpanded) {
@@ -2827,7 +2831,7 @@ void Application::displayStats() { · 17 unmodified lines
28272831 QString packetsString = locale.toString((int)voxelPacketsToProcess);
28282832 QString maxString = locale.toString((int)_recentMaxPackets);
28292833 voxelStats << "Voxel Packets to Process: " << qPrintable(packetsString)
2830− << " [Recent Max: " << qPrintable(maxString) << "]";
2834+ << " [Recent Max: " << qPrintable(maxString) << "]";
28312835 verticalOffset += STATS_PELS_PER_LINE;
28322836 drawText(horizontalOffset, verticalOffset, 0.10f, 0.f, 2.f, (char*)voxelStats.str().c_str(), WHITE_TEXT);
28332837 }
@@ -2989,12 +2993,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 155 unmodified lines
29892993 _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees
29902994 _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale());
29912995 _mirrorCamera.setTargetPosition(_myAvatar->getPosition());
2992−
2996+
29932997 } else if (_rearMirrorTools->getZoomLevel() == BODY) {
29942998 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
29952999 _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
29963000 _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition());
2997−
3001+
29983002 } else { // HEAD zoom level
29993003 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
30003004 _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
@@ -3009,7 +3013,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 8 unmodified lines
30093013 }
30103014 }
30113015 _mirrorCamera.setAspectRatio((float)region.width() / region.height());
3012−
3016+
30133017 _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
30143018 _mirrorCamera.update(1.0f/_fps);
30153019
@@ -3054,7 +3058,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines
30543058 if (!billboard) {
30553059 _rearMirrorTools->render(false);
30563060 }
3057−
3061+
30583062 // reset Viewport and projection matrix
30593063 glViewport(0, 0, _glWidget->width(), _glWidget->height());
30603064 glDisable(GL_SCISSOR_TEST);
@@ -3274,14 +3278,14 @@ void Application::setMenuShortcutsEnabled(bool enabled) { · 213 unmodified lines
32743278 }
32753279
32763280 void Application::updateWindowTitle(){
3277−
3281+
32783282 QString buildVersion = " (build " + applicationVersion() + ")";
32793283 NodeList* nodeList = NodeList::getInstance();
3280−
3284+
32813285 QString username = AccountManager::getInstance().getUsername();
32823286 QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString()
32833287 + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion;
3284−
3288+
32853289 qDebug("Application title set to: %s", title.toStdString().c_str());
32863290 _window->setWindowTitle(title);
32873291 }
@@ -3296,7 +3300,7 @@ void Application::domainChanged(const QString& domainHostname) { · 8 unmodified lines
32963300 _voxelServerJurisdictions.clear();
32973301 _octreeServerSceneStats.clear();
32983302 _particleServerJurisdictions.clear();
3299−
3303+
33003304 // reset the particle renderer
33013305 _particles.clear();
33023306
@@ -3306,12 +3310,12 @@ void Application::domainChanged(const QString& domainHostname) { · 3 unmodified lines
33063310
33073311 void Application::connectedToDomain(const QString& hostname) {
33083312 AccountManager& accountManager = AccountManager::getInstance();
3309−
3313+
33103314 if (accountManager.isLoggedIn()) {
33113315 // update our domain-server with the data-server we're logged in with
3312−
3316+
33133317 QString domainPutJsonString = "{\"address\":{\"domain\":\"" + hostname + "\"}}";
3314−
3318+
33153319 accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation,
33163320 JSONCallbackParameters(), domainPutJsonString.toUtf8());
33173321 }
@@ -3476,13 +3480,13 @@ void Application::loadScripts() { · 158 unmodified lines
34763480 // loads all saved scripts
34773481 QSettings* settings = new QSettings(this);
34783482 int size = settings->beginReadArray("Settings");
3479−
3483+
34803484 for (int i = 0; i < size; ++i){
34813485 settings->setArrayIndex(i);
34823486 QString string = settings->value("script").toString();
34833487 loadScript(string);
34843488 }
3485−
3489+
34863490 settings->endArray();
34873491 }
34883492
@@ -3497,42 +3501,72 @@ void Application::saveScripts() { · 8 unmodified lines
34973501 // saves all current running scripts
34983502 QSettings* settings = new QSettings(this);
34993503 settings->beginWriteArray("Settings");
3500− for (int i = 0; i < _activeScripts.size(); ++i){
3504+ for (int i = 0; i < getRunningScripts().size(); ++i){
35013505 settings->setArrayIndex(i);
3502− settings->setValue("script", _activeScripts.at(i));
3506+ settings->setValue("script", getRunningScripts().at(i));
35033507 }
3504−
3508+
35053509 settings->endArray();
35063510 }
35073511
35083512 void Application::stopAllScripts() {
35093513 // stops all current running scripts
3510− QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions();
3511− foreach (QAction* scriptAction, scriptActions) {
3512− scriptAction->activate(QAction::Trigger);
3513− qDebug() << "stopping script..." << scriptAction->text();
3514+ for (int i = 0; i < _scriptEnginesHash.size(); ++i) {
3515+ _scriptEnginesHash.values().at(i)->stop();
3516+ qDebug() << "stopping script..." << getRunningScripts().at(i);
35143517 }
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());
35163528 }
35173529
35183530 void Application::reloadAllScripts() {
35193531 // remember all the current scripts so we can reload them
3520− QStringList reloadList = _activeScripts;
3532+ QStringList reloadList = getRunningScripts();
35213533 // reloads all current running scripts
3522− QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions();
3523− foreach (QAction* scriptAction, scriptActions) {
3524− scriptAction->activate(QAction::Trigger);
3525− qDebug() << "stopping script..." << scriptAction->text();
3526− }
3534+ stopAllScripts();
35273535
3528− // NOTE: we don't need to clear the _activeScripts list because that is handled on script shutdown.
3529−
35303536 foreach (QString scriptName, reloadList){
35313537 qDebug() << "reloading script..." << scriptName;
35323538 loadScript(scriptName);
35333539 }
35343540 }
35353541
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+
35363570 void Application::uploadFST() {
35373571 FstReader reader;
35383572 if (reader.zip()) {
@@ -3540,29 +3574,17 @@ void Application::uploadFST() { · 1 unmodified line
35403574 }
35413575 }
35423576
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−
35513577 void Application::loadScript(const QString& scriptName) {
35523578
35533579 // start the script on a new thread...
3554− bool wantMenuItems = true; // tells the ScriptEngine object to add menu items for itself
3555− ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), wantMenuItems, &_controllerScriptingInterface);
3580+ ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), &_controllerScriptingInterface);
3581+ _scriptEnginesHash.insert(scriptName, scriptEngine);
35563582
35573583 if (!scriptEngine->hasScript()) {
35583584 qDebug() << "Application::loadScript(), script failed to load...";
35593585 return;
35603586 }
3561− _activeScripts.append(scriptName);
3562−
3563− // add a stop menu item
3564− Menu::getInstance()->addActionToQMenuAndActionHash(Menu::getInstance()->getActiveScriptsMenu(),
3565− scriptEngine->getScriptMenuName(), 0, scriptEngine, SLOT(stop()));
3587+ _runningScriptsWidget->setRunningScripts(getRunningScripts());
35663588
35673589 // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
35683590 // we can use the same ones from the application.
@@ -3570,7 +3592,7 @@ void Application::loadScript(const QString& scriptName) { · 1 unmodified line
35703592 scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree());
35713593 scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);
35723594 scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());
3573−
3595+
35743596 // hook our avatar object into this script engine
35753597 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
35763598
@@ -3595,8 +3617,6 @@ void Application::loadScript(const QString& scriptName) { · 18 unmodified lines
35953617 // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue
35963618 connect(scriptEngine, SIGNAL(finished(const QString&)), scriptEngine, SLOT(deleteLater()));
35973619 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&)));
36003620
36013621 // when the application is about to quit, stop our script engine so it unwinds properly
36023622 connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop()));
@@ -3620,12 +3640,12 @@ void Application::loadDialog() { · 17 unmodified lines
36203640 suggestedName = _previousScriptLocation;
36213641 }
36223642
3623− QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName,
3643+ QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName,
36243644 tr("JavaScript Files (*.js)"));
36253645 if (!fileNameString.isEmpty()) {
36263646 _previousScriptLocation = fileNameString;
36273647 }
3628−
3648+
36293649 loadScript(fileNameString);
36303650 }
36313651
@@ -3636,7 +3656,7 @@ void Application::loadScriptURLDialog() { · 4 unmodified lines
36363656 scriptURLDialog.setLabelText("Script:");
36373657 scriptURLDialog.setWindowFlags(Qt::Sheet);
36383658 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,
36403660 scriptURLDialog.size().height());
36413661
36423662 int dialogReturn = scriptURLDialog.exec();
@@ -3674,29 +3694,29 @@ void Application::checkVersion() { · 31 unmodified lines
36743694 }
36753695
36763696 void Application::parseVersionXml() {
3677−
3697+
36783698 #ifdef Q_OS_WIN32
36793699 QString operatingSystem("win");
36803700 #endif
3681−
3701+
36823702 #ifdef Q_OS_MAC
36833703 QString operatingSystem("mac");
36843704 #endif
3685−
3705+
36863706 #ifdef Q_OS_LINUX
36873707 QString operatingSystem("ubuntu");
36883708 #endif
3689−
3709+
36903710 QString releaseDate;
36913711 QString releaseNotes;
36923712 QString latestVersion;
36933713 QUrl downloadUrl;
36943714 QObject* sender = QObject::sender();
3695−
3715+
36963716 QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender));
36973717 while (!xml.atEnd() && !xml.hasError()) {
36983718 QXmlStreamReader::TokenType token = xml.readNext();
3699−
3719+
37003720 if (token == QXmlStreamReader::StartElement) {
37013721 if (xml.name() == "ReleaseDate") {
37023722 xml.readNext();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t