diff options
Diffstat (limited to 'indra/newview/llpaneloutfitedit.cpp')
-rw-r--r-- | indra/newview/llpaneloutfitedit.cpp | 145 |
1 files changed, 14 insertions, 131 deletions
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index 4982e98f8e..e07d5c064b 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -39,6 +39,7 @@ #include "llagentcamera.h" #include "llagentwearables.h" #include "llappearancemgr.h" +#include "lloutfitobserver.h" #include "llcofwearables.h" #include "llfilteredwearablelist.h" #include "llinventory.h" @@ -143,100 +144,6 @@ private: } }; -class LLCOFObserver : public LLInventoryObserver -{ -public: - LLCOFObserver(LLPanelOutfitEdit *panel) : mPanel(panel), - mCOFLastVersion(LLViewerInventoryCategory::VERSION_UNKNOWN) - { - gInventory.addObserver(this); - } - - virtual ~LLCOFObserver() - { - if (gInventory.containsObserver(this)) - { - gInventory.removeObserver(this); - } - } - - virtual void changed(U32 mask) - { - if (!gInventory.isInventoryUsable()) return; - - bool panel_updated = checkCOF(); - - if (!panel_updated) - { - checkBaseOutfit(); - } - } - -protected: - - /** Get a version of an inventory category specified by its UUID */ - static S32 getCategoryVersion(const LLUUID& cat_id) - { - LLViewerInventoryCategory* cat = gInventory.getCategory(cat_id); - if (!cat) return LLViewerInventoryCategory::VERSION_UNKNOWN; - - return cat->getVersion(); - } - - bool checkCOF() - { - LLUUID cof = LLAppearanceMgr::getInstance()->getCOF(); - if (cof.isNull()) return false; - - S32 cof_version = getCategoryVersion(cof); - - if (cof_version == mCOFLastVersion) return false; - - mCOFLastVersion = cof_version; - - mPanel->update(); - - return true; - } - - void checkBaseOutfit() - { - LLUUID baseoutfit_id = LLAppearanceMgr::getInstance()->getBaseOutfitUUID(); - - if (baseoutfit_id == mBaseOutfitId) - { - if (baseoutfit_id.isNull()) return; - - const S32 baseoutfit_ver = getCategoryVersion(baseoutfit_id); - - if (baseoutfit_ver == mBaseOutfitLastVersion) return; - } - else - { - mBaseOutfitId = baseoutfit_id; - mPanel->updateCurrentOutfitName(); - - if (baseoutfit_id.isNull()) return; - - mBaseOutfitLastVersion = getCategoryVersion(mBaseOutfitId); - } - - mPanel->updateVerbs(); - } - - - - - LLPanelOutfitEdit *mPanel; - - //last version number of a COF category - S32 mCOFLastVersion; - - LLUUID mBaseOutfitId; - - S32 mBaseOutfitLastVersion; -}; - class LLCOFDragAndDropObserver : public LLInventoryAddItemByAssetObserver { public: @@ -277,7 +184,6 @@ LLPanelOutfitEdit::LLPanelOutfitEdit() mSearchFilter(NULL), mCOFWearables(NULL), mInventoryItemsPanel(NULL), - mCOFObserver(NULL), mGearMenu(NULL), mCOFDragAndDropObserver(NULL), mInitialized(false), @@ -288,7 +194,12 @@ LLPanelOutfitEdit::LLPanelOutfitEdit() mSavedFolderState = new LLSaveFolderState(); mSavedFolderState->setApply(FALSE); - mCOFObserver = new LLCOFObserver(this); + + LLOutfitObserver& observer = LLOutfitObserver::instance(); + observer.addBOFReplacedCallback(boost::bind(&LLPanelOutfitEdit::updateCurrentOutfitName, this)); + observer.addBOFChangedCallback(boost::bind(&LLPanelOutfitEdit::updateVerbs, this)); + observer.addOutfitLockChangedCallback(boost::bind(&LLPanelOutfitEdit::updateVerbs, this)); + observer.addCOFChangedCallback(boost::bind(&LLPanelOutfitEdit::update, this)); mLookItemTypes.reserve(NUM_LOOK_ITEM_TYPES); for (U32 i = 0; i < NUM_LOOK_ITEM_TYPES; i++) @@ -303,7 +214,6 @@ LLPanelOutfitEdit::~LLPanelOutfitEdit() { delete mSavedFolderState; - delete mCOFObserver; delete mCOFDragAndDropObserver; delete mWearableListMaskCollector; @@ -371,7 +281,7 @@ BOOL LLPanelOutfitEdit::postBuild() childSetAction(REVERT_BTN, boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance())); mWearableListMaskCollector = new LLFindNonLinksByMask(ALL_ITEMS_MASK); - mWearableListTypeCollector = new LLFindWearablesOfType(LLWearableType::WT_NONE); + mWearableListTypeCollector = new LLFindActualWearablesOfType(LLWearableType::WT_NONE); mWearableItemsPanel = getChild<LLPanel>("filtered_wearables_panel"); mWearableItemsList = getChild<LLInventoryItemsList>("filtered_wearables_list"); @@ -585,35 +495,10 @@ void LLPanelOutfitEdit::onRemoveFromOutfitClicked(void) void LLPanelOutfitEdit::onEditWearableClicked(void) { - LLUUID id_to_edit = mCOFWearables->getSelectedUUID(); - LLViewerInventoryItem * item_to_edit = gInventory.getItem(id_to_edit); - - if (item_to_edit) + LLUUID selected_item_id = mCOFWearables->getSelectedUUID(); + if (selected_item_id.notNull()) { - // returns null if not a wearable (attachment, etc). - LLWearable* wearable_to_edit = gAgentWearables.getWearableFromAssetID(item_to_edit->getAssetUUID()); - if(wearable_to_edit) - { - bool can_modify = false; - bool is_complete = item_to_edit->isFinished(); - // if item_to_edit is a link, its properties are not appropriate, - // lets get original item with actual properties - LLViewerInventoryItem* original_item = gInventory.getItem(wearable_to_edit->getItemID()); - if(original_item) - { - can_modify = original_item->getPermissions().allowModifyBy(gAgentID); - is_complete = original_item->isFinished(); - } - - if (can_modify && is_complete) - { - LLSidepanelAppearance::editWearable(wearable_to_edit, getParent()); - if (mEditWearableBtn->getVisible()) - { - mEditWearableBtn->setVisible(FALSE); - } - } - } + gAgentWearables.editWearable(selected_item_id); } } @@ -756,16 +641,14 @@ void LLPanelOutfitEdit::updateCurrentOutfitName() //private void LLPanelOutfitEdit::updateVerbs() { - //*TODO implement better handling of COF dirtiness - LLAppearanceMgr::getInstance()->updateIsDirty(); - bool outfit_is_dirty = LLAppearanceMgr::getInstance()->isOutfitDirty(); + bool outfit_locked = LLAppearanceMgr::getInstance()->isOutfitLocked(); bool has_baseoutfit = LLAppearanceMgr::getInstance()->getBaseOutfitUUID().notNull(); - mSaveComboBtn->setSaveBtnEnabled(outfit_is_dirty); + mSaveComboBtn->setSaveBtnEnabled(!outfit_locked && outfit_is_dirty); childSetEnabled(REVERT_BTN, outfit_is_dirty && has_baseoutfit); - mSaveComboBtn->setMenuItemEnabled("save_outfit", outfit_is_dirty); + mSaveComboBtn->setMenuItemEnabled("save_outfit", !outfit_locked && outfit_is_dirty); mStatus->setText(outfit_is_dirty ? getString("unsaved_changes") : getString("now_editing")); |