mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 18:53:36 +02:00
commit
400f98b11d
7 changed files with 141 additions and 190 deletions
examples
interface/src
libraries/networking/src
|
@ -66,20 +66,20 @@ function textOverlayPosition() {
|
|||
Vec3.multiply(Quat.getUp(Camera.orientation), TEXT_DISTANCE_DOWN));
|
||||
}
|
||||
|
||||
var panelLocationOrder = [
|
||||
var panelPlaceOrder = [
|
||||
7, 8, 9, 10, 11, 12, 13,
|
||||
0, 1, 2, 3, 4, 5, 6,
|
||||
14, 15, 16, 17, 18, 19, 20
|
||||
];
|
||||
|
||||
// Location index is 0-based
|
||||
function locationIndexToPanelIndex(locationIndex) {
|
||||
return panelLocationOrder.indexOf(locationIndex) + 1;
|
||||
// place index is 0-based
|
||||
function placeIndexToPanelIndex(placeIndex) {
|
||||
return panelPlaceOrder.indexOf(placeIndex) + 1;
|
||||
}
|
||||
|
||||
// Panel index is 1-based
|
||||
function panelIndexToLocationIndex(panelIndex) {
|
||||
return panelLocationOrder[panelIndex - 1];
|
||||
function panelIndexToPlaceIndex(panelIndex) {
|
||||
return panelPlaceOrder[panelIndex - 1];
|
||||
}
|
||||
|
||||
var MAX_NUM_PANELS = 21;
|
||||
|
@ -148,25 +148,25 @@ function drawLobby() {
|
|||
}
|
||||
}
|
||||
|
||||
var locations = {};
|
||||
var places = {};
|
||||
|
||||
function changeLobbyTextures() {
|
||||
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();
|
||||
|
||||
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 = {
|
||||
textures: {}
|
||||
};
|
||||
|
||||
for (var j = 0; j < NUM_PANELS; j++) {
|
||||
var panelIndex = locationIndexToPanelIndex(j);
|
||||
textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/locations/"
|
||||
+ locations[j].id + "/hifi-location-" + locations[j].id + "_640x360.jpg";
|
||||
var panelIndex = placeIndexToPanelIndex(j);
|
||||
textureProp["textures"]["file" + panelIndex] = HIFI_PUBLIC_BUCKET + "images/places/"
|
||||
+ places[j].id + "/hifi-place-" + places[j].id + "_640x360.jpg";
|
||||
};
|
||||
|
||||
Overlays.editOverlay(panelWall, textureProp);
|
||||
|
@ -234,7 +234,7 @@ function cleanupLobby() {
|
|||
Audio.stopInjector(currentMuzakInjector);
|
||||
currentMuzakInjector = null;
|
||||
|
||||
locations = {};
|
||||
places = {};
|
||||
toggleEnvironmentRendering(true);
|
||||
|
||||
MyAvatar.detachOne(HELMET_ATTACHMENT_URL);
|
||||
|
@ -252,14 +252,14 @@ function actionStartEvent(event) {
|
|||
var panelStringIndex = panelName.indexOf("Panel");
|
||||
if (panelStringIndex != -1) {
|
||||
var panelIndex = parseInt(panelName.slice(5));
|
||||
var locationIndex = panelIndexToLocationIndex(panelIndex);
|
||||
if (locationIndex < locations.length) {
|
||||
var actionLocation = locations[locationIndex];
|
||||
var placeIndex = panelIndexToPlaceIndex(panelIndex);
|
||||
if (placeIndex < places.length) {
|
||||
var actionPlace = places[placeIndex];
|
||||
|
||||
print("Jumping to " + actionLocation.name + " at " + actionLocation.path
|
||||
+ " in " + actionLocation.domain.name + " after click on panel " + panelIndex + " with location index " + locationIndex);
|
||||
print("Jumping to " + actionPlace.name + " at " + actionPlace.address
|
||||
+ " after click on panel " + panelIndex + " with place index " + placeIndex);
|
||||
|
||||
Window.location = actionLocation;
|
||||
Window.location = actionPlace.address;
|
||||
maybeCleanupLobby();
|
||||
}
|
||||
}
|
||||
|
@ -302,15 +302,15 @@ function handleLookAt(pickRay) {
|
|||
var panelStringIndex = panelName.indexOf("Panel");
|
||||
if (panelStringIndex != -1) {
|
||||
var panelIndex = parseInt(panelName.slice(5));
|
||||
var locationIndex = panelIndexToLocationIndex(panelIndex);
|
||||
if (locationIndex < locations.length) {
|
||||
var actionLocation = locations[locationIndex];
|
||||
var placeIndex = panelIndexToPlaceIndex(panelIndex);
|
||||
if (placeIndex < places.length) {
|
||||
var actionPlace = places[placeIndex];
|
||||
|
||||
if (actionLocation.description == "") {
|
||||
Overlays.editOverlay(descriptionText, { text: actionLocation.name, visible: showText });
|
||||
if (actionPlace.description == "") {
|
||||
Overlays.editOverlay(descriptionText, { text: actionPlace.name, visible: showText });
|
||||
} else {
|
||||
// handle line wrapping
|
||||
var allWords = actionLocation.description.split(" ");
|
||||
var allWords = actionPlace.description.split(" ");
|
||||
var currentGoodLine = "";
|
||||
var currentTestLine = "";
|
||||
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
|
||||
addressManager->setPositionGetter(getPositionForPath);
|
||||
addressManager->setOrientationGetter(getOrientationForPath);
|
||||
|
||||
connect(addressManager.data(), &AddressManager::rootPlaceNameChanged, this, &Application::updateWindowTitle);
|
||||
|
||||
_settings = new QSettings(this);
|
||||
_numChangedSettings = 0;
|
||||
|
@ -916,13 +918,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
||||
break;
|
||||
|
||||
case Qt::Key_N:
|
||||
if (isMeta) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::NameLocation);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Qt::Key_Up:
|
||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
if (!isShifted) {
|
||||
|
@ -3151,8 +3146,14 @@ void Application::updateWindowTitle(){
|
|||
|
||||
QString connectionStatus = nodeList->getDomainHandler().isConnected() ? "" : " (NOT CONNECTED) ";
|
||||
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())
|
||||
+ DependencyManager::get<AddressManager>()->getCurrentDomain() + connectionStatus + buildVersion;
|
||||
+ currentPlaceName + connectionStatus + buildVersion;
|
||||
|
||||
#ifndef WIN32
|
||||
// crashes with vs2013/win32
|
||||
|
@ -3164,23 +3165,32 @@ void Application::updateWindowTitle(){
|
|||
void Application::updateLocationInServer() {
|
||||
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
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
|
||||
QJsonObject rootObject;
|
||||
|
||||
QJsonObject locationObject;
|
||||
|
||||
QString pathString = DependencyManager::get<AddressManager>()->currentPath();
|
||||
QString pathString = addressManager->currentPath();
|
||||
|
||||
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(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);
|
||||
|
||||
|
|
|
@ -134,16 +134,6 @@ Menu::Menu() :
|
|||
this, SLOT(deleteBookmark()));
|
||||
_deleteBookmarksMenu->setEnabled(false);
|
||||
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,
|
||||
MenuOption::AddressBar,
|
||||
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() {
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
|
||||
|
|
|
@ -205,8 +205,6 @@ private slots:
|
|||
void bookmarkLocation();
|
||||
void teleportToBookmark();
|
||||
void deleteBookmark();
|
||||
void nameLocation();
|
||||
void toggleLocationList();
|
||||
void hmdToolsClosed();
|
||||
void runTests();
|
||||
void showMetavoxelEditor();
|
||||
|
@ -292,8 +290,6 @@ private:
|
|||
QPointer<AttachmentsDialog> _attachmentsDialog;
|
||||
QPointer<BandwidthDialog> _bandwidthDialog;
|
||||
QPointer<CachesSizeDialog> _cachesSizeDialog;
|
||||
QPointer<DataWebDialog> _newLocationDialog;
|
||||
QPointer<DataWebDialog> _userLocationsDialog;
|
||||
QPointer<HMDToolsDialog> _hmdToolsDialog;
|
||||
QPointer<LodToolsDialog> _lodToolsDialog;
|
||||
QPointer<LoginDialog> _loginDialog;
|
||||
|
@ -413,8 +409,6 @@ namespace MenuOption {
|
|||
const QString Mirror = "Mirror";
|
||||
const QString MuteAudio = "Mute Microphone";
|
||||
const QString MuteEnvironment = "Mute Environment";
|
||||
const QString MyLocations = "My Locations...";
|
||||
const QString NameLocation = "Name this location";
|
||||
const QString NetworkSimulator = "Network Simulator...";
|
||||
const QString NewVoxelCullingMode = "New Voxel Culling Mode";
|
||||
const QString ObeyEnvironmentalGravity = "Obey Environmental Gravity";
|
||||
|
|
|
@ -25,16 +25,9 @@ QScriptValue LocationScriptingInterface::locationGetter(QScriptContext* context,
|
|||
QScriptValue LocationScriptingInterface::locationSetter(QScriptContext* context, QScriptEngine* engine) {
|
||||
const QVariant& argumentVariant = context->argument(0).toVariant();
|
||||
|
||||
|
||||
if (argumentVariant.canConvert(QMetaType::QVariantMap)) {
|
||||
// this argument is a variant map, so we'll assume it's an address map
|
||||
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()));
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#include "AddressManager.h"
|
||||
|
||||
AddressManager::AddressManager() :
|
||||
_currentDomain(),
|
||||
_rootPlaceName(),
|
||||
_rootPlaceID(),
|
||||
_positionGetter(NULL),
|
||||
_orientationGetter(NULL)
|
||||
{
|
||||
|
@ -37,7 +38,7 @@ const QUrl AddressManager::currentAddress() const {
|
|||
QUrl hifiURL;
|
||||
|
||||
hifiURL.setScheme(HIFI_URL_SCHEME);
|
||||
hifiURL.setHost(_currentDomain);
|
||||
hifiURL.setHost(_rootPlaceName);
|
||||
hifiURL.setPath(currentPath());
|
||||
|
||||
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() {
|
||||
static bool hasSetupParameters = false;
|
||||
static JSONCallbackParameters callbackParams;
|
||||
|
@ -173,67 +169,83 @@ void AddressManager::handleAPIResponse(QNetworkReply& requestReply) {
|
|||
emit lookupResultsFinished();
|
||||
}
|
||||
|
||||
void AddressManager::goToAddressFromObject(const QVariantMap& addressMap) {
|
||||
const QString ADDRESS_API_DOMAIN_KEY = "domain";
|
||||
const QString ADDRESS_API_ONLINE_KEY = "online";
|
||||
void AddressManager::goToAddressFromObject(const QVariantMap& dataObject) {
|
||||
|
||||
if (!addressMap.contains(ADDRESS_API_ONLINE_KEY)
|
||||
|| addressMap[ADDRESS_API_ONLINE_KEY].toBool()) {
|
||||
const QString DATA_OBJECT_PLACE_KEY = "place";
|
||||
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)) {
|
||||
QVariantMap domainObject = addressMap[ADDRESS_API_DOMAIN_KEY].toMap();
|
||||
if (!locationMap.contains(LOCATION_API_ONLINE_KEY)
|
||||
|| locationMap[LOCATION_API_ONLINE_KEY].toBool()) {
|
||||
|
||||
const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address";
|
||||
const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";
|
||||
|
||||
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);
|
||||
QVariantMap rootMap = locationMap[LOCATION_API_ROOT_KEY].toMap();
|
||||
if (rootMap.isEmpty()) {
|
||||
rootMap = locationMap;
|
||||
}
|
||||
|
||||
// set our current domain to the name that came back
|
||||
const QString DOMAIN_NAME_KEY = "name";
|
||||
QVariantMap domainObject = rootMap[LOCATION_API_DOMAIN_KEY].toMap();
|
||||
|
||||
_currentDomain = domainObject[DOMAIN_NAME_KEY].toString();
|
||||
|
||||
// take the path that came back
|
||||
const QString LOCATION_KEY = "location";
|
||||
const QString LOCATION_PATH_KEY = "path";
|
||||
QString returnedPath;
|
||||
|
||||
if (domainObject.contains(LOCATION_PATH_KEY)) {
|
||||
returnedPath = domainObject[LOCATION_PATH_KEY].toString();
|
||||
} else if (domainObject.contains(LOCATION_KEY)) {
|
||||
returnedPath = domainObject[LOCATION_KEY].toMap()[LOCATION_PATH_KEY].toString();
|
||||
} else if (addressMap.contains(LOCATION_PATH_KEY)) {
|
||||
returnedPath = addressMap[LOCATION_PATH_KEY].toString();
|
||||
}
|
||||
|
||||
bool shouldFaceViewpoint = addressMap.contains(ADDRESS_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;
|
||||
if (!domainObject.isEmpty()) {
|
||||
const QString DOMAIN_NETWORK_ADDRESS_KEY = "network_address";
|
||||
const QString DOMAIN_ICE_SERVER_ADDRESS_KEY = "ice_server_address";
|
||||
|
||||
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 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 {
|
||||
qDebug() << "Received an address manager API response with no domain key. Cannot parse.";
|
||||
qDebug() << addressMap;
|
||||
// we've been told that this result exists but is offline, emit our signal so the application can handle
|
||||
emit lookupResultIsOffline();
|
||||
}
|
||||
} else {
|
||||
// we've been told that this result exists but is offline, emit our signal so the application can handle
|
||||
emit lookupResultIsOffline();
|
||||
qDebug() << "Received an address manager API response with no location key or place key. Cannot parse.";
|
||||
qDebug() << locationMap;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,9 +377,18 @@ bool AddressManager::handleUsername(const QString& lookupString) {
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,8 @@ class AddressManager : public QObject, public Dependency {
|
|||
Q_PROPERTY(bool isConnected READ isConnected)
|
||||
Q_PROPERTY(QUrl href READ currentAddress)
|
||||
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 domainID READ getDomainID)
|
||||
public:
|
||||
bool isConnected();
|
||||
const QString& getProtocol() { return HIFI_URL_SCHEME; };
|
||||
|
@ -43,8 +42,10 @@ public:
|
|||
const QUrl currentAddress() const;
|
||||
const QString currentPath(bool withOrientation = true) const;
|
||||
|
||||
const QString& getCurrentDomain() const { return _currentDomain; }
|
||||
QString getDomainID() const;
|
||||
const QUuid& getRootPlaceID() const { return _rootPlaceID; }
|
||||
|
||||
const QString& getRootPlaceName() const { return _rootPlaceName; }
|
||||
void setRootPlaceName(const QString& rootPlaceName);
|
||||
|
||||
void attemptPlaceNameLookup(const QString& lookupString);
|
||||
|
||||
|
@ -69,13 +70,14 @@ signals:
|
|||
void locationChangeRequired(const glm::vec3& newPosition,
|
||||
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||
bool shouldFaceLocation);
|
||||
void rootPlaceNameChanged(const QString& newRootPlaceName);
|
||||
protected:
|
||||
AddressManager();
|
||||
private slots:
|
||||
void handleAPIResponse(QNetworkReply& requestReply);
|
||||
void handleAPIError(QNetworkReply& errorReply);
|
||||
private:
|
||||
void setDomainInfo(const QString& hostname, quint16 port, const QString& domainName = QString());
|
||||
void setDomainInfo(const QString& hostname, quint16 port);
|
||||
|
||||
const JSONCallbackParameters& apiCallbackParameters();
|
||||
|
||||
|
@ -85,7 +87,8 @@ private:
|
|||
bool handleRelativeViewpoint(const QString& pathSubsection, bool shouldFace = false);
|
||||
bool handleUsername(const QString& lookupString);
|
||||
|
||||
QString _currentDomain;
|
||||
QString _rootPlaceName;
|
||||
QUuid _rootPlaceID;
|
||||
PositionGetter _positionGetter;
|
||||
OrientationGetter _orientationGetter;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue