From f829a5b323c54db870d829b9b5e94736a538b1dd Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 27 Apr 2014 00:29:38 +0200 Subject: [PATCH 1/5] Fix CustomUrl Fixed custom url so that hifi://domain/ works. Also goes earlier to the location. --- interface/src/Application.cpp | 53 ++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 97b5c05f25..ee4862d515 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -316,6 +316,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : Particle::setVoxelEditPacketSender(&_voxelEditSender); Particle::setParticleEditPacketSender(&_particleEditSender); + // when -url in command line, teleport to location + urlGoTo(argc, constArgv); + // For now we're going to set the PPS for outbound packets to be super high, this is // probably not the right long term solution. But for now, we're going to do this to // allow you to move a particle around in your hand @@ -352,8 +355,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : QMutexLocker locker(&_settingsMutex); _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); } - //When -url in command line, teleport to location - urlGoTo(argc, constArgv); } Application::~Application() { @@ -3576,34 +3577,34 @@ void Application::takeSnapshot() { void Application::urlGoTo(int argc, const char * constArgv[]) { //Gets the url (hifi://domain/destination/orientation) QString customUrl = getCmdOption(argc, constArgv, "-url"); + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (urlParts.count() == 1) { + // location coordinates or place name + QString domain = urlParts[0]; + Menu::goToDomain(domain); + // as there are no coordinates, go to 0,0,0 + QString destination = "0,0,0"; + Menu::goTo(destination); + } else if (urlParts.count() > 1) { + // if url has 2 or more parts, the first one is domain name + QString domain = urlParts[0]; - 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]; - // 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(); - // any third part is an avatar orientation. - QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); - - Menu::goToDomain(domain); + Menu::goToDomain(domain); - // goto either @user, #place, or x-xx,y-yy,z-zz - // style co-ordinate. - Menu::goTo(destination); + // 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); + if (!orientation.isEmpty()) { + // location orientation + Menu::goToOrientation(orientation); } - } + } } From ec410d105b524d864f1fc63461e512050a48116c Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 27 Apr 2014 00:31:28 +0200 Subject: [PATCH 2/5] Fix CustomUrl Fixed custom url so that hifi://domain/ works. --- interface/src/Menu.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 44117df55c..524e496acc 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -931,7 +931,15 @@ void Menu::goTo() { if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) { QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); - if (urlParts.count() > 1) { + if (urlParts.count() == 1) { + // location coordinates or place name + QString domain = urlParts[0]; + goToDomain(domain); + // as there are no coordinates, go to 0,0,0 + QString destination = "0,0,0"; + goTo(destination); + } + else if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name QString domain = urlParts[0]; @@ -952,12 +960,7 @@ void Menu::goTo() { // location orientation goToOrientation(orientation); } - } else if (urlParts.count() == 1) { - // location coordinates or place name - QString destination = urlParts[0]; - goTo(destination); } - } else { goToUser(gotoDialog.textValue()); } From ac8adad0e07d3d088813bb31047a6820884f6953 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 29 Apr 2014 20:49:20 +0200 Subject: [PATCH 3/5] Remove 0,0,0 entry. --- interface/src/Menu.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 524e496acc..8ae2380aa3 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -935,9 +935,6 @@ void Menu::goTo() { // location coordinates or place name QString domain = urlParts[0]; goToDomain(domain); - // as there are no coordinates, go to 0,0,0 - QString destination = "0,0,0"; - goTo(destination); } else if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name From 14b91aa04bced778e1ef886ec176bf2d9daf7fdc Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 29 Apr 2014 20:49:40 +0200 Subject: [PATCH 4/5] Remove 0,0,0 entry --- interface/src/Application.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ee4862d515..1138c6b183 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3582,9 +3582,6 @@ void Application::urlGoTo(int argc, const char * constArgv[]) { // location coordinates or place name QString domain = urlParts[0]; Menu::goToDomain(domain); - // as there are no coordinates, go to 0,0,0 - QString destination = "0,0,0"; - Menu::goTo(destination); } else if (urlParts.count() > 1) { // if url has 2 or more parts, the first one is domain name QString domain = urlParts[0]; From 65706ae5f73fa0dc043bde2ea96e5c369c07c41f Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 29 Apr 2014 20:59:33 +0200 Subject: [PATCH 5/5] Re-add customUrl.startWith --- interface/src/Application.cpp | 56 ++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1138c6b183..457f884c8c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3577,31 +3577,33 @@ void Application::takeSnapshot() { void Application::urlGoTo(int argc, const char * constArgv[]) { //Gets the url (hifi://domain/destination/orientation) QString customUrl = getCmdOption(argc, constArgv, "-url"); - QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); - if (urlParts.count() == 1) { - // location coordinates or place name - QString domain = urlParts[0]; - Menu::goToDomain(domain); - } else 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); - } - } + if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) { + QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); + if (urlParts.count() == 1) { + // location coordinates or place name + QString domain = urlParts[0]; + Menu::goToDomain(domain); + } else 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); + } + } + } }