00001 00032 #include "llviewerprecompiledheaders.h" 00033 00034 #include "llmoveview.h" 00035 00036 // Library includes 00037 #include "indra_constants.h" 00038 00039 // Viewer includes 00040 #include "llagent.h" 00041 #include "llviewercontrol.h" 00042 #include "llbutton.h" 00043 #include "llviewerwindow.h" 00044 #include "lljoystickbutton.h" 00045 #include "lluictrlfactory.h" 00046 00047 // 00048 // Constants 00049 // 00050 00051 const F32 MOVE_BUTTON_DELAY = 0.0f; 00052 const F32 YAW_NUDGE_RATE = 0.05f; // fraction of normal speed 00053 const F32 NUDGE_TIME = 0.25f; // in seconds 00054 00055 // 00056 // Member functions 00057 // 00058 00059 // protected 00060 LLFloaterMove::LLFloaterMove(const LLSD& key) 00061 : LLFloater("move floater") 00062 { 00063 setIsChrome(TRUE); 00064 00065 const BOOL DONT_OPEN = FALSE; 00066 LLUICtrlFactory::getInstance()->buildFloater(this,"floater_moveview.xml", NULL, DONT_OPEN); 00067 00068 mForwardButton = getChild<LLJoystickAgentTurn>("forward btn"); 00069 mForwardButton->setHeldDownDelay(MOVE_BUTTON_DELAY); 00070 00071 mBackwardButton = getChild<LLJoystickAgentTurn>("backward btn"); 00072 mBackwardButton->setHeldDownDelay(MOVE_BUTTON_DELAY); 00073 00074 mSlideLeftButton = getChild<LLJoystickAgentSlide>("slide left btn"); 00075 mSlideLeftButton->setHeldDownDelay(MOVE_BUTTON_DELAY); 00076 00077 mSlideRightButton = getChild<LLJoystickAgentSlide>("slide right btn"); 00078 mSlideRightButton->setHeldDownDelay(MOVE_BUTTON_DELAY); 00079 00080 mTurnLeftButton = getChild<LLButton>("turn left btn"); 00081 mTurnLeftButton->setHeldDownDelay(MOVE_BUTTON_DELAY); 00082 mTurnLeftButton->setHeldDownCallback( turnLeft ); 00083 00084 mTurnRightButton = getChild<LLButton>("turn right btn"); 00085 mTurnRightButton->setHeldDownDelay(MOVE_BUTTON_DELAY); 00086 mTurnRightButton->setHeldDownCallback( turnRight ); 00087 00088 mMoveUpButton = getChild<LLButton>("move up btn"); 00089 childSetAction("move up btn",moveUp,NULL); 00090 mMoveUpButton->setHeldDownDelay(MOVE_BUTTON_DELAY); 00091 mMoveUpButton->setHeldDownCallback( moveUp ); 00092 00093 mMoveDownButton = getChild<LLButton>("move down btn"); 00094 childSetAction("move down btn",moveDown,NULL); 00095 mMoveDownButton->setHeldDownDelay(MOVE_BUTTON_DELAY); 00096 mMoveDownButton->setHeldDownCallback( moveDown ); 00097 } 00098 00099 // virtual 00100 void LLFloaterMove::onClose(bool app_quitting) 00101 { 00102 LLFloater::onClose(app_quitting); 00103 00104 if (!app_quitting) 00105 { 00106 gSavedSettings.setBOOL("ShowMovementControls", FALSE); 00107 } 00108 } 00109 00110 // 00111 // Static member functions 00112 // 00113 00114 void LLFloaterMove::onOpen() 00115 { 00116 LLFloater::onOpen(); 00117 gSavedSettings.setBOOL("ShowMovementControls", TRUE); 00118 } 00119 00120 // protected static 00121 F32 LLFloaterMove::getYawRate( F32 time ) 00122 { 00123 if( time < NUDGE_TIME ) 00124 { 00125 F32 rate = YAW_NUDGE_RATE + time * (1 - YAW_NUDGE_RATE)/ NUDGE_TIME; 00126 return rate; 00127 } 00128 else 00129 { 00130 return 1.f; 00131 } 00132 } 00133 00134 // protected static 00135 void LLFloaterMove::turnLeft(void *) 00136 { 00137 F32 time = getInstance()->mTurnLeftButton->getHeldDownTime(); 00138 gAgent.moveYaw( getYawRate( time ) ); 00139 } 00140 00141 // protected static 00142 void LLFloaterMove::turnRight(void *) 00143 { 00144 F32 time = getInstance()->mTurnRightButton->getHeldDownTime(); 00145 gAgent.moveYaw( -getYawRate( time ) ); 00146 } 00147 00148 // protected static 00149 void LLFloaterMove::moveUp(void *) 00150 { 00151 // Jumps or flys up, depending on fly state 00152 gAgent.moveUp(1); 00153 } 00154 00155 // protected static 00156 void LLFloaterMove::moveDown(void *) 00157 { 00158 // Crouches or flys down, depending on fly state 00159 gAgent.moveUp(-1); 00160 } 00161 00162 // EOF