mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 10:53:16 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into temp1
This commit is contained in:
commit
0fdc9c1855
10 changed files with 151 additions and 195 deletions
|
@ -66,20 +66,20 @@ function textOverlayPosition() {
|
||||||
Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN));
|
Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
var panelLocationOrder = [
|
var panelPlaceOrder = [
|
||||||
7, 8, 9, 10, 11, 12, 13,
|
7, 8, 9, 10, 11, 12, 13,
|
||||||
0, 1, 2, 3, 4, 5, 6,
|
0, 1, 2, 3, 4, 5, 6,
|
||||||
14, 15, 16, 17, 18, 19, 20
|
14, 15, 16, 17, 18, 19, 20
|
||||||
];
|
];
|
||||||
|
|
||||||
// Location index is 0-based
|
// place index is 0-based
|
||||||
function locationIndexToPanelIndex(locationIndex) {
|
function placeIndexToPanelIndex(placeIndex) {
|
||||||
return panelLocationOrder.indexOf(locationIndex) + 1;
|
return panelPlaceOrder.indexOf(placeIndex) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Panel index is 1-based
|
// Panel index is 1-based
|
||||||
function panelIndexToLocationIndex(panelIndex) {
|
function panelIndexToPlaceIndex(panelIndex) {
|
||||||
return panelLocationOrder[panelIndex - 1];
|
return panelPlaceOrder[panelIndex - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
var MAX_NUM_PANELS = 21;
|
var MAX_NUM_PANELS = 21;
|
||||||
|
@ -148,25 +148,25 @@ function drawLobby() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var locations = {};
|
var places = {};
|
||||||
|
|
||||||
function changeLobbyTextures() {
|
function changeLobbyTextures() {
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
req.open("GET", "https://data.highfidelity.io/api/v1/locations?limit=21", false);
|
req.open("GET", "https://data.highfidelity.io/api/v1/places?limit=21", false);
|
||||||
req.send();
|
req.send();
|
||||||
|
|
||||||
locations = JSON.parse(req.responseText).data.locations;
|
places = JSON.parse(req.responseText).data.places;
|
||||||
|
|
||||||
var NUM_PANELS = locations.length;
|
var NUM_PANELS = places.length;
|
||||||
|
|
||||||
var textureProp = {
|
var textureProp = {
|
||||||
textures: {}
|
textures: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var j = 0; j < NUM_PANELS; j++) {
|
for (var j = 0; j < NUM_PANELS; j++) {
|
||||||
var panelIndex = locationIndexToPanelIndex(j);
|
var panelIndex = placeIndexToPanelIndex(j);
|
||||||
textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/locations/"
|
textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/places/"
|
||||||
+ locations[j].id + "/hifi-location-" + locations[j].id + "_640x360.jpg";
|
+ places[j].id + "/hifi-place-" + places[j].id + "_640x360.jpg";
|
||||||
};
|
};
|
||||||
|
|
||||||
Overlays.editOverlay(panelWall, textureProp);
|
Overlays.editOverlay(panelWall, textureProp);
|
||||||
|
@ -234,7 +234,7 @@ function cleanupLobby() {
|
||||||
Audio.stopInjector(currentMuzakInjector);
|
Audio.stopInjector(currentMuzakInjector);
|
||||||
currentMuzakInjector = null;
|
currentMuzakInjector = null;
|
||||||
|
|
||||||
locations = {};
|
places = {};
|
||||||
toggleEnvironmentRendering(true);
|
toggleEnvironmentRendering(true);
|
||||||
|
|
||||||
MyAvatar.detachOne(HELMET_ATTACHMENT_URL);
|
MyAvatar.detachOne(HELMET_ATTACHMENT_URL);
|
||||||
|
@ -252,14 +252,14 @@ function actionStartEvent(event) {
|
||||||
var panelStringIndex = panelName.indexOf("Panel");
|
var panelStringIndex = panelName.indexOf("Panel");
|
||||||
if (panelStringIndex != -1) {
|
if (panelStringIndex != -1) {
|
||||||
var panelIndex = parseInt(panelName.slice(5));
|
var panelIndex = parseInt(panelName.slice(5));
|
||||||
var locationIndex = panelIndexToLocationIndex(panelIndex);
|
var placeIndex = panelIndexToPlaceIndex(panelIndex);
|
||||||
if (locationIndex < locations.length) {
|
if (placeIndex < places.length) {
|
||||||
var actionLocation = locations[locationIndex];
|
var actionPlace = places[placeIndex];
|
||||||
|
|
||||||
print("Jumping to " + actionLocation.name + " at " + actionLocation.path
|
print("Jumping to " + actionPlace.name + " at " + actionPlace.address
|
||||||
+ " in " + actionLocation.domain.name + " after click on panel " + panelIndex + " with location index " + locationIndex);
|
+ " after click on panel " + panelIndex + " with place index " + placeIndex);
|
||||||
|
|
||||||
Window.location = actionLocation;
|
Window.location = actionPlace.address;
|
||||||
maybeCleanupLobby();
|
maybeCleanupLobby();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,15 +302,15 @@ function handleLookAt(pickRay) {
|
||||||
var panelStringIndex = panelName.indexOf("Panel");
|
var panelStringIndex = panelName.indexOf("Panel");
|
||||||
if (panelStringIndex != -1) {
|
if (panelStringIndex != -1) {
|
||||||
var panelIndex = parseInt(panelName.slice(5));
|
var panelIndex = parseInt(panelName.slice(5));
|
||||||
var locationIndex = panelIndexToLocationIndex(panelIndex);
|
var placeIndex = panelIndexToPlaceIndex(panelIndex);
|
||||||
if (locationIndex < locations.length) {
|
if (placeIndex < places.length) {
|
||||||
var actionLocation = locations[locationIndex];
|
var actionPlace = places[placeIndex];
|
||||||
|
|
||||||
if (actionLocation.description == "") {
|
if (actionPlace.description == "") {
|
||||||
Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: showText });
|
Overlays.editOverlay(descriptionText, { text: actionPlace.name, visible: showText });
|
||||||
} else {
|
} else {
|
||||||
// handle line wrapping
|
// handle line wrapping
|
||||||
var allWords = actionLocation.description.split(" ");
|
var allWords = actionPlace.description.split(" ");
|
||||||
var currentGoodLine = "";
|
var currentGoodLine = "";
|
||||||
var currentTestLine = "";
|
var currentTestLine = "";
|
||||||
var formatedDescription = "";
|
var formatedDescription = "";
|
||||||
|
|
|
@ -338,6 +338,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
// use our MyAvatar position and quat for address manager path
|
// use our MyAvatar position and quat for address manager path
|
||||||
addressManager->setPositionGetter(getPositionForPath);
|
addressManager->setPositionGetter(getPositionForPath);
|
||||||
addressManager->setOrientationGetter(getOrientationForPath);
|
addressManager->setOrientationGetter(getOrientationForPath);
|
||||||
|
|
||||||
|
connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
|
||||||
|
|
||||||
_settings = new QSettings(this);
|
_settings = new QSettings(this);
|
||||||
_numChangedSettings = 0;
|
_numChangedSettings = 0;
|
||||||
|
@ -916,13 +918,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_N:
|
|
||||||
if (isMeta) {
|
|
||||||
Menu::getInstance()->triggerOption(MenuOption::NameLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
if (!isShifted) {
|
if (!isShifted) {
|
||||||
|
@ -3151,8 +3146,14 @@ void Application::updateWindowTitle(){
|
||||||
|
|
||||||
QString connectionStatus = nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED) ";
|
QString connectionStatus = nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED) ";
|
||||||
QString username = AccountManager::getInstance().getAccountInfo().getUsername();
|
QString username = AccountManager::getInstance().getAccountInfo().getUsername();
|
||||||
|
QString currentPlaceName = DependencyManager::get<AddressManager>()->getRootPlaceName();
|
||||||
|
|
||||||
|
if (currentPlaceName.isEmpty()) {
|
||||||
|
currentPlaceName = nodeList->getDomainHandler().getHostname();
|
||||||
|
}
|
||||||
|
|
||||||
QString title = QString() + (!username.isEmpty() ? username + " @ " : QString())
|
QString title = QString() + (!username.isEmpty() ? username + " @ " : QString())
|
||||||
+ DependencyManager::get<AddressManager>()->getCurrentDomain() + connectionStatus + buildVersion;
|
+ currentPlaceName + connectionStatus + buildVersion;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
// crashes with vs2013/win32
|
// crashes with vs2013/win32
|
||||||
|
@ -3164,23 +3165,32 @@ void Application::updateWindowTitle(){
|
||||||
void Application::updateLocationInServer() {
|
void Application::updateLocationInServer() {
|
||||||
|
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
auto addressManager = DependencyManager::get<AddressManager>();
|
||||||
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
|
|
||||||
if (accountManager.isLoggedIn() && domainHandler.isConnected() && !domainHandler.getUUID().isNull()) {
|
if (accountManager.isLoggedIn() && domainHandler.isConnected()
|
||||||
|
&& (!addressManager->getRootPlaceID().isNull() || !domainHandler.getUUID().isNull())) {
|
||||||
|
|
||||||
// construct a QJsonObject given the user's current address information
|
// construct a QJsonObject given the user's current address information
|
||||||
QJsonObject rootObject;
|
QJsonObject rootObject;
|
||||||
|
|
||||||
QJsonObject locationObject;
|
QJsonObject locationObject;
|
||||||
|
|
||||||
QString pathString = DependencyManager::get<AddressManager>()->currentPath();
|
QString pathString = addressManager->currentPath();
|
||||||
|
|
||||||
const QString LOCATION_KEY_IN_ROOT = "location";
|
const QString LOCATION_KEY_IN_ROOT = "location";
|
||||||
const QString PATH_KEY_IN_LOCATION = "path";
|
|
||||||
const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
|
|
||||||
|
|
||||||
|
const QString PATH_KEY_IN_LOCATION = "path";
|
||||||
locationObject.insert(PATH_KEY_IN_LOCATION, pathString);
|
locationObject.insert(PATH_KEY_IN_LOCATION, pathString);
|
||||||
locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainHandler.getUUID().toString());
|
|
||||||
|
if (!addressManager->getRootPlaceID().isNull()) {
|
||||||
|
const QString PLACE_ID_KEY_IN_LOCATION = "place_id";
|
||||||
|
locationObject.insert(PLACE_ID_KEY_IN_LOCATION, addressManager->getRootPlaceID().toString());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const QString DOMAIN_ID_KEY_IN_LOCATION = "domain_id";
|
||||||
|
locationObject.insert(DOMAIN_ID_KEY_IN_LOCATION, domainHandler.getUUID().toString());
|
||||||
|
}
|
||||||
|
|
||||||
rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject);
|
rootObject.insert(LOCATION_KEY_IN_ROOT, locationObject);
|
||||||
|
|
||||||
|
|
|
@ -134,16 +134,6 @@ Menu::Menu() :
|
||||||
this, SLOT(deleteBookmark()));
|
this, SLOT(deleteBookmark()));
|
||||||
_deleteBookmarksMenu->setEnabled(false);
|
_deleteBookmarksMenu->setEnabled(false);
|
||||||
loadBookmarks();
|
loadBookmarks();
|
||||||
addActionToQMenuAndActionHash(fileMenu,
|
|
||||||
MenuOption::NameLocation,
|
|
||||||
Qt::CTRL | Qt::Key_N,
|
|
||||||
this,
|
|
||||||
SLOT(nameLocation()));
|
|
||||||
addActionToQMenuAndActionHash(fileMenu,
|
|
||||||
MenuOption::MyLocations,
|
|
||||||
Qt::CTRL | Qt::Key_K,
|
|
||||||
this,
|
|
||||||
SLOT(toggleLocationList()));
|
|
||||||
addActionToQMenuAndActionHash(fileMenu,
|
addActionToQMenuAndActionHash(fileMenu,
|
||||||
MenuOption::AddressBar,
|
MenuOption::AddressBar,
|
||||||
Qt::Key_Enter,
|
Qt::Key_Enter,
|
||||||
|
@ -1172,66 +1162,6 @@ void Menu::displayNameLocationResponse(const QString& errorString) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::toggleLocationList() {
|
|
||||||
if (!_userLocationsDialog) {
|
|
||||||
JavascriptObjectMap locationObjectMap;
|
|
||||||
locationObjectMap.insert("InterfaceLocation", DependencyManager::get<AddressManager>().data());
|
|
||||||
_userLocationsDialog = DataWebDialog::dialogForPath("/user/locations", locationObjectMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_userLocationsDialog->isVisible()) {
|
|
||||||
_userLocationsDialog->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
_userLocationsDialog->raise();
|
|
||||||
_userLocationsDialog->activateWindow();
|
|
||||||
_userLocationsDialog->showNormal();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::nameLocation() {
|
|
||||||
// check if user is logged in or show login dialog if not
|
|
||||||
|
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
|
||||||
|
|
||||||
if (!accountManager.isLoggedIn()) {
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setText("We need to tie this location to your username.");
|
|
||||||
msgBox.setInformativeText("Please login first, then try naming the location again.");
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
|
||||||
msgBox.button(QMessageBox::Ok)->setText("Login");
|
|
||||||
|
|
||||||
if (msgBox.exec() == QMessageBox::Ok) {
|
|
||||||
loginForCurrentDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
|
||||||
if (domainHandler.getUUID().isNull()) {
|
|
||||||
const QString UNREGISTERED_DOMAIN_MESSAGE = "This domain is not registered with High Fidelity."
|
|
||||||
"\n\nYou cannot create a global location in an unregistered domain.";
|
|
||||||
QMessageBox::critical(this, "Unregistered Domain", UNREGISTERED_DOMAIN_MESSAGE);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_newLocationDialog) {
|
|
||||||
JavascriptObjectMap locationObjectMap;
|
|
||||||
locationObjectMap.insert("InterfaceLocation", DependencyManager::get<AddressManager>().data());
|
|
||||||
_newLocationDialog = DataWebDialog::dialogForPath("/user/locations/new", locationObjectMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_newLocationDialog->isVisible()) {
|
|
||||||
_newLocationDialog->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
_newLocationDialog->raise();
|
|
||||||
_newLocationDialog->activateWindow();
|
|
||||||
_newLocationDialog->showNormal();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::toggleLoginMenuItem() {
|
void Menu::toggleLoginMenuItem() {
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
|
||||||
|
|
|
@ -205,8 +205,6 @@ private slots:
|
||||||
void bookmarkLocation();
|
void bookmarkLocation();
|
||||||
void teleportToBookmark();
|
void teleportToBookmark();
|
||||||
void deleteBookmark();
|
void deleteBookmark();
|
||||||
void nameLocation();
|
|
||||||
void toggleLocationList();
|
|
||||||
void hmdToolsClosed();
|
void hmdToolsClosed();
|
||||||
void runTests();
|
void runTests();
|
||||||
void showMetavoxelEditor();
|
void showMetavoxelEditor();
|
||||||
|
@ -292,8 +290,6 @@ private:
|
||||||
QPointer<AttachmentsDialog> _attachmentsDialog;
|
QPointer<AttachmentsDialog> _attachmentsDialog;
|
||||||
QPointer<BandwidthDialog> _bandwidthDialog;
|
QPointer<BandwidthDialog> _bandwidthDialog;
|
||||||
QPointer<CachesSizeDialog> _cachesSizeDialog;
|
QPointer<CachesSizeDialog> _cachesSizeDialog;
|
||||||
QPointer<DataWebDialog> _newLocationDialog;
|
|
||||||
QPointer<DataWebDialog> _userLocationsDialog;
|
|
||||||
QPointer<HMDToolsDialog> _hmdToolsDialog;
|
QPointer<HMDToolsDialog> _hmdToolsDialog;
|
||||||
QPointer<LodToolsDialog> _lodToolsDialog;
|
QPointer<LodToolsDialog> _lodToolsDialog;
|
||||||
QPointer<LoginDialog> _loginDialog;
|
QPointer<LoginDialog> _loginDialog;
|
||||||
|
@ -413,8 +409,6 @@ namespace MenuOption {
|
||||||
const QString Mirror = "Mirror";
|
const QString Mirror = "Mirror";
|
||||||
const QString MuteAudio = "Mute Microphone";
|
const QString MuteAudio = "Mute Microphone";
|
||||||
const QString MuteEnvironment = "Mute Environment";
|
const QString MuteEnvironment = "Mute Environment";
|
||||||
const QString MyLocations = "My Locations...";
|
|
||||||
const QString NameLocation = "Name this location";
|
|
||||||
const QString NetworkSimulator = "Network Simulator...";
|
const QString NetworkSimulator = "Network Simulator...";
|
||||||
const QString NewVoxelCullingMode = "New Voxel Culling Mode";
|
const QString NewVoxelCullingMode = "New Voxel Culling Mode";
|
||||||
const QString ObeyEnvironmentalGravity = "Obey Environmental Gravity";
|
const QString ObeyEnvironmentalGravity = "Obey Environmental Gravity";
|
||||||
|
|
|
@ -25,16 +25,9 @@ QScriptValue LocationScriptingInterface::locationGetter(QScriptContext* context,
|
||||||
QScriptValue LocationScriptingInterface::locationSetter(QScriptContext* context, QScriptEngine* engine) {
|
QScriptValue LocationScriptingInterface::locationSetter(QScriptContext* context, QScriptEngine* engine) {
|
||||||
const QVariant& argumentVariant = context->argument(0).toVariant();
|
const QVariant& argumentVariant = context->argument(0).toVariant();
|
||||||
|
|
||||||
|
// just try and convert the argument to a string, should be a hifi:// address
|
||||||
if (argumentVariant.canConvert(QMetaType::QVariantMap)) {
|
QMetaObject::invokeMethod(DependencyManager::get<AddressManager>().data(), "handleLookupString",
|
||||||
// this argument is a variant map, so we'll assume it's an address map
|
Q_ARG(const QString&, argumentVariant.toString()));
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AddressManager>().data(), "goToAddressFromObject",
|
|
||||||
Q_ARG(const QVariantMap&, argumentVariant.toMap()));
|
|
||||||
} else {
|
|
||||||
// just try and convert the argument to a string, should be a hifi:// address
|
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<AddressManager>().data(), "handleLookupString",
|
|
||||||
Q_ARG(const QString&, argumentVariant.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return QScriptValue::UndefinedValue;
|
return QScriptValue::UndefinedValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,9 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
|
||||||
_rotation(base3DOverlay->_rotation),
|
_rotation(base3DOverlay->_rotation),
|
||||||
_isSolid(base3DOverlay->_isSolid),
|
_isSolid(base3DOverlay->_isSolid),
|
||||||
_isDashedLine(base3DOverlay->_isDashedLine),
|
_isDashedLine(base3DOverlay->_isDashedLine),
|
||||||
_ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection)
|
_ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection),
|
||||||
|
_drawInFront(base3DOverlay->_drawInFront),
|
||||||
|
_drawOnHUD(base3DOverlay->_drawOnHUD)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
#include "AddressManager.h"
|
#include "AddressManager.h"
|
||||||
|
|
||||||
AddressManager::AddressManager() :
|
AddressManager::AddressManager() :
|
||||||
_currentDomain(),
|
_rootPlaceName(),
|
||||||
|
_rootPlaceID(),
|
||||||
_positionGetter(NULL),
|
_positionGetter(NULL),
|
||||||
_orientationGetter(NULL)
|
_orientationGetter(NULL)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,7 @@ const QUrl AddressManager::currentAddress() const {
|
||||||
QUrl hifiURL;
|
QUrl hifiURL;
|
||||||
|
|
||||||
hifiURL.setScheme(HIFI_URL_SCHEME);
|
hifiURL.setScheme(HIFI_URL_SCHEME);
|
||||||
hifiURL.setHost(_currentDomain);
|
hifiURL.setHost(_rootPlaceName);
|
||||||
hifiURL.setPath(currentPath());
|
hifiURL.setPath(currentPath());
|
||||||
|
|
||||||
return hifiURL;
|
return hifiURL;
|
||||||
|
@ -88,11 +89,6 @@ const QString AddressManager::currentPath(bool withOrientation) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AddressManager::getDomainID() const {
|
|
||||||
const QUuid& domainID = DependencyManager::get<NodeList>()->getDomainHandler().getUUID();
|
|
||||||
return domainID.isNull() ? "" : uuidStringWithoutCurlyBraces(domainID);
|
|
||||||
}
|
|
||||||
|
|
||||||
const JSONCallbackParameters& AddressManager::apiCallbackParameters() {
|
const JSONCallbackParameters& AddressManager::apiCallbackParameters() {
|
||||||
static bool hasSetupParameters = false;
|
static bool hasSetupParameters = false;
|
||||||
static JSONCallbackParameters callbackParams;
|
static JSONCallbackParameters callbackParams;
|
||||||
|
@ -173,67 +169,83 @@ void AddressManager::handleAPIResponse(QNetworkReply& requestReply) {
|
||||||
emit lookupResultsFinished();
|
emit lookupResultsFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressManager::goToAddressFromObject(const QVariantMap& addressMap) {
|
void AddressManager::goToAddressFromObject(const QVariantMap& dataObject) {
|
||||||
const QString ADDRESS_API_DOMAIN_KEY = "domain";
|
|
||||||
const QString ADDRESS_API_ONLINE_KEY = "online";
|
|
||||||
|
|
||||||
if (!addressMap.contains(ADDRESS_API_ONLINE_KEY)
|
const QString DATA_OBJECT_PLACE_KEY = "place";
|
||||||
|| addressMap[ADDRESS_API_ONLINE_KEY].toBool()) {
|
const QString DATA_OBJECT_USER_LOCATION_KEY = "location";
|
||||||
|
|
||||||
|
QVariantMap locationMap;
|
||||||
|
if (dataObject.contains(DATA_OBJECT_PLACE_KEY)) {
|
||||||
|
locationMap = dataObject[DATA_OBJECT_PLACE_KEY].toMap();
|
||||||
|
} else {
|
||||||
|
locationMap = dataObject[DATA_OBJECT_USER_LOCATION_KEY].toMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!locationMap.isEmpty()) {
|
||||||
|
const QString LOCATION_API_ROOT_KEY = "root";
|
||||||
|
const QString LOCATION_API_DOMAIN_KEY = "domain";
|
||||||
|
const QString LOCATION_API_ONLINE_KEY = "online";
|
||||||
|
|
||||||
if (addressMap.contains(ADDRESS_API_DOMAIN_KEY)) {
|
if (!locationMap.contains(LOCATION_API_ONLINE_KEY)
|
||||||
QVariantMap domainObject = addressMap[ADDRESS_API_DOMAIN_KEY].toMap();
|
|| locationMap[LOCATION_API_ONLINE_KEY].toBool()) {
|
||||||
|
|
||||||
const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address";
|
QVariantMap rootMap = locationMap[LOCATION_API_ROOT_KEY].toMap();
|
||||||
const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";
|
if (rootMap.isEmpty()) {
|
||||||
|
rootMap = locationMap;
|
||||||
if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) {
|
|
||||||
QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString();
|
|
||||||
|
|
||||||
emit possibleDomainChangeRequired(domainHostname, DEFAULT_DOMAIN_SERVER_PORT);
|
|
||||||
} else {
|
|
||||||
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
|
||||||
|
|
||||||
const QString DOMAIN_ID_KEY = "id";
|
|
||||||
QString domainIDString = domainObject[DOMAIN_ID_KEY].toString();
|
|
||||||
QUuid domainID(domainIDString);
|
|
||||||
|
|
||||||
emit possibleDomainChangeRequiredViaICEForID(iceServerAddress, domainID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set our current domain to the name that came back
|
QVariantMap domainObject = rootMap[LOCATION_API_DOMAIN_KEY].toMap();
|
||||||
const QString DOMAIN_NAME_KEY = "name";
|
|
||||||
|
|
||||||
_currentDomain = domainObject[DOMAIN_NAME_KEY].toString();
|
if (!domainObject.isEmpty()) {
|
||||||
|
const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address";
|
||||||
// take the path that came back
|
const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";
|
||||||
const QString LOCATION_KEY = "location";
|
|
||||||
const QString LOCATION_PATH_KEY = "path";
|
if (domainObject.contains(DOMAIN_NETWORK_ADDRESS_KEY)) {
|
||||||
QString returnedPath;
|
QString domainHostname = domainObject[DOMAIN_NETWORK_ADDRESS_KEY].toString();
|
||||||
|
|
||||||
if (domainObject.contains(LOCATION_PATH_KEY)) {
|
emit possibleDomainChangeRequired(domainHostname, DEFAULT_DOMAIN_SERVER_PORT);
|
||||||
returnedPath = domainObject[LOCATION_PATH_KEY].toString();
|
} else {
|
||||||
} else if (domainObject.contains(LOCATION_KEY)) {
|
QString iceServerAddress = domainObject[DOMAIN_ICE_SERVER_ADDRESS_KEY].toString();
|
||||||
returnedPath = domainObject[LOCATION_KEY].toMap()[LOCATION_PATH_KEY].toString();
|
|
||||||
} else if (addressMap.contains(LOCATION_PATH_KEY)) {
|
const QString DOMAIN_ID_KEY = "id";
|
||||||
returnedPath = addressMap[LOCATION_PATH_KEY].toString();
|
QString domainIDString = domainObject[DOMAIN_ID_KEY].toString();
|
||||||
}
|
QUuid domainID(domainIDString);
|
||||||
|
|
||||||
bool shouldFaceViewpoint = addressMap.contains(ADDRESS_API_ONLINE_KEY);
|
emit possibleDomainChangeRequiredViaICEForID(iceServerAddress, domainID);
|
||||||
|
|
||||||
if (!returnedPath.isEmpty()) {
|
|
||||||
// try to parse this returned path as a viewpoint, that's the only thing it could be for now
|
|
||||||
if (!handleRelativeViewpoint(returnedPath, shouldFaceViewpoint)) {
|
|
||||||
qDebug() << "Received a location path that was could not be handled as a viewpoint -" << returnedPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set our current root place id to the ID that came back
|
||||||
|
const QString PLACE_ID_KEY = "id";
|
||||||
|
_rootPlaceID = rootMap[PLACE_ID_KEY].toUuid();
|
||||||
|
|
||||||
|
// set our current root place name to the name that came back
|
||||||
|
const QString PLACE_NAME_KEY = "name";
|
||||||
|
QString newRootPlaceName = rootMap[PLACE_NAME_KEY].toString();
|
||||||
|
setRootPlaceName(newRootPlaceName);
|
||||||
|
|
||||||
|
// take the path that came back
|
||||||
|
const QString PLACE_PATH_KEY = "path";
|
||||||
|
QString returnedPath = locationMap[PLACE_PATH_KEY].toString();
|
||||||
|
|
||||||
|
bool shouldFaceViewpoint = locationMap.contains(LOCATION_API_ONLINE_KEY);
|
||||||
|
|
||||||
|
if (!returnedPath.isEmpty()) {
|
||||||
|
// try to parse this returned path as a viewpoint, that's the only thing it could be for now
|
||||||
|
if (!handleRelativeViewpoint(returnedPath, shouldFaceViewpoint)) {
|
||||||
|
qDebug() << "Received a location path that was could not be handled as a viewpoint -" << returnedPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Received an address manager API response with no domain key. Cannot parse.";
|
||||||
|
qDebug() << locationMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Received an address manager API response with no domain key. Cannot parse.";
|
// we've been told that this result exists but is offline, emit our signal so the application can handle
|
||||||
qDebug() << addressMap;
|
emit lookupResultIsOffline();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we've been told that this result exists but is offline, emit our signal so the application can handle
|
qDebug() << "Received an address manager API response with no location key or place key. Cannot parse.";
|
||||||
emit lookupResultIsOffline();
|
qDebug() << locationMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,9 +377,18 @@ bool AddressManager::handleUsername(const QString& lookupString) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddressManager::setRootPlaceName(const QString& rootPlaceName) {
|
||||||
|
if (rootPlaceName != _rootPlaceName) {
|
||||||
|
_rootPlaceName = rootPlaceName;
|
||||||
|
emit rootPlaceNameChanged(_rootPlaceName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AddressManager::setDomainInfo(const QString& hostname, quint16 port, const QString& domainName) {
|
|
||||||
_currentDomain = domainName.isEmpty() ? hostname : domainName;
|
void AddressManager::setDomainInfo(const QString& hostname, quint16 port) {
|
||||||
|
_rootPlaceName = hostname;
|
||||||
|
_rootPlaceID = QUuid();
|
||||||
|
|
||||||
emit possibleDomainChangeRequired(hostname, port);
|
emit possibleDomainChangeRequired(hostname, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,8 @@ class AddressManager : public QObject, public Dependency {
|
||||||
Q_PROPERTY(bool isConnected READ isConnected)
|
Q_PROPERTY(bool isConnected READ isConnected)
|
||||||
Q_PROPERTY(QUrl href READ currentAddress)
|
Q_PROPERTY(QUrl href READ currentAddress)
|
||||||
Q_PROPERTY(QString protocol READ getProtocol)
|
Q_PROPERTY(QString protocol READ getProtocol)
|
||||||
Q_PROPERTY(QString hostname READ getCurrentDomain)
|
Q_PROPERTY(QString hostname READ getRootPlaceName)
|
||||||
Q_PROPERTY(QString pathname READ currentPath)
|
Q_PROPERTY(QString pathname READ currentPath)
|
||||||
Q_PROPERTY(QString domainID READ getDomainID)
|
|
||||||
public:
|
public:
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
const QString& getProtocol() { return HIFI_URL_SCHEME; };
|
const QString& getProtocol() { return HIFI_URL_SCHEME; };
|
||||||
|
@ -43,8 +42,10 @@ public:
|
||||||
const QUrl currentAddress() const;
|
const QUrl currentAddress() const;
|
||||||
const QString currentPath(bool withOrientation = true) const;
|
const QString currentPath(bool withOrientation = true) const;
|
||||||
|
|
||||||
const QString& getCurrentDomain() const { return _currentDomain; }
|
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
||||||
QString getDomainID() const;
|
|
||||||
|
const QString& getRootPlaceName() const { return _rootPlaceName; }
|
||||||
|
void setRootPlaceName(const QString& rootPlaceName);
|
||||||
|
|
||||||
void attemptPlaceNameLookup(const QString& lookupString);
|
void attemptPlaceNameLookup(const QString& lookupString);
|
||||||
|
|
||||||
|
@ -69,13 +70,14 @@ signals:
|
||||||
void locationChangeRequired(const glm::vec3& newPosition,
|
void locationChangeRequired(const glm::vec3& newPosition,
|
||||||
bool hasOrientationChange, const glm::quat& newOrientation,
|
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||||
bool shouldFaceLocation);
|
bool shouldFaceLocation);
|
||||||
|
void rootPlaceNameChanged(const QString& newRootPlaceName);
|
||||||
protected:
|
protected:
|
||||||
AddressManager();
|
AddressManager();
|
||||||
private slots:
|
private slots:
|
||||||
void handleAPIResponse(QNetworkReply& requestReply);
|
void handleAPIResponse(QNetworkReply& requestReply);
|
||||||
void handleAPIError(QNetworkReply& errorReply);
|
void handleAPIError(QNetworkReply& errorReply);
|
||||||
private:
|
private:
|
||||||
void setDomainInfo(const QString& hostname, quint16 port, const QString& domainName = QString());
|
void setDomainInfo(const QString& hostname, quint16 port);
|
||||||
|
|
||||||
const JSONCallbackParameters& apiCallbackParameters();
|
const JSONCallbackParameters& apiCallbackParameters();
|
||||||
|
|
||||||
|
@ -85,7 +87,8 @@ private:
|
||||||
bool handleRelativeViewpoint(const QString& pathSubsection, bool shouldFace = false);
|
bool handleRelativeViewpoint(const QString& pathSubsection, bool shouldFace = false);
|
||||||
bool handleUsername(const QString& lookupString);
|
bool handleUsername(const QString& lookupString);
|
||||||
|
|
||||||
QString _currentDomain;
|
QString _rootPlaceName;
|
||||||
|
QUuid _rootPlaceID;
|
||||||
PositionGetter _positionGetter;
|
PositionGetter _positionGetter;
|
||||||
OrientationGetter _orientationGetter;
|
OrientationGetter _orientationGetter;
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,6 +41,7 @@ const QUrl DEFAULT_NODE_AUTH_URL = QUrl("https://data.highfidelity.io");
|
||||||
LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort) :
|
LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short dtlsListenPort) :
|
||||||
_sessionUUID(),
|
_sessionUUID(),
|
||||||
_nodeHash(),
|
_nodeHash(),
|
||||||
|
_nodeMutex(QReadWriteLock::Recursive),
|
||||||
_nodeSocket(this),
|
_nodeSocket(this),
|
||||||
_dtlsSocket(NULL),
|
_dtlsSocket(NULL),
|
||||||
_localSockAddr(),
|
_localSockAddr(),
|
||||||
|
|
|
@ -83,11 +83,13 @@ template <typename T, typename ...Args>
|
||||||
QSharedPointer<T> DependencyManager::set(Args&&... args) {
|
QSharedPointer<T> DependencyManager::set(Args&&... args) {
|
||||||
static size_t hashCode = _manager.getHashCode<T>();
|
static size_t hashCode = _manager.getHashCode<T>();
|
||||||
|
|
||||||
QSharedPointer<T> instance(new T(args...), &T::customDeleter);
|
QSharedPointer<Dependency>& instance = _manager.safeGet(hashCode);
|
||||||
QSharedPointer<Dependency> storedInstance = qSharedPointerCast<Dependency>(instance);
|
instance.clear(); // Clear instance before creation of new one to avoid edge cases
|
||||||
_manager.safeGet(hashCode).swap(storedInstance);
|
QSharedPointer<T> newInstance(new T(args...), &T::customDeleter);
|
||||||
|
QSharedPointer<Dependency> storedInstance = qSharedPointerCast<Dependency>(newInstance);
|
||||||
|
instance.swap(storedInstance);
|
||||||
|
|
||||||
return instance;
|
return newInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
Loading…
Reference in a new issue