aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llnetmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llnetmap.cpp')
-rw-r--r--linden/indra/newview/llnetmap.cpp152
1 files changed, 131 insertions, 21 deletions
diff --git a/linden/indra/newview/llnetmap.cpp b/linden/indra/newview/llnetmap.cpp
index b0cce23..73f19d5 100644
--- a/linden/indra/newview/llnetmap.cpp
+++ b/linden/indra/newview/llnetmap.cpp
@@ -46,6 +46,7 @@
46#include "llcolorscheme.h" 46#include "llcolorscheme.h"
47#include "llviewercontrol.h" 47#include "llviewercontrol.h"
48#include "llfloateravatarinfo.h" 48#include "llfloateravatarinfo.h"
49#include "llfloatermap.h"
49#include "llfloaterworldmap.h" 50#include "llfloaterworldmap.h"
50#include "llframetimer.h" 51#include "llframetimer.h"
51#include "llmutelist.h" 52#include "llmutelist.h"
@@ -70,13 +71,15 @@
70#include "llglheaders.h" 71#include "llglheaders.h"
71 72
72const F32 MAP_SCALE_MIN = 32; 73const F32 MAP_SCALE_MIN = 32;
73const F32 MAP_SCALE_MID = 172; 74const F32 MAP_SCALE_MID = 1024;
74const F32 MAP_SCALE_MAX = 512; 75const F32 MAP_SCALE_MAX = 4096;
75const F32 MAP_SCALE_INCREMENT = 16; 76const F32 MAP_SCALE_INCREMENT = 16;
76const F32 MAP_MIN_PICK_DIST = 4; 77const F32 MAP_SCALE_ZOOM_FACTOR = 1.25f; // Zoom in factor per click of the scroll wheel (25%)
77const F32 MAP_MINOR_DIR_THRESHOLD = 0.08f; 78const F32 MAP_MINOR_DIR_THRESHOLD = 0.08f;
79const F32 MIN_DOT_RADIUS = 3.5f;
80const F32 DOT_SCALE = 0.75f;
81const F32 MIN_PICK_SCALE = 2.f;
78const S32 SLOP = 2; 82const S32 SLOP = 2;
79
80const S32 TRACKING_RADIUS = 3; 83const S32 TRACKING_RADIUS = 3;
81 84
82LLNetMap::LLNetMap(const std::string& name) : 85LLNetMap::LLNetMap(const std::string& name) :
@@ -92,6 +95,7 @@ LLNetMap::LLNetMap(const std::string& name) :
92{ 95{
93 mScale = gSavedSettings.getF32("MiniMapScale"); 96 mScale = gSavedSettings.getF32("MiniMapScale");
94 mPixelsPerMeter = mScale / LLWorld::getInstance()->getRegionWidthInMeters(); 97 mPixelsPerMeter = mScale / LLWorld::getInstance()->getRegionWidthInMeters();
98 mDotRadius = llmax(DOT_SCALE * mPixelsPerMeter, MIN_DOT_RADIUS);
95 99
96 mObjectImageCenterGlobal = gAgent.getCameraPositionGlobal(); 100 mObjectImageCenterGlobal = gAgent.getCameraPositionGlobal();
97 101
@@ -99,6 +103,8 @@ LLNetMap::LLNetMap(const std::string& name) :
99 (new LLScaleMap())->registerListener(this, "MiniMap.ZoomLevel"); 103 (new LLScaleMap())->registerListener(this, "MiniMap.ZoomLevel");
100 (new LLCenterMap())->registerListener(this, "MiniMap.Center"); 104 (new LLCenterMap())->registerListener(this, "MiniMap.Center");
101 (new LLCheckCenterMap())->registerListener(this, "MiniMap.CheckCenter"); 105 (new LLCheckCenterMap())->registerListener(this, "MiniMap.CheckCenter");
106 (new LLRotateMap())->registerListener(this, "MiniMap.Rotate");
107 (new LLCheckRotateMap())->registerListener(this, "MiniMap.CheckRotate");
102 (new LLShowWorldMap())->registerListener(this, "MiniMap.ShowWorldMap"); 108 (new LLShowWorldMap())->registerListener(this, "MiniMap.ShowWorldMap");
103 (new LLStopTracking())->registerListener(this, "MiniMap.StopTracking"); 109 (new LLStopTracking())->registerListener(this, "MiniMap.StopTracking");
104 (new LLEnableTracking())->registerListener(this, "MiniMap.EnableTracking"); 110 (new LLEnableTracking())->registerListener(this, "MiniMap.EnableTracking");
@@ -118,6 +124,11 @@ LLNetMap::LLNetMap(const std::string& name) :
118 mPopupMenuHandle = menu->getHandle(); 124 mPopupMenuHandle = menu->getHandle();
119} 125}
120 126
127BOOL LLNetMap::postBuild()
128{
129 return TRUE;
130}
131
121LLNetMap::~LLNetMap() 132LLNetMap::~LLNetMap()
122{ 133{
123} 134}
@@ -144,6 +155,7 @@ void LLNetMap::setScale( F32 scale )
144 } 155 }
145 156
146 mPixelsPerMeter = mScale / LLWorld::getInstance()->getRegionWidthInMeters(); 157 mPixelsPerMeter = mScale / LLWorld::getInstance()->getRegionWidthInMeters();
158 mDotRadius = llmax(DOT_SCALE * mPixelsPerMeter, MIN_DOT_RADIUS);
147 159
148 mUpdateNow = TRUE; 160 mUpdateNow = TRUE;
149} 161}
@@ -326,12 +338,16 @@ void LLNetMap::draw()
326 LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y); 338 LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y);
327 mClosestAgentToCursor.setNull(); 339 mClosestAgentToCursor.setNull();
328 F32 closest_dist = F32_MAX; 340 F32 closest_dist = F32_MAX;
341 F32 min_pick_dist = mDotRadius * MIN_PICK_SCALE;
329 342
330 // Draw avatars 343 // Draw avatars
331 LLColor4 avatar_color = gColors.getColor( "MapAvatar" ); 344 LLColor4 avatar_color = gColors.getColor( "MapAvatar" );
332 LLColor4 friend_color = gColors.getColor( "MapFriend" ); 345 LLColor4 friend_color = gColors.getColor( "MapFriend" );
333 LLColor4 muted_color = gColors.getColor( "MapMuted" ); 346 LLColor4 muted_color = gColors.getColor( "MapMuted" );
347 LLColor4 selected_color = gColors.getColor( "MapSelected" );
348 LLColor4 imp_dev_color = gColors.getColor( "MapImpDev" );
334 LLColor4 glyph_color; 349 LLColor4 glyph_color;
350 int selected = -1;
335 351
336 std::vector<LLUUID> avatar_ids; 352 std::vector<LLUUID> avatar_ids;
337 std::vector<LLVector3d> positions; 353 std::vector<LLVector3d> positions;
@@ -341,34 +357,78 @@ void LLNetMap::draw()
341 // TODO: it'd be very cool to draw these in sorted order from lowest Z to highest. 357 // TODO: it'd be very cool to draw these in sorted order from lowest Z to highest.
342 // just be careful to sort the avatar IDs along with the positions. -MG 358 // just be careful to sort the avatar IDs along with the positions. -MG
343 pos_map = globalPosToView(positions[i], rotate_map); 359 pos_map = globalPosToView(positions[i], rotate_map);
344 360
345 // Show them muted even if they're friends 361 // Save this entry to draw last
346 if (LLMuteList::getInstance()->isMuted(avatar_ids[i])) 362 if (LLFloaterMap::getSelected() == avatar_ids[i])
347 { 363 {
348 glyph_color = muted_color; 364 selected = i;
365 continue;
349 } 366 }
350 else if (is_agent_friend(avatar_ids[i])) 367 else
351 { 368 {
352 glyph_color = friend_color; 369 // Show them muted even if they're friends
370 if (LLMuteList::getInstance()->isMuted(avatar_ids[i]))
371 {
372 glyph_color = muted_color;
373 }
374 else if (LLFloaterMap::isImpDev(avatar_ids[i]))
375 {
376 glyph_color = imp_dev_color;
377 }
378 else if (is_agent_friend(avatar_ids[i]))
379 {
380 glyph_color = friend_color;
381 }
382 else
383 {
384 glyph_color = avatar_color;
385 }
353 } 386 }
354 else 387
388// [RLVa:KB] - Alternate: Imprudence-1.2.0
389 if ( gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES) )
355 { 390 {
391 // User is not allowed to see who it is, or even if it's a friend,
392 // due to RLV settings.
356 glyph_color = avatar_color; 393 glyph_color = avatar_color;
357 } 394 }
395// [/RLVa:KB]
358 396
359 LLWorldMapView::drawAvatar( 397 LLWorldMapView::drawAvatar(
360 pos_map.mV[VX], pos_map.mV[VY], 398 pos_map.mV[VX], pos_map.mV[VY],
361 glyph_color, 399 glyph_color,
362 pos_map.mV[VZ]); 400 pos_map.mV[VZ],
401 mDotRadius);
363 402
364 F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); 403 F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y));
365 if(dist_to_cursor < MAP_MIN_PICK_DIST && dist_to_cursor < closest_dist) 404 if(dist_to_cursor < min_pick_dist && dist_to_cursor < closest_dist)
366 { 405 {
367 closest_dist = dist_to_cursor; 406 closest_dist = dist_to_cursor;
368 mClosestAgentToCursor = avatar_ids[i]; 407 mClosestAgentToCursor = avatar_ids[i];
369 } 408 }
370 } 409 }
371 410
411 // Draw dot for selected avatar last
412 if (selected >= 0 && avatar_ids[selected].notNull())
413 {
414 pos_map = globalPosToView(positions[selected], rotate_map);
415 F32 glyph_radius = mDotRadius * 1.7f;
416 glyph_color = selected_color;
417
418 LLWorldMapView::drawAvatar(
419 pos_map.mV[VX], pos_map.mV[VY],
420 glyph_color,
421 pos_map.mV[VZ],
422 glyph_radius);
423
424 F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y));
425 if(dist_to_cursor < min_pick_dist && dist_to_cursor < closest_dist)
426 {
427 closest_dist = dist_to_cursor;
428 mClosestAgentToCursor = avatar_ids[selected];
429 }
430 }
431
372 // Draw dot for autopilot target 432 // Draw dot for autopilot target
373 if (gAgent.getAutoPilot()) 433 if (gAgent.getAutoPilot())
374 { 434 {
@@ -391,10 +451,13 @@ void LLNetMap::draw()
391 // Draw dot for self avatar position 451 // Draw dot for self avatar position
392 pos_global = gAgent.getPositionGlobal(); 452 pos_global = gAgent.getPositionGlobal();
393 pos_map = globalPosToView(pos_global, rotate_map); 453 pos_map = globalPosToView(pos_global, rotate_map);
394 LLUIImagePtr you = LLWorldMapView::sAvatarYouSmallImage; 454 LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage;
455 S32 dot_width = llround(mDotRadius * 2.f);
395 you->draw( 456 you->draw(
396 llround(pos_map.mV[VX]) - you->getWidth()/2, 457 llround(pos_map.mV[VX] - mDotRadius),
397 llround(pos_map.mV[VY]) - you->getHeight()/2); 458 llround(pos_map.mV[VY] - mDotRadius),
459 dot_width,
460 dot_width);
398 461
399 // Draw frustum 462 // Draw frustum
400 F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters(); 463 F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters();
@@ -451,6 +514,8 @@ void LLNetMap::draw()
451 setDirectionPos( getChild<LLTextBox>("se_label"), rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2); 514 setDirectionPos( getChild<LLTextBox>("se_label"), rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2);
452 515
453 LLView::draw(); 516 LLView::draw();
517
518 LLFloaterMap::updateRadar();
454} 519}
455 520
456void LLNetMap::reshape(S32 width, S32 height, BOOL called_from_parent) 521void LLNetMap::reshape(S32 width, S32 height, BOOL called_from_parent)
@@ -533,8 +598,12 @@ LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y, BOOL rotated )
533 598
534BOOL LLNetMap::handleScrollWheel(S32 x, S32 y, S32 clicks) 599BOOL LLNetMap::handleScrollWheel(S32 x, S32 y, S32 clicks)
535{ 600{
536 // note that clicks are reversed from what you'd think 601 // note that clicks are reversed from what you'd think: i.e. > 0 means zoom out, < 0 means zoom in
537 setScale(llclamp(mScale - clicks*MAP_SCALE_INCREMENT, MAP_SCALE_MIN, MAP_SCALE_MAX)); 602 F32 scale = mScale;
603
604 scale *= pow(MAP_SCALE_ZOOM_FACTOR, -clicks);
605 setScale(llclamp(scale, MAP_SCALE_MIN, MAP_SCALE_MAX));
606
538 return TRUE; 607 return TRUE;
539} 608}
540 609
@@ -552,11 +621,26 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rec
552 std::string fullname; 621 std::string fullname;
553 if(mClosestAgentToCursor.notNull() && gCacheName->getFullName(mClosestAgentToCursor, fullname)) 622 if(mClosestAgentToCursor.notNull() && gCacheName->getFullName(mClosestAgentToCursor, fullname))
554 { 623 {
555 msg.append(fullname); 624// [RLVa:KB] - Alternate: Imprudence-1.2.0
625 // User is not allowed to see who it is, due to RLV settings.
626 msg.append( (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? fullname : gRlvHandler.getAnonym(fullname) );
556 msg.append("\n"); 627 msg.append("\n");
628 // [/RLVa:KB]
557 } 629 }
558 msg.append( region->getName() );
559 630
631// [RLVa:KB] - Alternate: Imprudence-1.2.0
632 if ( gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC) )
633 {
634 // User is not allowed to see where they are, due to RLV settings.
635 msg.append( rlv_handler_t::cstrHidden );
636 }
637 else
638 {
639 msg.append( region->getName() );
640 }
641// [/RLVa:KB]
642
643
560 msg.append("\n"); 644 msg.append("\n");
561 gSavedSettings.getBOOL( "MiniMapTeleport" ) ? 645 gSavedSettings.getBOOL( "MiniMapTeleport" ) ?
562 msg.append(getString("tooltip_tp")) : msg.append(getString("tooltip_map")); 646 msg.append(getString("tooltip_tp")) : msg.append(getString("tooltip_map"));
@@ -893,6 +977,22 @@ bool LLNetMap::LLScaleMap::handleEvent(LLPointer<LLEvent> event, const LLSD& use
893 return true; 977 return true;
894} 978}
895 979
980bool LLNetMap::LLRotateMap::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
981{
982 BOOL rotate = gSavedSettings.getBOOL("MiniMapRotate");
983 gSavedSettings.setBOOL("MiniMapRotate", !rotate);
984
985 return true;
986}
987
988bool LLNetMap::LLCheckRotateMap::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
989{
990 LLNetMap *self = mPtr;
991 BOOL enabled = gSavedSettings.getBOOL("MiniMapRotate");
992 self->findControl(userdata["control"].asString())->setValue(enabled);
993 return true;
994}
995
896bool LLNetMap::LLCenterMap::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 996bool LLNetMap::LLCenterMap::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
897{ 997{
898 S32 center = userdata.asInteger(); 998 S32 center = userdata.asInteger();
@@ -940,6 +1040,13 @@ bool LLNetMap::LLEnableTracking::handleEvent(LLPointer<LLEvent> event, const LLS
940 1040
941bool LLNetMap::LLShowAgentProfile::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 1041bool LLNetMap::LLShowAgentProfile::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
942{ 1042{
1043// [RLVa:KB] - Alternate: Imprudence-1.2.0
1044 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
1045 {
1046 return true;
1047 }
1048// [/RLVa:KB]
1049
943 LLNetMap *self = mPtr; 1050 LLNetMap *self = mPtr;
944 LLFloaterAvatarInfo::show(self->mClosestAgentAtLastRightClick); 1051 LLFloaterAvatarInfo::show(self->mClosestAgentAtLastRightClick);
945 return true; 1052 return true;
@@ -948,6 +1055,9 @@ bool LLNetMap::LLShowAgentProfile::handleEvent(LLPointer<LLEvent> event, const L
948bool LLNetMap::LLEnableProfile::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) 1055bool LLNetMap::LLEnableProfile::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
949{ 1056{
950 LLNetMap *self = mPtr; 1057 LLNetMap *self = mPtr;
951 self->findControl(userdata["control"].asString())->setValue(self->isAgentUnderCursor()); 1058 //self->findControl(userdata["control"].asString())->setValue(self->isAgentUnderCursor());
1059// [RLVa:KB] - Alternate: Imprudence-1.2.0
1060 self->findControl(userdata["control"].asString())->setValue(self->isAgentUnderCursor() && !gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES));
1061// [/RLVa:KB]
952 return true; 1062 return true;
953} 1063}