From 9dd41cdceed43f1ffea14355c1b26c40db7b3591 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Thu, 4 Feb 2010 11:24:54 -0800 Subject: EXT-3144 EXT-4226: Re-employ tentative state for individual items in media settings Review #95 This change undoes some prior change that seems to not allow showing media data for multiple selection. There was all of this code put in to support displaying tentative state for media, but code was added to basically override it. Perhaps the reason was tentative state items were not ignored on apply...this change does that. --- indra/newview/llselectmgr.cpp | 95 +++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 48 deletions(-) (limited to 'indra/newview/llselectmgr.cpp') diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index bf08756051..9540894646 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -41,6 +41,7 @@ #include "lldbstrings.h" #include "lleconomy.h" #include "llgl.h" +#include "llmediaentry.h" #include "llrender.h" #include "llnotifications.h" #include "llpermissions.h" @@ -1739,70 +1740,70 @@ void LLSelectMgr::selectionSetFullbright(U8 fullbright) getSelection()->applyToObjects(&sendfunc); } -void LLSelectMgr::selectionSetMedia(U8 media_type) -{ - - struct f : public LLSelectedTEFunctor - { - U8 mMediaFlags; - f(const U8& t) : mMediaFlags(t) {} - bool apply(LLViewerObject* object, S32 te) - { - if (object->permModify()) - { - // update viewer has media - object->setTEMediaFlags(te, mMediaFlags); - } - return true; - } - } setfunc(media_type); - getSelection()->applyToTEs(&setfunc); - struct f2 : public LLSelectedObjectFunctor - { - virtual bool apply(LLViewerObject* object) - { - if (object->permModify()) - { - object->sendTEUpdate(); - } - return true; - } - } func2; - mSelectedObjects->applyToObjects( &func2 ); -} - // This function expects media_data to be a map containing relevant // media data name/value pairs (e.g. home_url, etc.) -void LLSelectMgr::selectionSetMediaData(const LLSD &media_data) -{ - +void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data) +{ struct f : public LLSelectedTEFunctor { + U8 mMediaFlags; const LLSD &mMediaData; - f(const LLSD& t) : mMediaData(t) {} + f(const U8& t, const LLSD& d) : mMediaFlags(t), mMediaData(d) {} bool apply(LLViewerObject* object, S32 te) { if (object->permModify()) { - LLVOVolume *vo = dynamic_cast(object); - if (NULL != vo) - { - vo->syncMediaData(te, mMediaData, true/*merge*/, true/*ignore_agent*/); - } + // If we are adding media, then check the current state of the + // media data on this face. + // - If it does not have media, AND we are NOT setting the HOME URL, then do NOT add media to this + // face. + // - If it does not have media, and we ARE setting the HOME URL, add media to this face. + // - If it does already have media, add/update media to/on this face + // If we are removing media, just do it (ignore the passed-in LLSD). + if (mMediaFlags & LLTextureEntry::MF_HAS_MEDIA) + { + llassert(mMediaData.isMap()); + const LLTextureEntry *texture_entry = object->getTE(te); + if (!mMediaData.isMap() || + (NULL != texture_entry) && !texture_entry->hasMedia() && !mMediaData.has(LLMediaEntry::HOME_URL_KEY)) + { + // skip adding/updating media + } + else { + // Add/update media + object->setTEMediaFlags(te, mMediaFlags); + LLVOVolume *vo = dynamic_cast(object); + llassert(NULL != vo); + if (NULL != vo) + { + vo->syncMediaData(te, mMediaData, true/*merge*/, true/*ignore_agent*/); + } + } + } + else + { + // delete media (or just set the flags) + object->setTEMediaFlags(te, mMediaFlags); + } } return true; } - } setfunc(media_data); + } setfunc(media_type, media_data); getSelection()->applyToTEs(&setfunc); - + struct f2 : public LLSelectedObjectFunctor { virtual bool apply(LLViewerObject* object) { if (object->permModify()) { - LLVOVolume *vo = dynamic_cast(object); - if (NULL != vo) + object->sendTEUpdate(); + LLVOVolume *vo = dynamic_cast(object); + llassert(NULL != vo); + // It's okay to skip this object if hasMedia() is false... + // the sendTEUpdate() above would remove all media data if it were + // there. + if (NULL != vo && vo->hasMedia()) { // Send updated media data FOR THE ENTIRE OBJECT vo->sendMediaDataUpdate(); @@ -1811,11 +1812,9 @@ void LLSelectMgr::selectionSetMediaData(const LLSD &media_data) return true; } } func2; - getSelection()->applyToObjects(&func2); + mSelectedObjects->applyToObjects( &func2 ); } - - void LLSelectMgr::selectionSetGlow(F32 glow) { struct f1 : public LLSelectedTEFunctor -- cgit v1.2.3