summaryrefslogtreecommitdiff
path: root/indra/newview/lloutfitslist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lloutfitslist.cpp')
-rw-r--r--indra/newview/lloutfitslist.cpp85
1 files changed, 72 insertions, 13 deletions
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index e20b2e26be..03df2d2b20 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -44,6 +44,7 @@
#include "llinventorymodel.h"
#include "lllistcontextmenu.h"
#include "llnotificationsutil.h"
+#include "lloutfitobserver.h"
#include "llsidetray.h"
#include "lltransutil.h"
#include "llviewermenu.h"
@@ -89,17 +90,33 @@ protected:
registrar.add("Outfit.Delete", boost::bind(deleteOutfit, selected_id));
enable_registrar.add("Outfit.OnEnable", boost::bind(&OutfitContextMenu::onEnable, this, _2));
+ enable_registrar.add("Outfit.OnVisible", boost::bind(&OutfitContextMenu::onVisible, this, _2));
return createFromFile("menu_outfit_tab.xml");
}
- bool onEnable(const LLSD& data)
+ bool onEnable(LLSD::String param)
+ {
+ LLUUID outfit_cat_id = mUUIDs.back();
+
+ if ("rename" == param)
+ {
+ return get_is_category_renameable(&gInventory, outfit_cat_id);
+ }
+
+ return true;
+ }
+
+ bool onVisible(LLSD::String param)
{
- std::string param = data.asString();
LLUUID outfit_cat_id = mUUIDs.back();
bool is_worn = LLAppearanceMgr::instance().getBaseOutfitUUID() == outfit_cat_id;
- if ("wear_replace" == param)
+ if ("edit" == param)
+ {
+ return is_worn;
+ }
+ else if ("wear_replace" == param)
{
return !is_worn;
}
@@ -111,14 +128,6 @@ protected:
{
return is_worn;
}
- else if ("edit" == param)
- {
- return is_worn;
- }
- else if ("rename" == param)
- {
- return get_is_category_renameable(&gInventory, outfit_cat_id);
- }
else if ("delete" == param)
{
return LLAppearanceMgr::instance().getCanRemoveOutfit(outfit_cat_id);
@@ -199,6 +208,9 @@ void LLOutfitsList::onOpen(const LLSD& /*info*/)
mCategoriesObserver->addCategory(outfits,
boost::bind(&LLOutfitsList::refreshList, this, outfits));
+ // Start observing changes in Current Outfit to update items worn state.
+ LLOutfitObserver::instance().addCOFChangedCallback(boost::bind(&LLOutfitsList::onCOFChanged, this));
+
// Fetch "My Outfits" contents and refresh the list to display
// initially fetched items. If not all items are fetched now
// the observer will refresh the list as soon as the new items
@@ -322,7 +334,7 @@ void LLOutfitsList::refreshList(const LLUUID& category_id)
// 3. Reset currently selected outfit id if it is being removed.
if (outfit_id == mSelectedOutfitUUID)
{
- mSelectedOutfitUUID = LLUUID();
+ setSelectedOutfitUUID(LLUUID());
}
// 4. Remove category UUID to accordion tab mapping.
@@ -385,6 +397,11 @@ void LLOutfitsList::setFilterSubString(const std::string& string)
mFilterSubString = string;
}
+boost::signals2::connection LLOutfitsList::addSelectionChangeCallback(selection_change_callback_t cb)
+{
+ return mSelectionChangeSignal.connect(cb);
+}
+
//////////////////////////////////////////////////////////////////////////
// Private methods
//////////////////////////////////////////////////////////////////////////
@@ -471,7 +488,12 @@ void LLOutfitsList::changeOutfitSelection(LLWearableItemsList* list, const LLUUI
}
mSelectedListsMap.insert(wearables_lists_map_value_t(category_id, list));
- mSelectedOutfitUUID = category_id;
+ setSelectedOutfitUUID(category_id);
+}
+
+void LLOutfitsList::setSelectedOutfitUUID(const LLUUID& category_id)
+{
+ mSelectionChangeSignal(mSelectedOutfitUUID = category_id);
}
void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl)
@@ -645,6 +667,43 @@ void LLOutfitsList::onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y)
LLWearableItemsList::ContextMenu::instance().show(list, selected_uuids, x, y);
}
+void LLOutfitsList::onCOFChanged()
+{
+ LLInventoryModel::changed_items_t changed_linked_items;
+
+ const LLInventoryModel::changed_items_t& changed_items = gInventory.getChangedIDs();
+ for (LLInventoryModel::changed_items_t::const_iterator iter = changed_items.begin();
+ iter != changed_items.end();
+ ++iter)
+ {
+ LLViewerInventoryItem* item = gInventory.getItem(*iter);
+ if (item)
+ {
+ // From gInventory we get the UUIDs of new links added to COF
+ // or removed from COF. These links UUIDs are not the same UUIDs
+ // that we have in each wearable items list. So we collect base items
+ // UUIDs to find all items or links that point to same base items in wearable
+ // items lists and update their worn state there.
+ changed_linked_items.insert(item->getLinkedUUID());
+ }
+ }
+
+ for (outfits_map_t::iterator iter = mOutfitsMap.begin();
+ iter != mOutfitsMap.end();
+ ++iter)
+ {
+ LLAccordionCtrlTab* tab = iter->second;
+ if (!tab) continue;
+
+ LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView());
+ if (!list) continue;
+
+ // Every list updates the labels of changed items or
+ // the links that point to these items.
+ list->updateChangedItems(changed_linked_items);
+ }
+}
+
bool is_tab_header_clicked(LLAccordionCtrlTab* tab, S32 y)
{
if(!tab || !tab->getHeaderVisible()) return false;