aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolpie.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/lltoolpie.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/lltoolpie.cpp')
-rw-r--r--linden/indra/newview/lltoolpie.cpp105
1 files changed, 49 insertions, 56 deletions
diff --git a/linden/indra/newview/lltoolpie.cpp b/linden/indra/newview/lltoolpie.cpp
index 4bb2111..0e8ba56 100644
--- a/linden/indra/newview/lltoolpie.cpp
+++ b/linden/indra/newview/lltoolpie.cpp
@@ -81,53 +81,51 @@ static ECursorType cursor_from_parcel_media(U8 click_action);
81 81
82 82
83LLToolPie::LLToolPie() 83LLToolPie::LLToolPie()
84: LLTool("Select"), 84: LLTool(std::string("Select")),
85 mPieMouseButtonDown( FALSE ), 85 mPieMouseButtonDown( FALSE ),
86 mGrabMouseButtonDown( FALSE ), 86 mGrabMouseButtonDown( FALSE ),
87 mHitLand( FALSE ),
88 mHitObjectID(),
89 mMouseOutsideSlop( FALSE ) 87 mMouseOutsideSlop( FALSE )
90{ } 88{ }
91 89
92 90
93BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) 91BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask)
94{ 92{
95 gPickFaces = TRUE;
96 //left mouse down always picks transparent 93 //left mouse down always picks transparent
97 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, leftMouseCallback, 94 gViewerWindow->pickAsync(x, y, mask, leftMouseCallback, TRUE, TRUE);
98 TRUE, TRUE);
99 mGrabMouseButtonDown = TRUE; 95 mGrabMouseButtonDown = TRUE;
100 return TRUE; 96 return TRUE;
101} 97}
102 98
103// static 99// static
104void LLToolPie::leftMouseCallback(S32 x, S32 y, MASK mask) 100void LLToolPie::leftMouseCallback(const LLPickInfo& pick_info)
105{ 101{
106 LLToolPie::getInstance()->pickAndShowMenu(x, y, mask, FALSE); 102 LLToolPie::getInstance()->mPick = pick_info;
103 LLToolPie::getInstance()->pickAndShowMenu(FALSE);
107} 104}
108 105
109BOOL LLToolPie::handleRightMouseDown(S32 x, S32 y, MASK mask) 106BOOL LLToolPie::handleRightMouseDown(S32 x, S32 y, MASK mask)
110{ 107{
111 // Pick faces in case they select "Copy Texture" and need that info.
112 gPickFaces = TRUE;
113 // don't pick transparent so users can't "pay" transparent objects 108 // don't pick transparent so users can't "pay" transparent objects
114 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, rightMouseCallback, 109 gViewerWindow->pickAsync(x, y, mask, rightMouseCallback, FALSE, TRUE);
115 FALSE, TRUE);
116 mPieMouseButtonDown = TRUE; 110 mPieMouseButtonDown = TRUE;
117 // don't steal focus from UI 111 // don't steal focus from UI
118 return FALSE; 112 return FALSE;
119} 113}
120 114
121// static 115// static
122void LLToolPie::rightMouseCallback(S32 x, S32 y, MASK mask) 116void LLToolPie::rightMouseCallback(const LLPickInfo& pick_info)
123{ 117{
124 LLToolPie::getInstance()->pickAndShowMenu(x, y, mask, TRUE); 118 LLToolPie::getInstance()->mPick = pick_info;
119 LLToolPie::getInstance()->pickAndShowMenu(TRUE);
125} 120}
126 121
127// True if you selected an object. 122// True if you selected an object.
128BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show) 123BOOL LLToolPie::pickAndShowMenu(BOOL always_show)
129{ 124{
130 if (!always_show && gLastHitParcelWall) 125 S32 x = mPick.mMousePt.mX;
126 S32 y = mPick.mMousePt.mY;
127 MASK mask = mPick.mKeyMask;
128 if (!always_show && mPick.mPickType == LLPickInfo::PICK_PARCEL_WALL)
131 { 129 {
132 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getCollisionParcel(); 130 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getCollisionParcel();
133 if (parcel) 131 if (parcel)
@@ -151,25 +149,18 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
151 } 149 }
152 150
153 // didn't click in any UI object, so must have clicked in the world 151 // didn't click in any UI object, so must have clicked in the world
154 LLViewerObject *object = gViewerWindow->lastObjectHit(); 152 LLViewerObject *object = mPick.getObject();
155 LLViewerObject *parent = NULL; 153 LLViewerObject *parent = NULL;
156 154
157 mHitLand = !object && !gLastHitPosGlobal.isExactlyZero(); 155 if (mPick.mPickType != LLPickInfo::PICK_LAND)
158 if (!mHitLand)
159 { 156 {
160 LLViewerParcelMgr::getInstance()->deselectLand(); 157 LLViewerParcelMgr::getInstance()->deselectLand();
161 } 158 }
162 159
163 if (object) 160 if (object)
164 { 161 {
165 mHitObjectID = object->mID;
166
167 parent = object->getRootEdit(); 162 parent = object->getRootEdit();
168 } 163 }
169 else
170 {
171 mHitObjectID.setNull();
172 }
173 164
174 BOOL touchable = (object && object->flagHandleTouch()) 165 BOOL touchable = (object && object->flagHandleTouch())
175 || (parent && parent->flagHandleTouch()); 166 || (parent && parent->flagHandleTouch());
@@ -206,19 +197,19 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
206 { 197 {
207 // pay event goes to object actually clicked on 198 // pay event goes to object actually clicked on
208 sClickActionObject = object; 199 sClickActionObject = object;
209 sLeftClickSelection = LLToolSelect::handleObjectSelection(object, MASK_NONE, FALSE, TRUE); 200 sLeftClickSelection = LLToolSelect::handleObjectSelection(mPick, FALSE, TRUE);
210 return TRUE; 201 return TRUE;
211 } 202 }
212 break; 203 break;
213 case CLICK_ACTION_BUY: 204 case CLICK_ACTION_BUY:
214 sClickActionObject = parent; 205 sClickActionObject = parent;
215 sLeftClickSelection = LLToolSelect::handleObjectSelection(parent, MASK_NONE, FALSE, TRUE); 206 sLeftClickSelection = LLToolSelect::handleObjectSelection(mPick, FALSE, TRUE, TRUE);
216 return TRUE; 207 return TRUE;
217 case CLICK_ACTION_OPEN: 208 case CLICK_ACTION_OPEN:
218 if (parent && parent->allowOpen()) 209 if (parent && parent->allowOpen())
219 { 210 {
220 sClickActionObject = parent; 211 sClickActionObject = parent;
221 sLeftClickSelection = LLToolSelect::handleObjectSelection(parent, MASK_NONE, FALSE, TRUE); 212 sLeftClickSelection = LLToolSelect::handleObjectSelection(mPick, FALSE, TRUE, TRUE);
222 } 213 }
223 return TRUE; 214 return TRUE;
224 case CLICK_ACTION_PLAY: 215 case CLICK_ACTION_PLAY:
@@ -239,12 +230,13 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
239 { 230 {
240 gGrabTransientTool = this; 231 gGrabTransientTool = this;
241 LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() ); 232 LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolGrab::getInstance() );
242 return LLToolGrab::getInstance()->handleObjectHit( object, x, y, mask); 233 return LLToolGrab::getInstance()->handleObjectHit( mPick );
243 } 234 }
244 235
245 if (!object && gLastHitHUDIcon && gLastHitHUDIcon->getSourceObject()) 236 LLHUDIcon* last_hit_hud_icon = mPick.mHUDIcon;
237 if (!object && last_hit_hud_icon && last_hit_hud_icon->getSourceObject())
246 { 238 {
247 LLFloaterScriptDebug::show(gLastHitHUDIcon->getSourceObject()->getID()); 239 LLFloaterScriptDebug::show(last_hit_hud_icon->getSourceObject()->getID());
248 } 240 }
249 241
250 // If left-click never selects or spawns a menu 242 // If left-click never selects or spawns a menu
@@ -273,7 +265,7 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
273 LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance()); 265 LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance());
274 gViewerWindow->hideCursor(); 266 gViewerWindow->hideCursor();
275 LLToolCamera::getInstance()->setMouseCapture(TRUE); 267 LLToolCamera::getInstance()->setMouseCapture(TRUE);
276 LLToolCamera::getInstance()->pickCallback(gViewerWindow->getCurrentMouseX(), gViewerWindow->getCurrentMouseY(), mask); 268 LLToolCamera::getInstance()->pickCallback(mPick);
277 gAgent.setFocusOnAvatar(TRUE, TRUE); 269 gAgent.setFocusOnAvatar(TRUE, TRUE);
278 270
279 return TRUE; 271 return TRUE;
@@ -292,22 +284,22 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
292 } 284 }
293 285
294 // Can't ignore children here. 286 // Can't ignore children here.
295 LLToolSelect::handleObjectSelection(object, mask, FALSE, TRUE); 287 LLToolSelect::handleObjectSelection(mPick, FALSE, TRUE);
296 288
297 // Spawn pie menu 289 // Spawn pie menu
298 if (mHitLand) 290 if (mPick.mPickType == LLPickInfo::PICK_LAND)
299 { 291 {
300 LLParcelSelectionHandle selection = LLViewerParcelMgr::getInstance()->selectParcelAt( gLastHitPosGlobal ); 292 LLParcelSelectionHandle selection = LLViewerParcelMgr::getInstance()->selectParcelAt( mPick.mPosGlobal );
301 gMenuHolder->setParcelSelection(selection); 293 gMenuHolder->setParcelSelection(selection);
302 gPieLand->show(x, y, mPieMouseButtonDown); 294 gPieLand->show(x, y, mPieMouseButtonDown);
303 295
304 // VEFFECT: ShowPie 296 // VEFFECT: ShowPie
305 LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_SPHERE, TRUE); 297 LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_SPHERE, TRUE);
306 effectp->setPositionGlobal(gLastHitPosGlobal); 298 effectp->setPositionGlobal(mPick.mPosGlobal);
307 effectp->setColor(LLColor4U(gAgent.getEffectColor())); 299 effectp->setColor(LLColor4U(gAgent.getEffectColor()));
308 effectp->setDuration(0.25f); 300 effectp->setDuration(0.25f);
309 } 301 }
310 else if (mHitObjectID == gAgent.getID() ) 302 else if (mPick.mObjectID == gAgent.getID() )
311 { 303 {
312 if(!gPieSelf) 304 if(!gPieSelf)
313 { 305 {
@@ -333,15 +325,15 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
333 325
334 // Object is an avatar, so check for mute by id. 326 // Object is an avatar, so check for mute by id.
335 LLVOAvatar* avatar = (LLVOAvatar*)object; 327 LLVOAvatar* avatar = (LLVOAvatar*)object;
336 LLString name = avatar->getFullname(); 328 std::string name = avatar->getFullname();
337 if (LLMuteList::getInstance()->isMuted(avatar->getID(), name)) 329 if (LLMuteList::getInstance()->isMuted(avatar->getID(), name))
338 { 330 {
339 gMenuHolder->childSetText("Avatar Mute", LLString("Unmute")); // *TODO:Translate 331 gMenuHolder->childSetText("Avatar Mute", std::string("Unmute")); // *TODO:Translate
340 //gMutePieMenu->setLabel("Unmute"); 332 //gMutePieMenu->setLabel("Unmute");
341 } 333 }
342 else 334 else
343 { 335 {
344 gMenuHolder->childSetText("Avatar Mute", LLString("Mute")); // *TODO:Translate 336 gMenuHolder->childSetText("Avatar Mute", std::string("Mute")); // *TODO:Translate
345 //gMutePieMenu->setLabel("Mute"); 337 //gMutePieMenu->setLabel("Mute");
346 } 338 }
347 339
@@ -354,7 +346,7 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
354 else 346 else
355 { 347 {
356 // BUG: What about chatting child objects? 348 // BUG: What about chatting child objects?
357 LLString name; 349 std::string name;
358 LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); 350 LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
359 if (node) 351 if (node)
360 { 352 {
@@ -362,12 +354,12 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
362 } 354 }
363 if (LLMuteList::getInstance()->isMuted(object->getID(), name)) 355 if (LLMuteList::getInstance()->isMuted(object->getID(), name))
364 { 356 {
365 gMenuHolder->childSetText("Object Mute", LLString("Unmute")); // *TODO:Translate 357 gMenuHolder->childSetText("Object Mute", std::string("Unmute")); // *TODO:Translate
366 //gMuteObjectPieMenu->setLabel("Unmute"); 358 //gMuteObjectPieMenu->setLabel("Unmute");
367 } 359 }
368 else 360 else
369 { 361 {
370 gMenuHolder->childSetText("Object Mute", LLString("Mute")); // *TODO:Translate 362 gMenuHolder->childSetText("Object Mute", std::string("Mute")); // *TODO:Translate
371 //gMuteObjectPieMenu->setLabel("Mute"); 363 //gMuteObjectPieMenu->setLabel("Mute");
372 } 364 }
373 365
@@ -377,7 +369,7 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
377 // Don't show when you click on someone else, it freaks them 369 // Don't show when you click on someone else, it freaks them
378 // out. 370 // out.
379 LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_SPHERE, TRUE); 371 LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_SPHERE, TRUE);
380 effectp->setPositionGlobal(gLastHitPosGlobal); 372 effectp->setPositionGlobal(mPick.mPosGlobal);
381 effectp->setColor(LLColor4U(gAgent.getEffectColor())); 373 effectp->setColor(LLColor4U(gAgent.getEffectColor()));
382 effectp->setDuration(0.25f); 374 effectp->setDuration(0.25f);
383 } 375 }
@@ -544,7 +536,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
544 LLViewerObject *parent = NULL; 536 LLViewerObject *parent = NULL;
545 if (gHoverView) 537 if (gHoverView)
546 { 538 {
547 object = gHoverView->getLastHoverObject(); 539 object = gViewerWindow->getHoverPick().getObject();
548 } 540 }
549 541
550 if (object) 542 if (object)
@@ -581,7 +573,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
581 573
582BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) 574BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
583{ 575{
584 LLViewerObject* obj = gViewerWindow->lastObjectHit(); 576 LLViewerObject* obj = mPick.getObject();
585 U8 click_action = final_click_action(obj); 577 U8 click_action = final_click_action(obj);
586 if (click_action != CLICK_ACTION_NONE) 578 if (click_action != CLICK_ACTION_NONE)
587 { 579 {
@@ -626,18 +618,18 @@ BOOL LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask)
626 618
627 if (gSavedSettings.getBOOL("DoubleClickAutoPilot")) 619 if (gSavedSettings.getBOOL("DoubleClickAutoPilot"))
628 { 620 {
629 if (gLastHitLand 621 if (mPick.mPickType == LLPickInfo::PICK_LAND
630 && !gLastHitPosGlobal.isExactlyZero()) 622 && !mPick.mPosGlobal.isExactlyZero())
631 { 623 {
632 handle_go_to(); 624 handle_go_to();
633 return TRUE; 625 return TRUE;
634 } 626 }
635 else if (gLastHitObjectID.notNull() 627 else if (mPick.mObjectID.notNull()
636 && !gLastHitPosGlobal.isExactlyZero()) 628 && !mPick.mPosGlobal.isExactlyZero())
637 { 629 {
638 // Hit an object 630 // Hit an object
639 // HACK: Call the last hit position the point we hit on the object 631 // HACK: Call the last hit position the point we hit on the object
640 gLastHitPosGlobal += gLastHitObjectOffset; 632 //gLastHitPosGlobal += gLastHitObjectOffset;
641 handle_go_to(); 633 handle_go_to();
642 return TRUE; 634 return TRUE;
643 } 635 }
@@ -649,7 +641,7 @@ BOOL LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask)
649 objects gets you into trouble. 641 objects gets you into trouble.
650 642
651 // If double-click on object or land, go there. 643 // If double-click on object or land, go there.
652 LLViewerObject *object = gViewerWindow->lastObjectHit(); 644 LLViewerObject *object = gViewerWindow->getLastPick().getObject();
653 if (object) 645 if (object)
654 { 646 {
655 if (object->isAvatar()) 647 if (object->isAvatar())
@@ -756,10 +748,11 @@ static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
756 if (objectp.isNull()) return; 748 if (objectp.isNull()) return;
757 749
758 // did we hit a valid face on the object? 750 // did we hit a valid face on the object?
759 if( gLastHitObjectFace < 0 || gLastHitObjectFace >= objectp->getNumTEs() ) return; 751 S32 face = LLToolPie::getInstance()->getPick().mObjectFace;
752 if( face < 0 || face >= objectp->getNumTEs() ) return;
760 753
761 // is media playing on this face? 754 // is media playing on this face?
762 if (!LLViewerMedia::isActiveMediaTexture(objectp->getTE(gLastHitObjectFace)->getID())) 755 if (!LLViewerMedia::isActiveMediaTexture(objectp->getTE(face)->getID()))
763 { 756 {
764 handle_click_action_play(); 757 handle_click_action_play();
765 return; 758 return;
@@ -767,7 +760,7 @@ static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
767 760
768 std::string media_url = std::string ( parcel->getMediaURL () ); 761 std::string media_url = std::string ( parcel->getMediaURL () );
769 std::string media_type = std::string ( parcel->getMediaType() ); 762 std::string media_type = std::string ( parcel->getMediaType() );
770 LLString::trim(media_url); 763 LLStringUtil::trim(media_url);
771 764
772 // Get the scheme, see if that is handled as well. 765 // Get the scheme, see if that is handled as well.
773 LLURI uri(media_url); 766 LLURI uri(media_url);
@@ -796,7 +789,7 @@ static ECursorType cursor_from_parcel_media(U8 click_action)
796 789
797 std::string media_url = std::string ( parcel->getMediaURL () ); 790 std::string media_url = std::string ( parcel->getMediaURL () );
798 std::string media_type = std::string ( parcel->getMediaType() ); 791 std::string media_type = std::string ( parcel->getMediaType() );
799 LLString::trim(media_url); 792 LLStringUtil::trim(media_url);
800 793
801 // Get the scheme, see if that is handled as well. 794 // Get the scheme, see if that is handled as well.
802 LLURI uri(media_url); 795 LLURI uri(media_url);