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.cpp489
1 files changed, 284 insertions, 205 deletions
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 9e51aaceca..1454a2f6af 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"
@@ -61,13 +62,16 @@
#include "llinventorymodelbackgroundfetch.h"
#include "llpaneloutfitsinventory.h"
#include "lluiconstants.h"
+#include "llsaveoutfitcombobtn.h"
#include "llscrolllistctrl.h"
#include "lltextbox.h"
+#include "lltrans.h"
#include "lluictrlfactory.h"
#include "llsdutil.h"
#include "llsidepanelappearance.h"
#include "lltoggleablemenu.h"
#include "llwearablelist.h"
+#include "llwearableitemslist.h"
static LLRegisterPanelClassWrapper<LLPanelOutfitEdit> t_outfit_edit("panel_outfit_edit");
@@ -75,101 +79,70 @@ const U64 WEARABLE_MASK = (1LL << LLInventoryType::IT_WEARABLE);
const U64 ATTACHMENT_MASK = (1LL << LLInventoryType::IT_ATTACHMENT) | (1LL << LLInventoryType::IT_OBJECT);
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 LLCOFObserver : public LLInventoryObserver
+class LLPanelOutfitEditGearMenu
{
public:
- LLCOFObserver(LLPanelOutfitEdit *panel) : mPanel(panel),
- mCOFLastVersion(LLViewerInventoryCategory::VERSION_UNKNOWN)
+ static LLMenuGL* create()
{
- gInventory.addObserver(this);
- }
+ LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
- virtual ~LLCOFObserver()
- {
- if (gInventory.containsObserver(this))
- {
- gInventory.removeObserver(this);
- }
- }
-
- virtual void changed(U32 mask)
- {
- if (!gInventory.isInventoryUsable()) return;
-
- bool panel_updated = checkCOF();
+ registrar.add("Wearable.Create", boost::bind(onCreate, _2));
- if (!panel_updated)
+ LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(
+ "menu_cof_gear.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
+ llassert(menu);
+ if (menu)
{
- checkBaseOutfit();
+ populateCreateWearableSubmenus(menu);
+ menu->buildDrawLabels();
}
- }
-
-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();
+ return menu;
}
- bool checkCOF()
+private:
+ static void onCreate(const LLSD& param)
{
- 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();
+ LLWearableType::EType type = LLWearableType::typeNameToType(param.asString());
+ if (type == LLWearableType::WT_NONE)
+ {
+ llwarns << "Invalid wearable type" << llendl;
+ return;
+ }
- return true;
+ LLAgentWearables::createWearable(type, true);
}
- void checkBaseOutfit()
+ // Populate the menu with items like "New Skin", "New Pants", etc.
+ static void populateCreateWearableSubmenus(LLMenuGL* menu)
{
- LLUUID baseoutfit_id = LLAppearanceMgr::getInstance()->getBaseOutfitUUID();
+ LLView* menu_clothes = gMenuHolder->findChildView("COF.Gear.New_Clothes", FALSE);
+ LLView* menu_bp = gMenuHolder->findChildView("COF.Geear.New_Body_Parts", FALSE);
- if (baseoutfit_id == mBaseOutfitId)
+ if (!menu_clothes || !menu_bp)
{
- if (baseoutfit_id.isNull()) return;
-
- const S32 baseoutfit_ver = getCategoryVersion(baseoutfit_id);
-
- if (baseoutfit_ver == mBaseOutfitLastVersion) return;
+ llassert(menu_clothes && menu_bp);
+ return;
}
- else
- {
- mBaseOutfitId = baseoutfit_id;
- mPanel->updateCurrentOutfitName();
- if (baseoutfit_id.isNull()) return;
-
- mBaseOutfitLastVersion = getCategoryVersion(mBaseOutfitId);
+ for (U8 i = LLWearableType::WT_SHAPE; i != (U8) LLWearableType::WT_COUNT; ++i)
+ {
+ LLWearableType::EType type = (LLWearableType::EType) i;
+ const std::string& type_name = LLWearableType::getTypeName(type);
+
+ LLMenuItemCallGL::Params p;
+ p.name = type_name;
+ p.label = LLWearableType::getTypeDefaultNewName(type);
+ p.on_click.function_name = "Wearable.Create";
+ p.on_click.parameter = LLSD(type_name);
+
+ LLView* parent = LLWearableType::getAssetType(type) == LLAssetType::AT_CLOTHING ?
+ menu_clothes : menu_bp;
+ LLUICtrlFactory::create<LLMenuItemCallGL>(p, parent);
}
-
- mPanel->updateVerbs();
}
-
-
-
-
- LLPanelOutfitEdit *mPanel;
-
- //last version number of a COF category
- S32 mCOFLastVersion;
-
- LLUUID mBaseOutfitId;
-
- S32 mBaseOutfitLastVersion;
};
class LLCOFDragAndDropObserver : public LLInventoryAddItemByAssetObserver
@@ -212,22 +185,28 @@ LLPanelOutfitEdit::LLPanelOutfitEdit()
mSearchFilter(NULL),
mCOFWearables(NULL),
mInventoryItemsPanel(NULL),
- mCOFObserver(NULL),
mGearMenu(NULL),
mCOFDragAndDropObserver(NULL),
- mInitialized(false)
+ mInitialized(false),
+ mAddWearablesPanel(NULL),
+ mFolderViewFilterCmbBox(NULL),
+ mListViewFilterCmbBox(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++)
+ mFolderViewItemTypes.reserve(NUM_FOLDER_VIEW_ITEM_TYPES);
+ for (U32 i = 0; i < NUM_FOLDER_VIEW_ITEM_TYPES; i++)
{
- mLookItemTypes.push_back(LLLookItemType());
+ mFolderViewItemTypes.push_back(LLLookItemType());
}
-
}
@@ -235,17 +214,42 @@ LLPanelOutfitEdit::~LLPanelOutfitEdit()
{
delete mSavedFolderState;
- delete mCOFObserver;
delete mCOFDragAndDropObserver;
+
+ while (!mListViewItemTypes.empty()) {
+ delete mListViewItemTypes.back();
+ mListViewItemTypes.pop_back();
+ }
}
BOOL LLPanelOutfitEdit::postBuild()
{
// gInventory.isInventoryUsable() no longer needs to be tested per Richard's fix for race conditions between inventory and panels
-
- mLookItemTypes[LIT_ALL] = LLLookItemType(getString("Filter.All"), ALL_ITEMS_MASK);
- mLookItemTypes[LIT_WEARABLE] = LLLookItemType(getString("Filter.Clothes/Body"), WEARABLE_MASK);
- mLookItemTypes[LIT_ATTACHMENT] = LLLookItemType(getString("Filter.Objects"), ATTACHMENT_MASK);
+
+ mFolderViewItemTypes[FVIT_ALL] = LLLookItemType(getString("Filter.All"), ALL_ITEMS_MASK);
+ mFolderViewItemTypes[FVIT_WEARABLE] = LLLookItemType(getString("Filter.Clothes/Body"), WEARABLE_MASK);
+ mFolderViewItemTypes[FVIT_ATTACHMENT] = LLLookItemType(getString("Filter.Objects"), ATTACHMENT_MASK);
+
+ //order is important, see EListViewItemType for order information
+ mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.All"), new LLFindByMask(ALL_ITEMS_MASK)));
+ mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Clothing"), new LLIsType(LLAssetType::AT_CLOTHING)));
+ mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Bodyparts"), new LLIsType(LLAssetType::AT_BODYPART)));
+ mListViewItemTypes.push_back(new LLFilterItem(getString("Filter.Objects"), new LLFindByMask(ATTACHMENT_MASK)));;
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("shape"), new LLFindActualWearablesOfType(LLWearableType::WT_SHAPE)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("skin"), new LLFindActualWearablesOfType(LLWearableType::WT_SKIN)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("hair"), new LLFindActualWearablesOfType(LLWearableType::WT_HAIR)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("eyes"), new LLFindActualWearablesOfType(LLWearableType::WT_EYES)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("shirt"), new LLFindActualWearablesOfType(LLWearableType::WT_SHIRT)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("pants"), new LLFindActualWearablesOfType(LLWearableType::WT_PANTS)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("shoes"), new LLFindActualWearablesOfType(LLWearableType::WT_SHOES)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("socks"), new LLFindActualWearablesOfType(LLWearableType::WT_SOCKS)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("jacket"), new LLFindActualWearablesOfType(LLWearableType::WT_JACKET)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("gloves"), new LLFindActualWearablesOfType(LLWearableType::WT_GLOVES)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("undershirt"), new LLFindActualWearablesOfType(LLWearableType::WT_UNDERSHIRT)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("underpants"), new LLFindActualWearablesOfType(LLWearableType::WT_UNDERPANTS)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("skirt"), new LLFindActualWearablesOfType(LLWearableType::WT_SKIRT)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("alpha"), new LLFindActualWearablesOfType(LLWearableType::WT_ALPHA)));
+ mListViewItemTypes.push_back(new LLFilterItem(LLTrans::getString("tattoo"), new LLFindActualWearablesOfType(LLWearableType::WT_TATTOO)));
mCurrentOutfitName = getChild<LLTextBox>("curr_outfit_name");
mStatus = getChild<LLTextBox>("status");
@@ -254,23 +258,23 @@ 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("gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), 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);
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));
-
+ mAddWearablesPanel = getChild<LLPanel>("add_wearables_panel");
- mInventoryItemsPanel = getChild<LLInventoryPanel>("inventory_items");
+ mInventoryItemsPanel = getChild<LLInventoryPanel>("folder_view");
mInventoryItemsPanel->setFilterTypes(ALL_ITEMS_MASK);
mInventoryItemsPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
mInventoryItemsPanel->setSelectCallback(boost::bind(&LLPanelOutfitEdit::onInventorySelectionChange, this, _1, _2));
@@ -278,18 +282,29 @@ 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();
- for (U32 i = 0; i < mLookItemTypes.size(); ++i)
+ mFolderViewFilterCmbBox = getChild<LLComboBox>("folder_view_filter_combobox");
+ mFolderViewFilterCmbBox->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onFolderViewFilterCommitted, this, _1));
+ mFolderViewFilterCmbBox->removeall();
+ for (U32 i = 0; i < mFolderViewItemTypes.size(); ++i)
{
- type_filter->add(mLookItemTypes[i].displayName);
+ mFolderViewFilterCmbBox->add(mFolderViewItemTypes[i].displayName);
}
- type_filter->setCurrentByIndex(LIT_ALL);
+ mFolderViewFilterCmbBox->setCurrentByIndex(FVIT_ALL);
+ mListViewFilterCmbBox = getChild<LLComboBox>("list_view_filter_combobox");
+ mListViewFilterCmbBox->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onListViewFilterCommitted, this, _1));
+ mListViewFilterCmbBox->removeall();
+ for (U32 i = 0; i < mListViewItemTypes.size(); ++i)
+ {
+ mListViewFilterCmbBox->add(mListViewItemTypes[i]->displayName);
+ }
+ mListViewFilterCmbBox->setCurrentByIndex(LVIT_ALL);
+
mSearchFilter = getChild<LLFilterEditor>("look_item_filter");
mSearchFilter->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onSearchEdit, this, _2));
-
+
+ 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");
@@ -299,18 +314,10 @@ BOOL LLPanelOutfitEdit::postBuild()
childSetAction(REVERT_BTN, boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance()));
- childSetAction(SAVE_BTN, boost::bind(&LLPanelOutfitEdit::saveOutfit, this, false));
- childSetAction("save_flyout_btn", boost::bind(&LLPanelOutfitEdit::showSaveMenu, this));
-
- LLUICtrl::CommitCallbackRegistry::ScopedRegistrar save_registar;
- save_registar.add("Outfit.Save.Action", boost::bind(&LLPanelOutfitEdit::saveOutfit, this, false));
- save_registar.add("Outfit.SaveAsNew.Action", boost::bind(&LLPanelOutfitEdit::saveOutfit, this, true));
- mSaveMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_save_outfit.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
-
- mWearableItemsPanel = getChild<LLPanel>("filtered_wearables_panel");
- mWearableItemsList = getChild<LLInventoryItemsList>("filtered_wearables_list");
- mWearableListManager = new LLFilteredWearableListManager(mWearableItemsList, ALL_ITEMS_MASK);
+ mWearablesListViewPanel = getChild<LLPanel>("filtered_wearables_panel");
+ mWearableItemsList = getChild<LLInventoryItemsList>("list_view");
+ mSaveComboBtn.reset(new LLSaveOutfitComboBtn(this));
return TRUE;
}
@@ -319,6 +326,10 @@ void LLPanelOutfitEdit::onOpen(const LLSD& key)
{
if (!mInitialized)
{
+ // *TODO: this method is called even panel is not visible to user because its parent layout panel is hidden.
+ // So, we can defer initializing a bit.
+ mWearableListManager = new LLFilteredWearableListManager(mWearableItemsList, mListViewItemTypes[LVIT_ALL]->collector);
+ mWearableListManager->populateList();
displayCurrentOutfit();
mInitialized = true;
}
@@ -335,7 +346,33 @@ void LLPanelOutfitEdit::moveWearable(bool closer_to_body)
void LLPanelOutfitEdit::toggleAddWearablesPanel()
{
- childSetVisible("add_wearables_panel", !childIsVisible("add_wearables_panel"));
+ BOOL current_visibility = mAddWearablesPanel->getVisible();
+ showAddWearablesPanel(!current_visibility);
+}
+
+void LLPanelOutfitEdit::showAddWearablesPanel(bool show_add_wearables)
+{
+ mAddWearablesPanel->setVisible(show_add_wearables);
+
+ childSetValue("show_add_wearables_btn", show_add_wearables);
+
+ updateFiltersVisibility();
+ childSetVisible("filter_button", show_add_wearables);
+
+ //search filter should be disabled
+ if (!show_add_wearables)
+ {
+ childSetValue("filter_button", false);
+
+ mFolderViewFilterCmbBox->setVisible(false);
+ mListViewFilterCmbBox->setVisible(false);
+
+ showWearablesFilter();
+ }
+
+ //switching button bars
+ childSetVisible("no_add_wearables_button_bar", !show_add_wearables);
+ childSetVisible("add_wearables_button_bar", show_add_wearables);
}
void LLPanelOutfitEdit::showWearablesFilter()
@@ -351,66 +388,43 @@ void LLPanelOutfitEdit::showWearablesFilter()
}
}
-void LLPanelOutfitEdit::showFilteredWearablesPanel()
+void LLPanelOutfitEdit::showWearablesListView()
{
- if(switchPanels(mInventoryItemsPanel, mWearableItemsPanel))
+ if(switchPanels(mInventoryItemsPanel, mWearablesListViewPanel))
{
mFolderViewBtn->setToggleState(FALSE);
mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign());
mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign());
+ updateFiltersVisibility();
}
mListViewBtn->setToggleState(TRUE);
}
-void LLPanelOutfitEdit::showFilteredFolderWearablesPanel()
+void LLPanelOutfitEdit::showWearablesFolderView()
{
- if(switchPanels(mWearableItemsPanel, mInventoryItemsPanel))
+ if(switchPanels(mWearablesListViewPanel, mInventoryItemsPanel))
{
mListViewBtn->setToggleState(FALSE);
mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign());
mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign());
+ updateFiltersVisibility();
}
mFolderViewBtn->setToggleState(TRUE);
}
-void LLPanelOutfitEdit::saveOutfit(bool as_new)
+void LLPanelOutfitEdit::updateFiltersVisibility()
{
- if (!as_new && LLAppearanceMgr::getInstance()->updateBaseOutfit())
- {
- // we don't need to ask for an outfit name, and updateBaseOutfit() successfully saved.
- // If updateBaseOutfit fails, ask for an outfit name anyways
- return;
- }
-
- LLPanelOutfitsInventory* panel_outfits_inventory = LLPanelOutfitsInventory::findInstance();
- if (panel_outfits_inventory)
- {
- panel_outfits_inventory->onSave();
- }
-
- //*TODO how to get to know when base outfit is updated or new outfit is created?
+ mListViewFilterCmbBox->setVisible(mWearablesListViewPanel->getVisible());
+ mFolderViewFilterCmbBox->setVisible(mInventoryItemsPanel->getVisible());
}
-void LLPanelOutfitEdit::showSaveMenu()
+void LLPanelOutfitEdit::onFolderViewFilterCommitted(LLUICtrl* ctrl)
{
- S32 x, y;
- LLUI::getMousePositionLocal(this, &x, &y);
+ S32 curr_filter_type = mFolderViewFilterCmbBox->getCurrentIndex();
+ if (curr_filter_type < 0) return;
- mSaveMenu->updateParent(LLMenuGL::sMenuContainer);
- LLMenuGL::showPopup(this, mSaveMenu, x, y);
-}
+ mInventoryItemsPanel->setFilterTypes(mFolderViewItemTypes[curr_filter_type].inventoryMask);
-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);
- mWearableListManager->setFilterMask(mLookItemTypes[curr_filter_type].inventoryMask);
- }
-
mSavedFolderState->setApply(TRUE);
mInventoryItemsPanel->getRootFolder()->applyFunctorRecursively(*mSavedFolderState);
@@ -421,6 +435,14 @@ void LLPanelOutfitEdit::onTypeFilterChanged(LLUICtrl* ctrl)
LLInventoryModelBackgroundFetch::instance().start();
}
+void LLPanelOutfitEdit::onListViewFilterCommitted(LLUICtrl* ctrl)
+{
+ S32 curr_filter_type = mListViewFilterCmbBox->getCurrentIndex();
+ if (curr_filter_type < 0) return;
+
+ mWearableListManager->setFilterCollector(mListViewItemTypes[curr_filter_type]->collector);
+}
+
void LLPanelOutfitEdit::onSearchEdit(const std::string& string)
{
if (mSearchString != string)
@@ -478,7 +500,7 @@ void LLPanelOutfitEdit::onAddToOutfitClicked(void)
selected_id = listenerp->getUUID();
}
- else if (mWearableItemsPanel->getVisible())
+ else if (mWearablesListViewPanel->getVisible())
{
selected_id = mWearableItemsList->getSelectedUUID();
}
@@ -488,6 +510,25 @@ void LLPanelOutfitEdit::onAddToOutfitClicked(void)
LLAppearanceMgr::getInstance()->wearItemOnAvatar(selected_id);
}
+void LLPanelOutfitEdit::onAddWearableClicked(void)
+{
+ LLPanelDummyClothingListItem* item = dynamic_cast<LLPanelDummyClothingListItem*>(mCOFWearables->getSelectedItem());
+
+ if(item)
+ {
+ showFilteredWearablesListView(item->getWearableType());
+ }
+}
+
+void LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id)
+{
+ LLViewerInventoryItem* item = gInventory.getLinkedItem(selected_item_id);
+
+ if (item && item->getType() == LLAssetType::AT_BODYPART)
+ {
+ showFilteredWearablesListView(item->getWearableType());
+ }
+}
void LLPanelOutfitEdit::onRemoveFromOutfitClicked(void)
{
@@ -499,35 +540,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);
}
}
@@ -567,24 +583,87 @@ 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::applyFolderViewFilter(EFolderViewItemType type)
+{
+ mFolderViewFilterCmbBox->setCurrentByIndex(type);
+ mFolderViewFilterCmbBox->onCommit();
+}
+
+void LLPanelOutfitEdit::applyListViewFilter(EListViewItemType type)
+{
+ mListViewFilterCmbBox->setCurrentByIndex(type);
+ mListViewFilterCmbBox->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();
+ applyFolderViewFilter(FVIT_ALL);
+ }
+
+ if (more_than_one_selected)
+ {
+ showWearablesListView();
+ applyListViewFilter(LVIT_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();
+ applyListViewFilter(LVIT_ALL);
+ return;
+ }
+
+ if (one_selected && !is_dummy_item)
+ {
+ if (item->isWearableType())
+ {
+ //single clothing or bodypart item is selected
+ showFilteredWearablesListView(item->getWearableType());
+ return;
+ }
+ else
+ {
+ //attachment is selected
+ showWearablesListView();
+ applyListViewFilter(LVIT_ATTACHMENT);
+ return;
+ }
+ }
+
}
+
+
void LLPanelOutfitEdit::update()
{
mCOFWearables->refresh();
@@ -670,19 +749,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();
- childSetEnabled(SAVE_BTN, outfit_is_dirty);
+ mSaveComboBtn->setSaveBtnEnabled(!outfit_locked && outfit_is_dirty);
childSetEnabled(REVERT_BTN, outfit_is_dirty && has_baseoutfit);
- mSaveMenu->setItemEnabled("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)
@@ -700,27 +778,28 @@ void LLPanelOutfitEdit::onGearButtonClick(LLUICtrl* clicked_button)
{
if(!mGearMenu)
{
- LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
-
- registrar.add("Gear.OnClick", boost::bind(&LLPanelOutfitEdit::onGearMenuItemClick, this, _2));
-
- mGearMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(
- "menu_cof_gear.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
- mGearMenu->buildDrawLabels();
- mGearMenu->updateParent(LLMenuGL::sMenuContainer);
+ mGearMenu = LLPanelOutfitEditGearMenu::create();
}
S32 menu_y = mGearMenu->getRect().getHeight() + clicked_button->getRect().getHeight();
LLMenuGL::showPopup(clicked_button, mGearMenu, 0, menu_y);
}
-void LLPanelOutfitEdit::onGearMenuItemClick(const LLSD& data)
+void LLPanelOutfitEdit::onAddMoreButtonClicked()
{
- std::string param = data.asString();
- if("add" == param)
- {
- // TODO
- }
+ toggleAddWearablesPanel();
+ filterWearablesBySelectedItem();
}
+void LLPanelOutfitEdit::showFilteredWearablesListView(LLWearableType::EType type)
+{
+ showAddWearablesPanel(true);
+ showWearablesListView();
+
+ //e_list_view_item_type implicitly contains LLWearableType::EType starting from LVIT_SHAPE
+ applyListViewFilter((EListViewItemType) (LVIT_SHAPE + type));
+}
+
+
+
// EOF