aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolpie.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/lltoolpie.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 'linden/indra/newview/lltoolpie.cpp')
-rw-r--r--linden/indra/newview/lltoolpie.cpp178
1 files changed, 153 insertions, 25 deletions
diff --git a/linden/indra/newview/lltoolpie.cpp b/linden/indra/newview/lltoolpie.cpp
index f41fa8f..ab60c67 100644
--- a/linden/indra/newview/lltoolpie.cpp
+++ b/linden/indra/newview/lltoolpie.cpp
@@ -35,6 +35,7 @@
35 35
36#include "indra_constants.h" 36#include "indra_constants.h"
37#include "llclickaction.h" 37#include "llclickaction.h"
38#include "llmediabase.h" // for status codes
38#include "llparcel.h" 39#include "llparcel.h"
39 40
40#include "llagent.h" 41#include "llagent.h"
@@ -54,25 +55,33 @@
54#include "lltoolmgr.h" 55#include "lltoolmgr.h"
55#include "lltoolselect.h" 56#include "lltoolselect.h"
56#include "llviewercamera.h" 57#include "llviewercamera.h"
58#include "llviewerparcelmedia.h"
57#include "llviewermenu.h" 59#include "llviewermenu.h"
58#include "llviewerobject.h"
59#include "llviewerobjectlist.h" 60#include "llviewerobjectlist.h"
61#include "llviewerobject.h"
60#include "llviewerparcelmgr.h" 62#include "llviewerparcelmgr.h"
61#include "llviewerwindow.h" 63#include "llviewerwindow.h"
64#include "llviewermedia.h"
62#include "llvoavatar.h" 65#include "llvoavatar.h"
63#include "llworld.h" 66#include "llworld.h"
64#include "llui.h" 67#include "llui.h"
68#include "llweb.h"
65 69
66LLToolPie *gToolPie = NULL; 70LLToolPie *gToolPie = NULL;
67 71
68LLPointer<LLViewerObject> LLToolPie::sClickActionObject; 72LLPointer<LLViewerObject> LLToolPie::sClickActionObject;
69LLHandle<LLObjectSelection> LLToolPie::sLeftClickSelection = NULL; 73LLSafeHandle<LLObjectSelection> LLToolPie::sLeftClickSelection = NULL;
70U8 LLToolPie::sClickAction = 0; 74U8 LLToolPie::sClickAction = 0;
71 75
72extern void handle_buy(void*); 76extern void handle_buy(void*);
73 77
74extern BOOL gDebugClicks; 78extern BOOL gDebugClicks;
75 79
80static void handle_click_action_play();
81static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp);
82static ECursorType cursor_from_parcel_media(U8 click_action);
83
84
76LLToolPie::LLToolPie() 85LLToolPie::LLToolPie()
77: LLTool("Select"), 86: LLTool("Select"),
78 mPieMouseButtonDown( FALSE ), 87 mPieMouseButtonDown( FALSE ),
@@ -87,6 +96,7 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask)
87{ 96{
88 if (!gCamera) return FALSE; 97 if (!gCamera) return FALSE;
89 98
99 gPickFaces = TRUE;
90 //left mouse down always picks transparent 100 //left mouse down always picks transparent
91 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, leftMouseCallback, 101 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, leftMouseCallback,
92 TRUE, TRUE); 102 TRUE, TRUE);
@@ -137,7 +147,7 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
137 else 147 else
138 { 148 {
139 // not selling passes, get info 149 // not selling passes, get info
140 LLFloaterLand::show(); 150 LLFloaterLand::showInstance();
141 } 151 }
142 } 152 }
143 153
@@ -211,6 +221,13 @@ BOOL LLToolPie::pickAndShowMenu(S32 x, S32 y, MASK mask, BOOL always_show)
211 sLeftClickSelection = LLToolSelect::handleObjectSelection(parent, MASK_NONE, FALSE, TRUE); 221 sLeftClickSelection = LLToolSelect::handleObjectSelection(parent, MASK_NONE, FALSE, TRUE);
212 } 222 }
213 return TRUE; 223 return TRUE;
224 case CLICK_ACTION_PLAY:
225 handle_click_action_play();
226 return TRUE;
227 case CLICK_ACTION_OPEN_MEDIA:
228 // sClickActionObject = object;
229 handle_click_action_open_media(object);
230 return TRUE;
214 } 231 }
215 } 232 }
216 233
@@ -411,6 +428,47 @@ U8 final_click_action(LLViewerObject* obj)
411 return click_action; 428 return click_action;
412} 429}
413 430
431ECursorType cursor_from_object(LLViewerObject* object)
432{
433 LLViewerObject* parent = NULL;
434 if (object)
435 {
436 parent = object->getRootEdit();
437 }
438 U8 click_action = final_click_action(object);
439 ECursorType cursor = UI_CURSOR_ARROW;
440 switch(click_action)
441 {
442 case CLICK_ACTION_SIT:
443 cursor = UI_CURSOR_TOOLSIT;
444 break;
445 case CLICK_ACTION_BUY:
446 cursor = UI_CURSOR_TOOLBUY;
447 break;
448 case CLICK_ACTION_OPEN:
449 // Open always opens the parent.
450 if (parent && parent->allowOpen())
451 {
452 cursor = UI_CURSOR_TOOLOPEN;
453 }
454 break;
455 case CLICK_ACTION_PAY:
456 if ((object && object->flagTakesMoney())
457 || (parent && parent->flagTakesMoney()))
458 {
459 cursor = UI_CURSOR_TOOLPAY;
460 }
461 break;
462 case CLICK_ACTION_PLAY:
463 case CLICK_ACTION_OPEN_MEDIA:
464 cursor = cursor_from_parcel_media(click_action);
465 break;
466 default:
467 break;
468 }
469 return cursor;
470}
471
414// When we get object properties after left-clicking on an object 472// When we get object properties after left-clicking on an object
415// with left-click = buy, if it's the same object, do the buy. 473// with left-click = buy, if it's the same object, do the buy.
416// static 474// static
@@ -486,28 +544,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
486 544
487 if (object && useClickAction(FALSE, mask, object, parent)) 545 if (object && useClickAction(FALSE, mask, object, parent))
488 { 546 {
489 U8 click_action = final_click_action(object); 547 ECursorType cursor = cursor_from_object(object);
490 ECursorType cursor = UI_CURSOR_ARROW;
491 switch(click_action)
492 {
493 default: break;
494 case CLICK_ACTION_SIT: cursor = UI_CURSOR_TOOLSIT; break;
495 case CLICK_ACTION_BUY: cursor = UI_CURSOR_TOOLBUY; break;
496 case CLICK_ACTION_OPEN:
497 // Open always opens the parent.
498 if (parent && parent->allowOpen())
499 {
500 cursor = UI_CURSOR_TOOLOPEN;
501 }
502 break;
503 case CLICK_ACTION_PAY:
504 if ((object && object->flagTakesMoney())
505 || (parent && parent->flagTakesMoney()))
506 {
507 cursor = UI_CURSOR_TOOLPAY;
508 }
509 break;
510 }
511 gViewerWindow->getWindow()->setCursor(cursor); 548 gViewerWindow->getWindow()->setCursor(cursor);
512 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl; 549 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
513 } 550 }
@@ -677,4 +714,95 @@ void LLToolPie::render()
677 return; 714 return;
678} 715}
679 716
717static void handle_click_action_play()
718{
719 LLParcel* parcel = gParcelMgr->getAgentParcel();
720 if (!parcel) return;
721
722 LLMediaBase::EStatus status = LLViewerParcelMedia::getStatus();
723 switch(status)
724 {
725 case LLMediaBase::STATUS_STARTED:
726 LLViewerParcelMedia::pause();
727 break;
728
729 case LLMediaBase::STATUS_PAUSED:
730 LLViewerParcelMedia::start();
731 break;
732
733 default:
734 LLViewerParcelMedia::play(parcel);
735 break;
736 }
737}
738
739static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
740{
741 //FIXME: how do we handle object in different parcel than us?
742 LLParcel* parcel = gParcelMgr->getAgentParcel();
743 if (!parcel) return;
744
745 // did we hit an object?
746 if (objectp.isNull()) return;
747
748 // did we hit a valid face on the object?
749 if( gLastHitObjectFace < 0 || gLastHitObjectFace >= objectp->getNumTEs() ) return;
750
751 // is media playing on this face?
752 if (!LLViewerMedia::isActiveMediaTexture(objectp->getTE(gLastHitObjectFace)->getID()))
753 {
754 handle_click_action_play();
755 return;
756 }
757
758 std::string media_url = std::string ( parcel->getMediaURL () );
759 std::string media_type = std::string ( parcel->getMediaType() );
760 LLString::trim(media_url);
761
762 // Get the scheme, see if that is handled as well.
763 LLURI uri(media_url);
764 std::string media_scheme = uri.scheme() != "" ? uri.scheme() : "http";
765
766 // HACK: This is directly referencing an impl name. BAD!
767 // This can be removed when we have a truly generic media browser that only
768 // builds an impl based on the type of url it is passed.
680 769
770 if( LLMediaManager::getInstance()->supportsMediaType( "LLMediaImplLLMozLib", media_scheme, media_type ) )
771 {
772 LLWeb::loadURL(media_url);
773 }
774}
775
776static ECursorType cursor_from_parcel_media(U8 click_action)
777{
778 // HACK: This is directly referencing an impl name. BAD!
779 // This can be removed when we have a truly generic media browser that only
780 // builds an impl based on the type of url it is passed.
781
782 //FIXME: how do we handle object in different parcel than us?
783 ECursorType open_cursor = UI_CURSOR_ARROW;
784 LLParcel* parcel = gParcelMgr->getAgentParcel();
785 if (!parcel) return open_cursor;
786
787 std::string media_url = std::string ( parcel->getMediaURL () );
788 std::string media_type = std::string ( parcel->getMediaType() );
789 LLString::trim(media_url);
790
791 // Get the scheme, see if that is handled as well.
792 LLURI uri(media_url);
793 std::string media_scheme = uri.scheme() != "" ? uri.scheme() : "http";
794
795 if( LLMediaManager::getInstance()->supportsMediaType( "LLMediaImplLLMozLib", media_scheme, media_type ) )
796 {
797 open_cursor = UI_CURSOR_TOOLMEDIAOPEN;
798 }
799
800 LLMediaBase::EStatus status = LLViewerParcelMedia::getStatus();
801 switch(status)
802 {
803 case LLMediaBase::STATUS_STARTED:
804 return click_action == CLICK_ACTION_PLAY ? UI_CURSOR_TOOLPAUSE : open_cursor;
805 default:
806 return UI_CURSOR_TOOLPLAY;
807 }
808}