History

Merge branch 'master' of git://github.com/worklist/hifi into 19498

Lucas Crisman committed 12 years ago

Commit 793179d2 parents 76921d9 cc1993629 files · +1408 −619Browse files

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

Unified · Split

interface/src/Application.cpp+165−164
@@ -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>
@@ -111,13 +111,11 @@ const float MIRROR_FIELD_OF_VIEW = 30.0f; · 55 unmodified lines
111111 const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";
112112 const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
113113
114−const QString CUSTOM_URL_SCHEME = "hifi:";
115−
116114 void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
117115 if (message.size() > 0) {
118116 QString dateString = QDateTime::currentDateTime().toTimeSpec(Qt::LocalTime).toString(Qt::ISODate);
119117 QString formattedMessage = QString("[%1] %2\n").arg(dateString).arg(message);
120−
118+
121119 fprintf(stdout, "%s", qPrintable(formattedMessage));
122120 Application::getInstance()->getLogger()->addMessage(qPrintable(formattedMessage));
123121 }
@@ -165,27 +163,28 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 41 unmodified lines
165163 _voxelHideShowThread(&_voxels),
166164 _packetsPerSecond(0),
167165 _bytesPerSecond(0),
166+ _previousScriptLocation(),
168167 _logger(new FileLogger(this))
169168 {
170169 // read the ApplicationInfo.ini file for Name/Version/Domain information
171170 QSettings applicationInfo(Application::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
172−
171+
173172 // set the associated application properties
174173 applicationInfo.beginGroup("INFO");
175−
174+
176175 qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
177−
176+
178177 setApplicationName(applicationInfo.value("name").toString());
179178 setApplicationVersion(BUILD_VERSION);
180179 setOrganizationName(applicationInfo.value("organizationName").toString());
181180 setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
182−
181+
183182 QSettings::setDefaultFormat(QSettings::IniFormat);
184−
183+
185184 _myAvatar = _avatarManager.getMyAvatar();
186185
187186 _applicationStartupTime = startup_time;
188−
187+
189188 QFontDatabase::addApplicationFont(Application::resourcesPath() + "styles/Inconsolata.otf");
190189 _window->setWindowTitle("Interface");
191190
@@ -200,19 +199,19 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 8 unmodified lines
200199 if (portStr) {
201200 listenPort = atoi(portStr);
202201 }
203−
202+
204203 // start the nodeThread so its event loop is running
205204 _nodeThread->start();
206−
205+
207206 // make sure the node thread is given highest priority
208207 _nodeThread->setPriority(QThread::TimeCriticalPriority);
209−
208+
210209 // put the NodeList and datagram processing on the node thread
211210 NodeList* nodeList = NodeList::createInstance(NodeType::Agent, listenPort);
212−
211+
213212 nodeList->moveToThread(_nodeThread);
214213 _datagramProcessor.moveToThread(_nodeThread);
215−
214+
216215 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
217216 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));
218217
@@ -234,20 +233,20 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 15 unmodified lines
234233 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));
235234 connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle);
236235 connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset);
237−
236+
238237 // connect to appropriate slots on AccountManager
239238 AccountManager& accountManager = AccountManager::getInstance();
240239 connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain);
241240 connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
242−
241+
243242 // set the account manager's root URL and trigger a login request if we don't have the access token
244243 accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL);
245−
244+
246245 // once the event loop has started, check and signal for an access token
247246 QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection);
248247
249248 _settings = new QSettings(this);
250−
249+
251250 // Check to see if the user passed in a command line option for loading a local
252251 // Voxel File.
253252 _voxelsFilename = getCmdOption(argc, constArgv, "-i");
@@ -261,7 +260,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 7 unmodified lines
261260 nodeList->addSetOfNodeTypesToNodeInterestSet(NodeSet() << NodeType::AudioMixer << NodeType::AvatarMixer
262261 << NodeType::VoxelServer << NodeType::ParticleServer
263262 << NodeType::MetavoxelServer);
264−
263+
265264 // connect to the packet sent signal of the _voxelEditSender and the _particleEditSender
266265 connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);
267266 connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent);
@@ -271,7 +270,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 3 unmodified lines
271270 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
272271 silentNodeTimer->moveToThread(_nodeThread);
273272 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
274−
273+
275274 // send the identity packet for our avatar each second to our avatar mixer
276275 QTimer* identityPacketTimer = new QTimer();
277276 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
@@ -319,14 +318,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 41 unmodified lines
319318
320319 // Set the sixense filtering
321320 _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
322−
321+
323322 checkVersion();
324−
323+
325324 _overlays.init(_glWidget); // do this before scripts load
326−
325+
327326 LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
328327 LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
329328
329+ _window->addDockWidget(Qt::NoDockWidgetArea, _runningScriptsWidget = new RunningScriptsWidget());
330+ _runningScriptsWidget->setRunningScripts(getRunningScripts());
331+ connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript);
332+
330333 // check first run...
331334 QVariant firstRunValue = _settings->value("firstRun",QVariant(true));
332335 if (firstRunValue.isValid() && firstRunValue.toBool()) {
@@ -334,7 +337,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 1 unmodified line
334337 // clear the scripts, and set out script to our default scripts
335338 clearScriptsBeforeRunning();
336339 loadScript("http://public.highfidelity.io/scripts/defaultScripts.js");
337−
340+
338341 _settings->setValue("firstRun",QVariant(false));
339342 } else {
340343 // do this as late as possible so that all required subsystems are inialized
@@ -345,34 +348,34 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 4 unmodified lines
345348 Application::~Application() {
346349
347350 qInstallMessageHandler(NULL);
348−
351+
349352 // make sure we don't call the idle timer any more
350353 delete idleTimer;
351−
354+
352355 Menu::getInstance()->saveSettings();
353356 _rearMirrorTools->saveSettings(_settings);
354−
357+
355358 _sharedVoxelSystem.changeTree(new VoxelTree);
356359 if (_voxelImporter) {
357360 _voxelImporter->saveSettings(_settings);
358361 delete _voxelImporter;
359362 }
360363 _settings->sync();
361−
364+
362365 // let the avatar mixer know we're out
363366 MyAvatar::sendKillAvatar();
364−
367+
365368 // ask the datagram processing thread to quit and wait until it is done
366369 _nodeThread->quit();
367370 _nodeThread->wait();
368−
371+
369372 // stop the audio process
370373 QMetaObject::invokeMethod(&_audio, "stop");
371−
374+
372375 // ask the audio thread to quit and wait until it is done
373376 _audio.thread()->quit();
374377 _audio.thread()->wait();
375−
378+
376379 _voxelProcessor.terminate();
377380 _voxelHideShowThread.terminate();
378381 _voxelEditSender.terminate();
@@ -385,9 +388,9 @@ Application::~Application() { · 6 unmodified lines
385388 Menu::getInstance()->deleteLater();
386389
387390 _myAvatar = NULL;
388−
391+
389392 delete _glWidget;
390−
393+
391394 AccountManager::getInstance().destroy();
392395 }
393396
@@ -579,7 +582,7 @@ void Application::paintGL() { · 185 unmodified lines
579582
580583 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
581584 renderRearViewMirror(_mirrorViewRect);
582−
585+
583586 } else if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
584587 _rearMirrorTools->render(true);
585588 }
@@ -660,10 +663,10 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 74 unmodified lines
660663 if (type == NodeType::VoxelServer && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
661664 continue;
662665 }
663−
666+
664667 // Perform the broadcast for one type
665668 int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(packet, NodeSet() << type);
666−
669+
667670 // Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
668671 BandwidthMeter::ChannelIndex channel;
669672 switch (type) {
@@ -682,32 +685,15 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod · 12 unmodified lines
682685 }
683686
684687 bool Application::event(QEvent* event) {
685−
688+
686689 // handle custom URL
687690 if (event->type() == QEvent::FileOpen) {
688691 QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
689− if (!fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME)) {
690− QString destination = fileEvent->url().toLocalFile().remove(CUSTOM_URL_SCHEME);
691− QStringList urlParts = destination.split('/', QString::SkipEmptyParts);
692−
693− if (urlParts.count() > 1) {
694− // if url has 2 or more parts, the first one is domain name
695− Menu::getInstance()->goToDomain(urlParts[0]);
696−
697− // location coordinates
698− Menu::getInstance()->goToDestination(urlParts[1]);
699− if (urlParts.count() > 2) {
700−
701− // location orientation
702− Menu::getInstance()->goToOrientation(urlParts[2]);
703− }
704− } else if (urlParts.count() == 1) {
705−
706− // location coordinates
707− Menu::getInstance()->goToDestination(urlParts[0]);
708− }
692+ bool isHifiSchemeURL = !fileEvent->url().isEmpty() && fileEvent->url().toLocalFile().startsWith(CUSTOM_URL_SCHEME);
693+ if (isHifiSchemeURL) {
694+ Menu::getInstance()->goTo(fileEvent->url().toString());
709695 }
710−
696+
711697 return false;
712698 }
713699 return QApplication::event(event);
@@ -718,7 +704,7 @@ void Application::keyPressEvent(QKeyEvent* event) { · 4 unmodified lines
718704 _keysPressed.insert(event->key());
719705
720706 _controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts
721−
707+
722708 // if one of our scripts have asked to capture this event, then stop processing it
723709 if (_controllerScriptingInterface.isKeyCaptured(event)) {
724710 return;
@@ -1130,7 +1116,7 @@ void Application::touchBeginEvent(QTouchEvent* event) { · 405 unmodified lines
11301116 if (_controllerScriptingInterface.isTouchCaptured()) {
11311117 return;
11321118 }
1133−
1119+
11341120 // put any application specific touch behavior below here..
11351121 _lastTouchAvgX = _touchAvgX;
11361122 _lastTouchAvgY = _touchAvgY;
@@ -1173,13 +1159,13 @@ void Application::dropEvent(QDropEvent *event) { · 36 unmodified lines
11731159 break;
11741160 }
11751161 }
1176−
1162+
11771163 SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
11781164 if (snapshotData) {
11791165 if (!snapshotData->getDomain().isEmpty()) {
11801166 Menu::getInstance()->goToDomain(snapshotData->getDomain());
11811167 }
1182−
1168+
11831169 _myAvatar->setPosition(snapshotData->getLocation());
11841170 _myAvatar->setOrientation(snapshotData->getOrientation());
11851171 } else {
@@ -1207,19 +1193,19 @@ void Application::timer() { · 21 unmodified lines
12071193 }
12081194
12091195 _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1210−
1196+
12111197 _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
12121198 _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
12131199 _frameCount = 0;
1214−
1200+
12151201 _datagramProcessor.resetCounters();
12161202
12171203 gettimeofday(&_timerStart, NULL);
12181204
12191205 // ask the node list to check in with the domain server
12201206 NodeList::getInstance()->sendDomainServerCheckIn();
1221−
1222−
1207+
1208+
12231209 }
12241210
12251211 void Application::idle() {
@@ -1256,11 +1242,11 @@ void Application::idle() { · 30 unmodified lines
12561242 _idleLoopMeasuredJitter = _idleLoopStdev.getStDev();
12571243 _idleLoopStdev.reset();
12581244 }
1259−
1245+
12601246 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
12611247 _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());
12621248 }
1263−
1249+
12641250 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
12651251 idleTimer->start(2);
12661252 }
@@ -1392,7 +1378,7 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 125 unmodified lines
13921378 tr("Sparse Voxel Octree Files (*.svo)"));
13931379 QByteArray fileNameAscii = fileNameString.toLocal8Bit();
13941380 const char* fileName = fileNameAscii.data();
1395−
1381+
13961382 VoxelTreeElement* selectedNode = _voxels.getTree()->getVoxelAt(sourceVoxel.x, sourceVoxel.y, sourceVoxel.z, sourceVoxel.s);
13971383 if (selectedNode) {
13981384 VoxelTree exportTree;
@@ -1406,12 +1392,12 @@ void Application::exportVoxels(const VoxelDetail& sourceVoxel) { · 7 unmodified lines
14061392
14071393 void Application::importVoxels() {
14081394 _importSucceded = false;
1409−
1395+
14101396 if (!_voxelImporter) {
14111397 _voxelImporter = new VoxelImporter(_window);
14121398 _voxelImporter->loadSettings(_settings);
14131399 }
1414−
1400+
14151401 if (!_voxelImporter->exec()) {
14161402 qDebug() << "[DEBUG] Import succeeded." << endl;
14171403 _importSucceded = true;
@@ -1425,7 +1411,7 @@ void Application::importVoxels() { · 7 unmodified lines
14251411
14261412 // restore the main window's active state
14271413 _window->activateWindow();
1428−
1414+
14291415 emit importDone();
14301416 }
14311417
@@ -1481,7 +1467,7 @@ void Application::pasteVoxels(const VoxelDetail& sourceVoxel) { · 49 unmodified lines
14811467 }
14821468
14831469 pasteVoxelsToOctalCode(octalCodeDestination);
1484−
1470+
14851471 if (calculatedOctCode) {
14861472 delete[] calculatedOctCode;
14871473 }
@@ -1518,9 +1504,9 @@ void Application::init() { · 30 unmodified lines
15181504
15191505 // Cleanup of the original shared tree
15201506 _sharedVoxelSystem.init();
1521−
1507+
15221508 _voxelImporter = new VoxelImporter(_window);
1523−
1509+
15241510 _environment.init();
15251511
15261512 _glowEffect.init();
@@ -1562,11 +1548,11 @@ void Application::init() { · 35 unmodified lines
15621548 _audio.setJitterBufferSamples(Menu::getInstance()->getAudioJitterBufferSamples());
15631549 }
15641550 qDebug("Loaded settings");
1565−
1551+
15661552 // initialize Visage and Faceshift after loading the menu settings
15671553 _faceshift.init();
15681554 _visage.init();
1569−
1555+
15701556 // fire off an immediate domain-server check in now that settings are loaded
15711557 NodeList::getInstance()->sendDomainServerCheckIn();
15721558
@@ -1585,20 +1571,20 @@ void Application::init() { · 12 unmodified lines
15851571 _particleCollisionSystem.init(&_particleEditSender, _particles.getTree(), _voxels.getTree(), &_audio, &_avatarManager);
15861572
15871573 // connect the _particleCollisionSystem to our script engine's ParticleScriptingInterface
1588− connect(&_particleCollisionSystem,
1574+ connect(&_particleCollisionSystem,
15891575 SIGNAL(particleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)),
1590− ScriptEngine::getParticlesScriptingInterface(),
1576+ ScriptEngine::getParticlesScriptingInterface(),
15911577 SLOT(forwardParticleCollisionWithVoxel(const ParticleID&, const VoxelDetail&, const glm::vec3&)));
15921578
1593− connect(&_particleCollisionSystem,
1579+ connect(&_particleCollisionSystem,
15941580 SIGNAL(particleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)),
1595− ScriptEngine::getParticlesScriptingInterface(),
1581+ ScriptEngine::getParticlesScriptingInterface(),
15961582 SLOT(forwardParticleCollisionWithParticle(const ParticleID&, const ParticleID&, const glm::vec3&)));
1597−
1583+
15981584 _audio.init(_glWidget);
15991585
16001586 _rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect, _settings);
1601−
1587+
16021588 connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
16031589 connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
16041590 connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
@@ -1721,7 +1707,7 @@ void Application::updateMyAvatarLookAtPosition() { · 116 unmodified lines
17211707 float distance = TREE_SCALE;
17221708 if (_myAvatar->getLookAtTargetAvatar() && _myAvatar != _myAvatar->getLookAtTargetAvatar()) {
17231709 distance = glm::distance(_mouseRayOrigin,
1724− static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition());
1710+ static_cast<Avatar*>(_myAvatar->getLookAtTargetAvatar())->getHead()->calculateAverageEyePosition());
17251711 }
17261712 const float FIXED_MIN_EYE_DISTANCE = 0.3f;
17271713 float minEyeDistance = FIXED_MIN_EYE_DISTANCE + (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON ? 0.0f :
@@ -1734,7 +1720,7 @@ void Application::updateMyAvatarLookAtPosition() { · 6 unmodified lines
17341720 eyePitch = _faceshift.getEstimatedEyePitch();
17351721 eyeYaw = _faceshift.getEstimatedEyeYaw();
17361722 trackerActive = true;
1737−
1723+
17381724 } else if (_visage.isActive()) {
17391725 eyePitch = _visage.getEstimatedEyePitch();
17401726 eyeYaw = _visage.getEstimatedEyeYaw();
@@ -1907,9 +1893,9 @@ void Application::update(float deltaTime) { · 166 unmodified lines
19071893
19081894 _particles.update(); // update the particles...
19091895 _particleCollisionSystem.update(); // collide the particles...
1910−
1896+
19111897 _overlays.update(deltaTime);
1912−
1898+
19131899 // let external parties know we're updating
19141900 emit simulating(deltaTime);
19151901 }
@@ -1933,7 +1919,7 @@ void Application::updateMyAvatar(float deltaTime) { · 17 unmodified lines
19331919 // actually need to calculate the view frustum planes to send these details
19341920 // to the server.
19351921 loadViewFrustum(_myCamera, _viewFrustum);
1936−
1922+
19371923 // Update my voxel servers with my current voxel query...
19381924 quint64 now = usecTimestampNow();
19391925 quint64 sinceLastQuery = now - _lastQueriedTime;
@@ -2209,7 +2195,7 @@ void Application::updateShadowMap() { · 269 unmodified lines
22092195 }
22102196 center = inverseRotation * center;
22112197 glm::vec3 minima(center.x - radius, center.y - radius, center.z - radius);
2212− glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius);
2198+ glm::vec3 maxima(center.x + radius, center.y + radius, center.z + radius);
22132199
22142200 // stretch out our extents in z so that we get all of the avatars
22152201 minima.z -= _viewFrustum.getFarClip() * 0.5f;
@@ -2230,7 +2216,7 @@ void Application::updateShadowMap() { · 14 unmodified lines
22302216 _shadowViewFrustum.setEyeOffsetPosition(glm::vec3());
22312217 _shadowViewFrustum.setEyeOffsetOrientation(glm::quat());
22322218 _shadowViewFrustum.calculate();
2233−
2219+
22342220 glMatrixMode(GL_PROJECTION);
22352221 glPushMatrix();
22362222 glLoadIdentity();
@@ -2285,19 +2271,19 @@ void Application::setupWorldLight() { · 48 unmodified lines
22852271
22862272 QImage Application::renderAvatarBillboard() {
22872273 _textureCache.getPrimaryFramebufferObject()->bind();
2288−
2274+
22892275 glDisable(GL_BLEND);
22902276
22912277 const int BILLBOARD_SIZE = 64;
22922278 renderRearViewMirror(QRect(0, _glWidget->height() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true);
2293−
2279+
22942280 QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
22952281 glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
2296−
2282+
22972283 glEnable(GL_BLEND);
2298−
2284+
22992285 _textureCache.getPrimaryFramebufferObject()->release();
2300−
2286+
23012287 return image;
23022288 }
23032289
@@ -2398,7 +2384,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 94 unmodified lines
23982384 "Application::displaySide() ... metavoxels...");
23992385 _metavoxels.render();
24002386 }
2401−
2387+
24022388 if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
24032389 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
24042390 "Application::displaySide() ... bucky balls...");
@@ -2411,7 +2397,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 6 unmodified lines
24112397 "Application::displaySide() ... particles...");
24122398 _particles.render();
24132399 }
2414−
2400+
24152401 // render the ambient occlusion effect if enabled
24162402 if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
24172403 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
@@ -2455,7 +2441,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 37 unmodified lines
24552441
24562442 // give external parties a change to hook in
24572443 emit renderingInWorldInterface();
2458−
2444+
24592445 // render JS/scriptable overlays
24602446 _overlays.render3D();
24612447 }
@@ -2504,17 +2490,16 @@ void Application::displayOverlay() { · 42 unmodified lines
25042490 renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude());
25052491 }
25062492 }
2507−
2493+
25082494 // Audio Scope
25092495 const int AUDIO_SCOPE_Y_OFFSET = 135;
25102496 if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
2511− _audio.renderMuteIcon(1, _glWidget->height() - 50);
25122497 if (Menu::getInstance()->isOptionChecked(MenuOption::Oscilloscope)) {
25132498 int oscilloscopeTop = _glWidget->height() - AUDIO_SCOPE_Y_OFFSET;
25142499 _audioScope.render(MIRROR_VIEW_LEFT_PADDING, oscilloscopeTop);
25152500 }
25162501 }
2517−
2502+
25182503 // Audio VU Meter and Mute Icon
25192504 const int MUTE_ICON_SIZE = 24;
25202505 const int AUDIO_METER_INSET = 2;
@@ -2523,7 +2508,7 @@ void Application::displayOverlay() { · 2 unmodified lines
25232508 const int AUDIO_METER_HEIGHT = 8;
25242509 const int AUDIO_METER_Y_GAP = 8;
25252510 const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_INSET;
2526−
2511+
25272512 int audioMeterY;
25282513 if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
25292514 audioMeterY = MIRROR_VIEW_HEIGHT + AUDIO_METER_Y_GAP;
@@ -2531,8 +2516,8 @@ void Application::displayOverlay() { · 1 unmodified line
25312516 audioMeterY = AUDIO_METER_Y_GAP;
25322517 }
25332518 _audio.renderMuteIcon(MIRROR_VIEW_LEFT_PADDING, audioMeterY);
2534−
2535−
2519+
2520+
25362521 const float AUDIO_METER_BLUE[] = {0.0, 0.0, 1.0};
25372522 const float AUDIO_METER_GREEN[] = {0.0, 1.0, 0.0};
25382523 const float AUDIO_METER_RED[] = {1.0, 0.0, 0.0};
@@ -2640,8 +2625,8 @@ void Application::displayOverlay() { · 101 unmodified lines
26402625 char frameTimer[10];
26412626 quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
26422627 sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
2643− int timerBottom =
2644− (Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
2628+ int timerBottom =
2629+ (Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
26452630 Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
26462631 ? 80 : 20;
26472632 drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0.f, frameTimer, WHITE_TEXT);
@@ -2684,12 +2669,12 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 36 unmodified lines
26842669 _mirrorCamera.setFieldOfView(BILLBOARD_FIELD_OF_VIEW); // degees
26852670 _mirrorCamera.setDistance(BILLBOARD_DISTANCE * _myAvatar->getScale());
26862671 _mirrorCamera.setTargetPosition(_myAvatar->getPosition());
2687−
2672+
26882673 } else if (_rearMirrorTools->getZoomLevel() == BODY) {
26892674 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
26902675 _mirrorCamera.setDistance(MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
26912676 _mirrorCamera.setTargetPosition(_myAvatar->getChestPosition());
2692−
2677+
26932678 } else { // HEAD zoom level
26942679 _mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
26952680 _mirrorCamera.setDistance(MIRROR_REARVIEW_DISTANCE * _myAvatar->getScale());
@@ -2704,7 +2689,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 8 unmodified lines
27042689 }
27052690 }
27062691 _mirrorCamera.setAspectRatio((float)region.width() / region.height());
2707−
2692+
27082693 _mirrorCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
27092694 _mirrorCamera.update(1.0f/_fps);
27102695
@@ -2749,7 +2734,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { · 38 unmodified lines
27492734 if (!billboard) {
27502735 _rearMirrorTools->render(false);
27512736 }
2752−
2737+
27532738 // reset Viewport and projection matrix
27542739 glViewport(0, 0, _glWidget->width(), _glWidget->height());
27552740 glDisable(GL_SCISSOR_TEST);
@@ -2969,14 +2954,14 @@ void Application::setMenuShortcutsEnabled(bool enabled) { · 213 unmodified lines
29692954 }
29702955
29712956 void Application::updateWindowTitle(){
2972−
2957+
29732958 QString buildVersion = " (build " + applicationVersion() + ")";
29742959 NodeList* nodeList = NodeList::getInstance();
2975−
2960+
29762961 QString username = AccountManager::getInstance().getUsername();
29772962 QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString()
29782963 + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion;
2979−
2964+
29802965 qDebug("Application title set to: %s", title.toStdString().c_str());
29812966 _window->setWindowTitle(title);
29822967 }
@@ -2991,7 +2976,7 @@ void Application::domainChanged(const QString& domainHostname) { · 8 unmodified lines
29912976 _voxelServerJurisdictions.clear();
29922977 _octreeServerSceneStats.clear();
29932978 _particleServerJurisdictions.clear();
2994−
2979+
29952980 // reset the particle renderer
29962981 _particles.clear();
29972982
@@ -3001,12 +2986,12 @@ void Application::domainChanged(const QString& domainHostname) { · 3 unmodified lines
30012986
30022987 void Application::connectedToDomain(const QString& hostname) {
30032988 AccountManager& accountManager = AccountManager::getInstance();
3004−
2989+
30052990 if (accountManager.isLoggedIn()) {
30062991 // update our domain-server with the data-server we're logged in with
3007−
2992+
30082993 QString domainPutJsonString = "{\"address\":{\"domain\":\"" + hostname + "\"}}";
3009−
2994+
30102995 accountManager.authenticatedRequest("/api/v1/users/address", QNetworkAccessManager::PutOperation,
30112996 JSONCallbackParameters(), domainPutJsonString.toUtf8());
30122997 }
@@ -3171,13 +3156,13 @@ void Application::loadScripts() { · 158 unmodified lines
31713156 // loads all saved scripts
31723157 QSettings* settings = new QSettings(this);
31733158 int size = settings->beginReadArray("Settings");
3174−
3159+
31753160 for (int i = 0; i < size; ++i){
31763161 settings->setArrayIndex(i);
31773162 QString string = settings->value("script").toString();
31783163 loadScript(string);
31793164 }
3180−
3165+
31813166 settings->endArray();
31823167 }
31833168
@@ -3192,42 +3177,72 @@ void Application::saveScripts() { · 8 unmodified lines
31923177 // saves all current running scripts
31933178 QSettings* settings = new QSettings(this);
31943179 settings->beginWriteArray("Settings");
3195− for (int i = 0; i < _activeScripts.size(); ++i){
3180+ for (int i = 0; i < getRunningScripts().size(); ++i){
31963181 settings->setArrayIndex(i);
3197− settings->setValue("script", _activeScripts.at(i));
3182+ settings->setValue("script", getRunningScripts().at(i));
31983183 }
3199−
3184+
32003185 settings->endArray();
32013186 }
32023187
32033188 void Application::stopAllScripts() {
32043189 // stops all current running scripts
3205− QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions();
3206− foreach (QAction* scriptAction, scriptActions) {
3207− scriptAction->activate(QAction::Trigger);
3208− qDebug() << "stopping script..." << scriptAction->text();
3190+ for (int i = 0; i < _scriptEnginesHash.size(); ++i) {
3191+ _scriptEnginesHash.values().at(i)->stop();
3192+ qDebug() << "stopping script..." << getRunningScripts().at(i);
32093193 }
3210− _activeScripts.clear();
3194+ _scriptEnginesHash.clear();
3195+ _runningScriptsWidget->setRunningScripts(getRunningScripts());
3196+}
3197+
3198+void Application::stopScript(const QString &scriptName)
3199+{
3200+ _scriptEnginesHash.value(scriptName)->stop();
3201+ qDebug() << "stopping script..." << scriptName;
3202+ _scriptEnginesHash.remove(scriptName);
3203+ _runningScriptsWidget->setRunningScripts(getRunningScripts());
32113204 }
32123205
32133206 void Application::reloadAllScripts() {
32143207 // remember all the current scripts so we can reload them
3215− QStringList reloadList = _activeScripts;
3208+ QStringList reloadList = getRunningScripts();
32163209 // reloads all current running scripts
3217− QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions();
3218− foreach (QAction* scriptAction, scriptActions) {
3219− scriptAction->activate(QAction::Trigger);
3220− qDebug() << "stopping script..." << scriptAction->text();
3221− }
3210+ stopAllScripts();
32223211
3223− // NOTE: we don't need to clear the _activeScripts list because that is handled on script shutdown.
3224−
32253212 foreach (QString scriptName, reloadList){
32263213 qDebug() << "reloading script..." << scriptName;
32273214 loadScript(scriptName);
32283215 }
32293216 }
32303217
3218+void Application::toggleRunningScriptsWidget()
3219+{
3220+ if (!_runningScriptsWidget->toggleViewAction()->isChecked()) {
3221+ _runningScriptsWidget->move(_window->geometry().topLeft().x(), _window->geometry().topLeft().y());
3222+ _runningScriptsWidget->resize(0, _window->height());
3223+ _runningScriptsWidget->toggleViewAction()->trigger();
3224+ _runningScriptsWidget->grabKeyboard();
3225+
3226+ QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget);
3227+ slideAnimation->setStartValue(_runningScriptsWidget->geometry());
3228+ slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(),
3229+ 310, _runningScriptsWidget->height()));
3230+ slideAnimation->setDuration(250);
3231+ slideAnimation->start(QAbstractAnimation::DeleteWhenStopped);
3232+ } else {
3233+ _runningScriptsWidget->releaseKeyboard();
3234+
3235+ QPropertyAnimation* slideAnimation = new QPropertyAnimation(_runningScriptsWidget, "geometry", _runningScriptsWidget);
3236+ slideAnimation->setStartValue(_runningScriptsWidget->geometry());
3237+ slideAnimation->setEndValue(QRect(_window->geometry().topLeft().x(), _window->geometry().topLeft().y(),
3238+ 0, _runningScriptsWidget->height()));
3239+ slideAnimation->setDuration(250);
3240+ slideAnimation->start(QAbstractAnimation::DeleteWhenStopped);
3241+
3242+ QTimer::singleShot(260, _runningScriptsWidget->toggleViewAction(), SLOT(trigger()));
3243+ }
3244+}
3245+
32313246 void Application::uploadFST(bool isHead) {
32323247 FstReader reader(isHead);
32333248 if (reader.zip()) {
@@ -3243,29 +3258,17 @@ void Application::uploadSkeleton() { · 9 unmodified lines
32433258 uploadFST(false);
32443259 }
32453260
3246−void Application::removeScriptName(const QString& fileNameString) {
3247− _activeScripts.removeOne(fileNameString);
3248−}
3249−
3250−void Application::cleanupScriptMenuItem(const QString& scriptMenuName) {
3251− Menu::getInstance()->removeAction(Menu::getInstance()->getActiveScriptsMenu(), scriptMenuName);
3252−}
3253−
32543261 void Application::loadScript(const QString& scriptName) {
32553262
32563263 // start the script on a new thread...
3257− bool wantMenuItems = true; // tells the ScriptEngine object to add menu items for itself
3258− ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), wantMenuItems, &_controllerScriptingInterface);
3264+ ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), &_controllerScriptingInterface);
3265+ _scriptEnginesHash.insert(scriptName, scriptEngine);
32593266
32603267 if (!scriptEngine->hasScript()) {
32613268 qDebug() << "Application::loadScript(), script failed to load...";
32623269 return;
32633270 }
3264− _activeScripts.append(scriptName);
3265−
3266− // add a stop menu item
3267− Menu::getInstance()->addActionToQMenuAndActionHash(Menu::getInstance()->getActiveScriptsMenu(),
3268− scriptEngine->getScriptMenuName(), 0, scriptEngine, SLOT(stop()));
3271+ _runningScriptsWidget->setRunningScripts(getRunningScripts());
32693272
32703273 // setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
32713274 // we can use the same ones from the application.
@@ -3273,7 +3276,7 @@ void Application::loadScript(const QString& scriptName) { · 1 unmodified line
32733276 scriptEngine->getVoxelsScriptingInterface()->setVoxelTree(_voxels.getTree());
32743277 scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);
32753278 scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());
3276−
3279+
32773280 // hook our avatar object into this script engine
32783281 scriptEngine->setAvatarData(_myAvatar, "MyAvatar"); // leave it as a MyAvatar class to expose thrust features
32793282
@@ -3298,8 +3301,6 @@ void Application::loadScript(const QString& scriptName) { · 18 unmodified lines
32983301 // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue
32993302 connect(scriptEngine, SIGNAL(finished(const QString&)), scriptEngine, SLOT(deleteLater()));
33003303 connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
3301− connect(scriptEngine, SIGNAL(finished(const QString&)), this, SLOT(removeScriptName(const QString&)));
3302− connect(scriptEngine, SIGNAL(cleanupMenuItem(const QString&)), this, SLOT(cleanupScriptMenuItem(const QString&)));
33033304
33043305 // when the application is about to quit, stop our script engine so it unwinds properly
33053306 connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop()));
@@ -3323,12 +3324,12 @@ void Application::loadDialog() { · 17 unmodified lines
33233324 suggestedName = _previousScriptLocation;
33243325 }
33253326
3326− QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName,
3327+ QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Open Script"), suggestedName,
33273328 tr("JavaScript Files (*.js)"));
33283329 if (!fileNameString.isEmpty()) {
33293330 _previousScriptLocation = fileNameString;
33303331 }
3331−
3332+
33323333 loadScript(fileNameString);
33333334 }
33343335
@@ -3339,7 +3340,7 @@ void Application::loadScriptURLDialog() { · 4 unmodified lines
33393340 scriptURLDialog.setLabelText("Script:");
33403341 scriptURLDialog.setWindowFlags(Qt::Sheet);
33413342 const float DIALOG_RATIO_OF_WINDOW = 0.30f;
3342− scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW,
3343+ scriptURLDialog.resize(scriptURLDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW,
33433344 scriptURLDialog.size().height());
33443345
33453346 int dialogReturn = scriptURLDialog.exec();
@@ -3377,29 +3378,29 @@ void Application::checkVersion() { · 31 unmodified lines
33773378 }
33783379
33793380 void Application::parseVersionXml() {
3380−
3381+
33813382 #ifdef Q_OS_WIN32
33823383 QString operatingSystem("win");
33833384 #endif
3384−
3385+
33853386 #ifdef Q_OS_MAC
33863387 QString operatingSystem("mac");
33873388 #endif
3388−
3389+
33893390 #ifdef Q_OS_LINUX
33903391 QString operatingSystem("ubuntu");
33913392 #endif
3392−
3393+
33933394 QString releaseDate;
33943395 QString releaseNotes;
33953396 QString latestVersion;
33963397 QUrl downloadUrl;
33973398 QObject* sender = QObject::sender();
3398−
3399+
33993400 QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender));
34003401 while (!xml.atEnd() && !xml.hasError()) {
34013402 QXmlStreamReader::TokenType token = xml.readNext();
3402−
3403+
34033404 if (token == QXmlStreamReader::StartElement) {
34043405 if (xml.name() == "ReleaseDate") {
34053406 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