aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmoveview.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llmoveview.cpp
parentREADME.txt (diff)
downloadmeta-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 'linden/indra/newview/llmoveview.cpp')
-rw-r--r--linden/indra/newview/llmoveview.cpp217
1 files changed, 217 insertions, 0 deletions
diff --git a/linden/indra/newview/llmoveview.cpp b/linden/indra/newview/llmoveview.cpp
new file mode 100644
index 0000000..878705f
--- /dev/null
+++ b/linden/indra/newview/llmoveview.cpp
@@ -0,0 +1,217 @@
1/**
2 * @file llmoveview.cpp
3 * @brief Container for movement buttons like forward, left, fly
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 "llmoveview.h"
31
32// Library includes
33#include "indra_constants.h"
34
35// Viewer includes
36#include "llagent.h"
37#include "llcallbacklist.h"
38#include "viewer.h"
39#include "llfontgl.h"
40#include "llbutton.h"
41#include "llviewerwindow.h"
42#include "lljoystickbutton.h"
43#include "llresmgr.h"
44#include "llvieweruictrlfactory.h"
45
46//
47// Constants
48//
49
50const F32 MOVE_BUTTON_DELAY = 0.0f;
51const F32 YAW_NUDGE_RATE = 0.05f; // fraction of normal speed
52const F32 NUDGE_TIME = 0.25f; // in seconds
53
54const char *MOVE_TITLE = "";
55
56//
57// Global statics
58//
59
60LLFloaterMove* LLFloaterMove::sInstance = NULL;
61
62
63//
64// Member functions
65//
66
67// protected
68LLFloaterMove::LLFloaterMove()
69: LLFloater("move floater", "FloaterMoveRect", MOVE_TITLE, FALSE, 100, 100, DRAG_ON_TOP,
70 MINIMIZE_NO)
71{
72 setIsChrome(TRUE);
73 gUICtrlFactory->buildFloater(this,"floater_moveview.xml");
74
75 mForwardButton = LLViewerUICtrlFactory::getJoystickAgentTurnByName(this, "forward btn");
76 mForwardButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
77
78 mBackwardButton = LLViewerUICtrlFactory::getJoystickAgentTurnByName(this, "backward btn");
79 mBackwardButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
80
81 mSlideLeftButton = LLViewerUICtrlFactory::getJoystickAgentSlideByName(this, "slide left btn");
82 mSlideLeftButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
83
84 mSlideRightButton = LLViewerUICtrlFactory::getJoystickAgentSlideByName(this, "slide right btn");
85 mSlideRightButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
86
87 mTurnLeftButton = LLUICtrlFactory::getButtonByName(this, "turn left btn");
88 mTurnLeftButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
89 mTurnLeftButton->setHeldDownCallback( turnLeft );
90
91 mTurnRightButton = LLUICtrlFactory::getButtonByName(this, "turn right btn");
92 mTurnRightButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
93 mTurnRightButton->setHeldDownCallback( turnRight );
94
95 mMoveUpButton = LLUICtrlFactory::getButtonByName(this, "move up btn");
96 childSetAction("move up btn",moveUp,NULL);
97 mMoveUpButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
98 mMoveUpButton->setHeldDownCallback( moveUp );
99
100 mMoveDownButton = LLUICtrlFactory::getButtonByName(this, "move down btn");
101 childSetAction("move down btn",moveDown,NULL);
102 mMoveDownButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
103 mMoveDownButton->setHeldDownCallback( moveDown );
104
105 mFlyButton = LLUICtrlFactory::getButtonByName(this, "fly btn");
106 childSetAction("fly btn",onFlyButtonClicked,NULL);
107
108 sInstance = this;
109}
110
111// protected
112LLFloaterMove::~LLFloaterMove()
113{
114 // children all deleted by LLView destructor
115 sInstance = NULL;
116}
117
118// virtual
119void LLFloaterMove::onClose(bool app_quitting)
120{
121 LLFloater::onClose(app_quitting);
122
123 if (!app_quitting)
124 {
125 gSavedSettings.setBOOL("ShowMovementControls", FALSE);
126 }
127}
128
129//
130// Static member functions
131//
132
133// static
134void LLFloaterMove::show(void*)
135{
136 if (sInstance)
137 {
138 sInstance->open();
139 }
140 else
141 {
142 LLFloaterMove* f = new LLFloaterMove();
143 f->open();
144 }
145
146 gSavedSettings.setBOOL("ShowMovementControls", TRUE);
147}
148
149// static
150void LLFloaterMove::toggle(void*)
151{
152 if (sInstance)
153 {
154 sInstance->close();
155 }
156 else
157 {
158 show(NULL);
159 }
160}
161
162// static
163BOOL LLFloaterMove::visible(void*)
164{
165 return (sInstance != NULL);
166}
167
168// protected static
169void LLFloaterMove::onFlyButtonClicked(void *)
170{
171 gAgent.toggleFlying();
172}
173
174
175// protected static
176F32 LLFloaterMove::getYawRate( F32 time )
177{
178 if( time < NUDGE_TIME )
179 {
180 F32 rate = YAW_NUDGE_RATE + time * (1 - YAW_NUDGE_RATE)/ NUDGE_TIME;
181 return rate;
182 }
183 else
184 {
185 return 1.f;
186 }
187}
188
189// protected static
190void LLFloaterMove::turnLeft(void *)
191{
192 F32 time = sInstance->mTurnLeftButton->getHeldDownTime();
193 gAgent.moveYaw( getYawRate( time ) );
194}
195
196// protected static
197void LLFloaterMove::turnRight(void *)
198{
199 F32 time = sInstance->mTurnRightButton->getHeldDownTime();
200 gAgent.moveYaw( -getYawRate( time ) );
201}
202
203// protected static
204void LLFloaterMove::moveUp(void *)
205{
206 // Jumps or flys up, depending on fly state
207 gAgent.moveUp(1);
208}
209
210// protected static
211void LLFloaterMove::moveDown(void *)
212{
213 // Crouches or flys down, depending on fly state
214 gAgent.moveUp(-1);
215}
216
217// EOF