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
master
Paul Guslisty 2010-09-10 15:59:35 +03:00
parent d073234832
commit 36f3535f70
8 changed files with 112 additions and 26 deletions

View File

@ -308,6 +308,7 @@ set(viewer_SOURCE_FILES
lloutfitslist.cpp
lloutfitobserver.cpp
lloutputmonitorctrl.cpp
llpanelappearancetab.cpp
llpanelavatar.cpp
llpanelavatartag.cpp
llpanelblockedlist.cpp

View File

@ -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;

View File

@ -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);
@ -173,11 +173,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.
*/

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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

View File

@ -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);

View File

@ -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>