Commit c185ba9a authored by NiranV's avatar NiranV
Browse files

Added: Ability to toggle crouch and map controls to toggling crouch via the Keybinding system.

parent dd0283b2
......@@ -862,6 +862,42 @@ void LLAgent::setFlying(BOOL fly, BOOL fail_sound)
mbFlagsDirty = TRUE;
}
void LLAgent::setCrouching(BOOL crouch)
{
if (isAgentAvatarValid())
{
// *HACK: Don't allow to start the flying mode if we got ANIM_AGENT_STANDUP signal
// because in this case we won't get a signal to start avatar flying animation and
// it will be walking with flying mode "ON" indication. However we allow to switch
// the flying mode off if we get ANIM_AGENT_STANDUP signal. See process_avatar_animation().
// See EXT-2781.
if (crouch && gAgentAvatarp->mSignaledAnimations.find(ANIM_AGENT_STANDUP) != gAgentAvatarp->mSignaledAnimations.end())
{
return;
}
// don't allow taking off while sitting
if (crouch && gAgentAvatarp->isSitting())
{
return;
}
}
if (crouch)
{
setControlFlags(AGENT_CONTROL_UP_NEG);
}
else
{
clearControlFlags(AGENT_CONTROL_UP_NEG);
}
gAgentAvatarp->setCrouching(crouch);
//BD
gDragonStatus->setCrouching(crouch);
}
// UI based mechanism of setting fly state
//-----------------------------------------------------------------------------
......@@ -882,6 +918,8 @@ void LLAgent::toggleFlying()
gAgent.setFlying( fly );
gAgentCamera.resetView();
if (fly)
gAgent.setCrouching(false);
}
// static
......@@ -895,6 +933,25 @@ bool LLAgent::enableFlying()
return !sitting;
}
//BD - Crouching Toggle
void LLAgent::toggleCrouching()
{
BOOL crouch = !gAgent.isCrouching();
gAgent.setCrouching(crouch);
}
//BD
bool LLAgent::isCrouching()
{
BOOL crouching = FALSE;
if (isAgentAvatarValid())
{
crouching = gAgentAvatarp->isCrouching();
}
return crouching;
}
// static
bool LLAgent::isSitting()
{
......
......@@ -350,7 +350,7 @@ class LLAgent : public LLOldEvents::LLObservable
S32 mCurrentFidget;
//--------------------------------------------------------------------
// Fly
// BD - Movement
//--------------------------------------------------------------------
public:
BOOL getFlying() const;
......@@ -359,6 +359,10 @@ class LLAgent : public LLOldEvents::LLObservable
static bool enableFlying();
BOOL canFly(); // Does this parcel allow you to fly?
static bool isSitting();
//BD - Toggle Crouching
void setCrouching(BOOL crouch);
static void toggleCrouching();
static bool isCrouching();
//--------------------------------------------------------------------
// Voice
......
......@@ -4860,6 +4860,12 @@ void LLAppViewer::idle()
gAgent.moveYaw(-1.f);
}*/
//BD - Toggle Crouching
if (gAgent.isCrouching())
{
gAgent.moveUp(-1.f, false);
}
{
LL_RECORD_BLOCK_TIME(FTM_AGENT_AUTOPILOT);
// Handle automatic walking towards points
......
......@@ -65,6 +65,9 @@ LLViewerKeyboard gViewerKeyboard;
void agent_jump( EKeystate s )
{
//BD - Toggle Crouching
gAgent.setCrouching(false);
static BOOL first_fly_attempt(TRUE);
if (KEYSTATE_UP == s)
{
......@@ -308,7 +311,7 @@ void agent_toggle_fly( EKeystate s )
// Only catch the edge
if (KEYSTATE_DOWN == s )
{
LLAgent::toggleFlying();
gAgent.toggleFlying();
}
}
......@@ -634,6 +637,15 @@ void start_gesture( EKeystate s )
}
}
//BD - Toggle Crouching
void toggle_crouch(EKeystate s)
{
if (KEYSTATE_DOWN == s)
{
gAgent.toggleCrouching();
}
}
#define REGISTER_KEYBOARD_ACTION(KEY, ACTION) LLREGISTER_STATIC(LLKeyboardActionRegistry, KEY, ACTION);
REGISTER_KEYBOARD_ACTION("jump", agent_jump);
REGISTER_KEYBOARD_ACTION("push_down", agent_push_down);
......@@ -679,6 +691,8 @@ REGISTER_KEYBOARD_ACTION("start_gesture", start_gesture);
REGISTER_KEYBOARD_ACTION("roll_left", camera_roll_left);
REGISTER_KEYBOARD_ACTION("roll_right", camera_roll_right);
REGISTER_KEYBOARD_ACTION("roll_reset", camera_roll_reset);
//BD - Toggle Crouching
REGISTER_KEYBOARD_ACTION("toggle_crouch", toggle_crouch);
#undef REGISTER_KEYBOARD_ACTION
LLViewerKeyboard::LLViewerKeyboard()
......
......@@ -694,7 +694,9 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
//BD - Custom Posing
mIsPosing(false),
mExpiryTime(0.0f),
mCurrentAction(0)
mCurrentAction(0),
//BD - Toggle Crouching
mIsCrouching(false)
{
// _LL_DEBUGS("AvatarRender") << "LLVOAvatar Constructor (0x" << this << ") id:" << mID << LL_ENDL;
......
......@@ -968,9 +968,14 @@ class LLVOAvatar :
BOOL isSitting(){return mIsSitting;}
void sitOnObject(LLViewerObject *sit_object);
void getOffObject();
//BD - Toggle Crouching
void setCrouching(bool crouch) { mIsCrouching = crouch; }
bool isCrouching() { return mIsCrouching; }
private:
// set this property only with LLVOAvatar::sitDown method
BOOL mIsSitting;
//BD - Toggle Crouching
bool mIsCrouching;
// position backup in case of missing data
LLVector3 mLastRootPos;
......
......@@ -48,6 +48,10 @@ width="669">
Fly
</string>
<string
name="toggle_crouch">
Crouch (Toggle)
</string>
<string
name="stop_moving">
Stop Movement
</string>
......
......@@ -152,6 +152,10 @@
name="push_down"
value="push_down" />
<combo_box.item
label="Crouch (Toggle)"
name="toggle_crouch"
value="toggle_crouch" />
<combo_box.item
label="Fly"
name="toggle_fly"
value="toggle_fly" />
......@@ -286,6 +290,10 @@
name="push_down"
value="push_down" />
<combo_box.item
label="Crouch (Toggle)"
name="toggle_crouch"
value="toggle_crouch" />
<combo_box.item
label="Fly"
name="toggle_fly"
value="toggle_fly" />
......@@ -380,6 +388,10 @@
name="push_down"
value="push_down" />
<combo_box.item
label="Crouch (Toggle)"
name="toggle_crouch"
value="toggle_crouch" />
<combo_box.item
label="Fly"
name="toggle_fly"
value="toggle_fly" />
......
......@@ -112,7 +112,7 @@
auto_resize="false"
background_visible="true"
bg_alpha_color="0 0 0 0.5"
visible="true"
visible="false"
name="crouching_layout"
width="110">
<button
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment