summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterworldmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterworldmap.cpp')
-rw-r--r--indra/newview/llfloaterworldmap.cpp186
1 files changed, 122 insertions, 64 deletions
diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index 983fd97b0b..3afa31b873 100644
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -3,31 +3,25 @@
* @author James Cook, Tom Yedwab
* @brief LLFloaterWorldMap class implementation
*
- * $LicenseInfo:firstyear=2003&license=viewergpl$
- *
- * Copyright (c) 2003-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2003&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -206,6 +200,7 @@ LLFloaterWorldMap::LLFloaterWorldMap(const LLSD& key)
mFactoryMap["objects_mapview"] = LLCallbackMap(createWorldMapView, NULL);
//Called from floater reg: LLUICtrlFactory::getInstance()->buildFloater(this, "floater_world_map.xml", FALSE);
+ mCommitCallbackRegistrar.add("WMap.Coordinates", boost::bind(&LLFloaterWorldMap::onCoordinatesCommit, this));
mCommitCallbackRegistrar.add("WMap.Location", boost::bind(&LLFloaterWorldMap::onLocationCommit, this));
mCommitCallbackRegistrar.add("WMap.AvatarCombo", boost::bind(&LLFloaterWorldMap::onAvatarComboCommit, this));
mCommitCallbackRegistrar.add("WMap.Landmark", boost::bind(&LLFloaterWorldMap::onLandmarkComboCommit, this));
@@ -247,7 +242,7 @@ BOOL LLFloaterWorldMap::postBuild()
landmark_combo->setTextEntryCallback( boost::bind(&LLFloaterWorldMap::onComboTextEntry, this) );
mCurZoomVal = log(LLWorldMapView::sMapScale)/log(2.f);
- childSetValue("zoom slider", LLWorldMapView::sMapScale);
+ getChild<LLUICtrl>("zoom slider")->setValue(LLWorldMapView::sMapScale);
setDefaultBtn(NULL);
@@ -320,7 +315,7 @@ void LLFloaterWorldMap::onOpen(const LLSD& key)
const LLUUID landmark_folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK);
LLInventoryModelBackgroundFetch::instance().start(landmark_folder_id);
- childSetFocus("location", TRUE);
+ getChild<LLUICtrl>("location")->setFocus( TRUE);
gFocusMgr.triggerFocusFlash();
buildAvatarIDList();
@@ -336,8 +331,6 @@ void LLFloaterWorldMap::onOpen(const LLSD& key)
}
}
-
-
// static
void LLFloaterWorldMap::reloadIcons(void*)
{
@@ -358,9 +351,9 @@ BOOL LLFloaterWorldMap::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
if(mPanel->pointInView(x, y))
{
- F32 slider_value = (F32)childGetValue("zoom slider").asReal();
+ F32 slider_value = (F32)getChild<LLUICtrl>("zoom slider")->getValue().asReal();
slider_value += ((F32)clicks * -0.3333f);
- childSetValue("zoom slider", LLSD(slider_value));
+ getChild<LLUICtrl>("zoom slider")->setValue(LLSD(slider_value));
return TRUE;
}
}
@@ -388,32 +381,32 @@ void LLFloaterWorldMap::draw()
LLViewerRegion* regionp = gAgent.getRegion();
bool agent_on_prelude = (regionp && regionp->isPrelude());
bool enable_go_home = gAgent.isGodlike() || !agent_on_prelude;
- childSetEnabled("Go Home", enable_go_home);
+ getChildView("Go Home")->setEnabled(enable_go_home);
updateLocation();
LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus();
if (LLTracker::TRACKING_AVATAR == tracking_status)
{
- childSetColor("avatar_icon", map_track_color);
+ getChild<LLUICtrl>("avatar_icon")->setColor( map_track_color);
}
else
{
- childSetColor("avatar_icon", map_track_disabled_color);
+ getChild<LLUICtrl>("avatar_icon")->setColor( map_track_disabled_color);
}
if (LLTracker::TRACKING_LANDMARK == tracking_status)
{
- childSetColor("landmark_icon", map_track_color);
+ getChild<LLUICtrl>("landmark_icon")->setColor( map_track_color);
}
else
{
- childSetColor("landmark_icon", map_track_disabled_color);
+ getChild<LLUICtrl>("landmark_icon")->setColor( map_track_disabled_color);
}
if (LLTracker::TRACKING_LOCATION == tracking_status)
{
- childSetColor("location_icon", map_track_color);
+ getChild<LLUICtrl>("location_icon")->setColor( map_track_color);
}
else
{
@@ -423,11 +416,11 @@ void LLFloaterWorldMap::draw()
double value = fmod(seconds, 2);
value = 0.5 + 0.5*cos(value * F_PI);
LLColor4 loading_color(0.0, F32(value/2), F32(value), 1.0);
- childSetColor("location_icon", loading_color);
+ getChild<LLUICtrl>("location_icon")->setColor( loading_color);
}
else
{
- childSetColor("location_icon", map_track_disabled_color);
+ getChild<LLUICtrl>("location_icon")->setColor( map_track_disabled_color);
}
}
@@ -437,16 +430,16 @@ void LLFloaterWorldMap::draw()
centerOnTarget(TRUE);
}
- childSetEnabled("Teleport", (BOOL)tracking_status);
-// childSetEnabled("Clear", (BOOL)tracking_status);
- childSetEnabled("Show Destination", (BOOL)tracking_status || LLWorldMap::getInstance()->isTracking());
- childSetEnabled("copy_slurl", (mSLURL.isValid()) );
+ getChildView("Teleport")->setEnabled((BOOL)tracking_status);
+// getChildView("Clear")->setEnabled((BOOL)tracking_status);
+ getChildView("Show Destination")->setEnabled((BOOL)tracking_status || LLWorldMap::getInstance()->isTracking());
+ getChildView("copy_slurl")->setEnabled((mSLURL.isValid()) );
setMouseOpaque(TRUE);
getDragHandle()->setMouseOpaque(TRUE);
//RN: snaps to zoom value because interpolation caused jitter in the text rendering
- if (!mZoomTimer.getStarted() && mCurZoomVal != (F32)childGetValue("zoom slider").asReal())
+ if (!mZoomTimer.getStarted() && mCurZoomVal != (F32)getChild<LLUICtrl>("zoom slider")->getValue().asReal())
{
mZoomTimer.start();
}
@@ -456,7 +449,7 @@ void LLFloaterWorldMap::draw()
interp = 1.f;
mZoomTimer.stop();
}
- mCurZoomVal = lerp(mCurZoomVal, (F32)childGetValue("zoom slider").asReal(), interp);
+ mCurZoomVal = lerp(mCurZoomVal, (F32)getChild<LLUICtrl>("zoom slider")->getValue().asReal(), interp);
F32 map_scale = 256.f*pow(2.f, mCurZoomVal);
LLWorldMapView::setScale( map_scale );
@@ -464,13 +457,13 @@ void LLFloaterWorldMap::draw()
// If above threshold level (i.e. low res) -> Disable all checkboxes
// If under threshold level (i.e. high res) -> Enable all checkboxes
bool enable = LLWorldMapView::showRegionInfo();
- childSetEnabled("people_chk", enable);
- childSetEnabled("infohub_chk", enable);
- childSetEnabled("telehub_chk", enable);
- childSetEnabled("land_for_sale_chk", enable);
- childSetEnabled("event_chk", enable);
- childSetEnabled("events_mature_chk", enable);
- childSetEnabled("events_adult_chk", enable);
+ getChildView("people_chk")->setEnabled(enable);
+ getChildView("infohub_chk")->setEnabled(enable);
+ getChildView("telehub_chk")->setEnabled(enable);
+ getChildView("land_for_sale_chk")->setEnabled(enable);
+ getChildView("event_chk")->setEnabled(enable);
+ getChildView("events_mature_chk")->setEnabled(enable);
+ getChildView("events_adult_chk")->setEnabled(enable);
LLFloater::draw();
}
@@ -494,7 +487,7 @@ void LLFloaterWorldMap::trackAvatar( const LLUUID& avatar_id, const std::string&
// convenience.
if(gAgent.isGodlike())
{
- childSetValue("spin z", LLSD(200.f));
+ getChild<LLUICtrl>("spin z")->setValue(LLSD(200.f));
}
// Don't re-request info if we already have it or we won't have it in time to teleport
if (mTrackedStatus != LLTracker::TRACKING_AVATAR || name != mTrackedAvatarName)
@@ -582,6 +575,10 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global)
S32 world_y = S32(pos_global.mdV[1] / 256);
LLWorldMapMessage::getInstance()->sendMapBlockRequest(world_x, world_y, world_x, world_y, true);
setDefaultBtn("");
+
+ // clicked on a non-region - turn off coord display
+ enableTeleportCoordsDisplay( false );
+
return;
}
if (sim_info->isDown())
@@ -592,6 +589,10 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global)
LLWorldMap::getInstance()->setTrackingInvalid();
LLTracker::stopTracking(NULL);
setDefaultBtn("");
+
+ // clicked on a down region - turn off coord display
+ enableTeleportCoordsDisplay( false );
+
return;
}
@@ -609,9 +610,40 @@ void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global)
LLTracker::trackLocation(pos_global, full_name, tooltip);
LLWorldMap::getInstance()->cancelTracking(); // The floater is taking over the tracking
+ LLVector3d coord_pos = LLTracker::getTrackedPositionGlobal();
+ updateTeleportCoordsDisplay( coord_pos );
+
+ // we have a valid region - turn on coord display
+ enableTeleportCoordsDisplay( true );
+
setDefaultBtn("Teleport");
}
+// enable/disable teleport destination coordinates
+void LLFloaterWorldMap::enableTeleportCoordsDisplay( bool enabled )
+{
+ childSetEnabled("teleport_coordinate_x", enabled );
+ childSetEnabled("teleport_coordinate_y", enabled );
+ childSetEnabled("teleport_coordinate_z", enabled );
+}
+
+// update display of teleport destination coordinates - pos is in global coordinates
+void LLFloaterWorldMap::updateTeleportCoordsDisplay( const LLVector3d& pos )
+{
+ // if we're going to update their value, we should also enable them
+ enableTeleportCoordsDisplay( true );
+
+ // convert global specified position to a local one
+ F32 region_local_x = (F32)fmod( pos.mdV[VX], (F64)REGION_WIDTH_METERS );
+ F32 region_local_y = (F32)fmod( pos.mdV[VY], (F64)REGION_WIDTH_METERS );
+ F32 region_local_z = (F32)fmod( pos.mdV[VZ], (F64)REGION_WIDTH_METERS );
+
+ // write in the values
+ childSetValue("teleport_coordinate_x", region_local_x );
+ childSetValue("teleport_coordinate_y", region_local_y );
+ childSetValue("teleport_coordinate_z", region_local_z );
+}
+
void LLFloaterWorldMap::updateLocation()
{
bool gotSimName;
@@ -636,7 +668,10 @@ void LLFloaterWorldMap::updateLocation()
mSetToUserPosition = FALSE;
// Fill out the location field
- childSetValue("location", agent_sim_name);
+ getChild<LLUICtrl>("location")->setValue(agent_sim_name);
+
+ // update the coordinate display with location of avatar in region
+ updateTeleportCoordsDisplay( agentPos );
// Figure out where user is
// Set the current SLURL
@@ -666,7 +701,11 @@ void LLFloaterWorldMap::updateLocation()
}
}
- childSetValue("location", sim_name);
+ getChild<LLUICtrl>("location")->setValue(sim_name);
+
+ // refresh coordinate display to reflect where user clicked.
+ LLVector3d coord_pos = LLTracker::getTrackedPositionGlobal();
+ updateTeleportCoordsDisplay( coord_pos );
// simNameFromPosGlobal can fail, so don't give the user an invalid SLURL
if ( gotSimName )
@@ -697,7 +736,7 @@ void LLFloaterWorldMap::trackURL(const std::string& region_name, S32 x_coord, S3
else
{
// fill in UI based on URL
- gFloaterWorldMap->childSetValue("location", region_name);
+ gFloaterWorldMap->getChild<LLUICtrl>("location")->setValue(region_name);
// Save local coords to highlight position after region global
// position is returned.
@@ -1094,7 +1133,7 @@ void LLFloaterWorldMap::onLocationFocusChanged( LLFocusableElement* focus )
void LLFloaterWorldMap::updateSearchEnabled()
{
if (childHasKeyboardFocus("location") &&
- childGetValue("location").asString().length() > 0)
+ getChild<LLUICtrl>("location")->getValue().asString().length() > 0)
{
setDefaultBtn("DoSearch");
}
@@ -1115,14 +1154,14 @@ void LLFloaterWorldMap::onLocationCommit()
mCompletingRegionName = "";
mLastRegionName = "";
- std::string str = childGetValue("location").asString();
+ std::string str = getChild<LLUICtrl>("location")->getValue().asString();
// Trim any leading and trailing spaces in the search target
std::string saved_str = str;
LLStringUtil::trim( str );
if ( str != saved_str )
{ // Set the value in the UI if any spaces were removed
- childSetValue("location", str);
+ getChild<LLUICtrl>("location")->setValue(str);
}
LLStringUtil::toLower(str);
@@ -1139,6 +1178,22 @@ void LLFloaterWorldMap::onLocationCommit()
}
}
+void LLFloaterWorldMap::onCoordinatesCommit()
+{
+ if( mIsClosing )
+ {
+ return;
+ }
+
+ S32 x_coord = (S32)childGetValue("teleport_coordinate_x").asReal();
+ S32 y_coord = (S32)childGetValue("teleport_coordinate_y").asReal();
+ S32 z_coord = (S32)childGetValue("teleport_coordinate_z").asReal();
+
+ const std::string region_name = childGetValue("location").asString();
+
+ trackURL( region_name, x_coord, y_coord, z_coord );
+}
+
void LLFloaterWorldMap::onClearBtn()
{
mTrackedStatus = LLTracker::TRACKING_NOTHING;
@@ -1199,6 +1254,9 @@ void LLFloaterWorldMap::centerOnTarget(BOOL animate)
else if(LLWorldMap::getInstance()->isTracking())
{
pos_global = LLWorldMap::getInstance()->getTrackedPositionGlobal() - gAgentCamera.getCameraPositionGlobal();;
+
+
+
}
else
{
@@ -1243,7 +1301,7 @@ void LLFloaterWorldMap::teleport()
&& av_tracker.haveTrackingInfo() )
{
pos_global = av_tracker.getGlobalPos();
- pos_global.mdV[VZ] = childGetValue("spin z");
+ pos_global.mdV[VZ] = getChild<LLUICtrl>("spin z")->getValue();
}
else if ( LLTracker::TRACKING_LANDMARK == tracking_status)
{
@@ -1412,7 +1470,7 @@ void LLFloaterWorldMap::updateSims(bool found_null_sim)
if (!match.isUndefined())
{
list->selectByValue(match);
- childSetFocus("search_results");
+ getChild<LLUICtrl>("search_results")->setFocus(TRUE);
onCommitSearchResult();
}
@@ -1460,7 +1518,7 @@ void LLFloaterWorldMap::onCommitSearchResult()
pos_global.mdV[VY] += (F64)pos_local.mV[VY];
pos_global.mdV[VZ] = (F64)pos_local.mV[VZ];
- childSetValue("location", sim_name);
+ getChild<LLUICtrl>("location")->setValue(sim_name);
trackLocation(pos_global);
setDefaultBtn("Teleport");
break;
@@ -1475,13 +1533,13 @@ void LLFloaterWorldMap::onChangeMaturity()
bool can_access_mature = gAgent.canAccessMature();
bool can_access_adult = gAgent.canAccessAdult();
- childSetVisible("events_mature_icon", can_access_mature);
- childSetVisible("events_mature_label", can_access_mature);
- childSetVisible("events_mature_chk", can_access_mature);
+ getChildView("events_mature_icon")->setVisible( can_access_mature);
+ getChildView("events_mature_label")->setVisible( can_access_mature);
+ getChildView("events_mature_chk")->setVisible( can_access_mature);
- childSetVisible("events_adult_icon", can_access_adult);
- childSetVisible("events_adult_label", can_access_adult);
- childSetVisible("events_adult_chk", can_access_adult);
+ getChildView("events_adult_icon")->setVisible( can_access_adult);
+ getChildView("events_adult_label")->setVisible( can_access_adult);
+ getChildView("events_adult_chk")->setVisible( can_access_adult);
// disable mature / adult events.
if (!can_access_mature)