diff options
author | Paul Guslisty <pguslisty@productengine.com> | 2010-09-10 15:59:35 +0300 |
---|---|---|
committer | Paul Guslisty <pguslisty@productengine.com> | 2010-09-10 15:59:35 +0300 |
commit | 36f3535f70f431d9da76aba556adc82c0781d0af (patch) | |
tree | c58375842668d07401889c4ba17c3fb7cabc2f9c /indra/newview | |
parent | d0732348325bf09ca72e7bebf6334051ff21c694 (diff) |
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
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 1 | ||||
-rw-r--r-- | indra/newview/lloutfitslist.cpp | 17 | ||||
-rw-r--r-- | indra/newview/lloutfitslist.h | 7 | ||||
-rw-r--r-- | indra/newview/llpanelappearancetab.cpp | 51 | ||||
-rw-r--r-- | indra/newview/llpanelappearancetab.h | 8 | ||||
-rw-r--r-- | indra/newview/llpanelwearing.cpp | 40 | ||||
-rw-r--r-- | indra/newview/llpanelwearing.h | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_wearing_gear.xml | 10 |
8 files changed, 112 insertions, 26 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 630902c48f..0188821b6e 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -308,6 +308,7 @@ set(viewer_SOURCE_FILES lloutfitslist.cpp lloutfitobserver.cpp lloutputmonitorctrl.cpp + llpanelappearancetab.cpp llpanelavatar.cpp llpanelavatartag.cpp llpanelblockedlist.cpp diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index a0ef43ea80..cf0b3d94bd 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -972,23 +972,6 @@ void LLOutfitsList::applyFilterToTab( } } -bool LLOutfitsList::canTakeOffSelected() -{ - uuid_vec_t selected_uuids; - getSelectedItemsUUIDs(selected_uuids); - - LLFindWearablesEx is_worn(/*is_worn=*/ true, /*include_body_parts=*/ false); - - for (uuid_vec_t::const_iterator it=selected_uuids.begin(); it != selected_uuids.end(); ++it) - { - LLViewerInventoryItem* item = gInventory.getItem(*it); - if (!item) continue; - - if (is_worn(NULL, item)) return true; - } - return false; -} - bool LLOutfitsList::canWearSelected() { uuid_vec_t selected_items; diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h index 37b909c93e..faf6f7ce1e 100644 --- a/indra/newview/lloutfitslist.h +++ b/indra/newview/lloutfitslist.h @@ -98,7 +98,7 @@ public: const LLUUID& getSelectedOutfitUUID() const { return mSelectedOutfitUUID; } - void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const; + /*virtual*/ void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const; boost::signals2::connection setSelectionChangeCallback(selection_change_callback_t cb); @@ -174,11 +174,6 @@ private: void applyFilterToTab(const LLUUID& category_id, LLAccordionCtrlTab* tab, const std::string& filter_substring); /** - * Returns true if there are any items that can be taken off among currently selected, otherwise false. - */ - bool canTakeOffSelected(); - - /** * Returns true if all selected items can be worn. */ bool canWearSelected(); diff --git a/indra/newview/llpanelappearancetab.cpp b/indra/newview/llpanelappearancetab.cpp new file mode 100644 index 0000000000..9910a3a2ac --- /dev/null +++ b/indra/newview/llpanelappearancetab.cpp @@ -0,0 +1,51 @@ +/** + * @file llpanelappearancetab.h + * @brief Tabs interface for Side Bar "My Appearance" panel + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llpanelappearancetab.h" + + +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" + +//virtual +bool LLPanelAppearanceTab::canTakeOffSelected() +{ + uuid_vec_t selected_uuids; + getSelectedItemsUUIDs(selected_uuids); + + LLFindWearablesEx is_worn(/*is_worn=*/ true, /*include_body_parts=*/ false); + + for (uuid_vec_t::const_iterator it=selected_uuids.begin(); it != selected_uuids.end(); ++it) + { + LLViewerInventoryItem* item = gInventory.getItem(*it); + if (!item) continue; + + if (is_worn(NULL, item)) return true; + } + return false; +} diff --git a/indra/newview/llpanelappearancetab.h b/indra/newview/llpanelappearancetab.h index fa929aac0a..81366c5db4 100644 --- a/indra/newview/llpanelappearancetab.h +++ b/indra/newview/llpanelappearancetab.h @@ -41,9 +41,17 @@ public: virtual void showGearMenu(LLView* spawning_view) = 0; + virtual void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const {} + static const std::string& getFilterSubString() { return sFilterSubString; } protected: + + /** + * Returns true if there are any items that can be taken off among currently selected, otherwise false. + */ + bool canTakeOffSelected(); + static std::string sFilterSubString; }; 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<LLMenuGL>( "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 diff --git a/indra/newview/llpanelwearing.h b/indra/newview/llpanelwearing.h index 6ae8efef99..1fa97735b1 100644 --- a/indra/newview/llpanelwearing.h +++ b/indra/newview/llpanelwearing.h @@ -60,8 +60,12 @@ public: /*virtual*/ void showGearMenu(LLView* spawning_view); + /*virtual*/ void getSelectedItemsUUIDs(uuid_vec_t& selected_uuids) const; + boost::signals2::connection setSelectionChangeCallback(commit_callback_t cb); + bool hasItemSelected(); + private: void onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y); diff --git a/indra/newview/skins/default/xui/en/menu_wearing_gear.xml b/indra/newview/skins/default/xui/en/menu_wearing_gear.xml index 747352cb29..84ab16c709 100644 --- a/indra/newview/skins/default/xui/en/menu_wearing_gear.xml +++ b/indra/newview/skins/default/xui/en/menu_wearing_gear.xml @@ -10,4 +10,14 @@ <on_click function="Gear.Edit" /> </menu_item_call> + <menu_item_call + label="Take Off" + layout="topleft" + name="takeoff"> + <on_click + function="Gear.TakeOff" /> + <on_enable + function="Gear.OnEnable" + parameter="take_off" /> + </menu_item_call> </menu> |