aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llnetmap.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llnetmap.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llnetmap.cpp193
1 files changed, 96 insertions, 97 deletions
diff --git a/linden/indra/newview/llnetmap.cpp b/linden/indra/newview/llnetmap.cpp
index ca6161b..01400b1 100644
--- a/linden/indra/newview/llnetmap.cpp
+++ b/linden/indra/newview/llnetmap.cpp
@@ -36,9 +36,9 @@
36 36
37#include "indra_constants.h" 37#include "indra_constants.h"
38#include "llui.h" 38#include "llui.h"
39#include "linked_lists.h"
40#include "llmath.h" // clampf() 39#include "llmath.h" // clampf()
41#include "llfocusmgr.h" 40#include "llfocusmgr.h"
41#include "llglimmediate.h"
42 42
43#include "llagent.h" 43#include "llagent.h"
44#include "llcallingcard.h" 44#include "llcallingcard.h"
@@ -117,9 +117,11 @@ LLNetMap::LLNetMap(
117 mTextBoxEast->setColor( minor_color ); 117 mTextBoxEast->setColor( minor_color );
118 addChild( mTextBoxEast ); 118 addChild( mTextBoxEast );
119 119
120 major_dir_rect.mRight += 1 ;
120 mTextBoxWest = new LLTextBox( "W", major_dir_rect ); 121 mTextBoxWest = new LLTextBox( "W", major_dir_rect );
121 mTextBoxWest->setColor( minor_color ); 122 mTextBoxWest->setColor( minor_color );
122 addChild( mTextBoxWest ); 123 addChild( mTextBoxWest );
124 major_dir_rect.mRight -= 1 ;
123 125
124 mTextBoxSouth = new LLTextBox( "S", major_dir_rect ); 126 mTextBoxSouth = new LLTextBox( "S", major_dir_rect );
125 mTextBoxSouth->setColor( minor_color ); 127 mTextBoxSouth->setColor( minor_color );
@@ -158,7 +160,7 @@ LLNetMap::LLNetMap(
158 &LLTracker::isTracking, NULL) ); 160 &LLTracker::isTracking, NULL) );
159 menu->setVisible(FALSE); 161 menu->setVisible(FALSE);
160 addChild(menu); 162 addChild(menu);
161 mPopupMenuHandle = menu->mViewHandle; 163 mPopupMenuHandle = menu->getHandle();
162 164
163 sInstance = this; 165 sInstance = this;
164 166
@@ -191,8 +193,8 @@ void LLNetMap::setScale( F32 scale )
191 193
192 if (mObjectImagep.notNull()) 194 if (mObjectImagep.notNull())
193 { 195 {
194 F32 half_width = (F32)(mRect.getWidth() / 2); 196 F32 half_width = (F32)(getRect().getWidth() / 2);
195 F32 half_height = (F32)(mRect.getHeight() / 2); 197 F32 half_height = (F32)(getRect().getHeight() / 2);
196 F32 radius = sqrt( half_width * half_width + half_height * half_height ); 198 F32 radius = sqrt( half_width * half_width + half_height * half_height );
197 199
198 F32 region_widths = (2.f*radius)/gMiniMapScale; 200 F32 region_widths = (2.f*radius)/gMiniMapScale;
@@ -256,17 +258,17 @@ void LLNetMap::draw()
256 glMatrixMode(GL_MODELVIEW); 258 glMatrixMode(GL_MODELVIEW);
257 259
258 // Draw background rectangle 260 // Draw background rectangle
259 glColor4fv( mBackgroundColor.mV ); 261 gGL.color4fv( mBackgroundColor.mV );
260 gl_rect_2d(0, mRect.getHeight(), mRect.getWidth(), 0); 262 gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0);
261 } 263 }
262 264
263 // region 0,0 is in the middle 265 // region 0,0 is in the middle
264 S32 center_sw_left = mRect.getWidth() / 2 + llfloor(mCurPanX); 266 S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX);
265 S32 center_sw_bottom = mRect.getHeight() / 2 + llfloor(mCurPanY); 267 S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY);
266 268
267 glPushMatrix(); 269 gGL.pushMatrix();
268 270
269 glTranslatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); 271 gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f);
270 272
271 if( LLNetMap::sRotateMap ) 273 if( LLNetMap::sRotateMap )
272 { 274 {
@@ -296,31 +298,31 @@ void LLNetMap::draw()
296 298
297 if (regionp == gAgent.getRegion()) 299 if (regionp == gAgent.getRegion())
298 { 300 {
299 glColor4f(1.f, 1.f, 1.f, 1.f); 301 gGL.color4f(1.f, 1.f, 1.f, 1.f);
300 } 302 }
301 else 303 else
302 { 304 {
303 glColor4f(0.8f, 0.8f, 0.8f, 1.f); 305 gGL.color4f(0.8f, 0.8f, 0.8f, 1.f);
304 } 306 }
305 307
306 if (!regionp->mAlive) 308 if (!regionp->mAlive)
307 { 309 {
308 glColor4f(1.f, 0.5f, 0.5f, 1.f); 310 gGL.color4f(1.f, 0.5f, 0.5f, 1.f);
309 } 311 }
310 312
311 313
312 // Draw using texture. 314 // Draw using texture.
313 LLViewerImage::bindTexture(regionp->getLand().getSTexture()); 315 LLViewerImage::bindTexture(regionp->getLand().getSTexture());
314 glBegin(GL_QUADS); 316 gGL.begin(GL_QUADS);
315 glTexCoord2f(0.f, 1.f); 317 gGL.texCoord2f(0.f, 1.f);
316 glVertex2f(left, top); 318 gGL.vertex2f(left, top);
317 glTexCoord2f(0.f, 0.f); 319 gGL.texCoord2f(0.f, 0.f);
318 glVertex2f(left, bottom); 320 gGL.vertex2f(left, bottom);
319 glTexCoord2f(1.f, 0.f); 321 gGL.texCoord2f(1.f, 0.f);
320 glVertex2f(right, bottom); 322 gGL.vertex2f(right, bottom);
321 glTexCoord2f(1.f, 1.f); 323 gGL.texCoord2f(1.f, 1.f);
322 glVertex2f(right, top); 324 gGL.vertex2f(right, top);
323 glEnd(); 325 gGL.end();
324 326
325 // Draw water 327 // Draw water
326 glAlphaFunc(GL_GREATER, ABOVE_WATERLINE_ALPHA / 255.f ); 328 glAlphaFunc(GL_GREATER, ABOVE_WATERLINE_ALPHA / 255.f );
@@ -328,16 +330,16 @@ void LLNetMap::draw()
328 if (regionp->getLand().getWaterTexture()) 330 if (regionp->getLand().getWaterTexture())
329 { 331 {
330 LLViewerImage::bindTexture(regionp->getLand().getWaterTexture()); 332 LLViewerImage::bindTexture(regionp->getLand().getWaterTexture());
331 glBegin(GL_QUADS); 333 gGL.begin(GL_QUADS);
332 glTexCoord2f(0.f, 1.f); 334 gGL.texCoord2f(0.f, 1.f);
333 glVertex2f(left, top); 335 gGL.vertex2f(left, top);
334 glTexCoord2f(0.f, 0.f); 336 gGL.texCoord2f(0.f, 0.f);
335 glVertex2f(left, bottom); 337 gGL.vertex2f(left, bottom);
336 glTexCoord2f(1.f, 0.f); 338 gGL.texCoord2f(1.f, 0.f);
337 glVertex2f(right, bottom); 339 gGL.vertex2f(right, bottom);
338 glTexCoord2f(1.f, 1.f); 340 gGL.texCoord2f(1.f, 1.f);
339 glVertex2f(right, top); 341 gGL.vertex2f(right, top);
340 glEnd(); 342 gGL.end();
341 } 343 }
342 } 344 }
343 glAlphaFunc(GL_GREATER,0.01f); 345 glAlphaFunc(GL_GREATER,0.01f);
@@ -378,18 +380,18 @@ void LLNetMap::draw()
378 F32 image_half_width = 0.5f*mObjectMapPixels; 380 F32 image_half_width = 0.5f*mObjectMapPixels;
379 F32 image_half_height = 0.5f*mObjectMapPixels; 381 F32 image_half_height = 0.5f*mObjectMapPixels;
380 382
381 glBegin(GL_QUADS); 383 gGL.begin(GL_QUADS);
382 glTexCoord2f(0.f, 1.f); 384 gGL.texCoord2f(0.f, 1.f);
383 glVertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); 385 gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]);
384 glTexCoord2f(0.f, 0.f); 386 gGL.texCoord2f(0.f, 0.f);
385 glVertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); 387 gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height);
386 glTexCoord2f(1.f, 0.f); 388 gGL.texCoord2f(1.f, 0.f);
387 glVertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); 389 gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height);
388 glTexCoord2f(1.f, 1.f); 390 gGL.texCoord2f(1.f, 1.f);
389 glVertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); 391 gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]);
390 glEnd(); 392 gGL.end();
391 393
392 glPopMatrix(); 394 gGL.popMatrix();
393 395
394 LLVector3d pos_global; 396 LLVector3d pos_global;
395 LLVector3 pos_map; 397 LLVector3 pos_map;
@@ -486,28 +488,28 @@ void LLNetMap::draw()
486 488
487 if( LLNetMap::sRotateMap ) 489 if( LLNetMap::sRotateMap )
488 { 490 {
489 glColor4fv(gFrustumMapColor.mV); 491 gGL.color4fv(gFrustumMapColor.mV);
490 492
491 glBegin( GL_TRIANGLES ); 493 gGL.begin( GL_TRIANGLES );
492 glVertex2f( ctr_x, ctr_y ); 494 gGL.vertex2f( ctr_x, ctr_y );
493 glVertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); 495 gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels );
494 glVertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); 496 gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels );
495 glEnd(); 497 gGL.end();
496 } 498 }
497 else 499 else
498 { 500 {
499 glColor4fv(gRotatingFrustumMapColor.mV); 501 gGL.color4fv(gRotatingFrustumMapColor.mV);
500 502
501 // If we don't rotate the map, we have to rotate the frustum. 503 // If we don't rotate the map, we have to rotate the frustum.
502 glPushMatrix(); 504 gGL.pushMatrix();
503 glTranslatef( ctr_x, ctr_y, 0 ); 505 gGL.translatef( ctr_x, ctr_y, 0 );
504 glRotatef( atan2( gCamera->getAtAxis().mV[VX], gCamera->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); 506 glRotatef( atan2( gCamera->getAtAxis().mV[VX], gCamera->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f);
505 glBegin( GL_TRIANGLES ); 507 gGL.begin( GL_TRIANGLES );
506 glVertex2f( 0, 0 ); 508 gGL.vertex2f( 0, 0 );
507 glVertex2f( -half_width_pixels, far_clip_pixels ); 509 gGL.vertex2f( -half_width_pixels, far_clip_pixels );
508 glVertex2f( half_width_pixels, far_clip_pixels ); 510 gGL.vertex2f( half_width_pixels, far_clip_pixels );
509 glEnd(); 511 gGL.end();
510 glPopMatrix(); 512 gGL.popMatrix();
511 } 513 }
512 } 514 }
513 515
@@ -542,8 +544,8 @@ LLVector3 LLNetMap::globalPosToView( const LLVector3d& global_pos )
542 pos_local.rotVec( rot ); 544 pos_local.rotVec( rot );
543 } 545 }
544 546
545 pos_local.mV[VX] += mRect.getWidth() / 2 + mCurPanX; 547 pos_local.mV[VX] += getRect().getWidth() / 2 + mCurPanX;
546 pos_local.mV[VY] += mRect.getHeight() / 2 + mCurPanY; 548 pos_local.mV[VY] += getRect().getHeight() / 2 + mCurPanY;
547 549
548 return pos_local; 550 return pos_local;
549} 551}
@@ -554,15 +556,15 @@ void LLNetMap::drawTracking(const LLVector3d& pos_global, const LLColor4& color,
554 LLVector3 pos_local = globalPosToView( pos_global ); 556 LLVector3 pos_local = globalPosToView( pos_global );
555 if( (pos_local.mV[VX] < 0) || 557 if( (pos_local.mV[VX] < 0) ||
556 (pos_local.mV[VY] < 0) || 558 (pos_local.mV[VY] < 0) ||
557 (pos_local.mV[VX] >= mRect.getWidth()) || 559 (pos_local.mV[VX] >= getRect().getWidth()) ||
558 (pos_local.mV[VY] >= mRect.getHeight()) ) 560 (pos_local.mV[VY] >= getRect().getHeight()) )
559 { 561 {
560 if (draw_arrow) 562 if (draw_arrow)
561 { 563 {
562 S32 x = llround( pos_local.mV[VX] ); 564 S32 x = llround( pos_local.mV[VX] );
563 S32 y = llround( pos_local.mV[VY] ); 565 S32 y = llround( pos_local.mV[VY] );
564 LLWorldMapView::drawTrackingCircle( mRect, x, y, color, 1, 10 ); 566 LLWorldMapView::drawTrackingCircle( getRect(), x, y, color, 1, 10 );
565 LLWorldMapView::drawTrackingArrow( mRect, x, y, color ); 567 LLWorldMapView::drawTrackingArrow( getRect(), x, y, color );
566 } 568 }
567 } 569 }
568 else 570 else
@@ -576,8 +578,8 @@ void LLNetMap::drawTracking(const LLVector3d& pos_global, const LLColor4& color,
576 578
577LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y ) 579LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y )
578{ 580{
579 x -= llround(mRect.getWidth() / 2 + mCurPanX); 581 x -= llround(getRect().getWidth() / 2 + mCurPanX);
580 y -= llround(mRect.getHeight() / 2 + mCurPanY); 582 y -= llround(getRect().getHeight() / 2 + mCurPanY);
581 583
582 LLVector3 pos_local( (F32)x, (F32)y, 0 ); 584 LLVector3 pos_local( (F32)x, (F32)y, 0 );
583 585
@@ -612,35 +614,32 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect_s
612 { 614 {
613 return FALSE; 615 return FALSE;
614 } 616 }
615 if( getVisible() && pointInView( x, y ) ) 617 LLViewerRegion* region = gWorldPointer->getRegionFromPosGlobal( viewPosToGlobal( x, y ) );
618 if( region )
616 { 619 {
617 LLViewerRegion* region = gWorldPointer->getRegionFromPosGlobal( viewPosToGlobal( x, y ) ); 620 msg.assign( region->getName() );
618 if( region )
619 {
620 msg.assign( region->getName() );
621 621
622#ifndef LL_RELEASE_FOR_DOWNLOAD 622#ifndef LL_RELEASE_FOR_DOWNLOAD
623 char buffer[MAX_STRING]; /*Flawfinder: ignore*/ 623 char buffer[MAX_STRING]; /*Flawfinder: ignore*/
624 msg.append("\n"); 624 msg.append("\n");
625 region->getHost().getHostName(buffer, MAX_STRING); 625 region->getHost().getHostName(buffer, MAX_STRING);
626 msg.append(buffer); 626 msg.append(buffer);
627 msg.append("\n"); 627 msg.append("\n");
628 region->getHost().getString(buffer, MAX_STRING); 628 region->getHost().getString(buffer, MAX_STRING);
629 msg.append(buffer); 629 msg.append(buffer);
630#endif 630#endif
631 // *TODO: put this under the control of XUI so it can be 631 // *TODO: put this under the control of XUI so it can be
632 // translated. 632 // translated.
633 msg.append("\n(Double-click to open Map)"); 633 msg.append("\n(Double-click to open Map)");
634 634
635 S32 SLOP = 4; 635 S32 SLOP = 4;
636 localPointToScreen( 636 localPointToScreen(
637 x - SLOP, y - SLOP, 637 x - SLOP, y - SLOP,
638 &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) ); 638 &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
639 sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP; 639 sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
640 sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP; 640 sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
641 }
642 handled = TRUE;
643 } 641 }
642 handled = TRUE;
644 return handled; 643 return handled;
645} 644}
646 645
@@ -651,8 +650,8 @@ void LLNetMap::setDirectionPos( LLTextBox* text_box, F32 rotation )
651 // Rotation of 0 means x = 1, y = 0 on the unit circle. 650 // Rotation of 0 means x = 1, y = 0 on the unit circle.
652 651
653 652
654 F32 map_half_height = (F32)(mRect.getHeight() / 2); 653 F32 map_half_height = (F32)(getRect().getHeight() / 2);
655 F32 map_half_width = (F32)(mRect.getWidth() / 2); 654 F32 map_half_width = (F32)(getRect().getWidth() / 2);
656 F32 text_half_height = (F32)(text_box->getRect().getHeight() / 2); 655 F32 text_half_height = (F32)(text_box->getRect().getHeight() / 2);
657 F32 text_half_width = (F32)(text_box->getRect().getWidth() / 2); 656 F32 text_half_width = (F32)(text_box->getRect().getWidth() / 2);
658 F32 radius = llmin( map_half_height - text_half_height, map_half_width - text_half_width ); 657 F32 radius = llmin( map_half_height - text_half_height, map_half_width - text_half_width );
@@ -762,9 +761,9 @@ void LLNetMap::renderPoint(const LLVector3 &pos_local, const LLColor4U &color,
762 761
763void LLNetMap::createObjectImage() 762void LLNetMap::createObjectImage()
764{ 763{
765 // Find the size of the side of a square that surrounds the circle that surrounds mRect. 764 // Find the size of the side of a square that surrounds the circle that surrounds getRect().
766 F32 half_width = (F32)(mRect.getWidth() / 2); 765 F32 half_width = (F32)(getRect().getWidth() / 2);
767 F32 half_height = (F32)(mRect.getHeight() / 2); 766 F32 half_height = (F32)(getRect().getHeight() / 2);
768 F32 radius = sqrt( half_width * half_width + half_height * half_height ); 767 F32 radius = sqrt( half_width * half_width + half_height * half_height );
769 S32 square_size = S32( 2 * radius ); 768 S32 square_size = S32( 2 * radius );
770 769
@@ -798,7 +797,7 @@ BOOL LLNetMap::handleDoubleClick( S32 x, S32 y, MASK mask )
798 797
799BOOL LLNetMap::handleRightMouseDown(S32 x, S32 y, MASK mask) 798BOOL LLNetMap::handleRightMouseDown(S32 x, S32 y, MASK mask)
800{ 799{
801 LLMenuGL* menu = (LLMenuGL*)LLView::getViewByHandle(mPopupMenuHandle); 800 LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
802 if (menu) 801 if (menu)
803 { 802 {
804 menu->buildDrawLabels(); 803 menu->buildDrawLabels();