summaryrefslogtreecommitdiff
path: root/indra/newview/llpaneloutfitsinventory.cpp
diff options
context:
space:
mode:
authorDave Parks <none@none>2010-06-07 23:05:22 -0500
committerDave Parks <none@none>2010-06-07 23:05:22 -0500
commitf461ae214c8c998f5a0e3661696a30d27ad2814e (patch)
treee9430d423ee46fad6cb8319575d37ec925b88e99 /indra/newview/llpaneloutfitsinventory.cpp
parent84e619a6dc9e5a5967c4ce035ac530a4588f72a5 (diff)
parent48809cb3a9350a0357a0fc710140e2437f3e068e (diff)
Merge with render-pipeline
Diffstat (limited to 'indra/newview/llpaneloutfitsinventory.cpp')
-rw-r--r--indra/newview/llpaneloutfitsinventory.cpp222
1 files changed, 188 insertions, 34 deletions
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp
index 59c1fb4f3c..5f67f3d989 100644
--- a/indra/newview/llpaneloutfitsinventory.cpp
+++ b/indra/newview/llpaneloutfitsinventory.cpp
@@ -42,6 +42,7 @@
#include "llfloaterworldmap.h"
#include "llfloaterinventory.h"
#include "llfoldervieweventlistener.h"
+#include "llinventorybridge.h"
#include "llinventoryfunctions.h"
#include "llinventorymodelbackgroundfetch.h"
#include "llinventorypanel.h"
@@ -50,6 +51,7 @@
#include "llmodaldialog.h"
#include "llnotificationsutil.h"
#include "lloutfitslist.h"
+#include "llsaveoutfitcombobtn.h"
#include "llsidepanelappearance.h"
#include "llsidetray.h"
#include "lltabcontainer.h"
@@ -69,18 +71,144 @@ static const std::string COF_TAB_NAME = "cof_tab";
static LLRegisterPanelClassWrapper<LLPanelOutfitsInventory> t_inventory("panel_outfits_inventory");
+class LLOutfitListGearMenu
+{
+public:
+ LLOutfitListGearMenu(LLOutfitsList* olist)
+ : mOutfitList(olist),
+ mMenu(NULL)
+ {
+ llassert_always(mOutfitList);
+
+ LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
+ LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
+
+ registrar.add("Gear.Wear", boost::bind(&LLOutfitListGearMenu::onWear, this));
+ registrar.add("Gear.TakeOff", boost::bind(&LLOutfitListGearMenu::onTakeOff, this));
+ registrar.add("Gear.Rename", boost::bind(&LLOutfitListGearMenu::onRename, this));
+ registrar.add("Gear.Delete", boost::bind(&LLOutfitListGearMenu::onDelete, this));
+ registrar.add("Gear.Create", boost::bind(&LLOutfitListGearMenu::onCreate, this, _2));
+
+ enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenu::onEnable, this, _2));
+
+ mMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(
+ "menu_outfit_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+ llassert(mMenu);
+ }
+
+ LLMenuGL* getMenu() { return mMenu; }
+
+private:
+ const LLUUID& getSelectedOutfitID()
+ {
+ return mOutfitList->getSelectedOutfitUUID();
+ }
+
+ LLViewerInventoryCategory* getSelectedOutfit()
+ {
+ const LLUUID& selected_outfit_id = getSelectedOutfitID();
+ if (selected_outfit_id.isNull())
+ {
+ return NULL;
+ }
+
+ LLViewerInventoryCategory* cat = gInventory.getCategory(selected_outfit_id);
+ return cat;
+ }
+
+ void onWear()
+ {
+ LLViewerInventoryCategory* selected_outfit = getSelectedOutfit();
+ if (selected_outfit)
+ {
+ LLAppearanceMgr::instance().wearInventoryCategory(
+ selected_outfit, /*copy=*/ FALSE, /*append=*/ FALSE);
+ }
+ }
+
+ void onTakeOff()
+ {
+ const LLUUID& selected_outfit_id = getSelectedOutfitID();
+ if (selected_outfit_id.notNull())
+ {
+ LLAppearanceMgr::instance().takeOffOutfit(selected_outfit_id);
+ }
+ }
+
+ void onRename()
+ {
+ const LLUUID& selected_outfit_id = getSelectedOutfitID();
+ if (selected_outfit_id.notNull())
+ {
+ LLAppearanceMgr::instance().renameOutfit(selected_outfit_id);
+ }
+ }
+
+ void onDelete()
+ {
+ const LLUUID& selected_outfit_id = getSelectedOutfitID();
+ if (selected_outfit_id.notNull())
+ {
+ remove_category(&gInventory, selected_outfit_id);
+ }
+ }
+
+ void onCreate(const LLSD& data)
+ {
+ LLWearableType::EType type = LLWearableType::typeNameToType(data.asString());
+ if (type == LLWearableType::WT_NONE)
+ {
+ llwarns << "Invalid wearable type" << llendl;
+ return;
+ }
+
+ LLAgentWearables::createWearable(type, true);
+ }
+
+ bool onEnable(LLSD::String param)
+ {
+ const LLUUID& selected_outfit_id = getSelectedOutfitID();
+ bool is_worn = LLAppearanceMgr::instance().getBaseOutfitUUID() == selected_outfit_id;
+
+ if ("wear" == param)
+ {
+ return !is_worn;
+ }
+ else if ("take_off" == param)
+ {
+ return is_worn;
+ }
+ else if ("rename" == param)
+ {
+ return get_is_category_renameable(&gInventory, selected_outfit_id);
+ }
+ else if ("delete" == param)
+ {
+ return LLAppearanceMgr::instance().getCanRemoveOutfit(selected_outfit_id);
+ }
+
+ return true;
+ }
+
+ LLOutfitsList* mOutfitList;
+ LLMenuGL* mMenu;
+};
LLPanelOutfitsInventory::LLPanelOutfitsInventory() :
mMyOutfitsPanel(NULL),
mCurrentOutfitPanel(NULL),
- mParent(NULL)
+ mParent(NULL),
+ mGearMenu(NULL),
+ mInitialized(false)
{
mSavedFolderState = new LLSaveFolderState();
mSavedFolderState->setApply(FALSE);
+ gAgentWearables.addLoadedCallback(boost::bind(&LLPanelOutfitsInventory::onWearablesLoaded, this));
}
LLPanelOutfitsInventory::~LLPanelOutfitsInventory()
{
+ delete mGearMenu;
delete mSavedFolderState;
}
@@ -90,12 +218,35 @@ BOOL LLPanelOutfitsInventory::postBuild()
initTabPanels();
initListCommandsHandlers();
+ // Fetch your outfits folder so that the links are in memory.
+ // ( This is only necessary if we want to show a warning if a user deletes an item that has a
+ // a link in an outfit, see "ConfirmItemDeleteHasLinks". )
+ const LLUUID &outfits_cat = gInventory.findCategoryUUIDForType(LLFolderType::FT_OUTFIT, false);
+ if (outfits_cat.notNull())
+ {
+ LLInventoryModelBackgroundFetch::instance().start(outfits_cat);
+ }
+
+ mSaveComboBtn.reset(new LLSaveOutfitComboBtn(this, true));
+
return TRUE;
}
// virtual
void LLPanelOutfitsInventory::onOpen(const LLSD& key)
{
+ if (!mInitialized)
+ {
+ LLSidepanelAppearance* panel_appearance = getAppearanceSP();
+ if (panel_appearance)
+ {
+ // *TODO: move these methods to LLPanelOutfitsInventory?
+ panel_appearance->fetchInventory();
+ panel_appearance->refreshCurrentOutfitName();
+ }
+ mInitialized = true;
+ }
+
// Make sure we know which tab is selected, update the filter,
// and update verbs.
onTabChange();
@@ -124,11 +275,6 @@ void LLPanelOutfitsInventory::onOpen(const LLSD& key)
void LLPanelOutfitsInventory::updateVerbs()
{
- if (mParent)
- {
- mParent->updateVerbs();
- }
-
if (mListCommands)
{
updateListCommands();
@@ -190,6 +336,7 @@ void LLPanelOutfitsInventory::onWearButtonClick()
if (!isCOFPanelActive())
{
mMyOutfitsPanel->performAction("replaceoutfit");
+ setWearablesLoading(true);
}
else
{
@@ -243,8 +390,7 @@ bool LLPanelOutfitsInventory::onSaveCommit(const LLSD& notification, const LLSD&
{
LLUUID outfit_folder = LLAppearanceMgr::getInstance()->makeNewOutfitLinks(outfit_name);
- LLSidepanelAppearance* panel_appearance =
- dynamic_cast<LLSidepanelAppearance *>(LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
+ LLSidepanelAppearance* panel_appearance = getAppearanceSP();
if (panel_appearance)
{
panel_appearance->showOutfitsInventoryPanel();
@@ -353,9 +499,8 @@ void LLPanelOutfitsInventory::initListCommandsHandlers()
{
mListCommands = getChild<LLPanel>("bottom_panel");
- mListCommands->childSetAction("options_gear_btn", boost::bind(&LLPanelOutfitsInventory::onGearButtonClick, this));
+ mListCommands->childSetAction("options_gear_btn", boost::bind(&LLPanelOutfitsInventory::showGearMenu, this));
mListCommands->childSetAction("trash_btn", boost::bind(&LLPanelOutfitsInventory::onTrashButtonClick, this));
- mListCommands->childSetAction("make_outfit_btn", boost::bind(&LLPanelOutfitsInventory::onAddButtonClick, this));
mListCommands->childSetAction("wear_btn", boost::bind(&LLPanelOutfitsInventory::onWearButtonClick, this));
LLDragAndDropButton* trash_btn = mListCommands->getChild<LLDragAndDropButton>("trash_btn");
@@ -365,11 +510,7 @@ void LLPanelOutfitsInventory::initListCommandsHandlers()
, _7 // EAcceptance* accept
));
- mCommitCallbackRegistrar.add("panel_outfits_inventory_gear_default.Custom.Action",
- boost::bind(&LLPanelOutfitsInventory::onCustomAction, this, _2));
- mEnableCallbackRegistrar.add("panel_outfits_inventory_gear_default.Enable",
- boost::bind(&LLPanelOutfitsInventory::isActionEnabled, this, _2));
- mMenuGearDefault = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("panel_outfits_inventory_gear_default.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+ mGearMenu = new LLOutfitListGearMenu(mMyOutfitsPanel);
}
void LLPanelOutfitsInventory::updateListCommands()
@@ -381,26 +522,17 @@ void LLPanelOutfitsInventory::updateListCommands()
mListCommands->childSetEnabled("trash_btn", trash_enabled);
mListCommands->childSetEnabled("wear_btn", wear_enabled);
mListCommands->childSetVisible("wear_btn", wear_enabled);
- mListCommands->childSetEnabled("make_outfit_btn", make_outfit_enabled);
-}
-
-void LLPanelOutfitsInventory::onGearButtonClick()
-{
- showActionMenu(mMenuGearDefault,"options_gear_btn");
+ mSaveComboBtn->setSaveBtnEnabled(make_outfit_enabled);
}
-void LLPanelOutfitsInventory::onAddButtonClick()
-{
- onSave();
-}
-
-void LLPanelOutfitsInventory::showActionMenu(LLMenuGL* menu, std::string spawning_view_name)
+void LLPanelOutfitsInventory::showGearMenu()
{
+ LLMenuGL* menu = mGearMenu ? mGearMenu->getMenu() : NULL;
if (menu)
{
menu->buildDrawLabels();
menu->updateParent(LLMenuGL::sMenuContainer);
- LLView* spawning_view = getChild<LLView> (spawning_view_name);
+ LLView* spawning_view = getChild<LLView>("options_gear_btn");
S32 menu_x, menu_y;
//show menu in co-ordinates of panel
spawning_view->localPointToOtherView(0, spawning_view->getRect().getHeight(), &menu_x, &menu_y, this);
@@ -482,8 +614,7 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata)
LLFolderView* root = getActivePanel()->getRootFolder();
if (root)
{
- std::set<LLUUID> selection_set;
- root->getSelectionList(selection_set);
+ std::set<LLUUID> selection_set = root->getSelectionList();
can_delete = (selection_set.size() > 0);
for (std::set<LLUUID>::iterator iter = selection_set.begin();
iter != selection_set.end();
@@ -504,8 +635,7 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata)
LLFolderView* root = getActivePanel()->getRootFolder();
if (root)
{
- std::set<LLUUID> selection_set;
- root->getSelectionList(selection_set);
+ std::set<LLUUID> selection_set = root->getSelectionList();
can_delete = (selection_set.size() > 0);
for (std::set<LLUUID>::iterator iter = selection_set.begin();
iter != selection_set.end();
@@ -557,8 +687,7 @@ bool LLPanelOutfitsInventory::hasItemsSelected()
LLFolderView* root = getActivePanel()->getRootFolder();
if (root)
{
- std::set<LLUUID> selection_set;
- root->getSelectionList(selection_set);
+ std::set<LLUUID> selection_set = root->getSelectionList();
has_items_selected = (selection_set.size() > 0);
}
}
@@ -623,6 +752,7 @@ void LLPanelOutfitsInventory::onTabChange()
else
{
mMyOutfitsPanel->setFilterSubString(mFilterSubString);
+ mMyOutfitsPanel->onOpen(LLSD());
}
updateVerbs();
@@ -642,3 +772,27 @@ BOOL LLPanelOutfitsInventory::isCOFPanelActive() const
{
return (childGetVisibleTab("appearance_tabs")->getName() == COF_TAB_NAME);
}
+
+void LLPanelOutfitsInventory::setWearablesLoading(bool val)
+{
+ mListCommands->childSetEnabled("wear_btn", !val);
+
+ llassert(mParent);
+ if (mParent)
+ {
+ mParent->setWearablesLoading(val);
+ }
+}
+
+void LLPanelOutfitsInventory::onWearablesLoaded()
+{
+ setWearablesLoading(false);
+}
+
+LLSidepanelAppearance* LLPanelOutfitsInventory::getAppearanceSP()
+{
+ static LLSidepanelAppearance* panel_appearance =
+ dynamic_cast<LLSidepanelAppearance*>
+ (LLSideTray::getInstance()->getPanel("sidepanel_appearance"));
+ return panel_appearance;
+}