diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 692094746eb2de4b670b6a6910bc5412b0263ca0..5e476f41b14499060ff0c70327be01afd5344b8f 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -78,13 +78,11 @@ const F32 PARCEL_POST_HEIGHT = 0.666f; // Returns true if you got at least one object void LLToolSelectRect::handleRectangleSelection(S32 x, S32 y, MASK mask) { -// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c +// [RLVa:KB] - @edit* and @interact // Block rectangle selection if: - // - prevented from editing and no exceptions are set (see below for the case where exceptions are set) + // - prevented from editing anything at all // - prevented from interacting at all - if ( (rlv_handler_t::isEnabled()) && - ( ((gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) && (!gRlvHandler.hasException(RLV_BHVR_EDIT))) || - (gRlvHandler.hasBehaviour(RLV_BHVR_INTERACT)) ) ) + if (RlvActions::isRlvEnabled() && (RlvActions::canEdit(ERlvCheckType::None) || RlvActions::hasBehaviour(RLV_BHVR_INTERACT)) ) { return; } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 0cb601cb49da6976c16abd1b540230129556291f..4e265e7bac31aadfd5508b2aecf1cc2cb0eafe67 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -4469,8 +4469,9 @@ void LLSelectMgr::convertTransient() void LLSelectMgr::deselectAllIfTooFar() { -// [RLVa:KB] - Checked: RLVa-1.3.0 - if ( (!mSelectedObjects->isEmpty()) && ((gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) || (gRlvHandler.hasBehaviour(RLV_BHVR_EDITOBJ))) ) +// [RLVa:KB] - @edit* + // Continuously verify the selection as soon as there is at least one prim we shouldn't be able to edit + if ( !mSelectedObjects->isEmpty() && RlvActions::isRlvEnabled() && !RlvActions::canEdit(ERlvCheckType::All) ) { struct NotTransientOrFocusedMediaOrEditable : public LLSelectedNodeFunctor { diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 4690e012f2478ba071c3734ebd7edf0fd3c8f03d..f49af5b091a0d186e9a891d99da667d373056804 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3036,17 +3036,19 @@ bool enable_object_edit() } else if (LLSelectMgr::getInstance()->selectGetAllValidAndObjectsFound()) { -// enable = true; -// [RLVa:KB] - Checked: 2010-11-29 (RLVa-1.3.0c) | Modified: RLVa-1.3.0c - bool fRlvCanEdit = (!gRlvHandler.hasBehaviour(RLV_BHVR_EDIT)) && (!gRlvHandler.hasBehaviour(RLV_BHVR_EDITOBJ)); - if (!fRlvCanEdit) +// [RLVa:KB] - @edit* + if (RlvActions::isRlvEnabled() && !RlvActions::canEdit(ERlvCheckType::All)) { LLObjectSelectionHandle hSel = LLSelectMgr::getInstance()->getSelection(); RlvSelectIsEditable f; - fRlvCanEdit = (hSel.notNull()) && ((hSel->getFirstRootNode(&f, TRUE)) == NULL); + enable = (hSel.notNull()) && (!hSel->getFirstRootNode(&f, true)); + } + else + { + enable = true; } - enable = fRlvCanEdit; // [/RLVa:KB] +// enable = true; } return enable; diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp index 83f04fbb5b044d955d5c48afa640e221f34bbead..80178cd36242e87645afc1809138b13f3eca2d86 100644 --- a/indra/newview/rlvactions.cpp +++ b/indra/newview/rlvactions.cpp @@ -419,19 +419,53 @@ bool RlvActions::canBuyObject(const LLUUID& idObj) return (!RlvHandler::instance().hasBehaviour(RLV_BHVR_BUY)); } -// Handles: @edit and @editobj +// Handles: @edit, @editobj, @editattach and @editworld +bool RlvActions::canEdit(ERlvCheckType eCheckType) +{ + RlvHandler& rlvHandler = RlvHandler::instance(); + switch (eCheckType) + { + case ERlvCheckType::All: + // No edit restrictions of any kind + return + !rlvHandler.hasBehaviour(RLV_BHVR_EDIT) && !rlvHandler.hasBehaviour(RLV_BHVR_EDITOBJ) && + !rlvHandler.hasBehaviour(RLV_BHVR_EDITATTACH) && !rlvHandler.hasBehaviour(RLV_BHVR_EDITWORLD); + + case ERlvCheckType::Some: + // Not @edit restricted (or at least one exception) and either not @editattach or not @editworld restricted + return + (!rlvHandler.hasBehaviour(RLV_BHVR_EDIT) || rlvHandler.hasException(RLV_BHVR_EDIT)) && + (!rlvHandler.hasBehaviour(RLV_BHVR_EDITATTACH) || rlvHandler.hasBehaviour(RLV_BHVR_EDITWORLD)); + + case ERlvCheckType::None: + // Either @edit restricted with no exceptions or @editattach and @editworld restricted at the same time + return + (rlvHandler.hasBehaviour(RLV_BHVR_EDIT) && !rlvHandler.hasException(RLV_BHVR_EDIT)) || + (rlvHandler.hasBehaviour(RLV_BHVR_EDITATTACH) && rlvHandler.hasBehaviour(RLV_BHVR_EDITWORLD)); + + default: + RLV_ASSERT(false); + return false; + } +} + +// Handles: @edit, @editobj, @editattach and @editworld bool RlvActions::canEdit(const LLViewerObject* pObj) { // User can edit the specified object if: // - not generally restricted from editing (or the object's root is an exception) // - not specifically restricted from editing this object's root + // - it's an attachment and not restricted from editing attachments + // it's a rezzed object and not restricted from editing any world objects // NOTE-RLVa: edit checks should *never* be subject to @fartouch distance checks since we don't have the pick offset so // instead just implicitly rely on the presence of a (transient) selection return (pObj) && ( (!RlvHandler::instance().hasBehaviour(RLV_BHVR_EDIT)) || (RlvHandler::instance().isException(RLV_BHVR_EDIT, pObj->getRootEdit()->getID())) ) && - ( (!RlvHandler::instance().hasBehaviour(RLV_BHVR_EDITOBJ)) || (!RlvHandler::instance().isException(RLV_BHVR_EDITOBJ, pObj->getRootEdit()->getID())) ); + ( (!RlvHandler::instance().hasBehaviour(RLV_BHVR_EDITOBJ)) || (!RlvHandler::instance().isException(RLV_BHVR_EDITOBJ, pObj->getRootEdit()->getID())) ) && + ( (pObj->isAttachment()) ? !RlvHandler::instance().hasBehaviour(RLV_BHVR_EDITATTACH) + : !RlvHandler::instance().hasBehaviour(RLV_BHVR_EDITWORLD) ); } // Handles: @fartouch and @interact diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h index d14354994925d471e9c82c7b91ecae7b373ff86f..217eb21a5881c7bf9fe7a8ea0441398b9b537933 100644 --- a/indra/newview/rlvactions.h +++ b/indra/newview/rlvactions.h @@ -33,6 +33,8 @@ class LLVOAvatar; // RlvActions class declaration - developer-friendly non-RLVa code facing class, use in lieu of RlvHandler whenever possible // +enum class ERlvCheckType { All, Some, None }; + class RlvActions { // ====== @@ -255,6 +257,11 @@ class RlvActions */ static bool canBuyObject(const LLUUID& idObj); + /* + * Returns true if the user can edit all, some, or nothing (used to bail early, or to skip expensive selection checks) + */ + static bool canEdit(ERlvCheckType eCheckType); + /* * Returns true if the user can edit the specified object (with an optional relative offset) */ diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h index 4d40fc14ba64fd985037a42ef1d411b408b43bb2..4b6a2f543d4643e5839e83d117722278dc98459a 100644 --- a/indra/newview/rlvdefines.h +++ b/indra/newview/rlvdefines.h @@ -157,7 +157,9 @@ enum ERlvBehaviour { RLV_BHVR_ALLOWIDLE, // "allowidle" RLV_BHVR_BUY, // "buy" RLV_BHVR_EDIT, // "edit" + RLV_BHVR_EDITATTACH, RLV_BHVR_EDITOBJ, // "editobj" + RLV_BHVR_EDITWORLD, RLV_BHVR_VIEWTRANSPARENT, RLV_BHVR_VIEWWIREFRAME, RLV_BHVR_PAY, // "pay" diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index 2eeee306d3456da494242527da33399bf13c2ad7..d69fbf45ed954d6b7481800a7bc8a1729d6339d6 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -102,7 +102,9 @@ RlvBehaviourDictionary::RlvBehaviourDictionary() addEntry(new RlvBehaviourInfo("detachthis_except", RLV_BHVR_DETACHTHISEXCEPT, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_NODE)); addEntry(new RlvBehaviourInfo("detachallthis_except", RLV_BHVR_DETACHTHISEXCEPT, RLV_TYPE_ADDREM, RlvBehaviourInfo::FORCEWEAR_SUBTREE)); addEntry(new RlvBehaviourGenericToggleProcessor<RLV_BHVR_EDIT, RLV_OPTION_NONE_OR_EXCEPTION>("edit")); + addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("editattach", RLV_BHVR_EDITATTACH)); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_EXCEPTION>("editobj", RLV_BHVR_EDITOBJ)); + addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("editworld", RLV_BHVR_EDITWORLD)); addEntry(new RlvBehaviourGenericToggleProcessor<RLV_BHVR_VIEWTRANSPARENT, RLV_OPTION_NONE>("viewtransparent", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); addEntry(new RlvBehaviourGenericToggleProcessor<RLV_BHVR_VIEWWIREFRAME, RLV_OPTION_NONE>("viewwireframe", RlvBehaviourInfo::BHVR_EXPERIMENTAL)); addEntry(new RlvBehaviourGenericProcessor<RLV_OPTION_NONE>("emote", RLV_BHVR_EMOTE));