Added @setcam_mouselook=n|y to prevent the user from going into mouselook

--HG--
branch : RLVa
master
Kitty Barnett 2016-06-19 19:34:17 +02:00
parent 70da447db9
commit 94c33e8ee3
7 changed files with 52 additions and 7 deletions

View File

@ -2150,6 +2150,10 @@ void LLAgentCamera::resetCamera()
void LLAgentCamera::changeCameraToMouselook(BOOL animate)
{
if (!gSavedSettings.getBOOL("EnableMouselook")
// [RLVa:KB] - Checked: RLVa-2.0.0
|| ( (RlvActions::isRlvEnabled()) && (!RlvActions::canChangeToMouselook()) )
// [/RLVa:KB]
|| LLViewerJoystick::getInstance()->getOverrideCamera())
{
return;

View File

@ -41,6 +41,17 @@ bool RlvActions::canChangeCameraPreset(const LLUUID& idRlvObject)
(!gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM_EYEOFFSET)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM_FOCUSOFFSET));
}
bool RlvActions::canChangeToMouselook()
{
// User can switch to mouselook if:
// - not specifically prevented from going into mouselook (NOTE: if an object has exclusive camera control only that object can prevent mouselook)
// - there is no minimum camera distance defined (or it's higher than > 0m)
const RlvBehaviourModifier* pCamDistMinModifier = RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_SETCAM_AVDISTMIN);
return
( (!gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM)) ? !gRlvHandler.hasBehaviour(RLV_BHVR_SETCAM_MOUSELOOK) : !gRlvHandler.hasBehaviour(pCamDistMinModifier->getPrimaryObject(), RLV_BHVR_SETCAM_MOUSELOOK) ) &&
( (!pCamDistMinModifier->hasValue()) || (pCamDistMinModifier->getValue<float>() == 0.f) );
}
bool RlvActions::isCameraDistanceClamped()
{
return

View File

@ -39,6 +39,11 @@ public:
*/
static bool canChangeCameraPreset(const LLUUID& idRlvObject);
/*
* Returns true if the user can switch to mouselook
*/
static bool canChangeToMouselook();
/*
* Returns true if the camera's distance (from either the avatar of the focus) is currently restricted/clamped
*/

View File

@ -200,6 +200,7 @@ enum ERlvBehaviour {
RLV_BHVR_SETCAM_FOV, // Changes the current (vertical) field of view
RLV_BHVR_SETCAM_FOVMIN, // Enforces a minimum (vertical) FOV
RLV_BHVR_SETCAM_FOVMAX, // Enforces a maximum (vertical) FOV
RLV_BHVR_SETCAM_MOUSELOOK, // Prevent the user from going into mouselook
RLV_BHVR_SETCAM_TEXTURES, // Replaces all textures with the specified texture (or the default unrezzed one)
RLV_BHVR_SETCAM_UNLOCK, // Forces the camera focus to the user's avatar

View File

@ -1639,12 +1639,13 @@ void RlvBehaviourToggleHandler<RLV_BHVR_SENDIM>::onCommandToggle(ERlvBehaviour e
gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->setHiddenFromSettingsEditor(fHasBhvr);
}
// Handles: @setcam_unlock=n|y toggles
template<> template<>
void RlvBehaviourToggleHandler<RLV_BHVR_SETCAM_UNLOCK>::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr)
// Handles: @setcam_avdistmin:<distance>=n|y changes
template<>
void RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_AVDISTMIN>::onValueChange() const
{
if (fHasBhvr)
handle_reset_view();
const RlvBehaviourModifier* pBhvrModifier = RlvBehaviourDictionary::instance().getModifier(RLV_MODIFIER_SETCAM_AVDISTMIN);
if ( (gAgentCamera.cameraMouselook()) && (!RlvActions::canChangeToMouselook()) )
gAgentCamera.changeCameraToThirdPerson();
}
// Handles: @setcam_eyeoffset:<vector3>=n|y and @setcam_focusoffset:<vector3>=n|y toggles
@ -1706,6 +1707,14 @@ void RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_FOVMAX>::onValueChange() co
LLViewerCamera::instance().setDefaultFOV(LLViewerCamera::instance().getDefaultFOV());
}
// Handles: @setcam_mouselook=n|y toggles
template<> template<>
void RlvBehaviourToggleHandler<RLV_BHVR_SETCAM_MOUSELOOK>::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr)
{
if ((fHasBhvr) && (gAgentCamera.cameraMouselook()))
gAgentCamera.changeCameraToThirdPerson();
}
// Handles: @setcam_textures[:<uuid>=n|y changes
template<>
void RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_TEXTURE>::onValueChange() const
@ -1727,6 +1736,14 @@ void RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_TEXTURE>::onValueChange() c
}
}
// Handles: @setcam_unlock=n|y toggles
template<> template<>
void RlvBehaviourToggleHandler<RLV_BHVR_SETCAM_UNLOCK>::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr)
{
if (fHasBhvr)
handle_reset_view();
}
// Handles: @setcam=n|y toggles
template<> template<>
void RlvBehaviourToggleHandler<RLV_BHVR_SETCAM>::onCommandToggle(ERlvBehaviour eBhvr, bool fHasBhvr)

