diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b01b694662..fa2afdf4b0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -356,6 +356,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : QMutexLocker locker(&_settingsMutex); _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); } + //When -url in command line, teleport to location + urlGoTo(argc, constArgv); } Application::~Application() { @@ -3566,3 +3568,38 @@ void Application::takeSnapshot() { Snapshot::saveSnapshot(_glWidget, _myAvatar); } + +void Application::urlGoTo(int argc, const char * constArgv[]) { + //Gets the url (hifi://domain/destination/orientation) + QString customUrl = getCmdOption(argc, constArgv, "-url"); + + if (customUrl.startsWith("hifi://")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; + + // second part is either a destination coordinate or + // a place name + QString destination = urlParts[1]; + + // any third part is an avatar orientation. + QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); + + Menu::goToDomain(domain); + + // goto either @user, #place, or x-xx,y-yy,z-zz + // style co-ordinate. + Menu::goTo(destination); + + if (!orientation.isEmpty()) { + // location orientation + Menu::goToOrientation(orientation); + } + } else if (urlParts.count() == 1) { + // location coordinates or place name + QString destination = urlParts[0]; + Menu::goTo(destination); + } + } +} diff --git a/interface/src/Application.h b/interface/src/Application.h index b8f8a0c0ff..9d609ad5f5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -129,6 +129,7 @@ public: void initializeGL(); void paintGL(); void resizeGL(int width, int height); + void urlGoTo(int argc, const char * constArgv[]); void keyPressEvent(QKeyEvent* event); void keyReleaseEvent(QKeyEvent* event); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index c17c9cc507..10d3376be5 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -135,10 +135,10 @@ public: void removeAction(QMenu* menu, const QString& actionName); - bool goToDestination(QString destination); - void goToOrientation(QString orientation); - void goToDomain(const QString newDomain); - void goTo(QString destination); + bool static goToDestination(QString destination); + void static goToOrientation(QString orientation); + void static goToDomain(const QString newDomain); + void static goTo(QString destination); public slots: