00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "lltoolgun.h"
00035
00036 #include "llviewerwindow.h"
00037 #include "llagent.h"
00038 #include "llviewercontrol.h"
00039 #include "llsky.h"
00040 #include "viewer.h"
00041 #include "llresmgr.h"
00042 #include "llfontgl.h"
00043 #include "llui.h"
00044 #include "llviewerimagelist.h"
00045 #include "llviewercamera.h"
00046 #include "llhudmanager.h"
00047 #include "lltoolmgr.h"
00048 #include "lltoolgrab.h"
00049
00050 LLToolGun::LLToolGun( LLToolComposite* composite )
00051 :
00052 LLTool( "gun", composite )
00053 {
00054 mCrosshairImg = gImageList.getImage( LLUUID( gSavedSettings.getString("UIImgCrosshairsUUID") ), MIPMAP_FALSE, TRUE );
00055 }
00056
00057 void LLToolGun::handleSelect()
00058 {
00059 gViewerWindow->hideCursor();
00060 gViewerWindow->moveCursorToCenter();
00061 gViewerWindow->mWindow->setMouseClipping(TRUE);
00062 }
00063
00064 void LLToolGun::handleDeselect()
00065 {
00066 gViewerWindow->moveCursorToCenter();
00067 gViewerWindow->showCursor();
00068 gViewerWindow->mWindow->setMouseClipping(FALSE);
00069 }
00070
00071 BOOL LLToolGun::handleMouseDown(S32 x, S32 y, MASK mask)
00072 {
00073 gGrabTransientTool = this;
00074 gToolMgr->getCurrentToolset()->selectTool( gToolGrab );
00075
00076 return gToolGrab->handleMouseDown(x, y, mask);
00077 }
00078
00079 BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask)
00080 {
00081 if( gAgent.cameraMouselook() )
00082 {
00083 #if 1
00084 const F32 NOMINAL_MOUSE_SENSITIVITY = 0.0025f;
00085 #else
00086 const F32 NOMINAL_MOUSE_SENSITIVITY = 0.025f;
00087 #endif
00088
00089
00090 F32 mouse_sensitivity = clamp_rescale(gMouseSensitivity, 0.f, 15.f, 0.5f, 2.75f) * NOMINAL_MOUSE_SENSITIVITY;
00091
00092
00093
00094
00095 S32 dx = -gViewerWindow->getCurrentMouseDX();
00096 S32 dy = -gViewerWindow->getCurrentMouseDY();
00097
00098 if (dx != 0 || dy != 0)
00099 {
00100
00101 if (gInvertMouse)
00102 {
00103 gAgent.pitch(mouse_sensitivity * -dy);
00104 }
00105 else
00106 {
00107 gAgent.pitch(mouse_sensitivity * dy);
00108 }
00109 LLVector3 skyward = gAgent.getReferenceUpVector();
00110 gAgent.rotate(mouse_sensitivity * dx, skyward.mV[VX], skyward.mV[VY], skyward.mV[VZ]);
00111
00112 if (gSavedSettings.getBOOL("MouseSun"))
00113 {
00114 gSky.setSunDirection(gCamera->getAtAxis(), LLVector3(0.f, 0.f, 0.f));
00115 gSky.setOverrideSun(TRUE);
00116 gSavedSettings.setVector3("SkySunDefaultPosition", gCamera->getAtAxis());
00117 }
00118
00119 gViewerWindow->moveCursorToCenter();
00120 gViewerWindow->hideCursor();
00121 }
00122
00123 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGun (mouselook)" << llendl;
00124 }
00125 else
00126 {
00127 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGun (not mouselook)" << llendl;
00128 }
00129
00130
00131 gViewerWindow->setCursor(UI_CURSOR_ARROW);
00132
00133 return TRUE;
00134 }
00135
00136 void LLToolGun::draw()
00137 {
00138 if( gSavedSettings.getBOOL("ShowCrosshairs") )
00139 {
00140 gl_draw_image(
00141 ( gViewerWindow->getWindowWidth() - mCrosshairImg->getWidth() ) / 2,
00142 ( gViewerWindow->getWindowHeight() - mCrosshairImg->getHeight() ) / 2,
00143 mCrosshairImg );
00144 }
00145 }