00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llmoveview.h"
00035
00036
00037 #include "indra_constants.h"
00038
00039
00040 #include "llagent.h"
00041 #include "llcallbacklist.h"
00042 #include "viewer.h"
00043 #include "llfontgl.h"
00044 #include "llbutton.h"
00045 #include "llviewerwindow.h"
00046 #include "lljoystickbutton.h"
00047 #include "llresmgr.h"
00048 #include "llvieweruictrlfactory.h"
00049
00050
00051
00052
00053
00054 const F32 MOVE_BUTTON_DELAY = 0.0f;
00055 const F32 YAW_NUDGE_RATE = 0.05f;
00056 const F32 NUDGE_TIME = 0.25f;
00057
00058 const char *MOVE_TITLE = "";
00059
00060
00061
00062
00063
00064 LLFloaterMove* LLFloaterMove::sInstance = NULL;
00065
00066
00067
00068
00069
00070
00071
00072 LLFloaterMove::LLFloaterMove()
00073 : LLFloater("move floater", "FloaterMoveRect", MOVE_TITLE, FALSE, 100, 100, DRAG_ON_TOP,
00074 MINIMIZE_NO)
00075 {
00076 setIsChrome(TRUE);
00077 gUICtrlFactory->buildFloater(this,"floater_moveview.xml");
00078
00079 mForwardButton = LLViewerUICtrlFactory::getJoystickAgentTurnByName(this, "forward btn");
00080 mForwardButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
00081
00082 mBackwardButton = LLViewerUICtrlFactory::getJoystickAgentTurnByName(this, "backward btn");
00083 mBackwardButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
00084
00085 mSlideLeftButton = LLViewerUICtrlFactory::getJoystickAgentSlideByName(this, "slide left btn");
00086 mSlideLeftButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
00087
00088 mSlideRightButton = LLViewerUICtrlFactory::getJoystickAgentSlideByName(this, "slide right btn");
00089 mSlideRightButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
00090
00091 mTurnLeftButton = LLUICtrlFactory::getButtonByName(this, "turn left btn");
00092 mTurnLeftButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
00093 mTurnLeftButton->setHeldDownCallback( turnLeft );
00094
00095 mTurnRightButton = LLUICtrlFactory::getButtonByName(this, "turn right btn");
00096 mTurnRightButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
00097 mTurnRightButton->setHeldDownCallback( turnRight );
00098
00099 mMoveUpButton = LLUICtrlFactory::getButtonByName(this, "move up btn");
00100 childSetAction("move up btn",moveUp,NULL);
00101 mMoveUpButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
00102 mMoveUpButton->setHeldDownCallback( moveUp );
00103
00104 mMoveDownButton = LLUICtrlFactory::getButtonByName(this, "move down btn");
00105 childSetAction("move down btn",moveDown,NULL);
00106 mMoveDownButton->setHeldDownDelay(MOVE_BUTTON_DELAY);
00107 mMoveDownButton->setHeldDownCallback( moveDown );
00108
00109 mFlyButton = LLUICtrlFactory::getButtonByName(this, "fly btn");
00110 childSetAction("fly btn",onFlyButtonClicked,NULL);
00111
00112 sInstance = this;
00113 }
00114
00115
00116 LLFloaterMove::~LLFloaterMove()
00117 {
00118
00119 sInstance = NULL;
00120 }
00121
00122
00123 void LLFloaterMove::onClose(bool app_quitting)
00124 {
00125 LLFloater::onClose(app_quitting);
00126
00127 if (!app_quitting)
00128 {
00129 gSavedSettings.setBOOL("ShowMovementControls", FALSE);
00130 }
00131 }
00132
00133
00134
00135
00136
00137
00138 void LLFloaterMove::show(void*)
00139 {
00140 if (sInstance)
00141 {
00142 sInstance->open();
00143 }
00144 else
00145 {
00146 LLFloaterMove* f = new LLFloaterMove();
00147 f->open();
00148 }
00149
00150 gSavedSettings.setBOOL("ShowMovementControls", TRUE);
00151 }
00152
00153
00154 void LLFloaterMove::toggle(void*)
00155 {
00156 if (sInstance)
00157 {
00158 sInstance->close();
00159 }
00160 else
00161 {
00162 show(NULL);
00163 }
00164 }
00165
00166
00167 BOOL LLFloaterMove::visible(void*)
00168 {
00169 return (sInstance != NULL);
00170 }
00171
00172
00173 void LLFloaterMove::onFlyButtonClicked(void *)
00174 {
00175 gAgent.toggleFlying();
00176 }
00177
00178
00179
00180 F32 LLFloaterMove::getYawRate( F32 time )
00181 {
00182 if( time < NUDGE_TIME )
00183 {
00184 F32 rate = YAW_NUDGE_RATE + time * (1 - YAW_NUDGE_RATE)/ NUDGE_TIME;
00185 return rate;
00186 }
00187 else
00188 {
00189 return 1.f;
00190 }
00191 }
00192
00193
00194 void LLFloaterMove::turnLeft(void *)
00195 {
00196 F32 time = sInstance->mTurnLeftButton->getHeldDownTime();
00197 gAgent.moveYaw( getYawRate( time ) );
00198 }
00199
00200
00201 void LLFloaterMove::turnRight(void *)
00202 {
00203 F32 time = sInstance->mTurnRightButton->getHeldDownTime();
00204 gAgent.moveYaw( -getYawRate( time ) );
00205 }
00206
00207
00208 void LLFloaterMove::moveUp(void *)
00209 {
00210
00211 gAgent.moveUp(1);
00212 }
00213
00214
00215 void LLFloaterMove::moveDown(void *)
00216 {
00217
00218 gAgent.moveUp(-1);
00219 }
00220
00221