History

Merge branch 'master' of https://github.com/worklist/hifi into menu_js

ZappoMan committed 12 years ago

Commit 263d6822 parents 0048099 039f9ff69 files · +2003 −4400Browse files

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

Unified · Split

interface/src/Application.cpp+64−46
@@ -51,11 +51,11 @@ · 50 unmodified lines
5151 #include <QMimeData>
5252 #include <QMessageBox>
5353
54+#include <AccountManager.h>
5455 #include <AudioInjector.h>
5556 #include <Logging.h>
5657 #include <OctalCode.h>
5758 #include <PacketHeaders.h>
58−#include <PairingHandler.h>
5959 #include <ParticlesScriptingInterface.h>
6060 #include <PerfStat.h>
6161 #include <UUID.h>
@@ -63,7 +63,6 @@ · 1 unmodified line
6363
6464 #include "Application.h"
6565 #include "ClipboardScriptingInterface.h"
66−#include "DataServerClient.h"
6766 #include "InterfaceVersion.h"
6867 #include "Menu.h"
6968 #include "Swatch.h"
@@ -129,7 +128,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 59 unmodified lines
129128 _wantToKillLocalVoxels(false),
130129 _audioScope(256, 200, true),
131130 _myAvatar(),
132− _profile(QString()),
133131 _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
134132 _mouseX(0),
135133 _mouseY(0),
@@ -161,11 +159,27 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 25 unmodified lines
161159 _pasteMode(false),
162160 _logger(new FileLogger(this))
163161 {
162+ switchToResourcesParentIfRequired();
163+
164+ // read the ApplicationInfo.ini file for Name/Version/Domain information
165+ QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat);
166+
167+ // set the associated application properties
168+ applicationInfo.beginGroup("INFO");
169+
170+ qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
171+
172+ setApplicationName(applicationInfo.value("name").toString());
173+ setApplicationVersion(BUILD_VERSION);
174+ setOrganizationName(applicationInfo.value("organizationName").toString());
175+ setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
176+
177+ QSettings::setDefaultFormat(QSettings::IniFormat);
178+
164179 _myAvatar = _avatarManager.getMyAvatar();
165180
166181 _applicationStartupTime = startup_time;
167−
168− switchToResourcesParentIfRequired();
182+
169183 QFontDatabase::addApplicationFont("resources/styles/Inconsolata.otf");
170184 _window->setWindowTitle("Interface");
171185
@@ -203,27 +217,27 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 31 unmodified lines
203217 connect(audioThread, SIGNAL(started()), &_audio, SLOT(start()));
204218
205219 audioThread->start();
206−
207− connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&)));
220+
221+ connect(&nodeList->getDomainInfo(), SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&)));
222+ connect(&nodeList->getDomainInfo(), SIGNAL(connectedToDomain(const QString&)), SLOT(connectedToDomain(const QString&)));
223+
208224 connect(nodeList, &NodeList::nodeAdded, this, &Application::nodeAdded);
209225 connect(nodeList, &NodeList::nodeKilled, this, &Application::nodeKilled);
210226 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
211227 connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer)));
212228 connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer)));
213229 connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle);
230+
231+ // connect to appropriate slots on AccountManager
232+ AccountManager& accountManager = AccountManager::getInstance();
233+ connect(&accountManager, &AccountManager::authRequired, Menu::getInstance(), &Menu::loginForCurrentDomain);
234+ connect(&accountManager, &AccountManager::usernameChanged, this, &Application::updateWindowTitle);
214235
215− // read the ApplicationInfo.ini file for Name/Version/Domain information
216− QSettings applicationInfo("resources/info/ApplicationInfo.ini", QSettings::IniFormat);
217−
218− // set the associated application properties
219− applicationInfo.beginGroup("INFO");
220−
221− setApplicationName(applicationInfo.value("name").toString());
222− setApplicationVersion(BUILD_VERSION);
223− setOrganizationName(applicationInfo.value("organizationName").toString());
224− setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
236+ // set the account manager's root URL and trigger a login request if we don't have the access token
237+ accountManager.setAuthURL(DEFAULT_NODE_AUTH_URL);
225238
226− qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
239+ // once the event loop has started, check and signal for an access token
240+ QMetaObject::invokeMethod(&accountManager, "checkAndSignalForAccessToken", Qt::QueuedConnection);
227241
228242 _settings = new QSettings(this);
229243
@@ -303,7 +317,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 73 unmodified lines
303317
304318 _overlays.init(_glWidget); // do this before scripts load
305319
306−
307320 // do this as late as possible so that all required subsystems are inialized
308321 loadScripts();
309322 }
@@ -602,13 +615,6 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum) · 292 unmodified lines
602615 glMatrixMode(GL_MODELVIEW);
603616 }
604617
605−void Application::resetProfile(const QString& username) {
606− // call the destructor on the old profile and construct a new one
607− (&_profile)->~Profile();
608− new (&_profile) Profile(username);
609− updateWindowTitle();
610−}
611−
612618 void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) {
613619 foreach(NodeType_t type, destinationNodeTypes) {
614620 // Intercept data to voxel server when voxels are disabled
@@ -1428,12 +1434,7 @@ void Application::timer() { · 813 unmodified lines
14281434 // ask the node list to check in with the domain server
14291435 NodeList::getInstance()->sendDomainServerCheckIn();
14301436
1431− // send unmatched DataServerClient packets
1432− DataServerClient::resendUnmatchedPackets();
1433−
1434− // give the MyAvatar object position, orientation to the Profile so it can propagate to the data-server
1435− _profile.updatePosition(_myAvatar->getPosition());
1436− _profile.updateOrientation(_myAvatar->getOrientation());
1437+
14371438 }
14381439
14391440 static glm::vec3 getFaceVector(BoxFace face) {
@@ -1493,6 +1494,8 @@ void Application::idle() { · 53 unmodified lines
14931494 _idleLoopMeasuredJitter = _idleLoopStdev.getStDev();
14941495 _idleLoopStdev.reset();
14951496 }
1497+
1498+ _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());
14961499
14971500 // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
14981501 idleTimer->start(2);
@@ -2815,10 +2818,20 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 1316 unmodified lines
28152818 "Application::displaySide() ... metavoxels...");
28162819 _metavoxels.render();
28172820 }
2821+
2822+ if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
2823+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2824+ "Application::displaySide() ... bucky balls...");
2825+ _buckyBalls.render();
2826+ }
28182827
28192828 // render particles...
2820− _particles.render();
2821−
2829+ if (Menu::getInstance()->isOptionChecked(MenuOption::Particles)) {
2830+ PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
2831+ "Application::displaySide() ... particles...");
2832+ _particles.render();
2833+ }
2834+
28222835 // render the ambient occlusion effect if enabled
28232836 if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
28242837 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
@@ -2931,9 +2944,6 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { · 106 unmodified lines
29312944 }
29322945 }
29332946
2934− // render transmitter pick ray, if non-empty
2935− _myAvatar->renderTransmitterPickRay();
2936−
29372947 // give external parties a change to hook in
29382948 emit renderingInWorldInterface();
29392949
@@ -2999,8 +3009,6 @@ void Application::displayOverlay() { · 59 unmodified lines
29993009 _myAvatar->renderHeadMouse();
30003010 }
30013011
3002− _myAvatar->renderTransmitterLevels(_glWidget->width(), _glWidget->height());
3003−
30043012 // Display stats and log text onscreen
30053013 glLineWidth(1.0f);
30063014 glPointSize(1.0f);
@@ -3979,17 +3987,15 @@ void Application::updateWindowTitle(){ · 972 unmodified lines
39793987 QString buildVersion = " (build " + applicationVersion() + ")";
39803988 NodeList* nodeList = NodeList::getInstance();
39813989
3982− QString title = QString() + _profile.getUsername() + " " + nodeList->getSessionUUID().toString()
3983− + " @ " + nodeList->getDomainHostname() + buildVersion;
3990+ QString username = AccountManager::getInstance().getUsername();
3991+ QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString()
3992+ + " @ " + nodeList->getDomainInfo().getHostname() + buildVersion;
39843993
39853994 qDebug("Application title set to: %s", title.toStdString().c_str());
39863995 _window->setWindowTitle(title);
39873996 }
39883997
39893998 void Application::domainChanged(const QString& domainHostname) {
3990− // update the user's last domain in their Profile (which will propagate to data-server)
3991− _profile.updateDomain(domainHostname);
3992−
39933999 updateWindowTitle();
39944000
39954001 // reset the environment so that we don't erroneously end up with multiple
@@ -4004,6 +4010,19 @@ void Application::domainChanged(const QString& domainHostname) { · 8 unmodified lines
40044010 _particles.clear();
40054011 }
40064012
4013+void Application::connectedToDomain(const QString& hostname) {
4014+ AccountManager& accountManager = AccountManager::getInstance();
4015+
4016+ if (accountManager.isLoggedIn()) {
4017+ // update our domain-server with the data-server we're logged in with
4018+
4019+ QString domainPutJsonString = "{\"location\":{\"domain\":\"" + hostname + "\"}}";
4020+
4021+ accountManager.authenticatedRequest("/api/v1/users/location", QNetworkAccessManager::PutOperation,
4022+ JSONCallbackParameters(), domainPutJsonString.toUtf8());
4023+ }
4024+}
4025+
40074026 void Application::nodeAdded(SharedNodePointer node) {
40084027 if (node->getType() == NodeType::AvatarMixer) {
40094028 // new avatar mixer, send off our identity packet right away
@@ -4392,6 +4411,5 @@ void Application::takeSnapshot() { · 382 unmodified lines
43924411 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
43934412 player->play();
43944413
4395− Snapshot::saveSnapshot(_glWidget, &_profile, _myAvatar);
4414+ Snapshot::saveSnapshot(_glWidget, _myAvatar);
43964415 }
4397−

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