summaryrefslogtreecommitdiff
path: root/indra/newview/llnetmap.cpp
diff options
context:
space:
mode:
authorAimee Linden <aimee@lindenlab.com>2010-09-07 21:51:41 +0100
committerAimee Linden <aimee@lindenlab.com>2010-09-07 21:51:41 +0100
commit71fd7c89aa3a35131ce8133b0b9997038fbbfe32 (patch)
tree41ceb9eb4d72ca66eb6dd701a5339c9e1f6ce7f7 /indra/newview/llnetmap.cpp
parentcfbb639aa60774dd1cac8ce53568e6a005d2acfb (diff)
VWR-17653 (SNOW-734) FIXED Show inspectors for avatars on the MiniMap
Reworked, as the original version clashed with the display names merge.
Diffstat (limited to 'indra/newview/llnetmap.cpp')
-rw-r--r--indra/newview/llnetmap.cpp97
1 files changed, 65 insertions, 32 deletions
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index b0b2a3f6f9..f084002385 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -568,48 +568,37 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, MASK mask )
{
return FALSE;
}
-
- // mToolTipMsg = "[AGENT][REGION](Double-click to open Map)"
-
- bool have_agent = false;
- LLStringUtil::format_map_t args;
- LLAvatarName av_name;
- if(mClosestAgentToCursor.notNull()
- && LLAvatarNameCache::get(mClosestAgentToCursor, &av_name))
- {
- args["[AGENT]"] = av_name.getCompleteName() + "\n";
- have_agent = true;
- }
- else
- {
- args["[AGENT]"] = "";
- }
-
- LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal( viewPosToGlobal( x, y ) );
- if( region && !have_agent)
- {
- args["[REGION]"] = region->getName() + "\n";
- }
- else
+
+ // If the cursor is near an avatar on the minimap, a mini-inspector will be
+ // shown for the avatar, instead of the normal map tooltip.
+ if (handleToolTipAgent(mClosestAgentToCursor))
{
- args["[REGION]"] = "";
+ return TRUE;
}
- std::string msg = mToolTipMsg;
- LLStringUtil::format(msg, args);
-
LLRect sticky_rect;
- // set sticky_rect
- if (region)
+ std::string region_name;
+ LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal( viewPosToGlobal( x, y ) );
+ if(region)
{
+ // set sticky_rect
S32 SLOP = 4;
- localPointToScreen(
- x - SLOP, y - SLOP,
- &(sticky_rect.mLeft), &(sticky_rect.mBottom) );
+ localPointToScreen(x - SLOP, y - SLOP, &(sticky_rect.mLeft), &(sticky_rect.mBottom));
sticky_rect.mRight = sticky_rect.mLeft + 2 * SLOP;
sticky_rect.mTop = sticky_rect.mBottom + 2 * SLOP;
+
+ region_name = region->getName();
+ if (!region_name.empty())
+ {
+ region_name += "\n";
+ }
}
+ LLStringUtil::format_map_t args;
+ args["[REGION]"] = region_name;
+ std::string msg = mToolTipMsg;
+ LLStringUtil::format(msg, args);
+
LLToolTipMgr::instance().show(LLToolTip::Params()
.message(msg)
.sticky_rect(sticky_rect));
@@ -617,6 +606,50 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, MASK mask )
return TRUE;
}
+BOOL LLNetMap::handleToolTipAgent(const LLUUID& avatar_id)
+{
+ LLAvatarName av_name;
+ if (avatar_id.isNull() || !LLAvatarNameCache::get(avatar_id, &av_name))
+ {
+ return FALSE;
+ }
+
+ // only show tooltip if same inspector not already open
+ LLFloater* existing_inspector = LLFloaterReg::findInstance("inspect_avatar");
+ if (!existing_inspector
+ || !existing_inspector->getVisible()
+ || existing_inspector->getKey()["avatar_id"].asUUID() != avatar_id)
+ {
+ LLInspector::Params p;
+ p.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLInspector>());
+ p.message(av_name.getCompleteName());
+ p.image.name("Inspector_I");
+ p.click_callback(boost::bind(showAvatarInspector, avatar_id));
+ p.visible_time_near(6.f);
+ p.visible_time_far(3.f);
+ p.delay_time(0.35f);
+ p.wrap(false);
+
+ LLToolTipMgr::instance().show(p);
+ }
+ return TRUE;
+}
+
+// static
+void LLNetMap::showAvatarInspector(const LLUUID& avatar_id)
+{
+ LLSD params;
+ params["avatar_id"] = avatar_id;
+
+ if (LLToolTipMgr::instance().toolTipVisible())
+ {
+ LLRect rect = LLToolTipMgr::instance().getToolTipRect();
+ params["pos"]["x"] = rect.mLeft;
+ params["pos"]["y"] = rect.mTop;
+ }
+
+ LLFloaterReg::showInstance("inspect_avatar", params);
+}
void LLNetMap::renderScaledPointGlobal( const LLVector3d& pos, const LLColor4U &color, F32 radius_meters )
{