diff options
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r-- | indra/newview/llselectmgr.cpp | 297 |
1 files changed, 142 insertions, 155 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index bdbb1bb797..0079b3bab8 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -211,7 +211,6 @@ LLSelectMgr::LLSelectMgr() mGridMode = GRID_MODE_WORLD; gSavedSettings.setS32("GridMode", (S32)GRID_MODE_WORLD); - mGridValid = FALSE; mSelectedObjects = new LLObjectSelection(); mHoverObjects = new LLObjectSelection(); @@ -1170,7 +1169,6 @@ void LLSelectMgr::setGridMode(EGridMode mode) mGridMode = mode; gSavedSettings.setS32("GridMode", mode); updateSelectionCenter(); - mGridValid = FALSE; } void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &scale) @@ -1271,7 +1269,6 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 & origin = mGridOrigin; rotation = mGridRotation; scale = mGridScale; - mGridValid = TRUE; } //----------------------------------------------------------------------------- @@ -2941,248 +2938,241 @@ BOOL LLSelectMgr::selectGetRootsCopy() return TRUE; } -//----------------------------------------------------------------------------- -// selectGetCreator() -// Creator information only applies to root objects. -//----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetCreator(LLUUID& result_id, std::string& name) +struct LLSelectGetFirstTest { - BOOL identical = TRUE; - BOOL first = TRUE; - LLUUID first_id; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) + LLSelectGetFirstTest() : mIdentical(true), mFirst(true) { } + virtual ~LLSelectGetFirstTest() { } + + // returns false to break out of the iteration. + bool checkMatchingNode(LLSelectNode* node) { - LLSelectNode* node = *iter; - if (!node->mValid) + if (!node || !node->mValid) { - return FALSE; + return false; } - if (first) + if (mFirst) { - first_id = node->mPermissions->getCreator(); - first = FALSE; + mFirstValue = getValueFromNode(node); + mFirst = false; } else { - if ( !(first_id == node->mPermissions->getCreator() ) ) + if ( mFirstValue != getValueFromNode(node) ) { - identical = FALSE; - break; + mIdentical = false; + // stop testing once we know not all selected are identical. + return false; } } - } - if (first_id.isNull()) - { - name = LLTrans::getString("AvatarNameNobody"); - return FALSE; + // continue testing. + return true; } - result_id = first_id; + bool mIdentical; + LLUUID mFirstValue; - if (identical) - { - name = LLSLURL("agent", first_id, "inspect").getSLURLString(); - } - else - { - name = LLTrans::getString("AvatarNameMultiple"); - } - - return identical; -} +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) = 0; +private: + bool mFirst; +}; -//----------------------------------------------------------------------------- -// selectGetOwner() -// Owner information only applies to roots. -//----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetOwner(LLUUID& result_id, std::string& name) +void LLSelectMgr::getFirst(LLSelectGetFirstTest* test) { - BOOL identical = TRUE; - BOOL first = TRUE; - BOOL first_group_owned = FALSE; - LLUUID first_id; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) + if (gSavedSettings.getBOOL("EditLinkedParts")) +{ + for (LLObjectSelection::valid_iterator iter = getSelection()->valid_begin(); + iter != getSelection()->valid_end(); ++iter ) { - LLSelectNode* node = *iter; - if (!node->mValid) + if (!test->checkMatchingNode(*iter)) { - return FALSE; + break; + } } - - if (first) - { - node->mPermissions->getOwnership(first_id, first_group_owned); - first = FALSE; } else { - LLUUID owner_id; - BOOL is_group_owned = FALSE; - if (!(node->mPermissions->getOwnership(owner_id, is_group_owned)) - || owner_id != first_id || is_group_owned != first_group_owned) + for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); + iter != getSelection()->root_object_end(); ++iter ) + { + if (!test->checkMatchingNode(*iter)) { - identical = FALSE; break; } } } - if (first_id.isNull()) - { - return FALSE; } - result_id = first_id; - - if (identical) +//----------------------------------------------------------------------------- +// selectGetCreator() +// Creator information only applies to roots unless editing linked parts. +//----------------------------------------------------------------------------- +struct LLSelectGetFirstCreator : public LLSelectGetFirstTest { - BOOL public_owner = (first_id.isNull() && !first_group_owned); - if (first_group_owned) +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) { - name = LLSLURL("group", first_id, "inspect").getSLURLString(); + return node->mPermissions->getCreator(); } - else if(!public_owner) +}; + +BOOL LLSelectMgr::selectGetCreator(LLUUID& result_id, std::string& name) { - name = LLSLURL("agent", first_id, "inspect").getSLURLString(); - } - else + LLSelectGetFirstCreator test; + getFirst(&test); + + if (test.mFirstValue.isNull()) { name = LLTrans::getString("AvatarNameNobody"); + return FALSE; } + + result_id = test.mFirstValue; + + if (test.mIdentical) + { + name = LLSLURL("agent", test.mFirstValue, "inspect").getSLURLString(); } else { name = LLTrans::getString("AvatarNameMultiple"); } - return identical; + return test.mIdentical; } - //----------------------------------------------------------------------------- -// selectGetLastOwner() -// Owner information only applies to roots. +// selectGetOwner() +// Owner information only applies to roots unless editing linked parts. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetLastOwner(LLUUID& result_id, std::string& name) -{ - BOOL identical = TRUE; - BOOL first = TRUE; - LLUUID first_id; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) +struct LLSelectGetFirstOwner : public LLSelectGetFirstTest { - LLSelectNode* node = *iter; - if (!node->mValid) +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) { - return FALSE; + // Don't use 'getOwnership' since we return a reference, not a copy. + // Will return LLUUID::null if unowned (which is not allowed and should never happen.) + return node->mPermissions->isGroupOwned() ? node->mPermissions->getGroup() : node->mPermissions->getOwner(); } +}; - if (first) - { - first_id = node->mPermissions->getLastOwner(); - first = FALSE; - } - else +BOOL LLSelectMgr::selectGetOwner(LLUUID& result_id, std::string& name) { - if ( !(first_id == node->mPermissions->getLastOwner() ) ) - { - identical = FALSE; - break; - } - } - } - if (first_id.isNull()) + LLSelectGetFirstOwner test; + getFirst(&test); + + if (test.mFirstValue.isNull()) { return FALSE; } - result_id = first_id; + result_id = test.mFirstValue; - if (identical) + if (test.mIdentical) { - BOOL public_owner = (first_id.isNull()); - if(!public_owner) + bool group_owned = selectIsGroupOwned(); + if (group_owned) { - name = LLSLURL("agent", first_id, "inspect").getSLURLString(); + name = LLSLURL("group", test.mFirstValue, "inspect").getSLURLString(); } else { - name.assign("Public or Group"); + name = LLSLURL("agent", test.mFirstValue, "inspect").getSLURLString(); } } else { - name.assign( "" ); + name = LLTrans::getString("AvatarNameMultiple"); } - return identical; + return test.mIdentical; } - //----------------------------------------------------------------------------- -// selectGetGroup() -// Group information only applies to roots. +// selectGetLastOwner() +// Owner information only applies to roots unless editing linked parts. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectGetGroup(LLUUID& result_id) +struct LLSelectGetFirstLastOwner : public LLSelectGetFirstTest { - BOOL identical = TRUE; - BOOL first = TRUE; - LLUUID first_id; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) +{ + return node->mPermissions->getLastOwner(); + } +}; + +BOOL LLSelectMgr::selectGetLastOwner(LLUUID& result_id, std::string& name) { - LLSelectNode* node = *iter; - if (!node->mValid) + LLSelectGetFirstLastOwner test; + getFirst(&test); + + if (test.mFirstValue.isNull()) { return FALSE; } - if (first) + result_id = test.mFirstValue; + + if (test.mIdentical) { - first_id = node->mPermissions->getGroup(); - first = FALSE; + name = LLSLURL("agent", test.mFirstValue, "inspect").getSLURLString(); } else { - if ( !(first_id == node->mPermissions->getGroup() ) ) - { - identical = FALSE; - break; + name.assign( "" ); } + + return test.mIdentical; } + +//----------------------------------------------------------------------------- +// selectGetGroup() +// Group information only applies to roots unless editing linked parts. +//----------------------------------------------------------------------------- +struct LLSelectGetFirstGroup : public LLSelectGetFirstTest +{ +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) + { + return node->mPermissions->getGroup(); } +}; - result_id = first_id; +BOOL LLSelectMgr::selectGetGroup(LLUUID& result_id) +{ + LLSelectGetFirstGroup test; + getFirst(&test); - return identical; + result_id = test.mFirstValue; + return test.mIdentical; } //----------------------------------------------------------------------------- // selectIsGroupOwned() -// Only operates on root nodes. -// Returns TRUE if all have valid data and they are all group owned. +// Only operates on root nodes unless editing linked parts. +// Returns TRUE if the first selected is group owned. //----------------------------------------------------------------------------- -BOOL LLSelectMgr::selectIsGroupOwned() -{ - BOOL found_one = FALSE; - for (LLObjectSelection::root_object_iterator iter = getSelection()->root_object_begin(); - iter != getSelection()->root_object_end(); iter++ ) +struct LLSelectGetFirstGroupOwner : public LLSelectGetFirstTest { - LLSelectNode* node = *iter; - if (!node->mValid) +protected: + virtual const LLUUID& getValueFromNode(LLSelectNode* node) { - return FALSE; - } - found_one = TRUE; - if (!node->mPermissions->isGroupOwned()) + if (node->mPermissions->isGroupOwned()) { - return FALSE; + return node->mPermissions->getGroup(); } + return LLUUID::null; } - return found_one ? TRUE : FALSE; +}; + +BOOL LLSelectMgr::selectIsGroupOwned() +{ + LLSelectGetFirstGroupOwner test; + getFirst(&test); + + return test.mFirstValue.notNull() ? TRUE : FALSE; } //----------------------------------------------------------------------------- @@ -4985,7 +4975,11 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data } func(id); LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func); - if (node) + if (!node) + { + llwarns << "Couldn't find object " << id << " selected." << llendl; + } + else { if (node->mInventorySerial != inv_serial) { @@ -5056,13 +5050,6 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data dialog_refresh_all(); - // silly hack to allow 'save into inventory' - if(gPopupMenuView->getVisible()) - { - gPopupMenuView->setItemEnabled(SAVE_INTO_INVENTORY, - enable_save_into_inventory(NULL)); - } - // hack for left-click buy object LLToolPie::selectionPropertiesReceived(); } |