summaryrefslogtreecommitdiff
path: root/indra/newview/lltoolpie.cpp
diff options
context:
space:
mode:
authorVadim ProductEngine <vsavchuk@productengine.com>2011-09-23 18:00:35 +0300
committerVadim ProductEngine <vsavchuk@productengine.com>2011-09-23 18:00:35 +0300
commitc80df5ac39e31fb17fa8a1158cbea2de8faf0319 (patch)
treed46fc29664e083da84aff9bd431defef7d51e2f2 /indra/newview/lltoolpie.cpp
parent627bd3c5b998b6a743b7b412235bc5a287dadfc4 (diff)
STORM-1612 FIXED Implemented click-to-walk in Advanced mode.
Changes: * Click and double click in-world can now trigger click-to-walk or click-to-teleport actions, depending on preferences. * Grouped keyboard- and mouse-related settings in Preferences -> Move.
Diffstat (limited to 'indra/newview/lltoolpie.cpp')
-rw-r--r--indra/newview/lltoolpie.cpp157
1 files changed, 122 insertions, 35 deletions
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index c38c8bad80..e614fe23d0 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -35,7 +35,7 @@
#include "llagent.h"
#include "llagentcamera.h"
#include "llavatarnamecache.h"
-#include "llviewercontrol.h"
+#include "lleventtimer.h"
#include "llfocusmgr.h"
#include "llfirstuse.h"
#include "llfloaterland.h"
@@ -57,6 +57,7 @@
#include "lltrans.h"
#include "llviewercamera.h"
#include "llviewerparcelmedia.h"
+#include "llviewercontrol.h"
#include "llviewermenu.h"
#include "llviewerobjectlist.h"
#include "llviewerobject.h"
@@ -76,6 +77,41 @@ 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);
+/**
+ * Schedule teleport to the specified location when user clicks in world.
+ *
+ * Deferring teleport is needed for double-click-to-walk to work.
+ * If double click in the world view occurs, teleport gets canceled.
+ */
+class LLClickToTeleportTimer : public LLEventTimer
+{
+ LOG_CLASS(LLClickToTeleportTimer);
+public:
+ LLClickToTeleportTimer(const LLVector3d& pos);
+ ~LLClickToTeleportTimer();
+ /*virtual*/ BOOL tick();
+
+private:
+ LLVector3d mTeleportPos;
+};
+
+LLClickToTeleportTimer::LLClickToTeleportTimer(const LLVector3d& pos)
+: LLEventTimer(0.33) // should be greater than double click interval
+, mTeleportPos(pos)
+{
+};
+
+LLClickToTeleportTimer::~LLClickToTeleportTimer()
+{
+ LLToolPie::instance().mClickToTeleportTimer = NULL;
+}
+
+BOOL LLClickToTeleportTimer::tick()
+{
+ lldebugs << "Teleporting to " << mTeleportPos << llendl;
+ gAgent.teleportViaLocationLookAt(mTeleportPos);
+ return TRUE; // destroy the timer
+}
LLToolPie::LLToolPie()
: LLTool(std::string("Pie")),
@@ -84,6 +120,8 @@ LLToolPie::LLToolPie()
mMouseSteerX(-1),
mMouseSteerY(-1),
mBlockClickToWalk(false),
+ mBlockClickToTeleport(false),
+ mClickToTeleportTimer(NULL),
mClickAction(0),
mClickActionBuyEnabled( gSavedSettings.getBOOL("ClickActionBuyEnabled") ),
mClickActionPayEnabled( gSavedSettings.getBOOL("ClickActionPayEnabled") )
@@ -479,6 +517,18 @@ void LLToolPie::resetSelection()
mClickAction = 0;
}
+void LLToolPie::walkToClickedLocation()
+{
+ if(mAutoPilotDestination) { mAutoPilotDestination->markDead(); }
+ mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE);
+ mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal);
+ mAutoPilotDestination->setPixelSize(5);
+ mAutoPilotDestination->setColor(LLColor4U(170, 210, 190));
+ mAutoPilotDestination->setDuration(3.f);
+
+ handle_go_to();
+}
+
// When we get object properties after left-clicking on an object
// with left-click = buy, if it's the same object, do the buy.
@@ -637,44 +687,64 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
mMouseButtonDown = false;
if (click_action == CLICK_ACTION_NONE // not doing 1-click action
- && gSavedSettings.getBOOL("ClickToWalk") // click to walk enabled
&& !gAgent.getFlying() // don't auto-navigate while flying until that works
&& gAgentAvatarp
&& !gAgentAvatarp->isSitting()
- && !mBlockClickToWalk // another behavior hasn't cancelled click to walk
&& !mPick.mPosGlobal.isExactlyZero() // valid coordinates for pick
&& (mPick.mPickType == LLPickInfo::PICK_LAND // we clicked on land
|| mPick.mObjectID.notNull())) // or on an object
{
- // handle special cases of steering picks
- LLViewerObject* avatar_object = mPick.getObject();
-
- // get pointer to avatar
- while (avatar_object && !avatar_object->isAvatar())
+ if (gSavedSettings.getBOOL("ClickToWalk")
+ && !mBlockClickToWalk) // another behavior hasn't cancelled click to walk
{
- avatar_object = (LLViewerObject*)avatar_object->getParent();
- }
+ // handle special cases of steering picks
+ LLViewerObject* avatar_object = mPick.getObject();
- if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf())
- {
- const F64 SELF_CLICK_WALK_DISTANCE = 3.0;
- // pretend we picked some point a bit in front of avatar
- mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE;
+ // get pointer to avatar
+ while (avatar_object && !avatar_object->isAvatar())
+ {
+ avatar_object = (LLViewerObject*)avatar_object->getParent();
+ }
+
+ if (avatar_object && ((LLVOAvatar*)avatar_object)->isSelf())
+ {
+ const F64 SELF_CLICK_WALK_DISTANCE = 3.0;
+ // pretend we picked some point a bit in front of avatar
+ mPick.mPosGlobal = gAgent.getPositionGlobal() + LLVector3d(LLViewerCamera::instance().getAtAxis()) * SELF_CLICK_WALK_DISTANCE;
+ }
+ gAgentCamera.setFocusOnAvatar(TRUE, TRUE);
+ walkToClickedLocation();
+ LLFirstUse::notMoving(false);
+
+ return TRUE;
}
- gAgentCamera.setFocusOnAvatar(TRUE, TRUE);
- if(mAutoPilotDestination) { mAutoPilotDestination->markDead(); }
- mAutoPilotDestination = (LLHUDEffectBlob *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BLOB, FALSE);
- mAutoPilotDestination->setPositionGlobal(mPick.mPosGlobal);
- mAutoPilotDestination->setPixelSize(5);
- mAutoPilotDestination->setColor(LLColor4U(170, 210, 190));
- mAutoPilotDestination->setDuration(3.f);
+ else if (gSavedSettings.getBOOL("ClickToTeleport") && !mBlockClickToTeleport)
+ {
+ LLViewerObject* objp = mPick.getObject();
+ LLViewerObject* parentp = objp ? objp->getRootEdit() : NULL;
- handle_go_to();
- LLFirstUse::notMoving(false);
+ bool is_in_world = mPick.mObjectID.notNull() && objp && !objp->isHUDAttachment();
+ bool is_land = mPick.mPickType == LLPickInfo::PICK_LAND;
+ bool has_touch_handler = (objp && objp->flagHandleTouch()) || (parentp && parentp->flagHandleTouch());
+ bool has_click_action = final_click_action(objp);
- mBlockClickToWalk = false;
+ if (is_land || (is_in_world && !has_touch_handler && !has_click_action))
+ {
+ LLVector3d pos = mPick.mPosGlobal;
+ pos.mdV[VZ] += gAgentAvatarp->getPelvisToFoot();
- return TRUE;
+ if (gSavedSettings.getBOOL("DoubleClickAutoPilot"))
+ {
+ // defer for more than the double click interval.
+ scheduleTeleport(pos);
+ }
+ else
+ {
+ gAgent.teleportViaLocationLookAt(pos);
+ }
+ return TRUE;
+ }
+ }
}
gViewerWindow->setCursor(UI_CURSOR_ARROW);
if (hasMouseCapture())
@@ -686,6 +756,7 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask)
gAgentCamera.setLookAt(LOOKAT_TARGET_CONVERSATION, obj); // maybe look at object/person clicked on
mBlockClickToWalk = false;
+ mBlockClickToTeleport = false;
return LLTool::handleMouseUp(x, y, mask);
}
@@ -706,18 +777,17 @@ BOOL LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask)
llinfos << "LLToolPie handleDoubleClick (becoming mouseDown)" << llendl;
}
+ cancelScheduledTeleport();
+
if (gSavedSettings.getBOOL("DoubleClickAutoPilot"))
{
- if (mPick.mPickType == LLPickInfo::PICK_LAND
- && !mPick.mPosGlobal.isExactlyZero())
- {
- handle_go_to();
- return TRUE;
- }
- else if (mPick.mObjectID.notNull()
- && !mPick.mPosGlobal.isExactlyZero())
+ // Avoid teleporting for the second time when user releases mouse button after double click.
+ mBlockClickToTeleport = true;
+
+ if ((mPick.mPickType == LLPickInfo::PICK_LAND && !mPick.mPosGlobal.isExactlyZero()) ||
+ (mPick.mObjectID.notNull() && !mPick.mPosGlobal.isExactlyZero()))
{
- handle_go_to();
+ walkToClickedLocation();
return TRUE;
}
}
@@ -1373,6 +1443,23 @@ bool LLToolPie::inCameraSteerMode()
return mMouseButtonDown && mMouseOutsideSlop && gSavedSettings.getBOOL("ClickToWalk");
}
+void LLToolPie::scheduleTeleport(const LLVector3d& pos)
+{
+ // cancel previously scheduled teleport (if any)
+ cancelScheduledTeleport();
+
+ // and schedule new one
+ mClickToTeleportTimer = new LLClickToTeleportTimer(pos);
+}
+
+void LLToolPie::cancelScheduledTeleport()
+{
+ if (mClickToTeleportTimer)
+ {
+ delete mClickToTeleportTimer;
+ }
+}
+
// true if x,y outside small box around start_x,start_y
BOOL LLToolPie::outsideSlop(S32 x, S32 y, S32 start_x, S32 start_y)
{