summaryrefslogtreecommitdiff
path: root/indra/newview/llpaneloutfitedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpaneloutfitedit.cpp')
-rw-r--r--indra/newview/llpaneloutfitedit.cpp145
1 files changed, 46 insertions, 99 deletions
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index dbccd243da..43c2f01da5 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -77,11 +77,16 @@ const U64 ALL_ITEMS_MASK = WEARABLE_MASK | ATTACHMENT_MASK;
static const std::string SAVE_BTN("save_btn");
static const std::string REVERT_BTN("revert_btn");
-class LLInventoryLookObserver : public LLInventoryObserver
+class LLCOFObserver : public LLInventoryObserver
{
public:
- LLInventoryLookObserver(LLPanelOutfitEdit *panel) : mPanel(panel) {}
- virtual ~LLInventoryLookObserver()
+ LLCOFObserver(LLPanelOutfitEdit *panel) : mPanel(panel),
+ mCOFLastVersion(LLViewerInventoryCategory::VERSION_UNKNOWN)
+ {
+ gInventory.addObserver(this);
+ }
+
+ virtual ~LLCOFObserver()
{
if (gInventory.containsObserver(this))
{
@@ -91,53 +96,43 @@ public:
virtual void changed(U32 mask)
{
- if (mask & (LLInventoryObserver::ADD | LLInventoryObserver::REMOVE))
- {
- mPanel->updateLookInfo();
- }
+ if (!gInventory.isInventoryUsable()) return;
+
+ LLUUID cof = LLAppearanceMgr::getInstance()->getCOF();
+ if (cof.isNull()) return;
+
+ LLViewerInventoryCategory* cat = gInventory.getCategory(cof);
+ if (!cat) return;
+
+ S32 cof_version = cat->getVersion();
+
+ if (cof_version == mCOFLastVersion) return;
+
+ mCOFLastVersion = cof_version;
+
+ mPanel->update();
}
+
protected:
LLPanelOutfitEdit *mPanel;
-};
-class LLLookFetchObserver : public LLInventoryFetchDescendentsObserver
-{
-public:
- LLLookFetchObserver(LLPanelOutfitEdit *panel) :
- mPanel(panel)
- {}
- LLLookFetchObserver() {}
- virtual void done()
- {
- mPanel->lookFetched();
- if(gInventory.containsObserver(this))
- {
- gInventory.removeObserver(this);
- }
- }
-private:
- LLPanelOutfitEdit *mPanel;
+ //last version number of a COF category
+ S32 mCOFLastVersion;
};
LLPanelOutfitEdit::LLPanelOutfitEdit()
: LLPanel(),
- mCurrentOutfitID(),
- mFetchLook(NULL),
mSearchFilter(NULL),
mCOFWearables(NULL),
mInventoryItemsPanel(NULL),
- mAddToOutfitBtn(NULL),
- mRemoveFromOutfitBtn(NULL),
- mLookObserver(NULL)
+ mCOFObserver(NULL)
{
mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE);
- mFetchLook = new LLLookFetchObserver(this);
- mLookObserver = new LLInventoryLookObserver(this);
- gInventory.addObserver(mLookObserver);
+ mCOFObserver = new LLCOFObserver(this);
mLookItemTypes.reserve(NUM_LOOK_ITEM_TYPES);
for (U32 i = 0; i < NUM_LOOK_ITEM_TYPES; i++)
@@ -151,17 +146,8 @@ LLPanelOutfitEdit::LLPanelOutfitEdit()
LLPanelOutfitEdit::~LLPanelOutfitEdit()
{
delete mSavedFolderState;
- if (gInventory.containsObserver(mFetchLook))
- {
- gInventory.removeObserver(mFetchLook);
- }
- delete mFetchLook;
-
- if (gInventory.containsObserver(mLookObserver))
- {
- gInventory.removeObserver(mLookObserver);
- }
- delete mLookObserver;
+
+ delete mCOFObserver;
}
BOOL LLPanelOutfitEdit::postBuild()
@@ -174,13 +160,20 @@ BOOL LLPanelOutfitEdit::postBuild()
mCurrentOutfitName = getChild<LLTextBox>("curr_outfit_name");
- childSetCommitCallback("add_btn", boost::bind(&LLPanelOutfitEdit::showAddWearablesPanel, this), NULL);
childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL);
childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showFilteredWearablesPanel, this), NULL);
mCOFWearables = getChild<LLCOFWearables>("cof_wearables_list");
mCOFWearables->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onOutfitItemSelectionChange, this));
+ mCOFWearables->getCOFCallbacks().mEditWearable = boost::bind(&LLPanelOutfitEdit::onEditWearableClicked, this);
+ mCOFWearables->getCOFCallbacks().mDeleteWearable = boost::bind(&LLPanelOutfitEdit::onRemoveFromOutfitClicked, this);
+ mCOFWearables->getCOFCallbacks().mMoveWearableCloser = boost::bind(&LLPanelOutfitEdit::moveWearable, this, true);
+ mCOFWearables->getCOFCallbacks().mMoveWearableFurther = boost::bind(&LLPanelOutfitEdit::moveWearable, this, false);
+
+ mCOFWearables->childSetAction("add_btn", boost::bind(&LLPanelOutfitEdit::toggleAddWearablesPanel, this));
+
+
mInventoryItemsPanel = getChild<LLInventoryPanel>("inventory_items");
mInventoryItemsPanel->setFilterTypes(ALL_ITEMS_MASK);
mInventoryItemsPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
@@ -209,13 +202,6 @@ BOOL LLPanelOutfitEdit::postBuild()
mAddToLookBtn->setEnabled(FALSE);
mAddToLookBtn->setVisible(FALSE); */
- childSetAction("add_to_outfit_btn", boost::bind(&LLPanelOutfitEdit::onAddToOutfitClicked, this));
- childSetEnabled("add_to_outfit_btn", false);
-
- mRemoveFromOutfitBtn = getChild<LLButton>("remove_from_outfit_btn");
- mRemoveFromOutfitBtn->setEnabled(FALSE);
- mRemoveFromOutfitBtn->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onRemoveFromOutfitClicked, this));
-
mEditWearableBtn = getChild<LLButton>("edit_wearable_btn");
mEditWearableBtn->setEnabled(FALSE);
mEditWearableBtn->setVisible(FALSE);
@@ -233,9 +219,6 @@ BOOL LLPanelOutfitEdit::postBuild()
mWearableListManager = new LLFilteredWearableListManager(
getChild<LLInventoryItemsList>("filtered_wearables_list"), ALL_ITEMS_MASK);
-
- childSetAction("move_closer_btn", boost::bind(&LLPanelOutfitEdit::moveWearable, this, true));
- childSetAction("move_further_btn", boost::bind(&LLPanelOutfitEdit::moveWearable, this, false));
return TRUE;
}
@@ -247,14 +230,11 @@ void LLPanelOutfitEdit::moveWearable(bool closer_to_body)
LLViewerInventoryItem* wearable_to_move = gInventory.getItem(item_id);
LLAppearanceMgr::getInstance()->moveWearable(wearable_to_move, closer_to_body);
-
- //*TODO why not to listen to inventory?
- updateLookInfo();
}
-void LLPanelOutfitEdit::showAddWearablesPanel()
+void LLPanelOutfitEdit::toggleAddWearablesPanel()
{
- childSetVisible("add_wearables_panel", childGetValue("add_btn"));
+ childSetVisible("add_wearables_panel", !childIsVisible("add_wearables_panel"));
}
void LLPanelOutfitEdit::showWearablesFilter()
@@ -365,10 +345,7 @@ void LLPanelOutfitEdit::onAddToOutfitClicked(void)
LLFolderViewEventListener* listenerp = curr_item->getListener();
if (!listenerp) return;
- if (LLAppearanceMgr::getInstance()->wearItemOnAvatar(listenerp->getUUID()))
- {
- updateLookInfo();
- }
+ LLAppearanceMgr::getInstance()->wearItemOnAvatar(listenerp->getUUID());
}
@@ -377,10 +354,6 @@ void LLPanelOutfitEdit::onRemoveFromOutfitClicked(void)
LLUUID id_to_remove = mCOFWearables->getSelectedUUID();
LLAppearanceMgr::getInstance()->removeItemFromAvatar(id_to_remove);
-
- updateLookInfo();
-
- mRemoveFromOutfitBtn->setEnabled(FALSE);
}
@@ -434,10 +407,7 @@ void LLPanelOutfitEdit::onInventorySelectionChange(const std::deque<LLFolderView
case LLAssetType::AT_CLOTHING:
case LLAssetType::AT_BODYPART:
case LLAssetType::AT_OBJECT:
- childSetEnabled("add_to_outfit_btn", true);
- break;
default:
- childSetEnabled("add_to_outfit_btn", false);
break;
}
@@ -470,42 +440,18 @@ void LLPanelOutfitEdit::onOutfitItemSelectionChange(void)
{
case LLAssetType::AT_CLOTHING:
case LLAssetType::AT_OBJECT:
- mRemoveFromOutfitBtn->setEnabled(TRUE);
- break;
default:
- mRemoveFromOutfitBtn->setEnabled(FALSE);
break;
}
}
-void LLPanelOutfitEdit::changed(U32 mask)
-{
-}
-
-void LLPanelOutfitEdit::lookFetched(void)
+void LLPanelOutfitEdit::update()
{
mCOFWearables->refresh();
updateVerbs();
}
-void LLPanelOutfitEdit::updateLookInfo()
-{
- if (getVisible())
- {
- mFetchLook->setFetchID(mCurrentOutfitID);
- mFetchLook->startFetch();
- if (mFetchLook->isFinished())
- {
- mFetchLook->done();
- }
- else
- {
- gInventory.addObserver(mFetchLook);
- }
- }
-}
-
void LLPanelOutfitEdit::displayCurrentOutfit()
{
if (!getVisible())
@@ -513,8 +459,6 @@ void LLPanelOutfitEdit::displayCurrentOutfit()
setVisible(TRUE);
}
- mCurrentOutfitID = LLAppearanceMgr::getInstance()->getCOF();
-
std::string current_outfit_name;
if (LLAppearanceMgr::getInstance()->getBaseOutfitName(current_outfit_name))
{
@@ -525,12 +469,15 @@ void LLPanelOutfitEdit::displayCurrentOutfit()
mCurrentOutfitName->setText(getString("No Outfit"));
}
- updateLookInfo();
+ update();
}
//private
void LLPanelOutfitEdit::updateVerbs()
{
+ //*TODO implement better handling of COF dirtiness
+ LLAppearanceMgr::getInstance()->updateIsDirty();
+
bool outfit_is_dirty = LLAppearanceMgr::getInstance()->isOutfitDirty();
childSetEnabled(SAVE_BTN, outfit_is_dirty);