From 32bb4ace5451a510721158f4cd07b62de1df9a11 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Thu, 11 Jun 2009 04:28:24 -0700 Subject: Added Link/Unlink buttons to the Tools floater --- linden/indra/newview/llfloatertools.cpp | 97 ++++++++++++++++++++++ linden/indra/newview/llfloatertools.h | 7 ++ .../skins/default/xui/en-us/floater_tools.xml | 58 +++++++------ 3 files changed, 136 insertions(+), 26 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llfloatertools.cpp b/linden/indra/newview/llfloatertools.cpp index 73b6061..84a1edc 100644 --- a/linden/indra/newview/llfloatertools.cpp +++ b/linden/indra/newview/llfloatertools.cpp @@ -46,6 +46,7 @@ #include "llfloateropenobject.h" #include "llfocusmgr.h" #include "llmenugl.h" +#include "llnotify.h" #include "llpanelcontents.h" #include "llpanelface.h" #include "llpanelland.h" @@ -235,6 +236,11 @@ BOOL LLFloaterTools::postBuild() mTextGridMode = getChild("text ruler mode"); mComboGridMode = getChild("combobox grid mode"); childSetCommitCallback("combobox grid mode",commit_grid_mode, this); + mBtnLink = getChild("link_btn"); + childSetAction("link_btn",onClickLink, this); + mBtnUnlink = getChild("unlink_btn"); + childSetAction("unlink_btn",onClickUnlink, this); + // // Create Buttons // @@ -387,6 +393,9 @@ LLFloaterTools::LLFloaterTools() mBtnDuplicate(NULL), mBtnDuplicateInPlace(NULL), + mBtnLink(NULL), + mBtnUnlink(NULL), + mComboTreesGrass(NULL), mCheckSticky(NULL), mCheckCopySelection(NULL), @@ -661,6 +670,44 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask) if (mCheckStretchUniform) mCheckStretchUniform->setVisible( edit_visible ); if (mCheckStretchTexture) mCheckStretchTexture->setVisible( edit_visible ); + if (mBtnLink) mBtnLink->setVisible( edit_visible ); + if (mBtnUnlink) mBtnUnlink->setVisible( edit_visible ); + + // Check to see if we can link things + bool can_link = false; + if (!gSavedSettings.getBOOL("EditLinkedParts")) + { + if(LLSelectMgr::getInstance()->selectGetAllRootsValid() && LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() >= 2) + { + struct f : public LLSelectedObjectFunctor + { + virtual bool apply(LLViewerObject* object) + { + return object->permModify(); + } + } + func; + const bool firstonly = true; + can_link = LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func, firstonly); + } + } + mBtnLink->setEnabled(can_link); + + // Check to see if we can unlink things + bool can_unlink = false; + if (LLSelectMgr::getInstance()->selectGetAllRootsValid() && + LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject() && + !LLSelectMgr::getInstance()->getSelection()->getFirstEditableObject()->isAttachment()) + { + if (LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() != + LLSelectMgr::getInstance()->getSelection()->getObjectCount()) + { + can_unlink = true; + } + } + mBtnUnlink->setEnabled(can_unlink); + + // Create buttons BOOL create_visible = (tool == LLToolCompCreate::getInstance()); @@ -1109,3 +1156,53 @@ void LLFloaterTools::onSelectTreesGrass(LLUICtrl*, void*) gSavedSettings.setString("LastGrass", selected); } } + +// static +void LLFloaterTools::onClickLink(void* data) +{ + if(!LLSelectMgr::getInstance()->selectGetAllRootsValid()) + { + LLNotifyBox::showXml("UnableToLinkWhileDownloading"); + return; + } + + S32 object_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount(); + if (object_count > MAX_CHILDREN_PER_TASK + 1) + { + LLStringUtil::format_map_t args; + args["[COUNT]"] = llformat("%d", object_count); + int max = MAX_CHILDREN_PER_TASK+1; + args["[MAX]"] = llformat("%d", max); + gViewerWindow->alertXml("UnableToLinkObjects", args); + return; + } + + if(LLSelectMgr::getInstance()->getSelection()->getRootObjectCount() < 2) + { + gViewerWindow->alertXml("CannotLinkIncompleteSet"); + return; + } + if(!LLSelectMgr::getInstance()->selectGetRootsModify()) + { + gViewerWindow->alertXml("CannotLinkModify"); + return; + } + LLUUID owner_id; + std::string owner_name; + if(!LLSelectMgr::getInstance()->selectGetOwner(owner_id, owner_name)) + { + // we don't actually care if you're the owner, but novices are + // the most likely to be stumped by this one, so offer the + // easiest and most likely solution. + gViewerWindow->alertXml("CannotLinkDifferentOwners"); + return; + } + LLSelectMgr::getInstance()->sendLink(); + return; +} + +// static +void LLFloaterTools::onClickUnlink(void* data) +{ + LLSelectMgr::getInstance()->sendDelink(); +} diff --git a/linden/indra/newview/llfloatertools.h b/linden/indra/newview/llfloatertools.h index 360b1df..8f88977 100644 --- a/linden/indra/newview/llfloatertools.h +++ b/linden/indra/newview/llfloatertools.h @@ -102,6 +102,7 @@ public: virtual void onFocusReceived(); static void setEditTool(void* data); void saveLastTool(); + private: static void setObjectType( void* data ); @@ -109,6 +110,9 @@ private: static void onClickGridOptions(void* data); + static void onClickLink(void* data); + static void onClickUnlink(void* data); + public: LLButton *mBtnFocus; @@ -152,6 +156,9 @@ public: LLButton *mBtnDuplicate; LLButton *mBtnDuplicateInPlace; + LLButton *mBtnLink; + LLButton *mBtnUnlink; + // Create buttons LLComboBox *mComboTreesGrass; LLCheckBoxCtrl *mCheckSticky; diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml b/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml index b649614..18d56b4 100644 --- a/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml +++ b/linden/indra/newview/skins/default/xui/en-us/floater_tools.xml @@ -79,43 +79,49 @@ - - +