diff options
author | Bryan O'Sullivan <bos@lindenlab.com> | 2009-08-31 13:47:47 -0700 |
---|---|---|
committer | Bryan O'Sullivan <bos@lindenlab.com> | 2009-08-31 13:47:47 -0700 |
commit | 30ff6cabd61f2f083df5df1e6e70cc94742af477 (patch) | |
tree | 631935f1cf59d19a91cdad65e9a75fe825afda7d /indra/newview/lltoolmgr.cpp | |
parent | ff11d74820c89822cd067b51727d9df1dc87d0d0 (diff) | |
parent | 3ac3a4b206c08ed06b889bdaa24074b6aa0e020a (diff) |
Merge with trunk
Diffstat (limited to 'indra/newview/lltoolmgr.cpp')
-rw-r--r-- | indra/newview/lltoolmgr.cpp | 110 |
1 files changed, 93 insertions, 17 deletions
diff --git a/indra/newview/lltoolmgr.cpp b/indra/newview/lltoolmgr.cpp index 5ba7217c99..d52e0b4b80 100644 --- a/indra/newview/lltoolmgr.cpp +++ b/indra/newview/lltoolmgr.cpp @@ -34,8 +34,13 @@ #include "lltoolmgr.h" -#include "lltool.h" +#include "lluictrl.h" +#include "llmenugl.h" +#include "llfloaterreg.h" + +#include "llfirstuse.h" // tools and manipulators +#include "lltool.h" #include "llmanipscale.h" #include "llselectmgr.h" #include "lltoolbrush.h" @@ -47,12 +52,14 @@ #include "lltoolindividual.h" #include "lltoolmorph.h" #include "lltoolpie.h" -#include "lltoolplacer.h" #include "lltoolselectland.h" #include "lltoolobjpicker.h" #include "lltoolpipette.h" #include "llagent.h" #include "llviewercontrol.h" +#include "llviewerjoystick.h" +#include "llviewermenu.h" +#include "llviewerparcelmgr.h" // Used when app not active to avoid processing hover. @@ -76,6 +83,11 @@ LLToolMgr::LLToolMgr() mSelectedTool( NULL ), mCurrentToolset( NULL ) { + // Not a panel, register these callbacks globally. + LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Active", boost::bind(&LLToolMgr::inEdit, this)); + LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("Build.Enabled", boost::bind(&LLToolMgr::canEdit, this)); + LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("Build.Toggle", boost::bind(&LLToolMgr::toggleBuildMode, this)); + gToolNull = new LLTool(LLStringUtil::null); // Does nothing setCurrentTool(gToolNull); @@ -168,11 +180,13 @@ void LLToolMgr::setCurrentTool( LLTool* tool ) mBaseTool = tool; updateToolStatus(); + + mSavedTool = NULL; } LLTool* LLToolMgr::getCurrentTool() { - MASK override_mask = gKeyboard->currentMask(TRUE); + MASK override_mask = gKeyboard ? gKeyboard->currentMask(TRUE) : 0; LLTool* cur_tool = NULL; // always use transient tools if available @@ -226,11 +240,77 @@ void LLToolMgr::updateToolStatus() getCurrentTool(); } -BOOL LLToolMgr::inEdit() +bool LLToolMgr::inEdit() { return mBaseTool != LLToolPie::getInstance() && mBaseTool != gToolNull; } +bool LLToolMgr::canEdit() +{ + return LLViewerParcelMgr::getInstance()->agentCanBuild(); +} + +void LLToolMgr::toggleBuildMode() +{ + if (inBuildMode()) + { + if (gSavedSettings.getBOOL("EditCameraMovement")) + { + // just reset the view, will pull us out of edit mode + handle_reset_view(); + } + else + { + // manually disable edit mode, but do not affect the camera + gAgent.resetView(false); + LLFloaterReg::hideInstance("build"); + gViewerWindow->showCursor(); + } + // avoid spurious avatar movements pulling out of edit mode + LLViewerJoystick::getInstance()->setNeedsReset(); + } + else + { + ECameraMode camMode = gAgent.getCameraMode(); + if (CAMERA_MODE_MOUSELOOK == camMode || CAMERA_MODE_CUSTOMIZE_AVATAR == camMode) + { + // pull the user out of mouselook or appearance mode when entering build mode + handle_reset_view(); + } + + if (gSavedSettings.getBOOL("EditCameraMovement")) + { + // camera should be set + if (LLViewerJoystick::getInstance()->getOverrideCamera()) + { + handle_toggle_flycam(); + } + + if (gAgent.getFocusOnAvatar()) + { + // zoom in if we're looking at the avatar + gAgent.setFocusOnAvatar(FALSE, ANIMATE); + gAgent.setFocusGlobal(gAgent.getPositionGlobal() + 2.0 * LLVector3d(gAgent.getAtAxis())); + gAgent.cameraZoomIn(0.666f); + gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD ); + } + } + + + setCurrentToolset(gBasicToolset); + getCurrentToolset()->selectTool( LLToolCompCreate::getInstance() ); + + // Could be first use + LLFirstUse::useBuild(); + + gAgent.resetView(false); + + // avoid spurious avatar movements + LLViewerJoystick::getInstance()->setNeedsReset(); + + } +} + bool LLToolMgr::inBuildMode() { // when entering mouselook inEdit() immediately returns true before @@ -277,22 +357,20 @@ void LLToolMgr::clearTransientTool() } -// The "gun tool", used for handling mouselook, captures the mouse and -// locks it within the window. When the app loses focus we need to -// release this locking. void LLToolMgr::onAppFocusLost() { - mSavedTool = mBaseTool; - mBaseTool = gToolNull; + if (mSelectedTool) + { + mSelectedTool->handleDeselect(); + } updateToolStatus(); } void LLToolMgr::onAppFocusGained() { - if (mSavedTool) + if (mSelectedTool) { - mBaseTool = mSavedTool; - mSavedTool = NULL; + mSelectedTool->handleSelect(); } updateToolStatus(); } @@ -396,8 +474,6 @@ void LLToolset::selectPrevTool() } } -void select_tool( void *tool_pointer ) -{ - LLTool *tool = (LLTool *)tool_pointer; - LLToolMgr::getInstance()->getCurrentToolset()->selectTool( tool ); -} +//////////////////////////////////////////////////////////////////////////// + + |