// This is called when user presses enter in the location input // or selects a location from the typed locations dropdown. void LLNavigationBar::onLocationSelection() { std::string typed_location = mCmbLocation->getSimple(); LLStringUtil::trim(typed_location); // Will not teleport to empty location. if (typed_location.empty()) return; //get selected item from combobox item LLSD value = mCmbLocation->getSelectedValue(); if(value.isUndefined() && !mCmbLocation->getTextEntry()->isDirty()) { // At this point we know that: there is no selected item in list and text field has NOT been changed // So there is no sense to try to change the location return; } /* since navbar list support autocompletion it contains several types of item: landmark, teleport hystory item, * typed by user slurl or region name. Let's find out which type of item the user has selected * to make decision about adding this location into typed history. see mSaveToLocationHistory * Note: * Only TYPED_REGION_SLURL item will be added into LLLocationHistory */ if(value.has("item_type")) { switch(value["item_type"].asInteger()) { case LANDMARK: if(value.has("AssetUUID")) { gAgent.teleportViaLandmark( LLUUID(value["AssetUUID"].asString())); return; } else { LLInventoryModel::item_array_t landmark_items = LLLandmarkActions::fetchLandmarksByName(typed_location, FALSE); if (!landmark_items.empty()) { gAgent.teleportViaLandmark( landmark_items[0]->getAssetUUID()); return; } } break; case TELEPORT_HISTORY: //in case of teleport item was selected, teleport by position too. case TYPED_REGION_SLURL: if(value.has("global_pos")) { gAgent.teleportViaLocation(LLVector3d(value["global_pos"])); return; } break; default: break; } } //Let's parse slurl or region name std::string region_name; LLVector3 local_coords(128, 128, 0); // Is the typed location a SLURL? LLSLURL slurl = LLSLURL(typed_location); if (slurl.getType() == LLSLURL::LOCATION) { region_name = slurl.getRegion(); local_coords = slurl.getPosition(); } else if(!slurl.isValid()) { // we have to do this check after previous, because LLUrlRegistry contains handlers for slurl too // but we need to know whether typed_location is a simple http url. if (LLUrlRegistry::instance().isUrl(typed_location)) { // display http:// URLs in the media browser, or // anything else is sent to the search floater LLWeb::loadURL(typed_location); return; } else { // assume that an user has typed the {region name} or possible {region_name, parcel} region_name = typed_location.substr(0,typed_location.find(',')); } } else { // was an app slurl, home, whatever. Bail return; } // Resolve the region name to its global coordinates. // If resolution succeeds we'll teleport. LLWorldMapMessage::url_callback_t cb = boost::bind( &LLNavigationBar::onRegionNameResponse, this, typed_location, region_name, local_coords, _1, _2, _3, _4); mSaveToLocationHistory = true; LLWorldMapMessage::getInstance()->sendNamedRegionRequest(region_name, cb, std::string("unused"), false); }