diff options
author | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-06-11 10:09:02 -0400 |
---|---|---|
committer | Brad Payne (Vir Linden) <vir@lindenlab.com> | 2010-06-11 10:09:02 -0400 |
commit | 8a5c71ea1d278beee89da04036e7923129581baf (patch) | |
tree | bdb7fd11e134fb2e17a6f2353ff9315672581777 /indra/newview/llpaneloutfitedit.cpp | |
parent | 17520c17b1eff7b26d264c8b6bd1f8ebbbde8d15 (diff) | |
parent | 0c8164b8947eee7b43ba0452821a3ff6d9f9dd38 (diff) |
merge
Diffstat (limited to 'indra/newview/llpaneloutfitedit.cpp')
-rw-r--r-- | indra/newview/llpaneloutfitedit.cpp | 284 |
1 files changed, 116 insertions, 168 deletions
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index 4982e98f8e..32b209dd0d 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,18 +184,23 @@ LLPanelOutfitEdit::LLPanelOutfitEdit() mSearchFilter(NULL), mCOFWearables(NULL), mInventoryItemsPanel(NULL), - mCOFObserver(NULL), mGearMenu(NULL), mCOFDragAndDropObserver(NULL), mInitialized(false), mAddWearablesPanel(NULL), mWearableListMaskCollector(NULL), - mWearableListTypeCollector(NULL) + mWearableListTypeCollector(NULL), + mFilterComboBox(NULL) { 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 +215,6 @@ LLPanelOutfitEdit::~LLPanelOutfitEdit() { delete mSavedFolderState; - delete mCOFObserver; delete mCOFDragAndDropObserver; delete mWearableListMaskCollector; @@ -325,12 +236,13 @@ BOOL LLPanelOutfitEdit::postBuild() mListViewBtn = getChild<LLButton>("list_view_btn"); childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL); - childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showFilteredFolderWearablesPanel, this), NULL); - childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showFilteredWearablesPanel, this), NULL); + childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL); + childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL); childSetCommitCallback("wearables_gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL); + childSetCommitCallback("gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL); mCOFWearables = getChild<LLCOFWearables>("cof_wearables_list"); - mCOFWearables->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onOutfitItemSelectionChange, this)); + mCOFWearables->setCommitCallback(boost::bind(&LLPanelOutfitEdit::filterWearablesBySelectedItem, this)); mCOFWearables->getCOFCallbacks().mAddWearable = boost::bind(&LLPanelOutfitEdit::onAddWearableClicked, this); mCOFWearables->getCOFCallbacks().mEditWearable = boost::bind(&LLPanelOutfitEdit::onEditWearableClicked, this); @@ -348,19 +260,20 @@ BOOL LLPanelOutfitEdit::postBuild() mCOFDragAndDropObserver = new LLCOFDragAndDropObserver(mInventoryItemsPanel->getModel()); - LLComboBox* type_filter = getChild<LLComboBox>("filter_wearables_combobox"); - type_filter->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onTypeFilterChanged, this, _1)); - type_filter->removeall(); + mFilterComboBox = getChild<LLComboBox>("filter_wearables_combobox"); + mFilterComboBox->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onTypeFilterChanged, this, _1)); + mFilterComboBox->removeall(); for (U32 i = 0; i < mLookItemTypes.size(); ++i) { - type_filter->add(mLookItemTypes[i].displayName); + mFilterComboBox->add(mLookItemTypes[i].displayName); } - type_filter->setCurrentByIndex(LIT_ALL); + mFilterComboBox->setCurrentByIndex(LIT_ALL); mSearchFilter = getChild<LLFilterEditor>("look_item_filter"); mSearchFilter->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onSearchEdit, this, _2)); - childSetAction("show_add_wearables_btn", boost::bind(&LLPanelOutfitEdit::toggleAddWearablesPanel, this)); + childSetAction("show_add_wearables_btn", boost::bind(&LLPanelOutfitEdit::onAddMoreButtonClicked, this)); + childSetAction("add_to_outfit_btn", boost::bind(&LLPanelOutfitEdit::onAddToOutfitClicked, this)); mEditWearableBtn = getChild<LLButton>("edit_wearable_btn"); @@ -371,7 +284,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"); @@ -443,7 +356,7 @@ void LLPanelOutfitEdit::showWearablesFilter() } } -void LLPanelOutfitEdit::showFilteredWearablesPanel() +void LLPanelOutfitEdit::showWearablesListView() { if(switchPanels(mInventoryItemsPanel, mWearableItemsPanel)) { @@ -454,7 +367,7 @@ void LLPanelOutfitEdit::showFilteredWearablesPanel() mListViewBtn->setToggleState(TRUE); } -void LLPanelOutfitEdit::showFilteredFolderWearablesPanel() +void LLPanelOutfitEdit::showWearablesFolderView() { if(switchPanels(mWearableItemsPanel, mInventoryItemsPanel)) { @@ -467,17 +380,12 @@ void LLPanelOutfitEdit::showFilteredFolderWearablesPanel() void LLPanelOutfitEdit::onTypeFilterChanged(LLUICtrl* ctrl) { - LLComboBox* type_filter = dynamic_cast<LLComboBox*>(ctrl); - llassert(type_filter); - if (type_filter) - { - U32 curr_filter_type = type_filter->getCurrentIndex(); - mInventoryItemsPanel->setFilterTypes(mLookItemTypes[curr_filter_type].inventoryMask); + U32 curr_filter_type = mFilterComboBox->getCurrentIndex(); + mInventoryItemsPanel->setFilterTypes(mLookItemTypes[curr_filter_type].inventoryMask); + + mWearableListMaskCollector->setFilterMask(mLookItemTypes[curr_filter_type].inventoryMask); + mWearableListManager->setFilterCollector(mWearableListMaskCollector); - mWearableListMaskCollector->setFilterMask(mLookItemTypes[curr_filter_type].inventoryMask); - mWearableListManager->setFilterCollector(mWearableListMaskCollector); - } - mSavedFolderState->setApply(TRUE); mInventoryItemsPanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState); @@ -561,7 +469,7 @@ void LLPanelOutfitEdit::onAddWearableClicked(void) if(item) { - showFilteredWearableItemsList(item->getWearableType()); + showFilteredWearablesListView(item->getWearableType()); } } @@ -571,7 +479,7 @@ void LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id if (item && item->getType() == LLAssetType::AT_BODYPART) { - showFilteredWearableItemsList(item->getWearableType()); + showFilteredWearablesListView(item->getWearableType()); } } @@ -585,35 +493,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); } } @@ -653,24 +536,81 @@ void LLPanelOutfitEdit::onInventorySelectionChange(const std::deque<LLFolderView current_item->addChild(mAddToLookBtn); */ } -void LLPanelOutfitEdit::onOutfitItemSelectionChange(void) -{ - LLUUID item_id = mCOFWearables->getSelectedUUID(); - //*TODO show Edit Wearable Button +void LLPanelOutfitEdit::applyFilter(e_look_item_type type) +{ + mFilterComboBox->setCurrentByIndex(type); + mFilterComboBox->onCommit(); +} + +void LLPanelOutfitEdit::filterWearablesBySelectedItem(void) +{ + if (!mAddWearablesPanel->getVisible()) return; + + uuid_vec_t ids; + mCOFWearables->getSelectedUUIDs(ids); - LLViewerInventoryItem* item_to_remove = gInventory.getItem(item_id); - if (!item_to_remove) return; + bool nothing_selected = ids.empty(); + bool one_selected = ids.size() == 1; + bool more_than_one_selected = ids.size() > 1; + bool is_dummy_item = (ids.size() && dynamic_cast<LLPanelDummyClothingListItem*>(mCOFWearables->getSelectedItem())); - switch (item_to_remove->getType()) + //resetting selection if no item is selected or than one item is selected + if (nothing_selected || more_than_one_selected) { - case LLAssetType::AT_CLOTHING: - case LLAssetType::AT_OBJECT: - default: - break; + if (nothing_selected) + { + showWearablesFolderView(); + } + + if (more_than_one_selected) + { + showWearablesListView(); + } + + applyFilter(LIT_ALL); + return; + } + + + //filter wearables by a type represented by a dummy item + if (one_selected && is_dummy_item) + { + onAddWearableClicked(); + return; + } + + LLViewerInventoryItem* item = gInventory.getItem(ids[0]); + if (!item && ids[0].notNull()) + { + //Inventory misses an item with non-zero id + showWearablesListView(); + applyFilter(LIT_ALL); + return; } + + if (one_selected && !is_dummy_item) + { + if (item->isWearableType()) + { + //single clothing or bodypart item is selected + showFilteredWearablesListView(item->getWearableType()); + mFilterComboBox->setLabel(getString("Filter.Custom")); + return; + } + else + { + //attachment is selected + showWearablesListView(); + applyFilter(LIT_ATTACHMENT); + return; + } + } + } + + void LLPanelOutfitEdit::update() { mCOFWearables->refresh(); @@ -756,19 +696,18 @@ 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")); + updateCurrentOutfitName(); } bool LLPanelOutfitEdit::switchPanels(LLPanel* switch_from_panel, LLPanel* switch_to_panel) @@ -793,12 +732,21 @@ void LLPanelOutfitEdit::onGearButtonClick(LLUICtrl* clicked_button) LLMenuGL::showPopup(clicked_button, mGearMenu, 0, menu_y); } -void LLPanelOutfitEdit::showFilteredWearableItemsList(LLWearableType::EType type) +void LLPanelOutfitEdit::onAddMoreButtonClicked() +{ + toggleAddWearablesPanel(); + filterWearablesBySelectedItem(); +} + +void LLPanelOutfitEdit::showFilteredWearablesListView(LLWearableType::EType type) { + mFilterComboBox->setLabel(getString("Filter.Custom")); mWearableListTypeCollector->setType(type); mWearableListManager->setFilterCollector(mWearableListTypeCollector); showAddWearablesPanel(true); - showFilteredWearablesPanel(); + showWearablesListView(); } + + // EOF |