From 36f3535f70f431d9da76aba556adc82c0781d0af Mon Sep 17 00:00:00 2001 From: Paul Guslisty Date: Fri, 10 Sep 2010 15:59:35 +0300 Subject: STORM-93 FIXED Added Take Off function to the gear menu and implemented this functionality using helper methods: canTakeOffSelected() - checking whether selected item(s) can be taken off hasItemSelected() - checking whether any item selected getSelectedItemsUUIDs() - returns selected items ids --- indra/newview/llpanelwearing.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpanelwearing.cpp') diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index a6bc34c62e..860470cd73 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -29,6 +29,7 @@ #include "llpanelwearing.h" #include "llappearancemgr.h" +#include "llinventoryfunctions.h" #include "llinventorymodel.h" #include "llinventoryobserver.h" #include "llsidetray.h" @@ -46,12 +47,16 @@ static void edit_outfit() class LLWearingGearMenu { public: - LLWearingGearMenu() - : mMenu(NULL) + LLWearingGearMenu(LLPanelWearing* panel_wearing) + : mMenu(NULL), mPanelWearing(panel_wearing) { LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; registrar.add("Gear.Edit", boost::bind(&edit_outfit)); + registrar.add("Gear.TakeOff", boost::bind(&LLWearingGearMenu::onTakeOff, this)); + + enable_registrar.add("Gear.OnEnable", boost::bind(&LLPanelWearing::isActionEnabled, mPanelWearing, _2)); mMenu = LLUICtrlFactory::getInstance()->createFromFile( "menu_wearing_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); @@ -70,7 +75,20 @@ public: } private: + + void onTakeOff() + { + uuid_vec_t selected_uuids; + mPanelWearing->getSelectedItemsUUIDs(selected_uuids); + + for (uuid_vec_t::const_iterator it=selected_uuids.begin(); it != selected_uuids.end(); ++it) + { + LLAppearanceMgr::instance().removeItemFromAvatar(*it); + } + } + LLMenuGL* mMenu; + LLPanelWearing* mPanelWearing; }; ////////////////////////////////////////////////////////////////////////// @@ -150,7 +168,7 @@ LLPanelWearing::LLPanelWearing() { mCategoriesObserver = new LLInventoryCategoriesObserver(); - mGearMenu = new LLWearingGearMenu(); + mGearMenu = new LLWearingGearMenu(this); mContextMenu = new LLWearingContextMenu(); } @@ -226,6 +244,12 @@ bool LLPanelWearing::isActionEnabled(const LLSD& userdata) // allow save only if outfit isn't locked and is dirty return !outfit_locked && outfit_dirty; } + + if (command_name == "take_off") + { + return hasItemSelected() && canTakeOffSelected(); + } + return false; } @@ -255,4 +279,14 @@ void LLPanelWearing::onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y) mContextMenu->show(ctrl, selected_uuids, x, y); } +bool LLPanelWearing::hasItemSelected() +{ + return mCOFItemsList->getSelectedItem() != NULL; +} + +void LLPanelWearing::getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const +{ + mCOFItemsList->getSelectedUUIDs(selected_uuids); +} + // EOF -- cgit v1.2.3