diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltoolgun.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/lltoolgun.cpp | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolgun.cpp b/linden/indra/newview/lltoolgun.cpp new file mode 100644 index 0000000..e4ec56a --- /dev/null +++ b/linden/indra/newview/lltoolgun.cpp | |||
@@ -0,0 +1,141 @@ | |||
1 | /** | ||
2 | * @file lltoolgun.cpp | ||
3 | * @brief LLToolGun class implementation | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "lltoolgun.h" | ||
31 | |||
32 | #include "llviewerwindow.h" | ||
33 | #include "llagent.h" | ||
34 | #include "llviewercontrol.h" | ||
35 | #include "llsky.h" | ||
36 | #include "viewer.h" | ||
37 | #include "llresmgr.h" | ||
38 | #include "llfontgl.h" | ||
39 | #include "llui.h" | ||
40 | #include "llviewerimagelist.h" | ||
41 | #include "llviewercamera.h" | ||
42 | #include "llhudmanager.h" | ||
43 | #include "lltoolmgr.h" | ||
44 | #include "lltoolgrab.h" | ||
45 | |||
46 | LLToolGun::LLToolGun( LLToolComposite* composite ) | ||
47 | : | ||
48 | LLTool( "gun", composite ) | ||
49 | { | ||
50 | mCrosshairImg = gImageList.getImage( LLUUID( gSavedSettings.getString("UIImgCrosshairsUUID") ), MIPMAP_FALSE, TRUE ); | ||
51 | } | ||
52 | |||
53 | void LLToolGun::handleSelect() | ||
54 | { | ||
55 | gViewerWindow->hideCursor(); | ||
56 | gViewerWindow->moveCursorToCenter(); | ||
57 | gViewerWindow->mWindow->setMouseClipping(TRUE); | ||
58 | } | ||
59 | |||
60 | void LLToolGun::handleDeselect() | ||
61 | { | ||
62 | gViewerWindow->moveCursorToCenter(); | ||
63 | gViewerWindow->showCursor(); | ||
64 | gViewerWindow->mWindow->setMouseClipping(FALSE); | ||
65 | } | ||
66 | |||
67 | BOOL LLToolGun::handleMouseDown(S32 x, S32 y, MASK mask) | ||
68 | { | ||
69 | gGrabTransientTool = this; | ||
70 | gCurrentToolset->selectTool( gToolGrab ); | ||
71 | |||
72 | return gToolGrab->handleMouseDown(x, y, mask); | ||
73 | } | ||
74 | |||
75 | BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask) | ||
76 | { | ||
77 | if( gAgent.cameraMouselook() ) | ||
78 | { | ||
79 | #if 1 //LL_WINDOWS || LL_DARWIN | ||
80 | const F32 NOMINAL_MOUSE_SENSITIVITY = 0.0025f; | ||
81 | #else | ||
82 | const F32 NOMINAL_MOUSE_SENSITIVITY = 0.025f; | ||
83 | #endif | ||
84 | |||
85 | |||
86 | F32 mouse_sensitivity = clamp_rescale(gMouseSensitivity, 0.f, 15.f, 0.5f, 2.75f) * NOMINAL_MOUSE_SENSITIVITY; | ||
87 | |||
88 | // ...move the view with the mouse | ||
89 | |||
90 | // get mouse movement delta | ||
91 | S32 dx = -gViewerWindow->getCurrentMouseDX(); | ||
92 | S32 dy = -gViewerWindow->getCurrentMouseDY(); | ||
93 | |||
94 | if (dx != 0 || dy != 0) | ||
95 | { | ||
96 | // ...actually moved off center | ||
97 | if (gInvertMouse) | ||
98 | { | ||
99 | gAgent.pitch(mouse_sensitivity * -dy); | ||
100 | } | ||
101 | else | ||
102 | { | ||
103 | gAgent.pitch(mouse_sensitivity * dy); | ||
104 | } | ||
105 | LLVector3 skyward = gAgent.getReferenceUpVector(); | ||
106 | gAgent.rotate(mouse_sensitivity * dx, skyward.mV[VX], skyward.mV[VY], skyward.mV[VZ]); | ||
107 | |||
108 | if (gSavedSettings.getBOOL("MouseSun")) | ||
109 | { | ||
110 | gSky.setSunDirection(gCamera->getAtAxis(), LLVector3(0.f, 0.f, 0.f)); | ||
111 | gSky.setOverrideSun(TRUE); | ||
112 | gSavedSettings.setVector3("SkySunDefaultPosition", gCamera->getAtAxis()); | ||
113 | } | ||
114 | |||
115 | gViewerWindow->moveCursorToCenter(); | ||
116 | gViewerWindow->hideCursor(); | ||
117 | } | ||
118 | |||
119 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGun (mouselook)" << llendl; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGun (not mouselook)" << llendl; | ||
124 | } | ||
125 | |||
126 | // HACK to avoid assert: error checking system makes sure that the cursor is set during every handleHover. This is actually a no-op since the cursor is hidden. | ||
127 | gViewerWindow->setCursor(UI_CURSOR_ARROW); | ||
128 | |||
129 | return TRUE; | ||
130 | } | ||
131 | |||
132 | void LLToolGun::draw() | ||
133 | { | ||
134 | if( gSavedSettings.getBOOL("ShowCrosshairs") ) | ||
135 | { | ||
136 | gl_draw_image( | ||
137 | ( gViewerWindow->getWindowWidth() - mCrosshairImg->getWidth() ) / 2, | ||
138 | ( gViewerWindow->getWindowHeight() - mCrosshairImg->getHeight() ) / 2, | ||
139 | mCrosshairImg ); | ||
140 | } | ||
141 | } | ||