summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorIgor Borovkov <iborovkov@productengine.com>2010-04-13 13:37:14 +0300
committerIgor Borovkov <iborovkov@productengine.com>2010-04-13 13:37:14 +0300
commit613b4e9361df55da3863a546c806493d48f848f3 (patch)
tree56925b69c44857339f662358c02f87476f20d442 /indra
parentab246784b069913363e544ab3c9a9fb615e0c71d (diff)
done EXT-6675 Fix TRASH btn on Edit Outfit panel to remove an item from avatar (from COF)
Trash button removes from avatar a selected item only of "clothing" and "object" types Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/209/ --HG-- branch : product-engine
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llappearancemgr.cpp35
-rw-r--r--indra/newview/llappearancemgr.h3
-rw-r--r--indra/newview/llpaneloutfitedit.cpp80
-rw-r--r--indra/newview/llpaneloutfitedit.h6
-rw-r--r--indra/newview/skins/default/xui/en/panel_outfit_edit.xml2
5 files changed, 76 insertions, 50 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 4a30ba3066..b6fc33e9a2 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -42,8 +42,10 @@
#include "llinventoryfunctions.h"
#include "llinventoryobserver.h"
#include "llnotificationsutil.h"
+#include "llselectmgr.h"
#include "llsidepanelappearance.h"
#include "llsidetray.h"
+#include "llviewerobjectlist.h"
#include "llvoavatar.h"
#include "llvoavatarself.h"
#include "llviewerregion.h"
@@ -1587,6 +1589,39 @@ void LLAppearanceMgr::wearBaseOutfit()
updateCOF(base_outfit_id);
}
+void LLAppearanceMgr::removeItemFromAvatar(const LLUUID& id_to_remove)
+{
+ LLViewerInventoryItem * item_to_remove = gInventory.getItem(id_to_remove);
+ if (!item_to_remove) return;
+
+ switch (item_to_remove->getType())
+ {
+ case LLAssetType::AT_CLOTHING:
+ if (get_is_item_worn(id_to_remove))
+ {
+ //*TODO move here the exact removing code from LLWearableBridge::removeItemFromAvatar in the future
+ LLWearableBridge::removeItemFromAvatar(item_to_remove);
+ }
+ break;
+ case LLAssetType::AT_OBJECT:
+ gMessageSystem->newMessageFast(_PREHASH_DetachAttachmentIntoInv);
+ gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
+ gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ gMessageSystem->addUUIDFast(_PREHASH_ItemID, item_to_remove->getLinkedUUID());
+ gMessageSystem->sendReliable( gAgent.getRegion()->getHost());
+
+ {
+ // this object might have been selected, so let the selection manager know it's gone now
+ LLViewerObject *found_obj = gObjectList.findObject(item_to_remove->getLinkedUUID());
+ if (found_obj)
+ {
+ LLSelectMgr::getInstance()->remove(found_obj);
+ };
+ }
+ default: break;
+ }
+}
+
//#define DUMP_CAT_VERBOSE
void LLAppearanceMgr::dumpCat(const LLUUID& cat_id, const std::string& msg)
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index dffd421898..83261bbbd0 100644
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -135,6 +135,9 @@ public:
// @return false if there is no base outfit
bool updateBaseOutfit();
+ //Remove clothing or detach an object from the agent (a bodypart cannot be removed)
+ void removeItemFromAvatar(const LLUUID& item_id);
+
protected:
LLAppearanceMgr();
~LLAppearanceMgr();
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index d1e6d7de42..75a2080f74 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -118,7 +118,7 @@ private:
LLPanelOutfitEdit::LLPanelOutfitEdit()
: LLPanel(), mCurrentOutfitID(), mFetchLook(NULL), mSearchFilter(NULL),
mLookContents(NULL), mInventoryItemsPanel(NULL), mAddToOutfitBtn(NULL),
-mRemoveFromLookBtn(NULL), mLookObserver(NULL)
+mRemoveFromOutfitBtn(NULL), mLookObserver(NULL)
{
mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE);
@@ -164,14 +164,10 @@ BOOL LLPanelOutfitEdit::postBuild()
childSetCommitCallback("add_btn", boost::bind(&LLPanelOutfitEdit::showAddWearablesPanel, this), NULL);
- /*
- mLookContents->setDoubleClickCallback(onDoubleClickSpeaker, this);
- mLookContents->setCommitOnSelectionChange(TRUE);
- mLookContents->setCommitCallback(boost::bind(&LLPanelActiveSpeakers::handleSpeakerSelect, this, _2));
- mLookContents->setSortChangedCallback(boost::bind(&LLPanelActiveSpeakers::onSortChanged, this));
- mLookContents->setContextMenu(LLScrollListCtrl::MENU_AVATAR);
- */
-
+ mLookContents = getChild<LLScrollListCtrl>("look_items_list");
+ mLookContents->sortByColumn("look_item_sort", TRUE);
+ mLookContents->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onOutfitItemSelectionChange, this));
+
mInventoryItemsPanel = getChild<LLInventoryPanel>("inventory_items");
mInventoryItemsPanel->setFilterTypes(ALL_ITEMS_MASK);
mInventoryItemsPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
@@ -207,31 +203,20 @@ BOOL LLPanelOutfitEdit::postBuild()
mUpBtn->setEnabled(TRUE);
mUpBtn->setClickedCallback(boost::bind(&LLPanelOutfitEdit::onUpClicked, this));
+ //*TODO rename mLookContents to mOutfitContents
mLookContents = getChild<LLScrollListCtrl>("look_items_list");
mLookContents->sortByColumn("look_item_sort", TRUE);
- mLookContents->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onLookItemSelectionChange, this));
+ mLookContents->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onOutfitItemSelectionChange, this));
+
+ mRemoveFromOutfitBtn = getChild<LLButton>("remove_from_outfit_btn");
+ mRemoveFromOutfitBtn->setEnabled(FALSE);
+ mRemoveFromOutfitBtn->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onRemoveFromOutfitClicked, this));
- /*
- LLButton::Params remove_params;
- remove_params.name("remove_from_look");
- remove_params.click_callback.function(boost::bind(&LLPanelOutfitEdit::onRemoveFromLookClicked, this));
- remove_params.label("-"); */
-
- //mRemoveFromLookBtn = LLUICtrlFactory::create<LLButton>(remove_params);
- mRemoveFromLookBtn = getChild<LLButton>("remove_from_look_btn");
- mRemoveFromLookBtn->setEnabled(FALSE);
- mRemoveFromLookBtn->setVisible(FALSE);
- //childSetAction("remove_from_look_btn", boost::bind(&LLPanelOutfitEdit::onRemoveFromLookClicked, this), this);
- mRemoveFromLookBtn->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onRemoveFromLookClicked, this));
- //getChild<LLPanel>("look_info_group_bar")->addChild(mRemoveFromLookBtn); remove_item_btn
-
mEditWearableBtn = getChild<LLButton>("edit_wearable_btn");
mEditWearableBtn->setEnabled(FALSE);
mEditWearableBtn->setVisible(FALSE);
mEditWearableBtn->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onEditWearableClicked, this));
- childSetAction("remove_item_btn", boost::bind(&LLPanelOutfitEdit::onRemoveFromLookClicked, this), this);
-
childSetAction("revert_btn", boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance()));
childSetAction("save_btn", boost::bind(&LLPanelOutfitEdit::saveOutfit, this, false));
@@ -353,27 +338,15 @@ void LLPanelOutfitEdit::onAddToOutfitClicked(void)
}
-void LLPanelOutfitEdit::onRemoveFromLookClicked(void)
+void LLPanelOutfitEdit::onRemoveFromOutfitClicked(void)
{
LLUUID id_to_remove = mLookContents->getSelectionInterface()->getCurrentID();
- LLViewerInventoryItem * item_to_remove = gInventory.getItem(id_to_remove);
-
- if (item_to_remove)
- {
- // returns null if not a wearable (attachment, etc).
- const LLWearable* wearable_to_remove = gAgentWearables.getWearableFromAssetID(item_to_remove->getAssetUUID());
- if (!wearable_to_remove || gAgentWearables.canWearableBeRemoved( wearable_to_remove ))
- {
- gInventory.purgeObject( id_to_remove );
- updateLookInfo();
- mRemoveFromLookBtn->setEnabled(FALSE);
- if (mRemoveFromLookBtn->getVisible())
- {
- mRemoveFromLookBtn->setVisible(FALSE);
- }
- }
- }
+ LLAppearanceMgr::getInstance()->removeItemFromAvatar(id_to_remove);
+
+ updateLookInfo();
+
+ mRemoveFromOutfitBtn->setEnabled(FALSE);
}
@@ -482,7 +455,7 @@ void LLPanelOutfitEdit::onInventorySelectionChange(const std::deque<LLFolderView
current_item->addChild(mAddToLookBtn); */
}
-void LLPanelOutfitEdit::onLookItemSelectionChange(void)
+void LLPanelOutfitEdit::onOutfitItemSelectionChange(void)
{
S32 left_offset = -4;
S32 top_offset = -10;
@@ -504,7 +477,22 @@ void LLPanelOutfitEdit::onLookItemSelectionChange(void)
{
mEditWearableBtn->setVisible(TRUE);
}
- //mLookContents->addChild(mRemoveFromLookBtn);
+
+
+ const LLUUID& id_item_to_remove = item->getUUID();
+ LLViewerInventoryItem* item_to_remove = gInventory.getItem(id_item_to_remove);
+ if (!item_to_remove) return;
+
+ switch (item_to_remove->getType())
+ {
+ case LLAssetType::AT_CLOTHING:
+ case LLAssetType::AT_OBJECT:
+ mRemoveFromOutfitBtn->setEnabled(TRUE);
+ break;
+ default:
+ mRemoveFromOutfitBtn->setEnabled(FALSE);
+ break;
+ }
}
void LLPanelOutfitEdit::changed(U32 mask)
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index 1a8d7d2bef..fa92d4c314 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -94,8 +94,8 @@ public:
void onSearchEdit(const std::string& string);
void onInventorySelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action);
void onAddToOutfitClicked(void);
- void onLookItemSelectionChange(void);
- void onRemoveFromLookClicked(void);
+ void onOutfitItemSelectionChange(void);
+ void onRemoveFromOutfitClicked(void);
void onEditWearableClicked(void);
void onUpClicked(void);
@@ -117,7 +117,7 @@ private:
LLSaveFolderState* mSavedFolderState;
std::string mSearchString;
LLButton* mAddToOutfitBtn;
- LLButton* mRemoveFromLookBtn;
+ LLButton* mRemoveFromOutfitBtn;
LLButton* mUpBtn;
LLButton* mEditWearableBtn;
LLToggleableMenu* mSaveMenu;
diff --git a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
index a5e6506463..9ece4aead8 100644
--- a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
+++ b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
@@ -211,7 +211,7 @@
image_selected="Toolbar_Middle_Selected"
image_unselected="Toolbar_Middle_Off"
layout="topleft"
- name="trash_btn"
+ name="remove_from_outfit_btn"
right="-1"
top="1"
width="31" />