1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321 |
- /**
- * @file lltoolpie.cpp
- * @brief LLToolPie class implementation
- *
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #include "llviewerprecompiledheaders.h"
- #include "lltoolpie.h"
- #include "lleditmenuhandler.h"
- #include "llmediaentry.h"
- #include "llmenugl.h"
- #include "llparcel.h"
- #include "lltrans.h"
- #include "llwindow.h" // For gDebugClicks
- #include "llagent.h"
- #include "llfirstuse.h"
- #include "llfloateravatarinfo.h"
- #include "llfloaterland.h"
- #include "llfloatertools.h"
- #include "llhoverview.h"
- #include "llhudeffectspiral.h"
- #include "llmutelist.h"
- //MK
- #include "mkrlinterface.h"
- //mk
- #include "llselectmgr.h"
- #include "lltoolfocus.h"
- #include "lltoolgrab.h"
- #include "lltoolmgr.h"
- #include "lltoolselect.h"
- #include "hbviewerautomation.h"
- #include "llviewercamera.h"
- #include "llviewercontrol.h"
- #include "llviewermedia.h"
- #include "llviewermediafocus.h"
- #include "llviewermenu.h"
- #include "llviewerobjectlist.h"
- #include "llviewerparcelmedia.h"
- #include "llviewerparcelmgr.h"
- #include "llvoavatarself.h"
- #include "llvovolume.h"
- #include "llworld.h"
- #include "llweb.h"
- extern void handle_buy(void*);
- static void handle_click_action_play();
- static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp);
- static ECursorType cursor_from_parcel_media(U8 click_action);
- LLToolPie gToolPie;
- LLToolPie::LLToolPie()
- : LLTool("Pie"),
- mPieMouseButtonDown(false),
- mGrabMouseButtonDown(false),
- mClickAction(0)
- {
- }
- bool LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask)
- {
- static LLCachedControl<bool> pick_transparent(gSavedSettings,
- "AllowPickTransparent");
- gViewerWindowp->pickAsync(x, y, mask, leftMouseCallback,
- // maybe pick transparent (normally no)
- pick_transparent,
- // not rigged, not particles, get surface info
- false, false, true);
- mGrabMouseButtonDown = true;
- return true;
- }
- //static
- void LLToolPie::leftMouseCallback(const LLPickInfo& pick_info)
- {
- gToolPie.mPick = pick_info;
- gToolPie.handleLeftClickPick();
- }
- bool LLToolPie::handleLeftClickPick()
- {
- S32 x = mPick.mMousePt.mX;
- S32 y = mPick.mMousePt.mY;
- MASK mask = mPick.mKeyMask;
- if (handleMediaClick(mPick))
- {
- return true;
- }
- if (mPick.mPickType == LLPickInfo::PICK_PARCEL_WALL)
- {
- LLParcel* parcelp = gViewerParcelMgr.getCollisionParcel();
- if (parcelp)
- {
- gViewerParcelMgr.selectCollisionParcel();
- if (parcelp->getParcelFlag(PF_USE_PASS_LIST) &&
- !gViewerParcelMgr.isCollisionBanned())
- {
- // If selling passes, just buy one
- void* deselect_when_done = (void*)true;
- LLPanelLandGeneral::onClickBuyPass(deselect_when_done);
- }
- else
- //MK
- if (!gRLenabled || !gRLInterface.mContainsShowloc)
- //mk
- {
- // Not selling passes, get info
- LLFloaterLand::showInstance();
- }
- }
- gFocusMgr.setKeyboardFocus(NULL);
- return LLTool::handleMouseDown(x, y, mask);
- }
- if (mPick.mPickType != LLPickInfo::PICK_LAND)
- {
- gViewerParcelMgr.deselectLand();
- }
- // Did not click in any UI object, so must have clicked in the world
- LLViewerObject* parent = NULL;
- LLViewerObject* object = mPick.getObject();
- if (object)
- {
- parent = object->getRootEdit();
- }
- // If we have a special action, do it.
- if (useClickAction(mask, object, parent))
- {
- //MK
- if (gRLenabled && !gRLInterface.canTouch(object, mPick.mIntersection))
- {
- return true;
- }
- //mk
- mClickAction = 0;
- if (object && object->getClickAction())
- {
- mClickAction = object->getClickAction();
- }
- else if (parent && parent->getClickAction())
- {
- mClickAction = parent->getClickAction();
- }
- switch (mClickAction)
- {
- case CLICK_ACTION_SIT:
- {
- if (isAgentAvatarValid() && !gAgentAvatarp->mIsSitting &&
- gSavedSettings.getBool("LeftClickToSit"))
- {
- // Agent is not already sitting
- handle_sit_or_stand();
- // Put focus in world when sitting on an object
- gFocusMgr.setKeyboardFocus(NULL);
- return true;
- }
- break; // else nothing (fall through to touch)
- }
- case CLICK_ACTION_PAY:
- {
- if (((object && object->flagTakesMoney()) ||
- (parent && parent->flagTakesMoney())) &&
- gSavedSettings.getBool("LeftClickToPay"))
- {
- // Pay event goes to object actually clicked on
- mClickActionObject = object;
- mLeftClickSelection =
- LLToolSelect::handleObjectSelection(mPick, false,
- true);
- if (gSelectMgr.selectGetAllValid())
- {
- // Call this right away, since we have all the info we
- // need to continue the action
- selectionPropertiesReceived();
- }
- return true;
- }
- break; // Else nothing (fall through to touch)
- }
- case CLICK_ACTION_BUY:
- {
- if (gSavedSettings.getBool("LeftClickToPay"))
- {
- mClickActionObject = parent;
- mLeftClickSelection =
- LLToolSelect::handleObjectSelection(mPick, false,
- true, true);
- if (gSelectMgr.selectGetAllValid())
- {
- // Call this right away, since we have all the info we
- // need to continue the action
- selectionPropertiesReceived();
- }
- return true;
- }
- break; // Else nothing (fall through to touch)
- }
- case CLICK_ACTION_OPEN:
- {
- if (parent && parent->allowOpen() &&
- gSavedSettings.getBool("LeftClickToOpen"))
- {
- mClickActionObject = parent;
- mLeftClickSelection =
- LLToolSelect::handleObjectSelection(mPick, false,
- true, true);
- if (gSelectMgr.selectGetAllValid())
- {
- // Call this right away, since we have all the info we
- // need to continue the action
- selectionPropertiesReceived();
- }
- return true;
- }
- break; // Else nothing (fall through to touch)
- }
- case CLICK_ACTION_PLAY:
- {
- if (gSavedSettings.getBool("LeftClickToPlay"))
- {
- handle_click_action_play();
- return true;
- }
- }
- case CLICK_ACTION_OPEN_MEDIA:
- {
- if (gSavedSettings.getBool("LeftClickToPlay"))
- {
- // mClickActionObject = object;
- handle_click_action_open_media(object);
- return true;
- }
- break; // Else nothing (fall through to touch)
- }
- case CLICK_ACTION_ZOOM:
- {
- if (gSavedSettings.getBool("LeftClickToZoom"))
- {
- constexpr F32 PADDING_FACTOR = 2.f;
- LLViewerObject* object =
- gObjectList.findObject(mPick.mObjectID);
- if (object)
- {
- gAgent.setFocusOnAvatar(false);
- LLBBox bbox = object->getBoundingBoxAgent();
- F32 aspect = gViewerCamera.getAspect();
- F32 view = gViewerCamera.getView();
- F32 angle_of_view = llmax(0.1f,
- aspect > 1.f ? view * aspect
- : view);
- F32 distance = bbox.getExtentLocal().length() *
- PADDING_FACTOR / atanf(angle_of_view);
- LLVector3 obj_to_cam = gViewerCamera.getOrigin() -
- bbox.getCenterAgent();
- obj_to_cam.normalize();
- LLVector3d center_global =
- gAgent.getPosGlobalFromAgent(bbox.getCenterAgent());
- gAgent.setCameraPosAndFocusGlobal(center_global +
- LLVector3d(obj_to_cam *
- distance),
- center_global,
- mPick.mObjectID);
- }
- return true;
- }
- break; // Else nothing (fall through to touch)
- }
- case CLICK_ACTION_DISABLED:
- return true;
- case CLICK_ACTION_TOUCH:
- default:
- break; // fall through to touch
- }
- }
- // Put focus back "in world"
- gFocusMgr.setKeyboardFocus(NULL);
- // Switch to grab tool if physical or triggerable
- bool touchable = (object && object->flagHandleTouch()) ||
- (parent && parent->flagHandleTouch());
- if (object && !object->isAvatar() &&
- (touchable || object->flagUsePhysics() ||
- (parent && !parent->isAvatar() && parent->flagUsePhysics())))
- {
- gGrabTransientTool = this;
- gToolMgr.getCurrentToolset()->selectTool(&gToolGrab);
- return gToolGrab.handleObjectHit(mPick);
- }
- if (!object)
- {
- LLHUDIcon* icon = mPick.mHUDIcon;
- LLViewerObject* src_obj = icon ? icon->getSourceObject() : NULL;
- if (src_obj)
- {
- const LLUUID& object_id = src_obj->getID();
- icon->fireClickedCallback(object_id);
- }
- }
- if (gSavedSettings.getBool("LeftClickSteersAvatar"))
- {
- // Mouse already released
- if (!mGrabMouseButtonDown)
- {
- return true;
- }
- while (object && object->isAttachment() && !object->flagHandleTouch())
- {
- // Do not pick avatar through hud attachment
- if (object->isHUDAttachment())
- {
- break;
- }
- object = (LLViewerObject*)object->getParent();
- }
- if (object && object == gAgentAvatarp)
- {
- // We left clicked on avatar, switch to focus mode
- gToolMgr.setTransientTool(&gToolFocus);
- gViewerWindowp->hideCursor();
- gToolFocus.setMouseCapture(true);
- gToolFocus.pickCallback(mPick);
- gAgent.setFocusOnAvatar();
- return true;
- }
- }
- // Could be first left-click on nothing
- LLFirstUse::useLeftClickNoHit();
- return LLTool::handleMouseDown(x, y, mask);
- }
- bool LLToolPie::handleRightMouseDown(S32 x, S32 y, MASK mask)
- {
- //MK
- // HACK : if alt-right-clicking and not in mouselook, HUDs are passed
- // through and we risk right-clicking in-world => discard this click
- if (gRLenabled && (mask & MASK_ALT) &&
- gAgent.getCameraMode() != CAMERA_MODE_MOUSELOOK)
- {
- handleMouseDown(x, y, mask);
- return true;
- }
- //mk
- static LLCachedControl<bool> pick_rigged_meshes(gSavedSettings,
- "AllowPickRiggedMeshes");
- static LLCachedControl<bool> pick_particles(gSavedSettings,
- "AllowPickParticles");
- mPieMouseButtonDown = true;
- // Note: we do not pick transparent so users cannot "pay" transparent
- // objects.
- gViewerWindowp->pickAsync(x, y, mask, rightMouseCallback,
- // do not (always) pick transparent
- false,
- // maybe pick rigged meshes or particles
- pick_rigged_meshes, pick_particles,
- // get surface info
- true);
- // Do not steal focus from UI
- return false;
- }
- bool LLToolPie::handleScrollWheel(S32 x, S32 y, S32 clicks)
- {
- return LLViewerMediaFocus::getInstance()->handleScrollWheel(x, y, clicks);
- }
- //static
- void LLToolPie::rightMouseCallback(const LLPickInfo& pick_info)
- {
- gToolPie.mPick = pick_info;
- gToolPie.handleRightClickPick();
- }
- bool LLToolPie::handleRightClickPick()
- {
- S32 x = mPick.mMousePt.mX;
- S32 y = mPick.mMousePt.mY;
- MASK mask = mPick.mKeyMask;
- LLViewerMediaFocus::getInstance()->clearFocus();
- if (mPick.mPickType != LLPickInfo::PICK_LAND)
- {
- gViewerParcelMgr.deselectLand();
- }
- // Put focus back "in world"
- gFocusMgr.setKeyboardFocus(NULL);
- // Cannot ignore children here.
- LLToolSelect::handleObjectSelection(mPick, false, true);
- if (!gMenuHolderp)
- {
- // Either at early initialization or late quitting stage
- return true;
- }
- // Did not click in any UI object, so must have clicked in-world
- LLViewerObject* object = mPick.getObject();
- if (object && object->isAttachment() && !object->isHUDAttachment() &&
- !object->permYouOwner())
- {
- // Find the avatar corresponding to any attachment object we do not own
- while (object->isAttachment())
- {
- object = (LLViewerObject*)object->getParent();
- if (!object) return false; // Orphaned object ?
- }
- }
- if (mask == MASK_SHIFT && gLuaPiep && gLuaPiep->onPieMenu(mPick, object))
- {
- gLuaPiep->show(x, y, mPieMouseButtonDown);
- LLTool::handleRightMouseDown(x, y, mask);
- return true;
- }
- // Spawn the pie menu
- if ((!object || !object->isHUDAttachment()) && // HUDs got priority !
- gPieParticlep && mPick.mPickParticle &&
- mPick.mParticleOwnerID.notNull())
- {
- gPieParticlep->show(x, y, mPieMouseButtonDown);
- return true;
- }
- else if (mPick.mPickType == LLPickInfo::PICK_LAND)
- {
- LLParcelSelectionHandle selection =
- gViewerParcelMgr.selectParcelAt(mPick.mPosGlobal);
- gMenuHolderp->setParcelSelection(selection);
- gPieLandp->show(x, y, mPieMouseButtonDown);
- // VEFFECT: ShowPie
- LLHUDEffectSpiral::sphereAtPosition(mPick.mPosGlobal);
- }
- else if (mPick.mObjectID == gAgentID)
- {
- LLMenuItemGL* item =
- gPieSelfp->getChild<LLMenuItemGL>("Self Sit", true, false);
- if (item)
- {
- if (isAgentAvatarValid() && gAgentAvatarp->mIsSitting)
- {
- item->setValue(LLTrans::getString("stand_up"));
- }
- else
- {
- item->setValue(LLTrans::getString("sit_here"));
- }
- }
- gPieSelfp->show(x, y, mPieMouseButtonDown);
- }
- else if (object)
- {
- if (gRLenabled && !object->isAvatar() && LLFloaterTools::isVisible() &&
- !gRLInterface.canEdit(object))
- {
- gFloaterToolsp->close();
- }
- gMenuHolderp->setObjectSelection(gSelectMgr.getSelection());
- if (object->isAvatar())
- {
- // Object is an avatar, so check for mute by id.
- LLVOAvatar* avatar = (LLVOAvatar*)object;
- LLUUID id = avatar->getID();
- std::string name = avatar->getFullname();
- if (gMutesPieMenup)
- {
- bool fully_muted = LLMuteList::isMuted(id, name);
- LLMenuItemGL* item =
- gMutesPieMenup->getChild<LLMenuItemGL>("Avatar Mute",
- true, false);
- if (item)
- {
- if (fully_muted)
- {
- item->setValue(LLTrans::getString("unmute_all"));
- }
- else
- {
- item->setValue(LLTrans::getString("mute_all"));
- }
- }
- item = gMutesPieMenup->getChild<LLMenuItemGL>("Avatar Mute chat",
- true, false);
- if (item)
- {
- if (LLMuteList::isMuted(id, name, LLMute::flagTextChat))
- {
- item->setValue(LLTrans::getString("unmute_chat"));
- }
- else
- {
- item->setValue(LLTrans::getString("mute_chat"));
- }
- }
- item = gMutesPieMenup->getChild<LLMenuItemGL>("Avatar Mute voice",
- true, false);
- if (item)
- {
- if (LLMuteList::isMuted(id, name, LLMute::flagVoiceChat))
- {
- item->setValue(LLTrans::getString("unmute_voice"));
- }
- else
- {
- item->setValue(LLTrans::getString("mute_voice"));
- }
- }
- item = gMutesPieMenup->getChild<LLMenuItemGL>("Avatar Mute sounds",
- true, false);
- if (item)
- {
- if (LLMuteList::isMuted(id, name, LLMute::flagObjectSounds))
- {
- item->setValue(LLTrans::getString("unmute_sounds"));
- }
- else
- {
- item->setValue(LLTrans::getString("mute_sounds"));
- }
- }
- item = gMutesPieMenup->getChild<LLMenuItemGL>("Avatar Mute particles",
- true, false);
- if (item)
- {
- if (LLMuteList::isMuted(id, name, LLMute::flagParticles))
- {
- item->setValue(LLTrans::getString("unmute_particles"));
- }
- else
- {
- item->setValue(LLTrans::getString("mute_particles"));
- }
- }
- LLVOAvatar::VisualMuteSettings val =
- avatar->getVisualMuteSettings();
- bool settings_available = LLVOAvatar::sUseImpostors;
- //MK
- settings_available = settings_available &&
- (!gRLenabled || !avatar->isRLVMuted());
- //mk
- item = gMutesPieMenup->getChild<LLMenuItemGL>("Avatar Always Render",
- true, false);
- if (item)
- {
- item->setEnabled(!fully_muted && settings_available &&
- val != LLVOAvatar::AV_ALWAYS_RENDER);
- }
- item = gMutesPieMenup->getChild<LLMenuItemGL>("Avatar Normal Render",
- true, false);
- if (item)
- {
- item->setEnabled(!fully_muted && settings_available &&
- val != LLVOAvatar::AV_RENDER_NORMALLY);
- }
- item = gMutesPieMenup->getChild<LLMenuItemGL>("Avatar Never Render",
- true, false);
- if (item)
- {
- item->setEnabled(!fully_muted && settings_available &&
- val != LLVOAvatar::AV_DO_NOT_RENDER);
- }
- }
- gPieAvatarp->show(x, y, mPieMouseButtonDown);
- }
- else if (object->isAttachment())
- {
- LLMenuItemGL* item =
- gPieAttachmentp->getChild<LLMenuItemGL>("Self Sit Attachment",
- true, false);
- if (item)
- {
- if (isAgentAvatarValid() && gAgentAvatarp->mIsSitting)
- {
- item->setValue(LLTrans::getString("stand_up"));
- }
- else
- {
- item->setValue(LLTrans::getString("sit_here"));
- }
- }
- gPieAttachmentp->show(x, y, mPieMouseButtonDown);
- }
- else
- {
- #if 0 // Sadly, the object name is unknown/empty when the pie menu is
- // built...
- std::string name;
- LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode();
- if (node)
- {
- name = node->mName;
- }
- #endif
- if (gPieObjectMutep)
- {
- LLMenuItemGL* item =
- gPieObjectMutep->getChild<LLMenuItemGL>("Mute object",
- true, false);
- if (item)
- {
- if (LLMuteList::isMuted(object->getID()))
- {
- item->setValue(LLTrans::getString("unmute"));
- }
- else
- {
- item->setValue(LLTrans::getString("mute"));
- }
- }
- #if 0 // Sadly, the object name is unknown/empty when the pie menu is
- // built... So, we cannot determine wether this object is
- // already muted by name of not.
- item = gPieObjectMutep->getChild<LLMenuItemGL>("Mute by name",
- true, false);
- if (item)
- {
- if (LLMuteList::isMuted(LLUUID::null, name))
- {
- item->setValue(LLTrans::getString("unmute_by_name"));
- }
- else
- {
- item->setValue(LLTrans::getString("mute_by_name"));
- }
- }
- #endif
- }
- #if 0 // Avatar puppets "jelly-dollifying" does not work anyway...
- LLVOAvatarPuppet* puppet = object->getPuppetAvatar();
- if (puppet && gPieObjectMutep)
- {
- LLVOAvatar::VisualMuteSettings val =
- puppet->getVisualMuteSettings();
- bool settings_available = LLVOAvatar::sUseImpostors;
- //MK
- settings_available = settings_available &&
- (!gRLenabled || !puppet->isRLVMuted());
- //mk
- LLMenuItemGL* item =
- gPieObjectMutep->getChild<LLMenuItemGL>("Puppet Always Render",
- true, false);
- if (item)
- {
- item->setEnabled(settings_available &&
- val != LLVOAvatar::AV_ALWAYS_RENDER);
- }
- item = gPieObjectMutep->getChild<LLMenuItemGL>("Puppet Normal Render",
- true, false);
- if (item)
- {
- item->setEnabled(settings_available &&
- val != LLVOAvatar::AV_RENDER_NORMALLY);
- }
- item = gPieObjectMutep->getChild<LLMenuItemGL>("Puppet Never Render",
- true, false);
- if (item)
- {
- item->setEnabled(settings_available &&
- val != LLVOAvatar::AV_DO_NOT_RENDER);
- }
- }
- #endif
- gPieObjectp->show(x, y, mPieMouseButtonDown);
- // VEFFECT: ShowPie object. Do not show when you click on someone
- // else: it could freak them out.
- LLHUDEffectSpiral::sphereAtPosition(mPick.mPosGlobal);
- }
- }
- // Ignore return value
- LLTool::handleRightMouseDown(x, y, mask);
- // We handled the event.
- return true;
- }
- bool LLToolPie::useClickAction(MASK mask, LLViewerObject* object,
- LLViewerObject* parent)
- {
- if (mask != MASK_NONE || !object || object->isAttachment() ||
- !LLPrimitive::isPrimitive(object->getPCode()))
- {
- return false;
- }
- U8 object_action = object->getClickAction();
- U8 parent_action = parent ? parent->getClickAction() : 0;
- return (object_action && object_action != CLICK_ACTION_DISABLED) ||
- (parent_action && parent_action != CLICK_ACTION_DISABLED);
- }
- U8 final_click_action(LLViewerObject* obj)
- {
- if (!obj || obj->isAttachment())
- {
- return CLICK_ACTION_NONE;
- }
- U8 object_action = obj->getClickAction();
- if (object_action)
- {
- return object_action;
- }
- // Note: at this point object_action = 0 = CLICK_ACTION_TOUCH
- LLViewerObject* parent = obj->getRootEdit();
- if (!parent)
- {
- return CLICK_ACTION_TOUCH;
- }
- U8 parent_action = parent->getClickAction();
- // CLICK_ACTION_DISABLED ("None" in UI) is intended for child action to
- // override parents action when assigned to parent or to child.
- if (/*parent_action && */parent_action != CLICK_ACTION_DISABLED)
- {
- // Note: no need to test for parent_action != 0 because
- // CLICK_ACTION_TOUCH = 0, which would be returned below anyway.
- return parent_action;
- }
- return CLICK_ACTION_TOUCH;
- }
- ECursorType cursor_from_object(LLViewerObject* object)
- {
- LLViewerObject* parent = NULL;
- if (object)
- {
- parent = object->getRootEdit();
- }
- U8 click_action = final_click_action(object);
- ECursorType cursor = UI_CURSOR_ARROW;
- switch (click_action)
- {
- case CLICK_ACTION_SIT:
- // Not already sitting ?
- if (isAgentAvatarValid() && !gAgentAvatarp->mIsSitting)
- {
- cursor = UI_CURSOR_TOOLSIT;
- }
- break;
- case CLICK_ACTION_BUY:
- cursor = UI_CURSOR_TOOLBUY;
- break;
- case CLICK_ACTION_OPEN:
- // Open always opens the parent.
- if (parent && parent->allowOpen())
- {
- cursor = UI_CURSOR_TOOLOPEN;
- }
- break;
- case CLICK_ACTION_PAY:
- if ((object && object->flagTakesMoney()) ||
- (parent && parent->flagTakesMoney()))
- {
- cursor = UI_CURSOR_TOOLPAY;
- }
- break;
- case CLICK_ACTION_ZOOM:
- cursor = UI_CURSOR_TOOLZOOMIN;
- break;
- case CLICK_ACTION_PLAY:
- case CLICK_ACTION_OPEN_MEDIA:
- cursor = cursor_from_parcel_media(click_action);
- break;
- default:
- break;
- }
- return cursor;
- }
- void LLToolPie::resetSelection()
- {
- mLeftClickSelection = NULL;
- mClickActionObject = NULL;
- mClickAction = 0;
- }
- //static
- void LLToolPie::selectionPropertiesReceived()
- {
- // Make sure all data has been received since this function will be called
- // repeatedly as the data comes in.
- if (!gSelectMgr.selectGetAllValid())
- {
- return;
- }
- LLObjectSelection* selection = gToolPie.getLeftClickSelection();
- if (selection)
- {
- LLViewerObject* selected_object = selection->getPrimaryObject();
- // since we don't currently have a way to lock a selection, it could
- // have changed after we initially clicked on the object
- if (selected_object == gToolPie.getClickActionObject())
- {
- U8 click_action = gToolPie.getClickAction();
- switch (click_action)
- {
- case CLICK_ACTION_BUY:
- // When we get object properties after left-clicking on an
- // object with left-click = buy, if it's the same object, do
- // the buy.
- handle_buy(NULL);
- break;
- case CLICK_ACTION_PAY:
- handle_give_money_dialog();
- break;
- case CLICK_ACTION_OPEN:
- //MK
- if (gRLenabled &&
- !gRLInterface.canEdit(gSelectMgr.getSelection()->getPrimaryObject()))
- {
- return;
- }
- if (gRLenabled &&
- !gRLInterface.canTouchFar(selected_object,
- gToolPie.getPick().mIntersection))
- {
- return;
- }
- //mk
- handle_object_open();
- break;
- default:
- break;
- }
- }
- }
- gToolPie.resetSelection();
- }
- bool LLToolPie::handleHover(S32 x, S32 y, MASK mask)
- {
- LLPickInfo hover_pick = gViewerWindowp->getHoverPick();
- LLViewerObject* object = hover_pick.getObject();
- LLViewerObject* parent = object ? object->getRootEdit() : NULL;
- if (handleMediaHover(hover_pick))
- {
- // Cursor set by media object
- // *TODO: implement glow-like highlighting ?
- }
- else if (object)
- {
- if (useClickAction(mask, object, parent))
- {
- ECursorType cursor = cursor_from_object(object);
- gWindowp->setCursor(cursor);
- }
- else if ((!object->isAvatar() && object->flagUsePhysics()) ||
- (parent && !parent->isAvatar() && parent->flagUsePhysics()))
- {
- gWindowp->setCursor(UI_CURSOR_TOOLGRAB);
- }
- else if ((object->getClickAction() != CLICK_ACTION_DISABLED ||
- !object->isAttachment()) &&
- (object->flagHandleTouch() ||
- (parent && parent->flagHandleTouch())))
- {
- gWindowp->setCursor(UI_CURSOR_HAND);
- }
- else
- {
- gWindowp->setCursor(UI_CURSOR_ARROW);
- }
- }
- else
- {
- gWindowp->setCursor(UI_CURSOR_ARROW);
- LLViewerMediaFocus::getInstance()->clearHover();
- }
- return true;
- }
- bool LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
- {
- LLViewerObject* obj = mPick.getObject();
- U8 click_action = final_click_action(obj);
- if (click_action == CLICK_ACTION_BUY || click_action == CLICK_ACTION_PAY ||
- click_action == CLICK_ACTION_OPEN)
- {
- // Because these actions open UI dialogs, we won't change the cursor
- // again until the next hover and GL pick over the world. Keep the
- // cursor an arrow, assuming that after the user moves off the UI, they
- // won't be on the same object anymore.
- gWindowp->setCursor(UI_CURSOR_ARROW);
- // Make sure the hover-picked object is ignored.
- gHoverViewp->resetLastHoverObject();
- }
- mGrabMouseButtonDown = false;
- gToolMgr.clearTransientTool();
- // Maybe look at object/person clicked on
- gAgent.setLookAt(LOOKAT_TARGET_CONVERSATION, obj);
- return LLTool::handleMouseUp(x, y, mask);
- }
- bool LLToolPie::handleRightMouseUp(S32 x, S32 y, MASK mask)
- {
- mPieMouseButtonDown = false;
- gToolMgr.clearTransientTool();
- return LLTool::handleRightMouseUp(x, y, mask);
- }
- bool LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask)
- {
- if (gDebugClicks)
- {
- llinfos << "LLToolPie handleDoubleClick (becoming mouseDown)"
- << llendl;
- }
- if (handleMediaDblClick(mPick))
- {
- return true;
- }
- if (mPick.mPosGlobal.isExactlyZero())
- {
- return false;
- }
- LLViewerObject* objp = mPick.getObject();
- LLViewerObject* parentp = objp ? objp->getRootEdit() : NULL;
- bool is_in_world = mPick.mObjectID.notNull() && objp &&
- !objp->isHUDAttachment();
- bool is_land = mPick.mPickType == LLPickInfo::PICK_LAND;
- bool has_touch_handler = false;
- bool has_click_action = false;
- if (!is_land && is_in_world && // Note: if is_in_world then objp != NULL
- !gSavedSettings.getBool("DoubleClickScriptedObject"))
- {
- has_touch_handler = objp->flagHandleTouch() ||
- (parentp && parentp->flagHandleTouch());
- has_click_action = final_click_action(objp);
- if (!has_touch_handler || !has_click_action)
- {
- // Is media playing on this face ?
- const LLTextureEntry* tep = objp->getTE(mPick.mObjectFace);
- viewer_media_t mediap =
- LLViewerMedia::getMediaImplFromTextureEntry(tep);
- if (mediap.notNull() && mediap->hasMedia())
- {
- has_touch_handler = has_click_action = true;
- }
- }
- }
- if (is_land || (is_in_world && !has_touch_handler && !has_click_action))
- {
- U32 action = gSavedSettings.getU32("DoubleClickAction");
- if (action == 1)
- {
- handle_go_to();
- return true;
- }
- else if (action == 2 && isAgentAvatarValid()
- //MK
- && !(gRLenabled && gRLInterface.contains ("tploc")))
- //mk
- {
- LLVector3d pos = mPick.mPosGlobal;
- pos.mdV[VZ] += gAgentAvatarp->getPelvisToFoot();
- gAgent.teleportViaLocationLookAt(pos);
- return true;
- }
- }
- return false;
- }
- void LLToolPie::handleDeselect()
- {
- if (hasMouseCapture())
- {
- setMouseCapture(false); // Calls onMouseCaptureLost() indirectly
- }
- // Remove temporary selection for pie menu
- gSelectMgr.validateSelection();
- }
- LLTool* LLToolPie::getOverrideTool(MASK mask)
- {
- if (mask == MASK_CONTROL || mask == (MASK_CONTROL | MASK_SHIFT))
- {
- return &gToolGrab;
- }
- return LLTool::getOverrideTool(mask);
- }
- void LLToolPie::stopEditing()
- {
- if (hasMouseCapture())
- {
- setMouseCapture(false); // Calls onMouseCaptureLost() indirectly
- }
- }
- static void handle_click_action_play()
- {
- LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getStatus();
- switch (status)
- {
- case LLViewerMediaImpl::MEDIA_PLAYING:
- LLViewerParcelMedia::pause();
- break;
- case LLViewerMediaImpl::MEDIA_PAUSED:
- LLViewerParcelMedia::start();
- break;
- default:
- LLViewerParcelMedia::play();
- }
- }
- bool LLToolPie::handleMediaClick(const LLPickInfo& pick)
- {
- // *FIXME: how do we handle object in different parcel than us ?
- LLParcel* parcelp = gViewerParcelMgr.getAgentParcel();
- LLPointer<LLViewerObject> objectp = pick.getObject();
- LLViewerMediaFocus* focusp = LLViewerMediaFocus::getInstance();
- if (!LLVOVolume::sObjectMediaClient || !parcelp || objectp.isNull() ||
- pick.mObjectFace < 0 || pick.mObjectFace >= objectp->getNumTEs())
- {
- focusp->clearFocus();
- return false;
- }
- // Does this face have media ?
- const LLTextureEntry* tep = objectp->getTE(pick.mObjectFace);
- viewer_media_t mediap = LLViewerMedia::getMediaImplFromTextureEntry(tep);
- if (mediap.isNull() || !mediap->hasMedia())
- {
- focusp->clearFocus();
- return false;
- }
- if (!focusp->isFocusedOnFace(pick.getObject(), pick.mObjectFace))
- {
- LL_DEBUGS("Media") << (mediap.isNull() ? "Media impl is NULL"
- : "New focus detected")
- << ", focusing on media face." << LL_ENDL;
- focusp->setFocusFace(true, pick.getObject(), pick.mObjectFace,
- mediap, pick.mNormal);
- }
- else if (gKeyboardp)
- {
- // Make sure keyboard focus is set to the media focus object.
- gFocusMgr.setKeyboardFocus(focusp);
- gEditMenuHandlerp = focusp->getFocusedMediaImpl();
- mediap->mouseDown(pick.mUVCoords, gKeyboardp->currentMask(true));
- // The mouse-up will happen when capture is lost
- mediap->mouseCapture();
- LL_DEBUGS("Media") << "Mouse down event passed to media" << LL_ENDL;
- }
- return true;
- }
- bool LLToolPie::handleMediaDblClick(const LLPickInfo& pick)
- {
- // *FIXME: how do we handle object in different parcel than us ?
- LLParcel* parcelp = gViewerParcelMgr.getAgentParcel();
- if (!parcelp)
- {
- return false;
- }
- LLViewerMediaFocus* focusp = LLViewerMediaFocus::getInstance();
- LLPointer<LLViewerObject> objectp = mPick.getObject();
- if (!LLVOVolume::sObjectMediaClient || objectp.isNull() ||
- pick.mObjectFace < 0 || pick.mObjectFace >= objectp->getNumTEs())
- {
- focusp->clearFocus();
- return false;
- }
- const LLTextureEntry* tep = objectp->getTE(pick.mObjectFace);
- viewer_media_t mediap = LLViewerMedia::getMediaImplFromTextureEntry(tep);
- if (mediap.isNull() || !mediap->hasMedia())
- {
- focusp->clearFocus();
- return false;
- }
- if (!focusp->isFocusedOnFace(pick.getObject(), pick.mObjectFace))
- {
- focusp->setFocusFace(true, pick.getObject(), pick.mObjectFace,
- mediap, pick.mNormal);
- }
- else if (gKeyboardp)
- {
- // Make sure keyboard focus is set to the media focus object.
- gFocusMgr.setKeyboardFocus(focusp);
- gEditMenuHandlerp = focusp->getFocusedMediaImpl();
- mediap->mouseDoubleClick(pick.mUVCoords,
- gKeyboardp->currentMask(true));
- // The mouse-up will happen when capture is lost
- mediap->mouseCapture();
- LL_DEBUGS("Media") << "Mouse double-click event passed to media"
- << LL_ENDL;
- }
- return true;
- }
- bool LLToolPie::handleMediaHover(const LLPickInfo& pick)
- {
- // *FIXME: how do we handle object in different parcel than us ?
- LLParcel* parcelp = gViewerParcelMgr.getAgentParcel();
- if (!parcelp)
- {
- return false;
- }
- LLViewerMediaFocus* focusp = LLViewerMediaFocus::getInstance();
- LLPointer<LLViewerObject> objectp = pick.getObject();
- // Early out cases. Must clear mouse over media focus flag did not hit an
- // object or did not hit a valid face
- if (!LLVOVolume::sObjectMediaClient || objectp.isNull() ||
- pick.mObjectFace < 0 || pick.mObjectFace >= objectp->getNumTEs())
- {
- focusp->clearHover();
- return false;
- }
- const LLTextureEntry* tep = objectp->getTE(pick.mObjectFace);
- viewer_media_t mediap = LLViewerMedia::getMediaImplFromTextureEntry(tep);
- if (mediap.notNull() && gKeyboardp && LLVOVolume::sObjectMediaClient)
- {
- // Update media hover object
- if (!focusp->isHoveringOverFace(objectp, pick.mObjectFace))
- {
- focusp->setHoverFace(objectp, pick.mObjectFace, mediap,
- pick.mNormal);
- gSelectMgr.setHoverObject(objectp, pick.mObjectFace);
- focusp->setPickInfo(pick);
- }
- // If this is the focused media face, send mouse move events.
- if (focusp->isFocusedOnFace(objectp, pick.mObjectFace))
- {
- mediap->mouseMove(pick.mUVCoords,
- gKeyboardp->currentMask(true));
- gViewerWindowp->setCursor(mediap->getLastSetCursor());
- }
- else
- {
- // This is not the focused face -- set the default cursor.
- gViewerWindowp->setCursor(UI_CURSOR_ARROW);
- }
- return true;
- }
- // In all other cases, clear media hover.
- focusp->clearHover();
- return false;
- }
- static void handle_click_action_open_media(LLPointer<LLViewerObject> objectp)
- {
- if (!LLVOVolume::sObjectMediaClient)
- {
- return; // Media disabled.
- }
- // *FIXME: how do we handle object in different parcel than us ?
- LLParcel* parcelp = gViewerParcelMgr.getAgentParcel();
- if (!parcelp)
- {
- return;
- }
- // Did we hit an object ?
- if (objectp.isNull()) return;
- // Did we hit a valid face on the object ?
- S32 face = gToolPie.getPick().mObjectFace;
- if (face < 0 || face >= objectp->getNumTEs()) return;
- // Is media playing on this face ?
- LLTextureEntry* tep = objectp->getTE(face);
- if (tep && LLViewerMedia::getMediaImplFromTextureID(tep->getID()))
- {
- handle_click_action_play();
- return;
- }
- std::string media_url = parcelp->getMediaURL();
- std::string media_type = parcelp->getMediaType();
- LLStringUtil::trim(media_url);
- // Get the scheme, see if that is handled as well.
- LLURI uri(media_url);
- std::string media_scheme = uri.scheme() != "" ? uri.scheme() : "http";
- LLWeb::loadURL(media_url);
- }
- static ECursorType cursor_from_parcel_media(U8 click_action)
- {
- if (!LLVOVolume::sObjectMediaClient)
- {
- return UI_CURSOR_ARROW; // Media disabled.
- }
- // *FIXME: how do we handle object in different parcel than us ?
- LLParcel* parcelp = gViewerParcelMgr.getAgentParcel();
- if (!parcelp)
- {
- return UI_CURSOR_ARROW;
- }
- LLViewerMediaImpl::EMediaStatus status = LLViewerParcelMedia::getStatus();
- if (status == LLViewerMediaImpl::MEDIA_PLAYING)
- {
- return click_action == CLICK_ACTION_PLAY ? UI_CURSOR_TOOLPAUSE
- : UI_CURSOR_TOOLMEDIAOPEN;
- }
- return UI_CURSOR_TOOLPLAY;
- }
|