From 879e4babe909eea25a58f187ac07974beee13eb2 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 29 Nov 2010 21:59:31 +0100 Subject: [PATCH] - internal : added preliminary support for @edit:=n|y and @editobj:=n|y --HG-- branch : RLVa --- indra/newview/rlvcommon.cpp | 7 +++++++ indra/newview/rlvcommon.h | 7 +++++++ indra/newview/rlvhandler.cpp | 37 +++++++++++++++++++++--------------- indra/newview/rlvhandler.h | 25 ++++++++++++++++++++++-- 4 files changed, 59 insertions(+), 17 deletions(-) diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp index 1631ee4e62..0a92e35dbb 100644 --- a/indra/newview/rlvcommon.cpp +++ b/indra/newview/rlvcommon.cpp @@ -525,6 +525,13 @@ bool RlvSelectHasLockedAttach::apply(LLSelectNode* pNode) return (pNode->getObject()) ? gRlvAttachmentLocks.isLockedAttachment(pNode->getObject()->getRootEdit()) : false; } +// Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c +bool RlvSelectIsEditable::apply(LLSelectNode* pNode) +{ + const LLViewerObject* pObj = pNode->getObject(); + return (pObj) && (!gRlvHandler.canEdit(pObj)); +} + // Checked: 2009-07-05 (RLVa-1.0.0b) | Modified: RLVa-0.2.0f bool RlvSelectIsOwnedByOrGroupOwned::apply(LLSelectNode* pNode) { diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h index d5f6141877..3e593082d8 100644 --- a/indra/newview/rlvcommon.h +++ b/indra/newview/rlvcommon.h @@ -184,6 +184,13 @@ struct RlvSelectHasLockedAttach : public LLSelectedNodeFunctor virtual bool apply(LLSelectNode* pNode); }; +// Filters out selected objects that can't be editable (i.e. getFirstNode() will return NULL if the selection is fully editable) +struct RlvSelectIsEditable : public LLSelectedNodeFunctor +{ + RlvSelectIsEditable() {} + /*virtual*/ bool apply(LLSelectNode* pNode); +}; + struct RlvSelectIsOwnedByOrGroupOwned : public LLSelectedNodeFunctor { RlvSelectIsOwnedByOrGroupOwned(const LLUUID& uuid) : m_idAgent(uuid) {} diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index b1bc275da2..afd8f715b3 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -1053,20 +1053,6 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd) pObj->mText->setString( (RLV_TYPE_ADD == eType) ? "" : pObj->mText->getObjectText()); } break; -#ifdef RLV_EXTENSION_CMD_TOUCHXXX - case RLV_BHVR_TOUCH: // @touch:=n - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l - { - // There should be an option and it should specify a valid UUID - LLUUID idException(strOption); - VERIFY_OPTION_REF(idException.notNull()); - - if (RLV_TYPE_ADD == eType) - addException(rlvCmd.getObjectID(), eBhvr, idException); - else - removeException(rlvCmd.getObjectID(), eBhvr, idException); - } - break; -#endif // RLV_EXTENSION_CMD_TOUCHXXX // The following block is only valid if there's no option case RLV_BHVR_SHOWLOC: // @showloc=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h case RLV_BHVR_SHOWNAMES: // @shownames=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h @@ -1092,7 +1078,6 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd) #ifdef RLV_EXTENSION_CMD_ALLOWIDLE case RLV_BHVR_ALLOWIDLE: // @allowidle=n|y - Checked: 2010-05-03 (RLVa-1.2.0g) | Modified: RLVa-1.1.0h #endif // RLV_EXTENSION_CMD_ALLOWIDLE - case RLV_BHVR_EDIT: // @edit=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h case RLV_BHVR_REZ: // @rez=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h case RLV_BHVR_FARTOUCH: // @fartouch=n|y - Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h #ifdef RLV_EXTENSION_CMD_INTERACT @@ -1117,6 +1102,7 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd) case RLV_BHVR_TOUCHATTACH: // @touchattach[:=n|y - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l case RLV_BHVR_TOUCHHUD: // @touchhud[:=n|y - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l #endif // RLV_EXTENSION_CMD_TOUCHXXX + case RLV_BHVR_EDIT: // @edit[:]=n|y - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c { LLUUID idException(strOption); if (idException.notNull()) // If there's an option then it should specify a valid UUID @@ -1130,6 +1116,27 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd) VERIFY_OPTION_REF(strOption.empty()); } break; + // + // The following block is only valid if there an option that specifies a valid UUID (reference-counted per option) + // + case RLV_BHVR_EDITOBJ: // @editobj:=n|y - Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c +#ifdef RLV_EXTENSION_CMD_TOUCHXXX + case RLV_BHVR_TOUCH: // @touch:=n|y - Checked: 2010-01-01 (RLVa-1.1.0l) | Added: RLVa-1.1.0l +#endif // RLV_EXTENSION_CMD_TOUCHXXX + { + // There should be an option and it should specify a valid UUID + LLUUID idException(strOption); + VERIFY_OPTION_REF(idException.notNull()); + + if (RLV_TYPE_ADD == eType) + addException(rlvCmd.getObjectID(), eBhvr, idException); + else + removeException(rlvCmd.getObjectID(), eBhvr, idException); + } + break; + // + // Unknown or invalid + // case RLV_BHVR_UNKNOWN: // Pass unknown commands on to registered command handlers return (notifyCommandHandlers(&RlvCommandHandler::onAddRemCommand, rlvCmd, eRet, false)) ? eRet : RLV_RET_FAILED_UNKNOWN; diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h index 15635f7f24..0b69dc46aa 100644 --- a/indra/newview/rlvhandler.h +++ b/indra/newview/rlvhandler.h @@ -57,6 +57,8 @@ public: // Adds or removes an exception for the specified behaviour void addException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption); void removeException(const LLUUID& idObj, ERlvBehaviour eBhvr, const RlvExceptionOption& varOption); + // Returns TRUE if the specified behaviour has an added exception + bool hasException(ERlvBehaviour eBhvr) const; // Returns TRUE if the specified option was added as an exception for the specified behaviour bool isException(ERlvBehaviour eBhvr, const RlvExceptionOption& varOption, ERlvExceptionCheck typeCheck = RLV_CHECK_DEFAULT) const; // Returns TRUE if the specified behaviour should behave "permissive" (rather than "strict"/"secure") @@ -92,7 +94,8 @@ public: void setSitSource(const LLVector3d& posSource) { m_posSitSource = posSource; } // @standtp // Command specific helper functions - bool canShowHoverText(LLViewerObject* pObj) const; // @showhovertext* command family + bool canEdit(const LLViewerObject* pObj) const; // @edit and @editobj + bool canShowHoverText(const LLViewerObject* pObj) const; // @showhovertext* command family bool canSit(LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero) const; bool canStand() const; bool canTouch(const LLViewerObject* pObj, const LLVector3& posOffset = LLVector3::zero) const; // @touch @@ -229,8 +232,20 @@ inline void RlvHandler::addException(const LLUUID& idObj, ERlvBehaviour eBhvr, c m_Exceptions.insert(std::pair(eBhvr, RlvException(idObj, eBhvr, varOption))); } +// Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c +inline bool RlvHandler::canEdit(const LLViewerObject* pObj) const +{ + // The specified object can be edited if: + // - not generally restricted from editing (or the object's root is an exception) + // - not specifically restricted from editing this object's root + return + (pObj) && + ((!hasBehaviour(RLV_BHVR_EDIT)) || (isException(RLV_BHVR_EDIT, pObj->getRootEdit()->getID()))) && + ((!hasBehaviour(RLV_BHVR_EDITOBJ)) || (!isException(RLV_BHVR_EDITOBJ, pObj->getRootEdit()->getID()))); +} + // Checked: 2010-03-27 (RLVa-1.2.0b) | Modified: RLVa-1.0.0f -inline bool RlvHandler::canShowHoverText(LLViewerObject *pObj) const +inline bool RlvHandler::canShowHoverText(const LLViewerObject *pObj) const { return ( (!pObj) || (LL_PCODE_VOLUME != pObj->getPCode()) || !( (hasBehaviour(RLV_BHVR_SHOWHOVERTEXTALL)) || @@ -319,6 +334,12 @@ inline bool RlvHandler::hasBehaviourExcept(ERlvBehaviour eBehaviour, const LLUUI return hasBehaviourExcept(eBehaviour, std::string(), idObj); } +// Checked: 2010-11-29 (RLVa-1.3.0c) | Added: RLVa-1.3.0c +inline bool RlvHandler::hasException(ERlvBehaviour eBhvr) const +{ + return (m_Exceptions.find(eBhvr) != m_Exceptions.end()); +} + inline bool RlvHandler::isPermissive(ERlvBehaviour eBhvr) const { return (RlvCommand::hasStrictVariant(eBhvr))