mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 05:23:09 +02:00
move username change to Login, add lastPosition and lastDomain
This commit is contained in:
parent
e437ae888b
commit
9112efaa36
6 changed files with 93 additions and 40 deletions
|
@ -102,6 +102,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_voxelImporter(_window),
|
_voxelImporter(_window),
|
||||||
_wantToKillLocalVoxels(false),
|
_wantToKillLocalVoxels(false),
|
||||||
_audioScope(256, 200, true),
|
_audioScope(256, 200, true),
|
||||||
|
_profile(QString()),
|
||||||
_mouseX(0),
|
_mouseX(0),
|
||||||
_mouseY(0),
|
_mouseY(0),
|
||||||
_touchAvgX(0.0f),
|
_touchAvgX(0.0f),
|
||||||
|
@ -456,6 +457,12 @@ void Application::updateProjectionMatrix() {
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::resetProfile(const QString& username) {
|
||||||
|
// call the destructor on the old profile and construct a new one
|
||||||
|
(&_profile)->~Profile();
|
||||||
|
new (&_profile) Profile(username);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||||
const char* nodeTypes, int numNodeTypes) {
|
const char* nodeTypes, int numNodeTypes) {
|
||||||
Application* self = getInstance();
|
Application* self = getInstance();
|
||||||
|
|
|
@ -111,7 +111,6 @@ public:
|
||||||
|
|
||||||
QGLWidget* getGLWidget() { return _glWidget; }
|
QGLWidget* getGLWidget() { return _glWidget; }
|
||||||
MyAvatar* getAvatar() { return &_myAvatar; }
|
MyAvatar* getAvatar() { return &_myAvatar; }
|
||||||
Profile* getProfile() { return &_profile; }
|
|
||||||
Audio* getAudio() { return &_audio; }
|
Audio* getAudio() { return &_audio; }
|
||||||
Camera* getCamera() { return &_myCamera; }
|
Camera* getCamera() { return &_myCamera; }
|
||||||
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
|
ViewFrustum* getViewFrustum() { return &_viewFrustum; }
|
||||||
|
@ -135,6 +134,9 @@ public:
|
||||||
|
|
||||||
Avatar* getLookatTargetAvatar() const { return _lookatTargetAvatar; }
|
Avatar* getLookatTargetAvatar() const { return _lookatTargetAvatar; }
|
||||||
|
|
||||||
|
Profile* getProfile() { return &_profile; }
|
||||||
|
void resetProfile(const QString& username);
|
||||||
|
|
||||||
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||||
const char* nodeTypes, int numNodeTypes);
|
const char* nodeTypes, int numNodeTypes);
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,12 @@ Menu::Menu() :
|
||||||
SLOT(aboutApp())))->setMenuRole(QAction::AboutRole);
|
SLOT(aboutApp())))->setMenuRole(QAction::AboutRole);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
(addActionToQMenuAndActionHash(fileMenu,
|
||||||
|
MenuOption::Login,
|
||||||
|
0,
|
||||||
|
this,
|
||||||
|
SLOT(login())));
|
||||||
|
|
||||||
(addActionToQMenuAndActionHash(fileMenu,
|
(addActionToQMenuAndActionHash(fileMenu,
|
||||||
MenuOption::Preferences,
|
MenuOption::Preferences,
|
||||||
Qt::CTRL | Qt::Key_Comma,
|
Qt::CTRL | Qt::Key_Comma,
|
||||||
|
@ -746,6 +752,40 @@ QLineEdit* lineEditForDomainHostname() {
|
||||||
return domainServerLineEdit;
|
return domainServerLineEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Menu::login() {
|
||||||
|
Application* applicationInstance = Application::getInstance();
|
||||||
|
QDialog dialog(applicationInstance->getGLWidget());
|
||||||
|
dialog.setWindowTitle("Login");
|
||||||
|
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
|
dialog.setLayout(layout);
|
||||||
|
|
||||||
|
QFormLayout* form = new QFormLayout();
|
||||||
|
layout->addLayout(form, 1);
|
||||||
|
|
||||||
|
QString username = applicationInstance->getProfile()->getUsername();
|
||||||
|
QLineEdit* usernameLineEdit = new QLineEdit(username);
|
||||||
|
usernameLineEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
|
form->addRow("Username:", usernameLineEdit);
|
||||||
|
|
||||||
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||||
|
dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject()));
|
||||||
|
layout->addWidget(buttons);
|
||||||
|
|
||||||
|
int ret = dialog.exec();
|
||||||
|
applicationInstance->getWindow()->activateWindow();
|
||||||
|
if (ret != QDialog::Accepted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usernameLineEdit->text() != username) {
|
||||||
|
// there has been a username change
|
||||||
|
// ask for a profile reset with the new username
|
||||||
|
applicationInstance->resetProfile(usernameLineEdit->text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::editPreferences() {
|
void Menu::editPreferences() {
|
||||||
Application* applicationInstance = Application::getInstance();
|
Application* applicationInstance = Application::getInstance();
|
||||||
|
|
||||||
|
@ -757,11 +797,6 @@ void Menu::editPreferences() {
|
||||||
QFormLayout* form = new QFormLayout();
|
QFormLayout* form = new QFormLayout();
|
||||||
layout->addLayout(form, 1);
|
layout->addLayout(form, 1);
|
||||||
|
|
||||||
QString avatarUsername = applicationInstance->getProfile()->getUsername();
|
|
||||||
QLineEdit* avatarUsernameEdit = new QLineEdit(avatarUsername);
|
|
||||||
avatarUsernameEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
|
||||||
form->addRow("Username:", avatarUsernameEdit);
|
|
||||||
|
|
||||||
QLineEdit* avatarURL = new QLineEdit(applicationInstance->getAvatar()->getVoxels()->getVoxelURL().toString());
|
QLineEdit* avatarURL = new QLineEdit(applicationInstance->getAvatar()->getVoxels()->getVoxelURL().toString());
|
||||||
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
avatarURL->setMinimumWidth(QLINE_MINIMUM_WIDTH);
|
||||||
form->addRow("Avatar URL:", avatarURL);
|
form->addRow("Avatar URL:", avatarURL);
|
||||||
|
@ -814,17 +849,6 @@ void Menu::editPreferences() {
|
||||||
|
|
||||||
QUrl faceModelURL(faceURLEdit->text());
|
QUrl faceModelURL(faceURLEdit->text());
|
||||||
|
|
||||||
|
|
||||||
if (avatarUsernameEdit->text() != avatarUsername) {
|
|
||||||
// there has been a username change - set the new UUID on the avatar instance
|
|
||||||
applicationInstance->getProfile()->setUsername(avatarUsernameEdit->text());
|
|
||||||
|
|
||||||
if (faceModelURL.toString() == faceURLString && !avatarUsernameEdit->text().isEmpty()) {
|
|
||||||
// if there was no change to the face model URL then ask the data-server for what it is
|
|
||||||
DataServerClient::getClientValueForKey(DataServerKey::FaceMeshURL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (faceModelURL.toString() != faceURLString) {
|
if (faceModelURL.toString() != faceURLString) {
|
||||||
// change the faceModelURL in the profile, it will also update this user's BlendFace
|
// change the faceModelURL in the profile, it will also update this user's BlendFace
|
||||||
applicationInstance->getProfile()->setFaceModelURL(faceModelURL);
|
applicationInstance->getProfile()->setFaceModelURL(faceModelURL);
|
||||||
|
|
|
@ -69,6 +69,7 @@ public slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void aboutApp();
|
void aboutApp();
|
||||||
|
void login();
|
||||||
void editPreferences();
|
void editPreferences();
|
||||||
void goToDomain();
|
void goToDomain();
|
||||||
void goToLocation();
|
void goToLocation();
|
||||||
|
@ -174,6 +175,7 @@ namespace MenuOption {
|
||||||
const QString ListenModePoint = "Listen Mode Point";
|
const QString ListenModePoint = "Listen Mode Point";
|
||||||
const QString ListenModeSingleSource = "Listen Mode Single Source";
|
const QString ListenModeSingleSource = "Listen Mode Single Source";
|
||||||
const QString Log = "Log";
|
const QString Log = "Log";
|
||||||
|
const QString Login = "Login";
|
||||||
const QString LookAtIndicator = "Look-at Indicator";
|
const QString LookAtIndicator = "Look-at Indicator";
|
||||||
const QString LookAtVectors = "Look-at Vectors";
|
const QString LookAtVectors = "Look-at Vectors";
|
||||||
const QString LowRes = "Lower Resolution While Moving";
|
const QString LowRes = "Lower Resolution While Moving";
|
||||||
|
|
|
@ -11,26 +11,15 @@
|
||||||
#include "Profile.h"
|
#include "Profile.h"
|
||||||
#include "DataServerClient.h"
|
#include "DataServerClient.h"
|
||||||
|
|
||||||
Profile::Profile() :
|
Profile::Profile(const QString &username) :
|
||||||
_username(),
|
_username(username),
|
||||||
_uuid(),
|
_uuid(),
|
||||||
_faceModelURL()
|
_lastDomain(),
|
||||||
|
_lastPosition(0.0, 0.0, 0.0),
|
||||||
|
_faceModelURL()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::clear() {
|
|
||||||
_username.clear();
|
|
||||||
_uuid = QUuid();
|
|
||||||
_faceModelURL.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Profile::setUsername(const QString &username) {
|
|
||||||
this->clear();
|
|
||||||
_username = username;
|
|
||||||
|
|
||||||
if (!_username.isEmpty()) {
|
if (!_username.isEmpty()) {
|
||||||
// we've been given a new username, ask the data-server for our UUID
|
// we've been given a new username, ask the data-server for profile
|
||||||
DataServerClient::getClientValueForKey(DataServerKey::UUID);
|
DataServerClient::getClientValueForKey(DataServerKey::UUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +39,27 @@ void Profile::setFaceModelURL(const QUrl& faceModelURL) {
|
||||||
Q_ARG(QUrl, _faceModelURL));
|
Q_ARG(QUrl, _faceModelURL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Profile::updatePositionInDomain(const QString& domain, const glm::vec3 position) {
|
||||||
|
if (!_username.isEmpty()) {
|
||||||
|
bool updateRequired = false;
|
||||||
|
|
||||||
|
if (_lastDomain != domain) {
|
||||||
|
_lastDomain = domain;
|
||||||
|
updateRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_lastPosition != position) {
|
||||||
|
_lastPosition = position;
|
||||||
|
updateRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateRequired) {
|
||||||
|
// either the domain or position or both have changed, time to send update to data-server
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Profile::saveData(QSettings* settings) {
|
void Profile::saveData(QSettings* settings) {
|
||||||
settings->beginGroup("Profile");
|
settings->beginGroup("Profile");
|
||||||
|
|
||||||
|
|
|
@ -13,26 +13,34 @@
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
class Profile {
|
class Profile {
|
||||||
public:
|
public:
|
||||||
Profile();
|
Profile(const QString& username);
|
||||||
|
|
||||||
void setUsername(const QString& username);
|
const QString& getUsername() const { return _username; }
|
||||||
QString& getUsername() { return _username; }
|
|
||||||
|
|
||||||
void setUUID(const QUuid& uuid);
|
void setUUID(const QUuid& uuid);
|
||||||
QUuid& getUUID() { return _uuid; }
|
const QUuid& getUUID() { return _uuid; }
|
||||||
|
|
||||||
void setFaceModelURL(const QUrl& faceModelURL);
|
void setFaceModelURL(const QUrl& faceModelURL);
|
||||||
QUrl& getFaceModelURL() { return _faceModelURL; }
|
const QUrl& getFaceModelURL() const { return _faceModelURL; }
|
||||||
|
|
||||||
void clear();
|
void updatePositionInDomain(const QString& domain, const glm::vec3 position);
|
||||||
|
|
||||||
|
QString getLastDomain() const { return _lastDomain; }
|
||||||
|
const glm::vec3& getLastPosition() const { return _lastPosition; }
|
||||||
|
|
||||||
|
void updateLastLocation(const glm::vec3 lastLocation);
|
||||||
|
|
||||||
void saveData(QSettings* settings);
|
void saveData(QSettings* settings);
|
||||||
void loadData(QSettings* settings);
|
void loadData(QSettings* settings);
|
||||||
private:
|
private:
|
||||||
QString _username;
|
QString _username;
|
||||||
QUuid _uuid;
|
QUuid _uuid;
|
||||||
|
QString _lastDomain;
|
||||||
|
glm::vec3 _lastPosition;
|
||||||
QUrl _faceModelURL;
|
QUrl _faceModelURL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue