diff options
author | Sergei Litovchuk <slitovchuk@productengine.com> | 2010-06-24 15:39:09 +0300 |
---|---|---|
committer | Sergei Litovchuk <slitovchuk@productengine.com> | 2010-06-24 15:39:09 +0300 |
commit | f5f43b5d3aba3071009d9caa63de1426699e19ec (patch) | |
tree | 41d98b536b00a371a7388ba20251148fa345a59c /indra/newview | |
parent | 216ef01f09191ac6571f9dd1b66004b6b35d6296 (diff) |
EXT-8014 FIXED Enabled "Take off" in My Outfits gear menu only if a worn item or base outfit is selected.
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/lloutfitslist.cpp | 71 | ||||
-rw-r--r-- | indra/newview/lloutfitslist.h | 7 |
2 files changed, 61 insertions, 17 deletions
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index 67442dd573..d9c31b4d1c 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -148,10 +148,27 @@ private: void onTakeOff() { - const LLUUID& selected_outfit_id = getSelectedOutfitID(); - if (selected_outfit_id.notNull()) + // Take off selected items if there are any + if (mOutfitList->hasItemSelected()) { - LLAppearanceMgr::instance().takeOffOutfit(selected_outfit_id); + uuid_vec_t selected_uuids; + mOutfitList->getSelectedItemsUUIDs(selected_uuids); + + for (uuid_vec_t::const_iterator it=selected_uuids.begin(); it != selected_uuids.end(); ++it) + { + if (get_is_item_worn(*it)) + { + LLAppearanceMgr::instance().removeItemFromAvatar(*it); + } + } + } + else // or take off the whole selected outfit if no items specified. + { + const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.notNull()) + { + LLAppearanceMgr::instance().takeOffOutfit(selected_outfit_id); + } } } @@ -474,7 +491,7 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) } // Handle removed tabs. - for (uuid_vec_t::const_iterator iter=vremoved.begin(); iter != vremoved.end(); iter++) + for (uuid_vec_t::const_iterator iter=vremoved.begin(); iter != vremoved.end(); ++iter) { outfits_map_t::iterator outfits_iter = mOutfitsMap.find((*iter)); if (outfits_iter != mOutfitsMap.end()) @@ -626,7 +643,10 @@ bool LLOutfitsList::isActionEnabled(const LLSD& userdata) } if (command_name == "take_off") { - return LLAppearanceMgr::getInstance()->getBaseOutfitUUID() == mSelectedOutfitUUID; + // Enable "Take Off" only if a worn item or base outfit is selected. + return ( !hasItemSelected() + && LLAppearanceMgr::getInstance()->getBaseOutfitUUID() == mSelectedOutfitUUID ) + || hasWornItemSelected(); } return false; } @@ -638,6 +658,22 @@ void LLOutfitsList::showGearMenu(LLView* spawning_view) mGearMenu->show(spawning_view); } +void LLOutfitsList::getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const +{ + // Collect selected items from all selected lists. + for (wearables_lists_map_t::const_iterator iter = mSelectedListsMap.begin(); + iter != mSelectedListsMap.end(); + ++iter) + { + uuid_vec_t uuids; + (*iter).second->getSelectedUUIDs(uuids); + + S32 prev_size = selected_uuids.size(); + selected_uuids.resize(prev_size + uuids.size()); + std::copy(uuids.begin(), uuids.end(), selected_uuids.begin() + prev_size); + } +} + boost::signals2::connection LLOutfitsList::setSelectionChangeCallback(selection_change_callback_t cb) { return mSelectionChangeSignal.connect(cb); @@ -894,6 +930,18 @@ void LLOutfitsList::applyFilterToTab( } } +bool LLOutfitsList::hasWornItemSelected() +{ + uuid_vec_t selected_uuids; + getSelectedItemsUUIDs(selected_uuids); + + for (uuid_vec_t::const_iterator it=selected_uuids.begin(); it != selected_uuids.end(); ++it) + { + if (get_is_item_worn(*it)) return true; + } + return false; +} + void LLOutfitsList::onAccordionTabRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id) { LLAccordionCtrlTab* tab = dynamic_cast<LLAccordionCtrlTab*>(ctrl); @@ -919,18 +967,7 @@ void LLOutfitsList::onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y) uuid_vec_t selected_uuids; - // Collect selected items from all selected lists. - for (wearables_lists_map_t::iterator iter = mSelectedListsMap.begin(); - iter != mSelectedListsMap.end(); - ++iter) - { - uuid_vec_t uuids; - (*iter).second->getSelectedUUIDs(uuids); - - S32 prev_size = selected_uuids.size(); - selected_uuids.resize(prev_size + uuids.size()); - std::copy(uuids.begin(), uuids.end(), selected_uuids.begin() + prev_size); - } + getSelectedItemsUUIDs(selected_uuids); LLWearableItemsList::ContextMenu::instance().show(list, selected_uuids, x, y); } diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index d207624792..f86a415200 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -103,6 +103,8 @@ public: const LLUUID& getSelectedOutfitUUID() const { return mSelectedOutfitUUID; } + void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const; + boost::signals2::connection setSelectionChangeCallback(selection_change_callback_t cb); /** @@ -173,6 +175,11 @@ private: */ void applyFilterToTab(const LLUUID& category_id, LLAccordionCtrlTab* tab, const std::string& filter_substring); + /** + * Returns true if there are any worn items among currently selected, otherwise false. + */ + bool hasWornItemSelected(); + void onAccordionTabRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id); void onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y); void onCOFChanged(); |