View File

@ -162,9 +162,9 @@ RlvBehaviourDictionary::RlvBehaviourDictionary()
// Camera
addEntry(new RlvBehaviourToggleProcessor<RLV_BHVR_SETCAM, RLV_OPTION_NONE>("setcam"));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_avdistmin", RLV_BHVR_SETCAM_AVDISTMIN));
addModifier(RLV_BHVR_SETCAM_AVDISTMIN, RLV_MODIFIER_SETCAM_AVDISTMIN, new RlvBehaviourModifier(0.0f, true, new RlvBehaviourModifier_CompMax()));
addModifier(RLV_BHVR_SETCAM_AVDISTMIN, RLV_MODIFIER_SETCAM_AVDISTMIN, new RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_AVDISTMIN>(0.0f, false, new RlvBehaviourModifier_CompMax()));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_avdistmax", RLV_BHVR_SETCAM_AVDISTMAX));
addModifier(RLV_BHVR_SETCAM_AVDISTMAX, RLV_MODIFIER_SETCAM_AVDISTMAX, new RlvBehaviourModifier(F32_MAX, true, new RlvBehaviourModifier_CompMin()));
addModifier(RLV_BHVR_SETCAM_AVDISTMAX, RLV_MODIFIER_SETCAM_AVDISTMAX, new RlvBehaviourModifier(F32_MAX, false, new RlvBehaviourModifier_CompMin()));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_focusdistmin", RLV_BHVR_SETCAM_FOCUSDISTMIN));
addModifier(RLV_BHVR_SETCAM_FOCUSDISTMIN, RLV_MODIFIER_SETCAM_FOCUSDISTMIN, new RlvBehaviourModifier(0.0f, true, new RlvBehaviourModifier_CompMax()));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_focusdistmax", RLV_BHVR_SETCAM_FOCUSDISTMAX));
@ -176,6 +176,7 @@ RlvBehaviourDictionary::RlvBehaviourDictionary()
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_fovmin", RLV_BHVR_SETCAM_FOVMIN));
addModifier(RLV_BHVR_SETCAM_FOVMIN, RLV_MODIFIER_SETCAM_FOVMIN, new RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_FOVMIN>(DEFAULT_FIELD_OF_VIEW, true, new RlvBehaviourModifier_CompMax()));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_MODIFIER>("setcam_fovmax", RLV_BHVR_SETCAM_FOVMAX));
addEntry(new RlvBehaviourToggleProcessor<RLV_BHVR_SETCAM_MOUSELOOK, RLV_OPTION_NONE>("setcam_mouselook"));
addModifier(RLV_BHVR_SETCAM_FOVMAX, RLV_MODIFIER_SETCAM_FOVMAX, new RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_FOVMAX>(DEFAULT_FIELD_OF_VIEW, true, new RlvBehaviourModifier_CompMin()));
addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE_OR_MODIFIER>("setcam_textures", RLV_BHVR_SETCAM_TEXTURES));
addModifier(RLV_BHVR_SETCAM_TEXTURES, RLV_MODIFIER_SETCAM_TEXTURE, new RlvBehaviourModifierHandler<RLV_MODIFIER_SETCAM_TEXTURE>(IMG_DEFAULT, true, nullptr));
@ -415,6 +416,11 @@ bool RlvBehaviourModifier::addValue(const RlvBehaviourModifierValue& modValue, c
return false;
}
const LLUUID& RlvBehaviourModifier::getPrimaryObject() const
{
return (m_pValueComparator) ? m_pValueComparator->m_idPrimaryObject : LLUUID::null;
}
bool RlvBehaviourModifier::hasValue() const {
// If no primary object is set this returns "any value set"; otherwise it returns "any value set by the primary object"
if ( (!m_pValueComparator) || (m_pValueComparator->m_idPrimaryObject.isNull()) )

View File

@ -212,6 +212,7 @@ public:
bool convertOptionValue(const std::string& optionValue, RlvBehaviourModifierValue& modValue) const;
bool getAddDefault() const { return m_fAddDefaultOnEmpty; }
const RlvBehaviourModifierValue& getDefaultValue() const { return m_DefaultValue; }
const LLUUID& getPrimaryObject() const;
const RlvBehaviourModifierValue& getValue() const { return (hasValue()) ? m_Values.front().first : m_DefaultValue; }
template<typename T> const T& getValue() const { return boost::get<T>(getValue()); }
bool hasValue() const;