summaryrefslogtreecommitdiff
path: root/indra/newview/llpathfindingpathtool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpathfindingpathtool.cpp')
-rw-r--r--indra/newview/llpathfindingpathtool.cpp115
1 files changed, 73 insertions, 42 deletions
diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp
index 1e327a3ba7..006755e20b 100644
--- a/indra/newview/llpathfindingpathtool.cpp
+++ b/indra/newview/llpathfindingpathtool.cpp
@@ -1,44 +1,46 @@
/**
- * @file llpathfindingpathtool.cpp
- * @author William Todd Stinson
- * @brief XXX
- *
- * $LicenseInfo:firstyear=2002&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
+* @file llpathfindingpathtool.cpp
+* @brief Implementation of llpathfindingpathtool
+* @author Stinson@lindenlab.com
+*
+* $LicenseInfo:firstyear=2012&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2012, Linden Research, Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+* $/LicenseInfo$
+*/
+
#include "llviewerprecompiledheaders.h"
+
#include "llpathfindingpathtool.h"
+#include <boost/function.hpp>
+#include <boost/signals2.hpp>
+
#include "llagent.h"
+#include "llpathfindingmanager.h"
+#include "llpathinglib.h"
#include "llsingleton.h"
#include "lltool.h"
#include "llviewercamera.h"
#include "llviewerregion.h"
#include "llviewerwindow.h"
-#include "llpathfindingmanager.h"
-#include "llpathinglib.h"
-
-#include <boost/function.hpp>
-#include <boost/signals2.hpp>
#define PATH_TOOL_NAME "PathfindingPathTool"
@@ -54,11 +56,6 @@ LLPathfindingPathTool::LLPathfindingPathTool()
mIsMiddleMouseButtonHeld(false),
mIsRightMouseButtonHeld(false)
{
- if (!LLPathingLib::getInstance())
- {
- LLPathingLib::initSystem();
- }
-
setCharacterWidth(1.0f);
setCharacterType(mCharacterType);
}
@@ -71,12 +68,25 @@ BOOL LLPathfindingPathTool::handleMouseDown(S32 pX, S32 pY, MASK pMask)
{
BOOL returnVal = FALSE;
- if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask))
+ if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld)
{
- computeFinalPoints(pX, pY, pMask);
- mIsLeftMouseButtonHeld = true;
- setMouseCapture(TRUE);
- returnVal = TRUE;
+ if (isAnyPathToolModKeys(pMask))
+ {
+ gViewerWindow->setCursor(isPointAModKeys(pMask)
+ ? UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD
+ : UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD);
+ computeFinalPoints(pX, pY, pMask);
+ mIsLeftMouseButtonHeld = true;
+ setMouseCapture(TRUE);
+ returnVal = TRUE;
+ }
+ else if (!isCameraModKeys(pMask))
+ {
+ gViewerWindow->setCursor(UI_CURSOR_TOOLNO);
+ mIsLeftMouseButtonHeld = true;
+ setMouseCapture(TRUE);
+ returnVal = TRUE;
+ }
}
mIsLeftMouseButtonHeld = true;
@@ -87,7 +97,7 @@ BOOL LLPathfindingPathTool::handleMouseUp(S32 pX, S32 pY, MASK pMask)
{
BOOL returnVal = FALSE;
- if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask))
+ if (mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld)
{
computeFinalPoints(pX, pY, pMask);
setMouseCapture(FALSE);
@@ -147,9 +157,16 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask)
{
BOOL returnVal = FALSE;
- if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask))
+ if (!mIsLeftMouseButtonHeld && !mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && !isAnyPathToolModKeys(pMask))
{
gViewerWindow->setCursor(UI_CURSOR_TOOLPATHFINDING);
+ }
+
+ if (!mIsMiddleMouseButtonHeld && !mIsRightMouseButtonHeld && isAnyPathToolModKeys(pMask))
+ {
+ gViewerWindow->setCursor(isPointAModKeys(pMask)
+ ? (mIsLeftMouseButtonHeld ? UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD : UI_CURSOR_TOOLPATHFINDING_PATH_START)
+ : (mIsLeftMouseButtonHeld ? UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD : UI_CURSOR_TOOLPATHFINDING_PATH_END));
computeTempPoints(pX, pY, pMask);
returnVal = TRUE;
}
@@ -162,6 +179,15 @@ BOOL LLPathfindingPathTool::handleHover(S32 pX, S32 pY, MASK pMask)
return returnVal;
}
+BOOL LLPathfindingPathTool::handleKey(KEY pKey, MASK pMask)
+{
+ // Eat the escape key or else the camera tool will pick up and reset to default view. This,
+ // in turn, will cause some other methods to get called. And one of those methods will reset
+ // the current toolset back to the basic toolset. This means that the pathfinding path toolset
+ // will no longer be active, but typically with pathfinding path elements on screen.
+ return (pKey == KEY_ESCAPE);
+}
+
LLPathfindingPathTool::EPathStatus LLPathfindingPathTool::getPathStatus() const
{
EPathStatus status = kPathStatusUnknown;
@@ -287,6 +313,11 @@ bool LLPathfindingPathTool::isPointBModKeys(MASK pMask) const
return ((pMask & MASK_SHIFT) != 0);
}
+bool LLPathfindingPathTool::isCameraModKeys(MASK pMask) const
+{
+ return ((pMask & MASK_ALT) != 0);
+}
+
void LLPathfindingPathTool::getRayPoints(S32 pX, S32 pY, LLVector3 &pRayStart, LLVector3 &pRayEnd) const
{
LLVector3 dv = gViewerWindow->mouseDirectionGlobal(pX, pY);