summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llagentwearables.cpp2
-rw-r--r--indra/newview/llcofwearables.cpp90
2 files changed, 76 insertions, 16 deletions
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index acf43dda1e..342f9a5d80 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -2006,6 +2006,8 @@ bool LLAgentWearables::moveWearable(const LLViewerInventoryItem* item, bool clos
// static
void LLAgentWearables::createWearable(LLWearableType::EType type, bool wear, const LLUUID& parent_id)
{
+ if (type == LLWearableType::WT_INVALID || type == LLWearableType::WT_NONE) return;
+
LLWearable* wearable = LLWearableList::instance().createNewWearable(type);
LLAssetType::EType asset_type = wearable->getAssetType();
LLInventoryType::EType inv_type = LLInventoryType::IT_WEARABLE;
diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index 916d53da3c..611396b0e5 100644
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -58,13 +58,19 @@ static const LLWearableItemNameComparator WEARABLE_NAME_COMPARATOR;
class CofContextMenu : public LLListContextMenu
{
protected:
- static void updateCreateWearableLabel(LLMenuGL* menu, const LLUUID& item_id)
+ CofContextMenu(LLCOFWearables* cof_wearables)
+ : mCOFWearables(cof_wearables)
+ {
+ llassert(mCOFWearables);
+ }
+
+ void updateCreateWearableLabel(LLMenuGL* menu, const LLUUID& item_id)
{
LLMenuItemGL* menu_item = menu->getChild<LLMenuItemGL>("create_new");
+ LLWearableType::EType w_type = getWearableType(item_id);
// Hide the "Create new <WEARABLE_TYPE>" if it's irrelevant.
- LLViewerInventoryItem* item = gInventory.getLinkedItem(item_id);
- if (!item || !item->isWearableType())
+ if (w_type == LLWearableType::WT_NONE)
{
menu_item->setVisible(FALSE);
return;
@@ -72,25 +78,67 @@ protected:
// Set proper label for the "Create new <WEARABLE_TYPE>" menu item.
LLStringUtil::format_map_t args;
- LLWearableType::EType w_type = item->getWearableType();
args["[WEARABLE_TYPE]"] = LLWearableType::getTypeDefaultNewName(w_type);
std::string new_label = LLTrans::getString("CreateNewWearable", args);
menu_item->setLabel(new_label);
}
- static void createNew(const LLUUID& item_id)
+ void createNew(const LLUUID& item_id)
{
- LLViewerInventoryItem* item = gInventory.getLinkedItem(item_id);
- if (!item || !item->isWearableType()) return;
+ LLAgentWearables::createWearable(getWearableType(item_id), true);
+ }
+
+ // Get wearable type of the given item.
+ //
+ // There is a special case: so-called "dummy items"
+ // (i.e. the ones that are there just to indicate that you're not wearing
+ // any wearables of the corresponding type. They are currently grayed out
+ // and suffixed with "not worn").
+ // Those items don't have an UUID, but they do have an associated wearable type.
+ // If the user has invoked context menu for such item,
+ // we ignore the passed item_id and retrieve wearable type from the item.
+ LLWearableType::EType getWearableType(const LLUUID& item_id)
+ {
+ if (!isDummyItem(item_id))
+ {
+ LLViewerInventoryItem* item = gInventory.getLinkedItem(item_id);
+ if (item && item->isWearableType())
+ {
+ return item->getWearableType();
+ }
+ }
+ else if (mCOFWearables) // dummy item selected
+ {
+ LLPanelDummyClothingListItem* item;
+
+ item = dynamic_cast<LLPanelDummyClothingListItem*>(mCOFWearables->getSelectedItem());
+ if (item)
+ {
+ return item->getWearableType();
+ }
+ }
+
+ return LLWearableType::WT_NONE;
+ }
- LLAgentWearables::createWearable(item->getWearableType(), true);
+ static bool isDummyItem(const LLUUID& item_id)
+ {
+ return item_id.isNull();
}
+
+ LLCOFWearables* mCOFWearables;
};
//////////////////////////////////////////////////////////////////////////
-class CofAttachmentContextMenu : public LLListContextMenu
+class CofAttachmentContextMenu : public CofContextMenu
{
+public:
+ CofAttachmentContextMenu(LLCOFWearables* cof_wearables)
+ : CofContextMenu(cof_wearables)
+ {
+ }
+
protected:
/*virtual*/ LLContextMenu* createMenu()
@@ -108,8 +156,13 @@ protected:
class CofClothingContextMenu : public CofContextMenu
{
-protected:
+public:
+ CofClothingContextMenu(LLCOFWearables* cof_wearables)
+ : CofContextMenu(cof_wearables)
+ {
+ }
+protected:
/*virtual*/ LLContextMenu* createMenu()
{
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
@@ -121,7 +174,7 @@ protected:
registrar.add("Clothing.MoveUp", boost::bind(moveWearable, selected_id, false));
registrar.add("Clothing.MoveDown", boost::bind(moveWearable, selected_id, true));
registrar.add("Clothing.Edit", boost::bind(LLAgentWearables::editWearable, selected_id));
- registrar.add("Clothing.Create", boost::bind(createNew, selected_id));
+ registrar.add("Clothing.Create", boost::bind(&CofClothingContextMenu::createNew, this, selected_id));
enable_registrar.add("Clothing.OnEnable", boost::bind(&CofClothingContextMenu::onEnable, this, _2));
@@ -171,8 +224,13 @@ protected:
class CofBodyPartContextMenu : public CofContextMenu
{
-protected:
+public:
+ CofBodyPartContextMenu(LLCOFWearables* cof_wearables)
+ : CofContextMenu(cof_wearables)
+ {
+ }
+protected:
/*virtual*/ LLContextMenu* createMenu()
{
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
@@ -184,7 +242,7 @@ protected:
LLPanelOutfitEdit* panel_oe = dynamic_cast<LLPanelOutfitEdit*>(LLSideTray::getInstance()->getPanel("panel_outfit_edit"));
registrar.add("BodyPart.Replace", boost::bind(&LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked, panel_oe, selected_id));
registrar.add("BodyPart.Edit", boost::bind(LLAgentWearables::editWearable, selected_id));
- registrar.add("BodyPart.Create", boost::bind(createNew, selected_id));
+ registrar.add("BodyPart.Create", boost::bind(&CofBodyPartContextMenu::createNew, this, selected_id));
enable_registrar.add("BodyPart.OnEnable", boost::bind(&CofBodyPartContextMenu::onEnable, this, _2));
@@ -219,9 +277,9 @@ LLCOFWearables::LLCOFWearables() : LLPanel(),
mBodyParts(NULL),
mLastSelectedList(NULL)
{
- mClothingMenu = new CofClothingContextMenu();
- mAttachmentMenu = new CofAttachmentContextMenu();
- mBodyPartMenu = new CofBodyPartContextMenu();
+ mClothingMenu = new CofClothingContextMenu(this);
+ mAttachmentMenu = new CofAttachmentContextMenu(this);
+ mBodyPartMenu = new CofBodyPartContextMenu(this);
};
LLCOFWearables::~LLCOFWearables()