Merge pull request #2736 from SydoxX/master

Fix CustomUrl
This commit is contained in:
Clément Brisset 2014-04-29 12:07:44 -07:00
commit 7c21fab50c
2 changed files with 21 additions and 21 deletions

View file

@ -316,6 +316,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
Particle::setVoxelEditPacketSender(&_voxelEditSender); Particle::setVoxelEditPacketSender(&_voxelEditSender);
Particle::setParticleEditPacketSender(&_particleEditSender); 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 // 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 // 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 // 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); QMutexLocker locker(&_settingsMutex);
_previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString(); _previousScriptLocation = _settings->value("LastScriptLocation", QVariant("")).toString();
} }
//When -url in command line, teleport to location
urlGoTo(argc, constArgv);
} }
Application::~Application() { Application::~Application() {
@ -3576,34 +3577,33 @@ void Application::takeSnapshot() {
void Application::urlGoTo(int argc, const char * constArgv[]) { void Application::urlGoTo(int argc, const char * constArgv[]) {
//Gets the url (hifi://domain/destination/orientation) //Gets the url (hifi://domain/destination/orientation)
QString customUrl = getCmdOption(argc, constArgv, "-url"); QString customUrl = getCmdOption(argc, constArgv, "-url");
if(customUrl.startsWith(CUSTOM_URL_SCHEME + "//")) {
if (customUrl.startsWith("hifi://")) {
QStringList urlParts = customUrl.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); QStringList urlParts = customUrl.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];
Menu::goToDomain(domain);
} else if (urlParts.count() > 1) {
// if url has 2 or more parts, the first one is domain name // if url has 2 or more parts, the first one is domain name
QString domain = urlParts[0]; QString domain = urlParts[0];
// second part is either a destination coordinate or // second part is either a destination coordinate or
// a place name // a place name
QString destination = urlParts[1]; QString destination = urlParts[1];
// any third part is an avatar orientation. // any third part is an avatar orientation.
QString orientation = urlParts.count() > 2 ? urlParts[2] : QString(); 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 // goto either @user, #place, or x-xx,y-yy,z-zz
// style co-ordinate. // style co-ordinate.
Menu::goTo(destination); Menu::goTo(destination);
if (!orientation.isEmpty()) { if (!orientation.isEmpty()) {
// location orientation // location orientation
Menu::goToOrientation(orientation); Menu::goToOrientation(orientation);
} }
} else if (urlParts.count() == 1) { }
// location coordinates or place name
QString destination = urlParts[0];
Menu::goTo(destination);
}
} }
} }

View file

@ -903,7 +903,12 @@ void Menu::goTo() {
if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) { if (desiredDestination.startsWith(CUSTOM_URL_SCHEME + "//")) {
QStringList urlParts = desiredDestination.remove(0, CUSTOM_URL_SCHEME.length() + 2).split('/', QString::SkipEmptyParts); 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);
}
else if (urlParts.count() > 1) {
// if url has 2 or more parts, the first one is domain name // if url has 2 or more parts, the first one is domain name
QString domain = urlParts[0]; QString domain = urlParts[0];
@ -924,12 +929,7 @@ void Menu::goTo() {
// location orientation // location orientation
goToOrientation(orientation); goToOrientation(orientation);
} }
} else if (urlParts.count() == 1) {
// location coordinates or place name
QString destination = urlParts[0];
goTo(destination);
} }
} else { } else {
goToUser(gotoDialog.textValue()); goToUser(gotoDialog.textValue());
} }