diff options
author | Aimee Linden <aimee@lindenlab.com> | 2010-09-07 21:51:41 +0100 |
---|---|---|
committer | Aimee Linden <aimee@lindenlab.com> | 2010-09-07 21:51:41 +0100 |
commit | 71fd7c89aa3a35131ce8133b0b9997038fbbfe32 (patch) | |
tree | 41ceb9eb4d72ca66eb6dd701a5339c9e1f6ce7f7 /indra/newview | |
parent | cfbb639aa60774dd1cac8ce53568e6a005d2acfb (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')
-rw-r--r-- | indra/newview/llnetmap.cpp | 97 | ||||
-rw-r--r-- | indra/newview/llnetmap.h | 3 |
2 files changed, 67 insertions, 33 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 ) { diff --git a/indra/newview/llnetmap.h b/indra/newview/llnetmap.h index e25ada4c95..650bce0da4 100644 --- a/indra/newview/llnetmap.h +++ b/indra/newview/llnetmap.h @@ -86,13 +86,14 @@ private: void drawTracking( const LLVector3d& pos_global, const LLColor4& color, BOOL draw_arrow = TRUE); + BOOL handleToolTipAgent(const LLUUID& avatar_id); static void showAvatarInspector(const LLUUID& avatar_id); void createObjectImage(); -private: static bool outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y, S32 slop); +private: bool mUpdateNow; LLUIColor mBackgroundColor; |