diff options
24 files changed, 1900 insertions, 1695 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9be5aec47d..0be289052c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -222,6 +222,7 @@ set(viewer_SOURCE_FILES llfloaterpathfindingcharacters.cpp llfloaterpathfindingconsole.cpp llfloaterpathfindinglinksets.cpp + llfloaterpathfindingobjects.cpp llfloaterpay.cpp llfloaterperms.cpp llfloaterpostprocess.cpp @@ -425,6 +426,8 @@ set(viewer_SOURCE_FILES llpathfindingnavmesh.cpp llpathfindingnavmeshstatus.cpp llpathfindingnavmeshzone.cpp + llpathfindingobject.cpp + llpathfindingobjectlist.cpp llpathfindingpathtool.cpp llphysicsmotion.cpp llphysicsshapebuilderutil.cpp @@ -791,6 +794,7 @@ set(viewer_HEADER_FILES llfloaterpathfindingcharacters.h llfloaterpathfindingconsole.h llfloaterpathfindinglinksets.h + llfloaterpathfindingobjects.h llfloaterpay.h llfloaterperms.h llfloaterpostprocess.h @@ -983,6 +987,8 @@ set(viewer_HEADER_FILES llpathfindingnavmesh.h llpathfindingnavmeshstatus.h llpathfindingnavmeshzone.h + llpathfindingobject.h + llpathfindingobjectlist.h llpathfindingpathtool.h llphysicsmotion.h llphysicsshapebuilderutil.h diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index d0706b0bc0..6599bac6a6 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -26,176 +26,29 @@ */ #include "llviewerprecompiledheaders.h" -#include "llfloater.h" + #include "llfloaterpathfindingcharacters.h" + +#include "llfloaterreg.h" +#include "llfloaterpathfindingobjects.h" +#include "llpathfindingcharacter.h" #include "llpathfindingcharacterlist.h" #include "llsd.h" -#include "llagent.h" -#include "llhandle.h" -#include "llfloaterreg.h" -#include "lltextbase.h" -#include "llscrolllistitem.h" -#include "llscrolllistctrl.h" -#include "llcheckboxctrl.h" -#include "llradiogroup.h" -#include "llbutton.h" -#include "llresmgr.h" -#include "llviewerregion.h" -#include "llhttpclient.h" #include "lluuid.h" -#include "llviewerobject.h" -#include "llviewerobjectlist.h" -#include "llviewermenu.h" -#include "llselectmgr.h" -#include "llenvmanager.h" +#include "llviewerregion.h" //--------------------------------------------------------------------------- // LLFloaterPathfindingCharacters //--------------------------------------------------------------------------- -BOOL LLFloaterPathfindingCharacters::postBuild() -{ - mCharactersScrollList = findChild<LLScrollListCtrl>("pathfinding_characters"); - llassert(mCharactersScrollList != NULL); - mCharactersScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onCharactersSelectionChange, this)); - mCharactersScrollList->sortByColumnIndex(0, true); - - mCharactersStatus = findChild<LLTextBase>("characters_status"); - llassert(mCharactersStatus != NULL); - - mRefreshListButton = findChild<LLButton>("refresh_characters_list"); - llassert(mRefreshListButton != NULL); - mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onRefreshCharactersClicked, this)); - - mSelectAllButton = findChild<LLButton>("select_all_characters"); - llassert(mSelectAllButton != NULL); - mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectAllCharactersClicked, this)); - - mSelectNoneButton = findChild<LLButton>("select_none_characters"); - llassert(mSelectNoneButton != NULL); - mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked, this)); - - mShowBeaconCheckBox = findChild<LLCheckBoxCtrl>("show_beacon"); - llassert(mShowBeaconCheckBox != NULL); - - mTakeButton = findChild<LLButton>("take_characters"); - llassert(mTakeButton != NULL) - mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCharactersClicked, this)); - - mTakeCopyButton = findChild<LLButton>("take_copy_characters"); - llassert(mTakeCopyButton != NULL) - mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked, this)); - - mReturnButton = findChild<LLButton>("return_characters"); - llassert(mReturnButton != NULL) - mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onReturnCharactersClicked, this)); - - mDeleteButton = findChild<LLButton>("delete_characters"); - llassert(mDeleteButton != NULL) - mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onDeleteCharactersClicked, this)); - - mTeleportButton = findChild<LLButton>("teleport_to_character"); - llassert(mTeleportButton != NULL) - mTeleportButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked, this)); - - return LLFloater::postBuild(); -} - -void LLFloaterPathfindingCharacters::onOpen(const LLSD& pKey) -{ - LLFloater::onOpen(pKey); - - requestGetCharacters(); - selectNoneCharacters(); - mCharactersScrollList->setCommitOnSelectionChange(true); - - if (!mSelectionUpdateSlot.connected()) - { - mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingCharacters::updateControls, this)); - } - - if (!mRegionBoundarySlot.connected()) - { - mRegionBoundarySlot = LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterPathfindingCharacters::onRegionBoundaryCross, this)); - } -} - -void LLFloaterPathfindingCharacters::onClose(bool pAppQuitting) -{ - if (mRegionBoundarySlot.connected()) - { - mRegionBoundarySlot.disconnect(); - } - - if (mSelectionUpdateSlot.connected()) - { - mSelectionUpdateSlot.disconnect(); - } - - mCharactersScrollList->setCommitOnSelectionChange(false); - selectNoneCharacters(); - if (mCharacterSelection.notNull()) - { - mCharacterSelection.clear(); - } - - LLFloater::onClose(pAppQuitting); -} - -void LLFloaterPathfindingCharacters::draw() -{ - if (mShowBeaconCheckBox->get()) - { - std::vector<LLScrollListItem*> selectedItems = mCharactersScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - std::vector<LLViewerObject *> viewerObjects; - viewerObjects.reserve(numSelectedItems); - - for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); - selectedItemIter != selectedItems.end(); ++selectedItemIter) - { - const LLScrollListItem *selectedItem = *selectedItemIter; - - const std::string &objectName = selectedItem->getColumn(0)->getValue().asString(); - - LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID()); - if (viewerObject != NULL) - { - gObjectList.addDebugBeacon(viewerObject->getPositionAgent(), objectName, LLColor4(0.f, 0.f, 1.f, 0.8f), LLColor4(1.f, 1.f, 1.f, 1.f), 6); - } - } - } - } - - LLFloater::draw(); -} - void LLFloaterPathfindingCharacters::openCharactersViewer() { LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); } LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) - : LLFloater(pSeed), - mCharactersScrollList(NULL), - mCharactersStatus(NULL), - mRefreshListButton(NULL), - mSelectAllButton(NULL), - mSelectNoneButton(NULL), - mShowBeaconCheckBox(NULL), - mTakeButton(NULL), - mTakeCopyButton(NULL), - mReturnButton(NULL), - mDeleteButton(NULL), - mTeleportButton(NULL), - mMessagingState(kMessagingUnknown), - mMessagingRequestId(0U), - mCharacterListPtr(), - mCharacterSelection(), - mSelectionUpdateSlot() + : LLFloaterPathfindingObjects(pSeed), + mBeaconColor() { } @@ -203,208 +56,52 @@ LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() { } -LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const -{ - return mMessagingState; -} - -void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagingState) -{ - mMessagingState = pMessagingState; - updateControls(); -} - -void LLFloaterPathfindingCharacters::requestGetCharacters() -{ - LLPathfindingManager::getInstance()->requestGetCharacters(++mMessagingRequestId, boost::bind(&LLFloaterPathfindingCharacters::handleNewCharacters, this, _1, _2, _3)); -} - -void LLFloaterPathfindingCharacters::handleNewCharacters(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr) -{ - llassert(pRequestId <= mMessagingRequestId); - if (pRequestId == mMessagingRequestId) - { - switch (pCharacterRequestStatus) - { - case LLPathfindingManager::kRequestStarted : - setMessagingState(kMessagingGetRequestSent); - break; - case LLPathfindingManager::kRequestCompleted : - mCharacterListPtr = pCharacterListPtr; - updateScrollList(); - setMessagingState(kMessagingComplete); - break; - case LLPathfindingManager::kRequestNotEnabled : - clearCharacters(); - setMessagingState(kMessagingNotEnabled); - break; - case LLPathfindingManager::kRequestError : - setMessagingState(kMessagingGetError); - break; - default : - setMessagingState(kMessagingGetError); - llassert(0); - break; - } - } -} - -void LLFloaterPathfindingCharacters::onCharactersSelectionChange() -{ - mCharacterSelection.clear(); - LLSelectMgr::getInstance()->deselectAll(); - - std::vector<LLScrollListItem*> selectedItems = mCharactersScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - std::vector<LLViewerObject *> viewerObjects; - viewerObjects.reserve(numSelectedItems); - - for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); - selectedItemIter != selectedItems.end(); ++selectedItemIter) - { - const LLScrollListItem *selectedItem = *selectedItemIter; - - LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID()); - if (viewerObject != NULL) - { - viewerObjects.push_back(viewerObject); - } - } - - if (!viewerObjects.empty()) - { - mCharacterSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); - } - } - - updateControls(); -} - -void LLFloaterPathfindingCharacters::onRefreshCharactersClicked() -{ - requestGetCharacters(); -} - -void LLFloaterPathfindingCharacters::onSelectAllCharactersClicked() -{ - selectAllCharacters(); -} - -void LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked() +BOOL LLFloaterPathfindingCharacters::postBuild() { - selectNoneCharacters(); -} + mBeaconColor = LLUIColorTable::getInstance()->getColor("PathfindingCharacterBeaconColor"); -void LLFloaterPathfindingCharacters::onTakeCharactersClicked() -{ - handle_take(); + return LLFloaterPathfindingObjects::postBuild(); } -void LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked() +void LLFloaterPathfindingCharacters::requestGetObjects() { - handle_take_copy(); + LLPathfindingManager::getInstance()->requestGetCharacters(getNewRequestId(), boost::bind(&LLFloaterPathfindingCharacters::handleNewObjectList, this, _1, _2, _3)); } -void LLFloaterPathfindingCharacters::onReturnCharactersClicked() +LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const { - handle_object_return(); -} + llassert(pObjectListPtr != NULL); + llassert(!pObjectListPtr->isEmpty()); -void LLFloaterPathfindingCharacters::onDeleteCharactersClicked() -{ - handle_object_delete(); -} + LLSD scrollListData; -void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() -{ - std::vector<LLScrollListItem*> selectedItems = mCharactersScrollList->getAllSelected(); - llassert(selectedItems.size() == 1); - if (selectedItems.size() == 1) + for (LLPathfindingObjectList::const_iterator objectIter = pObjectListPtr->begin(); objectIter != pObjectListPtr->end(); ++objectIter) { - std::vector<LLScrollListItem*>::const_reference selectedItemRef = selectedItems.front(); - const LLScrollListItem *selectedItem = selectedItemRef; - LLPathfindingCharacterList::const_iterator characterIter = mCharacterListPtr->find(selectedItem->getUUID().asString()); - const LLPathfindingCharacterPtr &characterPtr = characterIter->second; - const LLVector3 &characterLocation = characterPtr->getLocation(); - - LLViewerRegion* region = gAgent.getRegion(); - if (region != NULL) - { - gAgent.teleportRequest(region->getHandle(), characterLocation, true); - } + const LLPathfindingCharacter *characterPtr = dynamic_cast<const LLPathfindingCharacter *>(objectIter->second.get()); + LLSD element = buildCharacterScrollListData(characterPtr); + scrollListData.append(element); } -} - -void LLFloaterPathfindingCharacters::onRegionBoundaryCross() -{ - requestGetCharacters(); -} - -void LLFloaterPathfindingCharacters::selectAllCharacters() -{ - mCharactersScrollList->selectAll(); -} -void LLFloaterPathfindingCharacters::selectNoneCharacters() -{ - mCharactersScrollList->deselectAllItems(); + return scrollListData; } -void LLFloaterPathfindingCharacters::clearCharacters() +S32 LLFloaterPathfindingCharacters::getNameColumnIndex() const { - if (mCharacterListPtr != NULL) - { - mCharacterListPtr->clear(); - } - updateScrollList(); + return 0; } -void LLFloaterPathfindingCharacters::updateControls() +const LLColor4 &LLFloaterPathfindingCharacters::getBeaconColor() const { - updateStatusMessage(); - updateEnableStateOnListActions(); - updateEnableStateOnEditFields(); + return mBeaconColor; } -void LLFloaterPathfindingCharacters::updateScrollList() +LLPathfindingObjectListPtr LLFloaterPathfindingCharacters::getEmptyObjectList() const { - std::vector<LLScrollListItem*> selectedItems = mCharactersScrollList->getAllSelected(); - int numSelectedItems = selectedItems.size(); - uuid_vec_t selectedUUIDs; - if (numSelectedItems > 0) - { - selectedUUIDs.reserve(selectedItems.size()); - for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin(); - itemIter != selectedItems.end(); ++itemIter) - { - const LLScrollListItem *listItem = *itemIter; - selectedUUIDs.push_back(listItem->getUUID()); - } - } - - S32 origScrollPosition = mCharactersScrollList->getScrollPos(); - mCharactersScrollList->deleteAllItems(); - - if (mCharacterListPtr != NULL) - { - for (LLPathfindingCharacterList::const_iterator characterIter = mCharacterListPtr->begin(); - characterIter != mCharacterListPtr->end(); ++characterIter) - { - const LLPathfindingCharacterPtr& character(characterIter->second); - LLSD element = buildCharacterScrollListElement(character); - mCharactersScrollList->addElement(element); - } - } - - mCharactersScrollList->selectMultiple(selectedUUIDs); - mCharactersScrollList->setScrollPos(origScrollPosition); - updateControls(); + LLPathfindingObjectListPtr objectListPtr(new LLPathfindingCharacterList()); + return objectListPtr; } -LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListElement(const LLPathfindingCharacterPtr pCharacterPtr) const +LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const { LLSD columns; @@ -439,106 +136,3 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListElement(const LLPat return element; } - -void LLFloaterPathfindingCharacters::updateStatusMessage() -{ - static const LLColor4 errorColor = LLUIColorTable::instance().getColor("PathfindingErrorColor"); - static const LLColor4 warningColor = LLUIColorTable::instance().getColor("PathfindingWarningColor"); - - std::string statusText(""); - LLStyle::Params styleParams; - - switch (getMessagingState()) - { - case kMessagingUnknown: - statusText = getString("characters_messaging_initial"); - styleParams.color = errorColor; - break; - case kMessagingGetRequestSent : - statusText = getString("characters_messaging_get_inprogress"); - styleParams.color = warningColor; - break; - case kMessagingGetError : - statusText = getString("characters_messaging_get_error"); - styleParams.color = errorColor; - break; - case kMessagingComplete : - if (mCharactersScrollList->isEmpty()) - { - statusText = getString("characters_messaging_complete_none_found"); - } - else - { - S32 numItems = mCharactersScrollList->getItemCount(); - S32 numSelectedItems = mCharactersScrollList->getNumSelected(); - - LLLocale locale(LLStringUtil::getLocale()); - std::string numItemsString; - LLResMgr::getInstance()->getIntegerString(numItemsString, numItems); - - std::string numSelectedItemsString; - LLResMgr::getInstance()->getIntegerString(numSelectedItemsString, numSelectedItems); - - LLStringUtil::format_map_t string_args; - string_args["[NUM_SELECTED]"] = numSelectedItemsString; - string_args["[NUM_TOTAL]"] = numItemsString; - statusText = getString("characters_messaging_complete_available", string_args); - } - break; - case kMessagingNotEnabled: - statusText = getString("characters_messaging_not_enabled"); - styleParams.color = errorColor; - break; - default: - statusText = getString("characters_messaging_initial"); - styleParams.color = errorColor; - llassert(0); - break; - } - - mCharactersStatus->setText((LLStringExplicit)statusText, styleParams); -} - -void LLFloaterPathfindingCharacters::updateEnableStateOnListActions() -{ - switch (getMessagingState()) - { - case kMessagingUnknown: - case kMessagingGetRequestSent : - mRefreshListButton->setEnabled(FALSE); - mSelectAllButton->setEnabled(FALSE); - mSelectNoneButton->setEnabled(FALSE); - break; - case kMessagingGetError : - case kMessagingNotEnabled : - mRefreshListButton->setEnabled(TRUE); - mSelectAllButton->setEnabled(FALSE); - mSelectNoneButton->setEnabled(FALSE); - break; - case kMessagingComplete : - { - int numItems = mCharactersScrollList->getItemCount(); - int numSelectedItems = mCharactersScrollList->getNumSelected(); - mRefreshListButton->setEnabled(TRUE); - mSelectAllButton->setEnabled(numSelectedItems < numItems); - mSelectNoneButton->setEnabled(numSelectedItems > 0); - } - break; - default: - llassert(0); - break; - } -} - -void LLFloaterPathfindingCharacters::updateEnableStateOnEditFields() -{ - int numSelectedItems = mCharactersScrollList->getNumSelected(); - bool isEditEnabled = (numSelectedItems > 0); - - mShowBeaconCheckBox->setEnabled(isEditEnabled); - mTakeButton->setEnabled(isEditEnabled && visible_take_object()); - mTakeCopyButton->setEnabled(isEditEnabled && enable_object_take_copy()); - mReturnButton->setEnabled(isEditEnabled && enable_object_return()); - mDeleteButton->setEnabled(isEditEnabled && enable_object_delete()); - mTeleportButton->setEnabled(numSelectedItems == 1); -} diff --git a/indra/newview/llfloaterpathfindingcharacters.h b/indra/newview/llfloaterpathfindingcharacters.h index b7b326b885..c4277b9d25 100644 --- a/indra/newview/llfloaterpathfindingcharacters.h +++ b/indra/newview/llfloaterpathfindingcharacters.h @@ -28,101 +28,45 @@ #ifndef LL_LLFLOATERPATHFINDINGCHARACTERS_H #define LL_LLFLOATERPATHFINDINGCHARACTERS_H -#include <string> -#include <map> - -#include "llfloater.h" +#include "llfloaterpathfindingobjects.h" #include "llpathfindingcharacter.h" -#include "llpathfindingcharacterlist.h" #include "llpathfindingmanager.h" -#include "llselectmgr.h" - -#include <boost/signals2.hpp> +#include "llpathfindingobjectlist.h" +#include "v4color.h" -class LLSD; -class LLTextBase; -class LLScrollListCtrl; +class LLButton; class LLCheckBoxCtrl; class LLRadioGroup; -class LLButton; +class LLScrollListCtrl; +class LLSD; +class LLTextBase; -class LLFloaterPathfindingCharacters - : public LLFloater +class LLFloaterPathfindingCharacters : public LLFloaterPathfindingObjects { - friend class LLFloaterReg; - public: - typedef enum - { - kMessagingUnknown, - kMessagingGetRequestSent, - kMessagingGetError, - kMessagingComplete, - kMessagingNotEnabled - } EMessagingState; - - virtual BOOL postBuild(); - virtual void onOpen(const LLSD& pKey); - virtual void onClose(bool pAppQuitting); - virtual void draw(); - - static void openCharactersViewer(); + static void openCharactersViewer(); protected: + friend class LLFloaterReg; -private: - LLScrollListCtrl *mCharactersScrollList; - LLTextBase *mCharactersStatus; - LLButton *mRefreshListButton; - LLButton *mSelectAllButton; - LLButton *mSelectNoneButton; - LLCheckBoxCtrl *mShowBeaconCheckBox; - LLButton *mTakeButton; - LLButton *mTakeCopyButton; - LLButton *mReturnButton; - LLButton *mDeleteButton; - LLButton *mTeleportButton; - - EMessagingState mMessagingState; - LLPathfindingManager::request_id_t mMessagingRequestId; - LLPathfindingCharacterListPtr mCharacterListPtr; - LLObjectSelectionHandle mCharacterSelection; - boost::signals2::connection mSelectionUpdateSlot; - boost::signals2::connection mRegionBoundarySlot; - - // Does its own instance management, so clients not allowed - // to allocate or destroy. LLFloaterPathfindingCharacters(const LLSD& pSeed); virtual ~LLFloaterPathfindingCharacters(); - EMessagingState getMessagingState() const; - void setMessagingState(EMessagingState pMessagingState); + virtual BOOL postBuild(); - void requestGetCharacters(); - void handleNewCharacters(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr); + virtual void requestGetObjects(); - void onCharactersSelectionChange(); - void onRefreshCharactersClicked(); - void onSelectAllCharactersClicked(); - void onSelectNoneCharactersClicked(); - void onTakeCharactersClicked(); - void onTakeCopyCharactersClicked(); - void onReturnCharactersClicked(); - void onDeleteCharactersClicked(); - void onTeleportCharacterToMeClicked(); - void onRegionBoundaryCross(); + virtual LLSD convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const; - void selectAllCharacters(); - void selectNoneCharacters(); - void clearCharacters(); + virtual S32 getNameColumnIndex() const; + virtual const LLColor4 &getBeaconColor() const; - void updateControls(); - void updateScrollList(); - LLSD buildCharacterScrollListElement(const LLPathfindingCharacterPtr pCharacterPtr) const; + virtual LLPathfindingObjectListPtr getEmptyObjectList() const; + +private: + LLSD buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const; - void updateStatusMessage(); - void updateEnableStateOnListActions(); - void updateEnableStateOnEditFields(); + LLColor4 mBeaconColor; }; #endif // LL_LLFLOATERPATHFINDINGCHARACTERS_H diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index 746601bdbb..7fe22f65cf 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -26,35 +26,34 @@ */ #include "llviewerprecompiledheaders.h" -#include "llfloater.h" -#include "llfloaterreg.h" + #include "llfloaterpathfindinglinksets.h" -#include "llsd.h" -#include "lluuid.h" -#include "v3math.h" -#include "lltextvalidate.h" + +#include <boost/bind.hpp> + #include "llagent.h" -#include "lltextbase.h" +#include "llbutton.h" +#include "llcheckboxctrl.h" +#include "llcombobox.h" +#include "llfloater.h" +#include "llfloaterreg.h" #include "lllineeditor.h" -#include "llscrolllistitem.h" +#include "llnotificationsutil.h" +#include "llpathfindinglinkset.h" +#include "llpathfindinglinksetlist.h" +#include "llpathfindingmanager.h" #include "llscrolllistctrl.h" -#include "llcombobox.h" -#include "llcheckboxctrl.h" -#include "llbutton.h" -#include "llresmgr.h" -#include "llviewerregion.h" +#include "llscrolllistitem.h" +#include "llsd.h" #include "llselectmgr.h" +#include "lltextbase.h" +#include "lltextvalidate.h" +#include "lluuid.h" #include "llviewermenu.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" -#include "llpathfindinglinkset.h" -#include "llpathfindinglinksetlist.h" -#include "llpathfindingmanager.h" -#include "llnotificationsutil.h" -#include "llenvmanager.h" - -#include <boost/bind.hpp> -#include <boost/signals2.hpp> +#include "llviewerregion.h" +#include "v3math.h" #define XUI_LINKSET_USE_NONE 0 #define XUI_LINKSET_USE_WALKABLE 1 @@ -68,10 +67,65 @@ // LLFloaterPathfindingLinksets //--------------------------------------------------------------------------- +void LLFloaterPathfindingLinksets::onOpen(const LLSD& pKey) +{ + LLFloaterPathfindingObjects::onOpen(pKey); + + if (!mAgentStateSlot.connected()) + { + mAgentStateSlot = LLPathfindingManager::getInstance()->registerAgentStateListener(boost::bind(&LLFloaterPathfindingLinksets::onAgentStateChange, this, _1)); + } +} + +void LLFloaterPathfindingLinksets::onClose(bool pIsAppQuitting) +{ + if (mAgentStateSlot.connected()) + { + mAgentStateSlot.disconnect(); + } + + LLFloaterPathfindingObjects::onClose(pIsAppQuitting); +} + +void LLFloaterPathfindingLinksets::openLinksetsEditor() +{ + LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_linksets"); +} + +LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed) + : LLFloaterPathfindingObjects(pSeed), + mFilterByName(NULL), + mFilterByDescription(NULL), + mFilterByLinksetUse(NULL), + mEditLinksetUse(NULL), + mEditLinksetUseWalkable(NULL), + mEditLinksetUseStaticObstacle(NULL), + mEditLinksetUseDynamicObstacle(NULL), + mEditLinksetUseMaterialVolume(NULL), + mEditLinksetUseExclusionVolume(NULL), + mEditLinksetUseDynamicPhantom(NULL), + mLabelWalkabilityCoefficients(NULL), + mLabelEditA(NULL), + mEditA(NULL), + mLabelEditB(NULL), + mEditB(NULL), + mLabelEditC(NULL), + mEditC(NULL), + mLabelEditD(NULL), + mEditD(NULL), + mApplyEditsButton(NULL), + mBeaconColor(), + mAgentStateSlot() +{ +} + +LLFloaterPathfindingLinksets::~LLFloaterPathfindingLinksets() +{ +} + BOOL LLFloaterPathfindingLinksets::postBuild() { - childSetAction("apply_filters", boost::bind(&LLFloaterPathfindingLinksets::onApplyAllFilters, this)); - childSetAction("clear_filters", boost::bind(&LLFloaterPathfindingLinksets::onClearFiltersClicked, this)); + mBeaconColor = LLUIColorTable::getInstance()->getColor("PathfindingLinksetBeaconColor"); mFilterByName = findChild<LLLineEditor>("filter_by_name"); llassert(mFilterByName != NULL); @@ -89,73 +143,32 @@ BOOL LLFloaterPathfindingLinksets::postBuild() llassert(mFilterByLinksetUse != NULL); mFilterByLinksetUse->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyAllFilters, this)); - mLinksetsScrollList = findChild<LLScrollListCtrl>("pathfinding_linksets"); - llassert(mLinksetsScrollList != NULL); - mLinksetsScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onLinksetsSelectionChange, this)); - mLinksetsScrollList->sortByColumnIndex(0, true); - - mLinksetsStatus = findChild<LLTextBase>("linksets_status"); - llassert(mLinksetsStatus != NULL); - - mRefreshListButton = findChild<LLButton>("refresh_linksets_list"); - llassert(mRefreshListButton != NULL); - mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onRefreshLinksetsClicked, this)); - - mSelectAllButton = findChild<LLButton>("select_all_linksets"); - llassert(mSelectAllButton != NULL); - mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onSelectAllLinksetsClicked, this)); - - mSelectNoneButton = findChild<LLButton>("select_none_linksets"); - llassert(mSelectNoneButton != NULL); - mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked, this)); - - mShowBeaconCheckBox = findChild<LLCheckBoxCtrl>("show_beacon"); - llassert(mShowBeaconCheckBox != NULL); - - mTakeButton = findChild<LLButton>("take_linksets"); - llassert(mTakeButton != NULL); - mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onTakeClicked, this)); - - mTakeCopyButton = findChild<LLButton>("take_copy_linksets"); - llassert(mTakeCopyButton != NULL); - mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onTakeCopyClicked, this)); - - mReturnButton = findChild<LLButton>("return_linksets"); - llassert(mReturnButton != NULL); - mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onReturnClicked, this)); - - mDeleteButton = findChild<LLButton>("delete_linksets"); - llassert(mDeleteButton != NULL); - mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onDeleteClicked, this)); - - mTeleportButton = findChild<LLButton>("teleport_me_to_linkset"); - llassert(mTeleportButton != NULL); - mTeleportButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onTeleportClicked, this)); + childSetAction("apply_filters", boost::bind(&LLFloaterPathfindingLinksets::onApplyAllFilters, this)); + childSetAction("clear_filters", boost::bind(&LLFloaterPathfindingLinksets::onClearFiltersClicked, this)); mEditLinksetUse = findChild<LLComboBox>("edit_linkset_use"); llassert(mEditLinksetUse != NULL); - mEditLinksetUse->clearRows(); - mEditLinksetUseUnset = mEditLinksetUse->addElement(buildLinksetUseScrollListElement(getString("linkset_choose_use"), XUI_LINKSET_USE_NONE)); + mEditLinksetUseUnset = mEditLinksetUse->addElement(buildLinksetUseScrollListData(getString("linkset_choose_use"), XUI_LINKSET_USE_NONE)); llassert(mEditLinksetUseUnset != NULL); - mEditLinksetUseWalkable = mEditLinksetUse->addElement(buildLinksetUseScrollListElement(getLinksetUseString(LLPathfindingLinkset::kWalkable), XUI_LINKSET_USE_WALKABLE)); + mEditLinksetUseWalkable = mEditLinksetUse->addElement(buildLinksetUseScrollListData(getLinksetUseString(LLPathfindingLinkset::kWalkable), XUI_LINKSET_USE_WALKABLE)); llassert(mEditLinksetUseWalkable != NULL); - mEditLinksetUseStaticObstacle = mEditLinksetUse->addElement(buildLinksetUseScrollListElement(getLinksetUseString(LLPathfindingLinkset::kStaticObstacle), XUI_LINKSET_USE_STATIC_OBSTACLE)); + mEditLinksetUseStaticObstacle = mEditLinksetUse->addElement(buildLinksetUseScrollListData(getLinksetUseString(LLPathfindingLinkset::kStaticObstacle), XUI_LINKSET_USE_STATIC_OBSTACLE)); llassert(mEditLinksetUseStaticObstacle != NULL); - mEditLinksetUseDynamicObstacle = mEditLinksetUse->addElement(buildLinksetUseScrollListElement(getLinksetUseString(LLPathfindingLinkset::kDynamicObstacle), XUI_LINKSET_USE_DYNAMIC_OBSTACLE)); + mEditLinksetUseDynamicObstacle = mEditLinksetUse->addElement(buildLinksetUseScrollListData(getLinksetUseString(LLPathfindingLinkset::kDynamicObstacle), XUI_LINKSET_USE_DYNAMIC_OBSTACLE)); llassert(mEditLinksetUseDynamicObstacle != NULL); - mEditLinksetUseMaterialVolume = mEditLinksetUse->addElement(buildLinksetUseScrollListElement(getLinksetUseString(LLPathfindingLinkset::kMaterialVolume), XUI_LINKSET_USE_MATERIAL_VOLUME)); + mEditLinksetUseMaterialVolume = mEditLinksetUse->addElement(buildLinksetUseScrollListData(getLinksetUseString(LLPathfindingLinkset::kMaterialVolume), XUI_LINKSET_USE_MATERIAL_VOLUME)); llassert(mEditLinksetUseMaterialVolume != NULL); - mEditLinksetUseExclusionVolume = mEditLinksetUse->addElement(buildLinksetUseScrollListElement(getLinksetUseString(LLPathfindingLinkset::kExclusionVolume), XUI_LINKSET_USE_EXCLUSION_VOLUME)); + mEditLinksetUseExclusionVolume = mEditLinksetUse->addElement(buildLinksetUseScrollListData(getLinksetUseString(LLPathfindingLinkset::kExclusionVolume), XUI_LINKSET_USE_EXCLUSION_VOLUME)); llassert(mEditLinksetUseExclusionVolume != NULL); - mEditLinksetUseDynamicPhantom = mEditLinksetUse->addElement(buildLinksetUseScrollListElement(getLinksetUseString(LLPathfindingLinkset::kDynamicPhantom), XUI_LINKSET_USE_DYNAMIC_PHANTOM)); + mEditLinksetUseDynamicPhantom = mEditLinksetUse->addElement(buildLinksetUseScrollListData(getLinksetUseString(LLPathfindingLinkset::kDynamicPhantom), XUI_LINKSET_USE_DYNAMIC_PHANTOM)); llassert(mEditLinksetUseDynamicPhantom != NULL); mEditLinksetUse->selectFirstItem(); @@ -199,325 +212,106 @@ BOOL LLFloaterPathfindingLinksets::postBuild() llassert(mApplyEditsButton != NULL); mApplyEditsButton->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onApplyChangesClicked, this)); - return LLFloater::postBuild(); + return LLFloaterPathfindingObjects::postBuild(); } -void LLFloaterPathfindingLinksets::onOpen(const LLSD& pKey) +void LLFloaterPathfindingLinksets::requestGetObjects() { - LLFloater::onOpen(pKey); - - requestGetLinksets(); - selectNoneLinksets(); - mLinksetsScrollList->setCommitOnSelectionChange(true); - - if (!mAgentStateSlot.connected()) - { - mAgentStateSlot = LLPathfindingManager::getInstance()->registerAgentStateListener(boost::bind(&LLFloaterPathfindingLinksets::onAgentStateCB, this, _1)); - } - - if (!mSelectionUpdateSlot.connected()) - { - mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingLinksets::updateControls, this)); - } - - if (!mRegionBoundarySlot.connected()) - { - mRegionBoundarySlot = LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterPathfindingLinksets::onRegionBoundaryCross, this)); - } + LLPathfindingManager::getInstance()->requestGetLinksets(getNewRequestId(), boost::bind(&LLFloaterPathfindingLinksets::handleNewObjectList, this, _1, _2, _3)); } -void LLFloaterPathfindingLinksets::onClose(bool pAppQuitting) +LLSD LLFloaterPathfindingLinksets::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const { - if (mRegionBoundarySlot.connected()) - { - mRegionBoundarySlot.disconnect(); - } - - if (mSelectionUpdateSlot.connected()) - { - mSelectionUpdateSlot.disconnect(); - } - - if (mAgentStateSlot.connected()) - { - mAgentStateSlot.disconnect(); - } + llassert(pObjectListPtr != NULL); + llassert(!pObjectListPtr->isEmpty()); - mLinksetsScrollList->setCommitOnSelectionChange(false); - selectNoneLinksets(); - if (mLinksetsSelection.notNull()) - { - mLinksetsSelection.clear(); - } + std::string nameFilter = mFilterByName->getText(); + std::string descriptionFilter = mFilterByDescription->getText(); + LLPathfindingLinkset::ELinksetUse linksetUseFilter = getFilterLinksetUse(); + bool isFilteringName = !nameFilter.empty(); + bool isFilteringDescription = !descriptionFilter.empty(); + bool isFilteringLinksetUse = (linksetUseFilter != LLPathfindingLinkset::kUnknown); - LLFloater::onClose(pAppQuitting); -} + LLSD scrollListData; + const LLVector3& avatarPosition = gAgent.getPositionAgent(); -void LLFloaterPathfindingLinksets::draw() -{ - if (mShowBeaconCheckBox->get()) + if (isFilteringName || isFilteringDescription || isFilteringLinksetUse) { - std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected(); - if (!selectedItems.empty()) + LLStringUtil::toUpper(nameFilter); + LLStringUtil::toUpper(descriptionFilter); + for (LLPathfindingObjectList::const_iterator objectIter = pObjectListPtr->begin(); objectIter != pObjectListPtr->end(); ++objectIter) { - int numSelectedItems = selectedItems.size(); - - std::vector<LLViewerObject *> viewerObjects; - viewerObjects.reserve(numSelectedItems); - - for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); - selectedItemIter != selectedItems.end(); ++selectedItemIter) + const LLPathfindingLinkset *linksetPtr = dynamic_cast<const LLPathfindingLinkset *>(objectIter->second.get()); + std::string linksetName = (linksetPtr->isTerrain() ? getString("linkset_terrain_name") : linksetPtr->getName()); + std::string linksetDescription = linksetPtr->getDescription(); + LLStringUtil::toUpper(linksetName); + LLStringUtil::toUpper(linksetDescription); + if ((!isFilteringName || (linksetName.find(nameFilter) != std::string::npos)) && + (!isFilteringDescription || (linksetDescription.find(descriptionFilter) != std::string::npos)) && + (!isFilteringLinksetUse || (linksetPtr->getLinksetUse() == linksetUseFilter))) { - const LLScrollListItem *selectedItem = *selectedItemIter; - - LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID()); - if (viewerObject != NULL) - { - const std::string &objectName = selectedItem->getColumn(0)->getValue().asString(); - gObjectList.addDebugBeacon(viewerObject->getPositionAgent(), objectName, LLColor4(0.f, 0.f, 1.f, 0.8f), LLColor4(1.f, 1.f, 1.f, 1.f), 6); - } + LLSD element = buildLinksetScrollListData(linksetPtr, avatarPosition); + scrollListData.append(element); } } } - - LLFloater::draw(); -} - -void LLFloaterPathfindingLinksets::openLinksetsEditor() -{ - LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_linksets"); -} - -LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed) - : LLFloater(pSeed), - mFilterByName(NULL), - mFilterByDescription(NULL), - mFilterByLinksetUse(NULL), - mLinksetsScrollList(NULL), - mLinksetsStatus(NULL), - mRefreshListButton(NULL), - mSelectAllButton(NULL), - mSelectNoneButton(NULL), - mShowBeaconCheckBox(NULL), - mTakeButton(NULL), - mTakeCopyButton(NULL), - mReturnButton(NULL), - mDeleteButton(NULL), - mTeleportButton(NULL), - mEditLinksetUse(NULL), - mLabelWalkabilityCoefficients(NULL), - mLabelEditA(NULL), - mEditA(NULL), - mLabelEditB(NULL), - mEditB(NULL), - mLabelEditC(NULL), - mEditC(NULL), - mLabelEditD(NULL), - mEditD(NULL), - mApplyEditsButton(NULL), - mMessagingState(kMessagingUnknown), - mMessagingRequestId(0U), - mLinksetsListPtr(), - mLinksetsSelection(), - mAgentStateSlot(), - mSelectionUpdateSlot() -{ -} - -LLFloaterPathfindingLinksets::~LLFloaterPathfindingLinksets() -{ -} - -LLFloaterPathfindingLinksets::EMessagingState LLFloaterPathfindingLinksets::getMessagingState() const -{ - return mMessagingState; -} - -void LLFloaterPathfindingLinksets::setMessagingState(EMessagingState pMessagingState) -{ - mMessagingState = pMessagingState; - updateControls(); -} - -void LLFloaterPathfindingLinksets::requestGetLinksets() -{ - LLPathfindingManager::getInstance()->requestGetLinksets(++mMessagingRequestId, boost::bind(&LLFloaterPathfindingLinksets::handleNewLinksets, this, _1, _2, _3)); -} - -void LLFloaterPathfindingLinksets::requestSetLinksets(LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) -{ - LLPathfindingManager::getInstance()->requestSetLinksets(++mMessagingRequestId, pLinksetList, pLinksetUse, pA, pB, pC, pD, boost::bind(&LLFloaterPathfindingLinksets::handleUpdateLinksets, this, _1, _2, _3)); -} - -void LLFloaterPathfindingLinksets::handleNewLinksets(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pLinksetsRequestStatus, LLPathfindingLinksetListPtr pLinksetsListPtr) -{ - llassert(pRequestId <= mMessagingRequestId); - if (pRequestId == mMessagingRequestId) - { - mLinksetsListPtr = pLinksetsListPtr; - updateScrollList(); - - switch (pLinksetsRequestStatus) - { - case LLPathfindingManager::kRequestStarted : - setMessagingState(kMessagingGetRequestSent); - break; - case LLPathfindingManager::kRequestCompleted : - mLinksetsListPtr = pLinksetsListPtr; - updateScrollList(); - setMessagingState(kMessagingComplete); - break; - case LLPathfindingManager::kRequestNotEnabled : - clearLinksets(); - setMessagingState(kMessagingNotEnabled); - break; - case LLPathfindingManager::kRequestError : - setMessagingState(kMessagingGetError); - break; - default : - setMessagingState(kMessagingGetError); - llassert(0); - break; - } - } -} - -void LLFloaterPathfindingLinksets::handleUpdateLinksets(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pLinksetsRequestStatus, LLPathfindingLinksetListPtr pLinksetsListPtr) -{ - llassert(pRequestId <= mMessagingRequestId); - if (pRequestId == mMessagingRequestId) + else { - switch (pLinksetsRequestStatus) + for (LLPathfindingObjectList::const_iterator objectIter = pObjectListPtr->begin(); objectIter != pObjectListPtr->end(); ++objectIter) { - case LLPathfindingManager::kRequestStarted : - setMessagingState(kMessagingSetRequestSent); - break; - case LLPathfindingManager::kRequestCompleted : - if (mLinksetsListPtr == NULL) - { - mLinksetsListPtr = pLinksetsListPtr; - } - else if (pLinksetsListPtr != NULL) - { - mLinksetsListPtr->update(*pLinksetsListPtr); - } - updateScrollList(); - setMessagingState(kMessagingComplete); - break; - case LLPathfindingManager::kRequestNotEnabled : - clearLinksets(); - setMessagingState(kMessagingNotEnabled); - break; - case LLPathfindingManager::kRequestError : - setMessagingState(kMessagingSetError); - break; - default : - setMessagingState(kMessagingSetError); - llassert(0); - break; + const LLPathfindingLinkset *linksetPtr = dynamic_cast<const LLPathfindingLinkset *>(objectIter->second.get()); + LLSD element = buildLinksetScrollListData(linksetPtr, avatarPosition); + scrollListData.append(element); } } -} -void LLFloaterPathfindingLinksets::onApplyAllFilters() -{ - applyFilters(); + return scrollListData; } -void LLFloaterPathfindingLinksets::onClearFiltersClicked() +void LLFloaterPathfindingLinksets::updateControls() { - clearFilters(); + LLFloaterPathfindingObjects::updateControls(); + updateStateOnEditFields(); + updateStateOnEditLinksetUse(); } -void LLFloaterPathfindingLinksets::onLinksetsSelectionChange() +void LLFloaterPathfindingLinksets::updateSelection() { - mLinksetsSelection.clear(); - LLSelectMgr::getInstance()->deselectAll(); - - std::vector<LLScrollListItem *> selectedItems = mLinksetsScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - std::vector<LLViewerObject *>viewerObjects; - viewerObjects.reserve(numSelectedItems); - - for (std::vector<LLScrollListItem *>::const_iterator selectedItemIter = selectedItems.begin(); - selectedItemIter != selectedItems.end(); ++selectedItemIter) - { - const LLScrollListItem *selectedItem = *selectedItemIter; - - LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID()); - if (viewerObject != NULL) - { - viewerObjects.push_back(viewerObject); - } - } - - if (!viewerObjects.empty()) - { - mLinksetsSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); - } - } - + LLFloaterPathfindingObjects::updateSelection(); updateEditFieldValues(); - updateControls(); -} - -void LLFloaterPathfindingLinksets::onRefreshLinksetsClicked() -{ - requestGetLinksets(); -} - -void LLFloaterPathfindingLinksets::onSelectAllLinksetsClicked() -{ - selectAllLinksets(); + updateStateOnEditFields(); + updateStateOnEditLinksetUse(); } -void LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked() +S32 LLFloaterPathfindingLinksets::getNameColumnIndex() const { - selectNoneLinksets(); + return 0; } -void LLFloaterPathfindingLinksets::onTakeClicked() +const LLColor4 &LLFloaterPathfindingLinksets::getBeaconColor() const { - handle_take(); + return mBeaconColor; } -void LLFloaterPathfindingLinksets::onTakeCopyClicked() +LLPathfindingObjectListPtr LLFloaterPathfindingLinksets::getEmptyObjectList() const { - handle_take_copy(); + LLPathfindingObjectListPtr objectListPtr(new LLPathfindingLinksetList()); + return objectListPtr; } -void LLFloaterPathfindingLinksets::onReturnClicked() +void LLFloaterPathfindingLinksets::requestSetLinksets(LLPathfindingObjectListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) { - handle_object_return(); + LLPathfindingManager::getInstance()->requestSetLinksets(getNewRequestId(), pLinksetList, pLinksetUse, pA, pB, pC, pD, boost::bind(&LLFloaterPathfindingLinksets::handleUpdateObjectList, this, _1, _2, _3)); } -void LLFloaterPathfindingLinksets::onDeleteClicked() +void LLFloaterPathfindingLinksets::onApplyAllFilters() { - handle_object_delete(); + applyFilters(); } -void LLFloaterPathfindingLinksets::onTeleportClicked() +void LLFloaterPathfindingLinksets::onClearFiltersClicked() { - std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected(); - llassert(selectedItems.size() == 1); - if (selectedItems.size() == 1) - { - std::vector<LLScrollListItem*>::const_reference selectedItemRef = selectedItems.front(); - const LLScrollListItem *selectedItem = selectedItemRef; - llassert(mLinksetsListPtr != NULL); - LLPathfindingLinksetList::const_iterator linksetIter = mLinksetsListPtr->find(selectedItem->getUUID().asString()); - const LLPathfindingLinksetPtr linksetPtr = linksetIter->second; - const LLVector3 &linksetLocation = linksetPtr->getLocation(); - - LLViewerRegion* region = gAgent.getRegion(); - if (region != NULL) - { - gAgent.teleportRequest(region->getHandle(), linksetLocation, true); - } - } + clearFilters(); } void LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl) @@ -526,12 +320,19 @@ void LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered(LLUICtrl *pUI llassert(pLineEditor != NULL); const std::string &valueString = pLineEditor->getText(); - S32 value = static_cast<S32>(atoi(valueString.c_str())); + S32 value; - if ((value < LLPathfindingLinkset::MIN_WALKABILITY_VALUE) || (value > LLPathfindingLinkset::MAX_WALKABILITY_VALUE)) + if (LLStringUtil::convertToS32(valueString, value)) { - value = llclamp(value, LLPathfindingLinkset::MIN_WALKABILITY_VALUE, LLPathfindingLinkset::MAX_WALKABILITY_VALUE); - pLineEditor->setValue(LLSD(value)); + if ((value < LLPathfindingLinkset::MIN_WALKABILITY_VALUE) || (value > LLPathfindingLinkset::MAX_WALKABILITY_VALUE)) + { + value = llclamp(value, LLPathfindingLinkset::MIN_WALKABILITY_VALUE, LLPathfindingLinkset::MAX_WALKABILITY_VALUE); + pLineEditor->setValue(LLSD(value)); + } + } + else + { + pLineEditor->setValue(LLSD(LLPathfindingLinkset::MAX_WALKABILITY_VALUE)); } } @@ -540,19 +341,14 @@ void LLFloaterPathfindingLinksets::onApplyChangesClicked() applyEdit(); } -void LLFloaterPathfindingLinksets::onAgentStateCB(LLPathfindingManager::EAgentState pAgentState) +void LLFloaterPathfindingLinksets::onAgentStateChange(LLPathfindingManager::EAgentState pAgentState) { updateControls(); } -void LLFloaterPathfindingLinksets::onRegionBoundaryCross() -{ - requestGetLinksets(); -} - void LLFloaterPathfindingLinksets::applyFilters() { - updateScrollList(); + rebuildObjectsScrollList(); } void LLFloaterPathfindingLinksets::clearFilters() @@ -560,40 +356,13 @@ void LLFloaterPathfindingLinksets::clearFilters() mFilterByName->clear(); mFilterByDescription->clear(); setFilterLinksetUse(LLPathfindingLinkset::kUnknown); - updateScrollList(); -} - -void LLFloaterPathfindingLinksets::selectAllLinksets() -{ - mLinksetsScrollList->selectAll(); -} - -void LLFloaterPathfindingLinksets::selectNoneLinksets() -{ - mLinksetsScrollList->deselectAllItems(); -} - -void LLFloaterPathfindingLinksets::clearLinksets() -{ - if (mLinksetsListPtr != NULL) - { - mLinksetsListPtr->clear(); - } - updateScrollList(); -} - -void LLFloaterPathfindingLinksets::updateControls() -{ - updateStatusMessage(); - updateEnableStateOnListActions(); - updateEnableStateOnEditFields(); + rebuildObjectsScrollList(); } void LLFloaterPathfindingLinksets::updateEditFieldValues() { - std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected(); - int numSelectedItems = selectedItems.size(); - if (numSelectedItems <= 0) + int numSelectedObjects = getNumSelectedObjects(); + if (numSelectedObjects <= 0) { mEditLinksetUse->selectFirstItem(); mEditA->clear(); @@ -603,92 +372,22 @@ void LLFloaterPathfindingLinksets::updateEditFieldValues() } else { - LLScrollListItem *firstItem = selectedItems.front(); - - llassert(mLinksetsListPtr != NULL); - LLPathfindingLinksetList::const_iterator linksetIter = mLinksetsListPtr->find(firstItem->getUUID().asString()); - const LLPathfindingLinksetPtr linksetPtr(linksetIter->second); - - setEditLinksetUse(linksetPtr->getLinksetUse()); - mEditA->setValue(LLSD(linksetPtr->getWalkabilityCoefficientA())); - mEditB->setValue(LLSD(linksetPtr->getWalkabilityCoefficientB())); - mEditC->setValue(LLSD(linksetPtr->getWalkabilityCoefficientC())); - mEditD->setValue(LLSD(linksetPtr->getWalkabilityCoefficientD())); - updateEnableStateOnEditLinksetUse(); - } -} - -void LLFloaterPathfindingLinksets::updateScrollList() -{ - std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected(); - int numSelectedItems = selectedItems.size(); - uuid_vec_t selectedUUIDs; - if (numSelectedItems > 0) - { - selectedUUIDs.reserve(selectedItems.size()); - for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin(); - itemIter != selectedItems.end(); ++itemIter) - { - const LLScrollListItem *listItem = *itemIter; - selectedUUIDs.push_back(listItem->getUUID()); - } - } - - S32 origScrollPosition = mLinksetsScrollList->getScrollPos(); - mLinksetsScrollList->deleteAllItems(); - - if (mLinksetsListPtr != NULL) - { - std::string nameFilter = mFilterByName->getText(); - std::string descriptionFilter = mFilterByDescription->getText(); - LLPathfindingLinkset::ELinksetUse linksetUseFilter = getFilterLinksetUse(); - bool isFilteringName = !nameFilter.empty(); - bool isFilteringDescription = !descriptionFilter.empty(); - bool isFilteringLinksetUse = (linksetUseFilter != LLPathfindingLinkset::kUnknown); + LLPathfindingObjectPtr firstSelectedObjectPtr = getFirstSelectedObject(); + llassert(firstSelectedObjectPtr != NULL); - const LLVector3& avatarPosition = gAgent.getPositionAgent(); + const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(firstSelectedObjectPtr.get()); - if (isFilteringName || isFilteringDescription || isFilteringLinksetUse) - { - LLStringUtil::toUpper(nameFilter); - LLStringUtil::toUpper(descriptionFilter); - for (LLPathfindingLinksetList::const_iterator linksetIter = mLinksetsListPtr->begin(); - linksetIter != mLinksetsListPtr->end(); ++linksetIter) - { - const LLPathfindingLinksetPtr linksetPtr(linksetIter->second); - std::string linksetName = (linksetPtr->isTerrain() ? getString("linkset_terrain_name") : linksetPtr->getName()); - std::string linksetDescription = linksetPtr->getDescription(); - LLStringUtil::toUpper(linksetName); - LLStringUtil::toUpper(linksetDescription); - if ((!isFilteringName || (linksetName.find(nameFilter) != std::string::npos)) && - (!isFilteringDescription || (linksetDescription.find(descriptionFilter) != std::string::npos)) && - (!isFilteringLinksetUse || (linksetPtr->getLinksetUse() == linksetUseFilter))) - { - LLSD element = buildLinksetScrollListElement(linksetPtr, avatarPosition); - mLinksetsScrollList->addElement(element); - } - } - } - else - { - for (LLPathfindingLinksetList::const_iterator linksetIter = mLinksetsListPtr->begin(); - linksetIter != mLinksetsListPtr->end(); ++linksetIter) - { - const LLPathfindingLinksetPtr linksetPtr(linksetIter->second); - LLSD element = buildLinksetScrollListElement(linksetPtr, avatarPosition); - mLinksetsScrollList->addElement(element); - } - } + setEditLinksetUse(linkset->getLinksetUse()); + mEditA->setValue(LLSD(linkset->getWalkabilityCoefficientA())); + mEditB->setValue(LLSD(linkset->getWalkabilityCoefficientB())); + mEditC->setValue(LLSD(linkset->getWalkabilityCoefficientC())); + mEditD->setValue(LLSD(linkset->getWalkabilityCoefficientD())); } - - mLinksetsScrollList->selectMultiple(selectedUUIDs); - mLinksetsScrollList->setScrollPos(origScrollPosition); - updateEditFieldValues(); - updateControls(); } -LLSD LLFloaterPathfindingLinksets::buildLinksetScrollListElement(const LLPathfindingLinksetPtr pLinksetPtr, const LLVector3 &pAvatarPosition) const +LLSD LLFloaterPathfindingLinksets::buildLinksetScrollListData(const LLPathfindingLinkset *pLinksetPtr, const LLVector3 &pAvatarPosition) const { + llassert(pLinksetPtr != NULL); LLSD columns; if (pLinksetPtr->isTerrain()) @@ -780,184 +479,61 @@ LLSD LLFloaterPathfindingLinksets::buildLinksetScrollListElement(const LLPathfin return element; } -LLSD LLFloaterPathfindingLinksets::buildLinksetUseScrollListElement(const std::string &label, S32 value) const +LLSD LLFloaterPathfindingLinksets::buildLinksetUseScrollListData(const std::string &pLabel, S32 pValue) const { LLSD columns; columns[0]["column"] = "name"; columns[0]["relwidth"] = static_cast<LLSD::Real>(100.0f); - columns[0]["value"] = label; + columns[0]["value"] = pLabel; columns[0]["font"] = "SANSSERIF"; LLSD element; - element["value"] = value; + element["value"] = pValue; element["column"] = columns; return element; } -bool LLFloaterPathfindingLinksets::isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse linksetUse) const +bool LLFloaterPathfindingLinksets::isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const { - bool showWarning = false; + bool isShowWarning = false; - if (linksetUse != LLPathfindingLinkset::kUnknown) + if (pLinksetUse != LLPathfindingLinkset::kUnknown) { - std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected(); - if (!selectedItems.empty()) + LLPathfindingObjectListPtr selectedObjects = getSelectedObjects(); + if ((selectedObjects != NULL) && !selectedObjects->isEmpty()) { - for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); - !showWarning && (selectedItemIter != selectedItems.end()); ++selectedItemIter) - { - const LLScrollListItem *selectedItem = *selectedItemIter; - llassert(mLinksetsListPtr != NULL); - LLPathfindingLinksetList::const_iterator linksetIter = mLinksetsListPtr->find(selectedItem->getUUID().asString()); - llassert(linksetIter != mLinksetsListPtr->end()); - const LLPathfindingLinksetPtr linksetPtr = linksetIter->second; - showWarning = linksetPtr->isShowUnmodifiablePhantomWarning(linksetUse); - } - } - } - - return showWarning; -} - -bool LLFloaterPathfindingLinksets::isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse linksetUse) const -{ - bool showWarning = false; - - if (linksetUse != LLPathfindingLinkset::kUnknown) - { - std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); - !showWarning && (selectedItemIter != selectedItems.end()); ++selectedItemIter) - { - const LLScrollListItem *selectedItem = *selectedItemIter; - llassert(mLinksetsListPtr != NULL); - LLPathfindingLinksetList::const_iterator linksetIter = mLinksetsListPtr->find(selectedItem->getUUID().asString()); - llassert(linksetIter != mLinksetsListPtr->end()); - const LLPathfindingLinksetPtr linksetPtr = linksetIter->second; - showWarning = linksetPtr->isShowCannotBeVolumeWarning(linksetUse); - } + const LLPathfindingLinksetList *linksetList = dynamic_cast<const LLPathfindingLinksetList *>(selectedObjects.get()); + isShowWarning = linksetList->isShowUnmodifiablePhantomWarning(pLinksetUse); } } - return showWarning; + return isShowWarning; } -void LLFloaterPathfindingLinksets::updateStatusMessage() +bool LLFloaterPathfindingLinksets::isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const { - static const LLColor4 errorColor = LLUIColorTable::instance().getColor("PathfindingErrorColor"); - static const LLColor4 warningColor = LLUIColorTable::instance().getColor("PathfindingWarningColor"); - - std::string statusText(""); - LLStyle::Params styleParams; + bool isShowWarning = false; - switch (getMessagingState()) + if (pLinksetUse != LLPathfindingLinkset::kUnknown) { - case kMessagingUnknown: - statusText = getString("linksets_messaging_initial"); - styleParams.color = errorColor; - break; - case kMessagingGetRequestSent : - statusText = getString("linksets_messaging_get_inprogress"); - styleParams.color = warningColor; - break; - case kMessagingGetError : - statusText = getString("linksets_messaging_get_error"); - styleParams.color = errorColor; - break; - case kMessagingSetRequestSent : - statusText = getString("linksets_messaging_set_inprogress"); - styleParams.color = warningColor; - break; - case kMessagingSetError : - statusText = getString("linksets_messaging_set_error"); - styleParams.color = errorColor; - break; - case kMessagingComplete : - if (mLinksetsScrollList->isEmpty()) - { - statusText = getString("linksets_messaging_complete_none_found"); - } - else + LLPathfindingObjectListPtr selectedObjects = getSelectedObjects(); + if ((selectedObjects != NULL) && !selectedObjects->isEmpty()) { - S32 numItems = mLinksetsScrollList->getItemCount(); - S32 numSelectedItems = mLinksetsScrollList->getNumSelected(); - - LLLocale locale(LLStringUtil::getLocale()); - std::string numItemsString; - LLResMgr::getInstance()->getIntegerString(numItemsString, numItems); - - std::string numSelectedItemsString; - LLResMgr::getInstance()->getIntegerString(numSelectedItemsString, numSelectedItems); - - LLStringUtil::format_map_t string_args; - string_args["[NUM_SELECTED]"] = numSelectedItemsString; - string_args["[NUM_TOTAL]"] = numItemsString; - statusText = getString("linksets_messaging_complete_available", string_args); + const LLPathfindingLinksetList *linksetList = dynamic_cast<const LLPathfindingLinksetList *>(selectedObjects.get()); + isShowWarning = linksetList->isShowCannotBeVolumeWarning(pLinksetUse); } - break; - case kMessagingNotEnabled : - statusText = getString("linksets_messaging_not_enabled"); - styleParams.color = errorColor; - break; - default: - statusText = getString("linksets_messaging_initial"); - styleParams.color = errorColor; - llassert(0); - break; } - mLinksetsStatus->setText((LLStringExplicit)statusText, styleParams); + return isShowWarning; } -void LLFloaterPathfindingLinksets::updateEnableStateOnListActions() +void LLFloaterPathfindingLinksets::updateStateOnEditFields() { - switch (getMessagingState()) - { - case kMessagingUnknown: - case kMessagingGetRequestSent : - case kMessagingSetRequestSent : - mRefreshListButton->setEnabled(FALSE); - mSelectAllButton->setEnabled(FALSE); - mSelectNoneButton->setEnabled(FALSE); - break; - case kMessagingGetError : - case kMessagingSetError : - case kMessagingNotEnabled : - mRefreshListButton->setEnabled(TRUE); - mSelectAllButton->setEnabled(FALSE); - mSelectNoneButton->setEnabled(FALSE); - break; - case kMessagingComplete : - { - int numItems = mLinksetsScrollList->getItemCount(); - int numSelectedItems = mLinksetsScrollList->getNumSelected(); - mRefreshListButton->setEnabled(TRUE); - mSelectAllButton->setEnabled(numSelectedItems < numItems); - mSelectNoneButton->setEnabled(numSelectedItems > 0); - } - break; - default: - llassert(0); - break; - } -} - -void LLFloaterPathfindingLinksets::updateEnableStateOnEditFields() -{ - int numSelectedItems = mLinksetsScrollList->getNumSelected(); + int numSelectedItems = getNumSelectedObjects(); bool isEditEnabled = ((numSelectedItems > 0) && LLPathfindingManager::getInstance()->isAllowAlterPermanent()); - mShowBeaconCheckBox->setEnabled(numSelectedItems > 0); - mTakeButton->setEnabled(isEditEnabled && visible_take_object()); - mTakeCopyButton->setEnabled(isEditEnabled && enable_object_take_copy()); - mReturnButton->setEnabled(isEditEnabled && enable_object_return()); - mDeleteButton->setEnabled(isEditEnabled && enable_object_delete()); - mTeleportButton->setEnabled(numSelectedItems == 1); - mEditLinksetUse->setEnabled(isEditEnabled); mLabelWalkabilityCoefficients->setEnabled(isEditEnabled); @@ -973,7 +549,7 @@ void LLFloaterPathfindingLinksets::updateEnableStateOnEditFields() mApplyEditsButton->setEnabled(isEditEnabled && (getMessagingState() == kMessagingComplete)); } -void LLFloaterPathfindingLinksets::updateEnableStateOnEditLinksetUse() +void LLFloaterPathfindingLinksets::updateStateOnEditLinksetUse() { BOOL useWalkable = FALSE; BOOL useStaticObstacle = FALSE; @@ -982,54 +558,11 @@ void LLFloaterPathfindingLinksets::updateEnableStateOnEditLinksetUse() BOOL useExclusionVolume = FALSE; BOOL useDynamicPhantom = FALSE; - std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected(); - if (!selectedItems.empty()) + LLPathfindingObjectListPtr selectedObjects = getSelectedObjects(); + if ((selectedObjects != NULL) && !selectedObjects->isEmpty()) { - for (std::vector<LLScrollListItem*>::const_iterator selectedItemIter = selectedItems.begin(); - !(useWalkable && useStaticObstacle && useDynamicObstacle && useMaterialVolume && useExclusionVolume && useDynamicPhantom) && (selectedItemIter != selectedItems.end()); - ++selectedItemIter) - { - const LLScrollListItem *selectedItem = *selectedItemIter; - llassert(mLinksetsListPtr != NULL); - LLPathfindingLinksetList::const_iterator linksetIter = mLinksetsListPtr->find(selectedItem->getUUID().asString()); - llassert(linksetIter != mLinksetsListPtr->end()); - const LLPathfindingLinksetPtr linksetPtr = linksetIter->second; - - if (linksetPtr->isTerrain()) - { - useWalkable = TRUE; - } - else - { - if (linksetPtr->isModifiable()) - { - useWalkable = TRUE; - useStaticObstacle = TRUE; - useDynamicObstacle = TRUE; - useDynamicPhantom = TRUE; - if (linksetPtr->canBeVolume()) - { - useMaterialVolume = TRUE; - useExclusionVolume = TRUE; - } - } - else if (linksetPtr->isPhantom()) - { - useDynamicPhantom = TRUE; - if (linksetPtr->canBeVolume()) - { - useMaterialVolume = TRUE; - useExclusionVolume = TRUE; - } - } - else - { - useWalkable = TRUE; - useStaticObstacle = TRUE; - useDynamicObstacle = TRUE; - } - } - } + const LLPathfindingLinksetList *linksetList = dynamic_cast<const LLPathfindingLinksetList *>(selectedObjects.get()); + linksetList->determinePossibleStates(useWalkable, useStaticObstacle, useDynamicObstacle, useMaterialVolume, useExclusionVolume, useDynamicPhantom); } mEditLinksetUseWalkable->setEnabled(useWalkable); @@ -1085,8 +618,8 @@ void LLFloaterPathfindingLinksets::handleApplyEdit(const LLSD &pNotification, co void LLFloaterPathfindingLinksets::doApplyEdit() { - std::vector<LLScrollListItem*> selectedItems = mLinksetsScrollList->getAllSelected(); - if (!selectedItems.empty()) + LLPathfindingObjectListPtr selectedObjects = getSelectedObjects(); + if ((selectedObjects != NULL) && !selectedObjects->isEmpty()) { LLPathfindingLinkset::ELinksetUse linksetUse = getEditLinksetUse(); const std::string &aString = mEditA->getText(); @@ -1098,21 +631,8 @@ void LLFloaterPathfindingLinksets::doApplyEdit() S32 cValue = static_cast<S32>(atoi(cString.c_str())); S32 dValue = static_cast<S32>(atoi(dString.c_str())); - LLPathfindingLinksetListPtr editListPtr(new LLPathfindingLinksetList()); - for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin(); - itemIter != selectedItems.end(); ++itemIter) - { - const LLScrollListItem *listItem = *itemIter; - LLUUID uuid = listItem->getUUID(); - const std::string &uuidString = uuid.asString(); - llassert(mLinksetsListPtr != NULL); - LLPathfindingLinksetList::iterator linksetIter = mLinksetsListPtr->find(uuidString); - llassert(linksetIter != mLinksetsListPtr->end()); - LLPathfindingLinksetPtr linksetPtr = linksetIter->second; - editListPtr->insert(std::pair<std::string, LLPathfindingLinksetPtr>(uuidString, linksetPtr)); - } - requestSetLinksets(editListPtr, linksetUse, aValue, bValue, cValue, dValue); + requestSetLinksets(selectedObjects, linksetUse, aValue, bValue, cValue, dValue); } } diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h index 0fa4d9aac9..bad803f420 100644 --- a/indra/newview/llfloaterpathfindinglinksets.h +++ b/indra/newview/llfloaterpathfindinglinksets.h @@ -28,142 +28,70 @@ #ifndef LL_LLFLOATERPATHFINDINGLINKSETS_H #define LL_LLFLOATERPATHFINDINGLINKSETS_H -#include "llfloater.h" -#include "lluuid.h" -#include "llselectmgr.h" +#include "llfloaterpathfindingobjects.h" #include "llpathfindinglinkset.h" -#include "llpathfindinglinksetlist.h" #include "llpathfindingmanager.h" +#include "llpathfindingobjectlist.h" +#include "v4color.h" -#include <boost/signals2.hpp> - +class LLButton; +class LLComboBox; +class LLLineEditor; +class LLScrollListItem; class LLSD; -class LLUICtrl; class LLTextBase; -class LLScrollListCtrl; -class LLScrollListItem; -class LLLineEditor; -class LLComboBox; -class LLCheckBoxCtrl; -class LLButton; +class LLUICtrl; -class LLFloaterPathfindingLinksets -: public LLFloater +class LLFloaterPathfindingLinksets : public LLFloaterPathfindingObjects { - friend class LLFloaterReg; - public: - typedef enum - { - kMessagingUnknown, - kMessagingGetRequestSent, - kMessagingGetError, - kMessagingSetRequestSent, - kMessagingSetError, - kMessagingComplete, - kMessagingNotEnabled - } EMessagingState; - - virtual BOOL postBuild(); + virtual void onOpen(const LLSD& pKey); - virtual void onClose(bool pAppQuitting); - virtual void draw(); + virtual void onClose(bool pIsAppQuitting); - static void openLinksetsEditor(); + static void openLinksetsEditor(); protected: + friend class LLFloaterReg; -private: - LLLineEditor *mFilterByName; - LLLineEditor *mFilterByDescription; - LLComboBox *mFilterByLinksetUse; - LLScrollListCtrl *mLinksetsScrollList; - LLTextBase *mLinksetsStatus; - LLButton *mRefreshListButton; - LLButton *mSelectAllButton; - LLButton *mSelectNoneButton; - LLCheckBoxCtrl *mShowBeaconCheckBox; - LLButton *mTakeButton; - LLButton *mTakeCopyButton; - LLButton *mReturnButton; - LLButton *mDeleteButton; - LLButton *mTeleportButton; - LLComboBox *mEditLinksetUse; - LLScrollListItem *mEditLinksetUseUnset; - LLScrollListItem *mEditLinksetUseWalkable; - LLScrollListItem *mEditLinksetUseStaticObstacle; - LLScrollListItem *mEditLinksetUseDynamicObstacle; - LLScrollListItem *mEditLinksetUseMaterialVolume; - LLScrollListItem *mEditLinksetUseExclusionVolume; - LLScrollListItem *mEditLinksetUseDynamicPhantom; - LLTextBase *mLabelWalkabilityCoefficients; - LLTextBase *mLabelEditA; - LLLineEditor *mEditA; - LLTextBase *mLabelEditB; - LLLineEditor *mEditB; - LLTextBase *mLabelEditC; - LLLineEditor *mEditC; - LLTextBase *mLabelEditD; - LLLineEditor *mEditD; - LLButton *mApplyEditsButton; - - EMessagingState mMessagingState; - LLPathfindingManager::request_id_t mMessagingRequestId; - LLPathfindingLinksetListPtr mLinksetsListPtr; - LLObjectSelectionHandle mLinksetsSelection; - LLPathfindingManager::agent_state_slot_t mAgentStateSlot; - boost::signals2::connection mSelectionUpdateSlot; - boost::signals2::connection mRegionBoundarySlot; - - // Does its own instance management, so clients not allowed - // to allocate or destroy. LLFloaterPathfindingLinksets(const LLSD& pSeed); virtual ~LLFloaterPathfindingLinksets(); - EMessagingState getMessagingState() const; - void setMessagingState(EMessagingState pMessagingState); + virtual BOOL postBuild(); + + virtual void requestGetObjects(); + + virtual LLSD convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const; + + virtual void updateControls(); + virtual void updateSelection(); - void requestGetLinksets(); - void requestSetLinksets(LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD); - void handleNewLinksets(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pLinksetsRequestStatus, LLPathfindingLinksetListPtr pLinksetsListPtr); - void handleUpdateLinksets(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pLinksetsRequestStatus, LLPathfindingLinksetListPtr pLinksetsListPtr); + virtual S32 getNameColumnIndex() const; + virtual const LLColor4 &getBeaconColor() const; + + virtual LLPathfindingObjectListPtr getEmptyObjectList() const; + +private: + void requestSetLinksets(LLPathfindingObjectListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD); void onApplyAllFilters(); void onClearFiltersClicked(); - void onLinksetsSelectionChange(); - void onRefreshLinksetsClicked(); - void onSelectAllLinksetsClicked(); - void onSelectNoneLinksetsClicked(); - void onTakeClicked(); - void onTakeCopyClicked(); - void onReturnClicked(); - void onDeleteClicked(); - void onTeleportClicked(); void onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl); void onApplyChangesClicked(); - void onAgentStateCB(LLPathfindingManager::EAgentState pAgentState); - void onRegionBoundaryCross(); + void onAgentStateChange(LLPathfindingManager::EAgentState pAgentState); void applyFilters(); void clearFilters(); - void selectAllLinksets(); - void selectNoneLinksets(); - void clearLinksets(); - - void updateControls(); void updateEditFieldValues(); - void updateScrollList(); - LLSD buildLinksetScrollListElement(const LLPathfindingLinksetPtr pLinksetPtr, const LLVector3 &pAvatarPosition) const; - LLSD buildLinksetUseScrollListElement(const std::string &label, S32 value) const; + LLSD buildLinksetScrollListData(const LLPathfindingLinkset *pLinksetPtr, const LLVector3 &pAvatarPosition) const; + LLSD buildLinksetUseScrollListData(const std::string &pLabel, S32 pValue) const; - bool isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse linksetUse) const; - bool isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse linksetUse) const; + bool isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const; + bool isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const; - void updateStatusMessage(); - void updateEnableStateOnListActions(); - void updateEnableStateOnEditFields(); - void updateEnableStateOnEditLinksetUse(); + void updateStateOnEditFields(); + void updateStateOnEditLinksetUse(); void applyEdit(); void handleApplyEdit(const LLSD &pNotification, const LLSD &pResponse); @@ -179,6 +107,32 @@ private: LLPathfindingLinkset::ELinksetUse convertToLinksetUse(LLSD pXuiValue) const; LLSD convertToXuiValue(LLPathfindingLinkset::ELinksetUse pLinksetUse) const; + + LLLineEditor *mFilterByName; + LLLineEditor *mFilterByDescription; + LLComboBox *mFilterByLinksetUse; + LLComboBox *mEditLinksetUse; + LLScrollListItem *mEditLinksetUseUnset; + LLScrollListItem *mEditLinksetUseWalkable; + LLScrollListItem *mEditLinksetUseStaticObstacle; + LLScrollListItem *mEditLinksetUseDynamicObstacle; + LLScrollListItem *mEditLinksetUseMaterialVolume; + LLScrollListItem *mEditLinksetUseExclusionVolume; + LLScrollListItem *mEditLinksetUseDynamicPhantom; + LLTextBase *mLabelWalkabilityCoefficients; + LLTextBase *mLabelEditA; + LLLineEditor *mEditA; + LLTextBase *mLabelEditB; + LLLineEditor *mEditB; + LLTextBase *mLabelEditC; + LLLineEditor *mEditC; + LLTextBase *mLabelEditD; + LLLineEditor *mEditD; + LLButton *mApplyEditsButton; + + LLColor4 mBeaconColor; + + LLPathfindingManager::agent_state_slot_t mAgentStateSlot; }; #endif // LL_LLFLOATERPATHFINDINGLINKSETS_H diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp new file mode 100644 index 0000000000..3b3de3f417 --- /dev/null +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -0,0 +1,680 @@ +/** +* @file llfloaterpathfindingobjects.cpp +* @brief Implementation of llfloaterpathfindingobjects +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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 "llfloaterpathfindingobjects.h" + +#include <vector> + +#include <boost/bind.hpp> +#include <boost/signals2.hpp> + +#include "v4color.h" + +#include "llagent.h" +#include "llbutton.h" +#include "llcheckboxctrl.h" +#include "llcombobox.h" +#include "llenvmanager.h" +#include "lllineeditor.h" +#include "llfloater.h" +#include "llpathfindingmanager.h" +#include "llresmgr.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "llselectmgr.h" +#include "llsd.h" +#include "llstring.h" +#include "llstyle.h" +#include "lltextbase.h" +#include "lluicolortable.h" +#include "llviewermenu.h" +#include "llviewerobject.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" + +#define DEFAULT_BEACON_WIDTH 6 + +//--------------------------------------------------------------------------- +// LLFloaterPathfindingObjects +//--------------------------------------------------------------------------- + +void LLFloaterPathfindingObjects::onOpen(const LLSD &pKey) +{ + LLFloater::onOpen(pKey); + + selectNoneObjects(); + mObjectsScrollList->setCommitOnSelectionChange(TRUE); + + if (!mSelectionUpdateSlot.connected()) + { + mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingObjects::onSelectionListChanged, this)); + } + + if (!mRegionBoundaryCrossingSlot.connected()) + { + mRegionBoundaryCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLFloaterPathfindingObjects::onRegionBoundaryCrossed, this)); + } + + requestGetObjects(); +} + +void LLFloaterPathfindingObjects::onClose(bool pIsAppQuitting) +{ + if (mRegionBoundaryCrossingSlot.connected()) + { + mRegionBoundaryCrossingSlot.disconnect(); + } + + if (mSelectionUpdateSlot.connected()) + { + mSelectionUpdateSlot.disconnect(); + } + + mObjectsScrollList->setCommitOnSelectionChange(FALSE); + selectNoneObjects(); + + if (mObjectsSelection.notNull()) + { + mObjectsSelection.clear(); + } +} + +void LLFloaterPathfindingObjects::draw() +{ + LLFloater::draw(); + + if (isShowBeacons()) + { + std::vector<LLScrollListItem *> selectedItems = mObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + S32 nameColumnIndex = getNameColumnIndex(); + const LLColor4 &beaconColor = getBeaconColor(); + const LLColor4 &beaconTextColor = getBeaconTextColor(); + S32 beaconWidth = getBeaconWidth(); + + std::vector<LLViewerObject *> viewerObjects; + viewerObjects.reserve(numSelectedItems); + + for (std::vector<LLScrollListItem *>::const_iterator selectedItemIter = selectedItems.begin(); + selectedItemIter != selectedItems.end(); ++selectedItemIter) + { + const LLScrollListItem *selectedItem = *selectedItemIter; + + LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID()); + if (viewerObject != NULL) + { + const std::string &objectName = selectedItem->getColumn(nameColumnIndex)->getValue().asString(); + gObjectList.addDebugBeacon(viewerObject->getPositionAgent(), objectName, beaconColor, beaconTextColor, beaconWidth); + } + } + } + } +} + +LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) + : LLFloater(pSeed), + mObjectsScrollList(NULL), + mMessagingStatus(NULL), + mRefreshListButton(NULL), + mSelectAllButton(NULL), + mSelectNoneButton(NULL), + mShowBeaconCheckBox(NULL), + mTakeButton(NULL), + mTakeCopyButton(NULL), + mReturnButton(NULL), + mDeleteButton(NULL), + mTeleportButton(NULL), + mDefaultBeaconColor(), + mDefaultBeaconTextColor(), + mErrorTextColor(), + mWarningTextColor(), + mMessagingState(kMessagingUnknown), + mMessagingRequestId(0U), + mObjectList(), + mObjectsSelection(), + mSelectionUpdateSlot(), + mRegionBoundaryCrossingSlot() +{ +} + +LLFloaterPathfindingObjects::~LLFloaterPathfindingObjects() +{ +} + +BOOL LLFloaterPathfindingObjects::postBuild() +{ + mDefaultBeaconColor = LLUIColorTable::getInstance()->getColor("PathfindingDefaultBeaconColor"); + mDefaultBeaconTextColor = LLUIColorTable::getInstance()->getColor("PathfindingDefaultBeaconTextColor"); + mErrorTextColor = LLUIColorTable::getInstance()->getColor("PathfindingErrorColor"); + mWarningTextColor = LLUIColorTable::getInstance()->getColor("PathfindingWarningColor"); + + mObjectsScrollList = findChild<LLScrollListCtrl>("objects_scroll_list"); + llassert(mObjectsScrollList != NULL); + mObjectsScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onScrollListSelectionChanged, this)); + mObjectsScrollList->sortByColumnIndex(static_cast<U32>(getNameColumnIndex()), TRUE); + + mMessagingStatus = findChild<LLTextBase>("messaging_status"); + llassert(mMessagingStatus != NULL); + + mRefreshListButton = findChild<LLButton>("refresh_objects_list"); + llassert(mRefreshListButton != NULL); + mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onRefreshObjectsClicked, this)); + + mSelectAllButton = findChild<LLButton>("select_all_objects"); + llassert(mSelectAllButton != NULL); + mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onSelectAllObjectsClicked, this)); + + mSelectNoneButton = findChild<LLButton>("select_none_objects"); + llassert(mSelectNoneButton != NULL); + mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onSelectNoneObjectsClicked, this)); + + mShowBeaconCheckBox = findChild<LLCheckBoxCtrl>("show_beacon"); + llassert(mShowBeaconCheckBox != NULL); + + mTakeButton = findChild<LLButton>("take_objects"); + llassert(mTakeButton != NULL); + mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeClicked, this)); + + mTakeCopyButton = findChild<LLButton>("take_copy_objects"); + llassert(mTakeCopyButton != NULL); + mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeCopyClicked, this)); + + mReturnButton = findChild<LLButton>("return_objects"); + llassert(mReturnButton != NULL); + mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onReturnClicked, this)); + + mDeleteButton = findChild<LLButton>("delete_objects"); + llassert(mDeleteButton != NULL); + mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onDeleteClicked, this)); + + mTeleportButton = findChild<LLButton>("teleport_me_to_object"); + llassert(mTeleportButton != NULL); + mTeleportButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTeleportClicked, this)); + + return LLFloater::postBuild(); +} + +void LLFloaterPathfindingObjects::requestGetObjects() +{ +} + +LLPathfindingManager::request_id_t LLFloaterPathfindingObjects::getNewRequestId() +{ + return ++mMessagingRequestId; +} + +void LLFloaterPathfindingObjects::handleNewObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList) +{ + llassert(pRequestId <= mMessagingRequestId); + if (pRequestId == mMessagingRequestId) + { + switch (pRequestStatus) + { + case LLPathfindingManager::kRequestStarted : + setMessagingState(kMessagingGetRequestSent); + break; + case LLPathfindingManager::kRequestCompleted : + mObjectList = pObjectList; + rebuildObjectsScrollList(); + setMessagingState(kMessagingComplete); + break; + case LLPathfindingManager::kRequestNotEnabled : + clearAllObjects(); + setMessagingState(kMessagingNotEnabled); + break; + case LLPathfindingManager::kRequestError : + clearAllObjects(); + setMessagingState(kMessagingGetError); + break; + default : + clearAllObjects(); + setMessagingState(kMessagingGetError); + llassert(0); + break; + } + } +} + +void LLFloaterPathfindingObjects::handleUpdateObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList) +{ + llassert(pRequestId <= mMessagingRequestId); + if (pRequestId == mMessagingRequestId) + { + switch (pRequestStatus) + { + case LLPathfindingManager::kRequestStarted : + setMessagingState(kMessagingGetRequestSent); + break; + case LLPathfindingManager::kRequestCompleted : + if (mObjectList == NULL) + { + mObjectList = pObjectList; + } + else + { + mObjectList->update(pObjectList); + } + rebuildObjectsScrollList(); + setMessagingState(kMessagingComplete); + break; + case LLPathfindingManager::kRequestNotEnabled : + clearAllObjects(); + setMessagingState(kMessagingNotEnabled); + break; + case LLPathfindingManager::kRequestError : + setMessagingState(kMessagingGetError); + break; + default : + setMessagingState(kMessagingGetError); + llassert(0); + break; + } + } +} + +void LLFloaterPathfindingObjects::rebuildObjectsScrollList() +{ + std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected(); + int numSelectedItems = selectedItems.size(); + uuid_vec_t selectedUUIDs; + if (numSelectedItems > 0) + { + selectedUUIDs.reserve(selectedItems.size()); + for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin(); + itemIter != selectedItems.end(); ++itemIter) + { + const LLScrollListItem *listItem = *itemIter; + selectedUUIDs.push_back(listItem->getUUID()); + } + } + + S32 origScrollPosition = mObjectsScrollList->getScrollPos(); + mObjectsScrollList->deleteAllItems(); + + if ((mObjectList != NULL) && !mObjectList->isEmpty()) + { + LLSD scrollListData = convertObjectsIntoScrollListData(mObjectList); + llassert(scrollListData.isArray()); + for (LLSD::array_const_iterator elementIter = scrollListData.beginArray(); elementIter != scrollListData.endArray(); ++elementIter) + { + const LLSD &element = *elementIter; + mObjectsScrollList->addElement(element); + } + } + + mObjectsScrollList->selectMultiple(selectedUUIDs); + mObjectsScrollList->setScrollPos(origScrollPosition); + updateControls(); +} + +LLSD LLFloaterPathfindingObjects::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const +{ + llassert(0); + LLSD nullObjs = LLSD::emptyArray(); + return nullObjs; +} + +void LLFloaterPathfindingObjects::updateControls() +{ + updateMessagingStatus(); + updateStateOnListActionControls(); + updateStateOnEditFields(); +} + +void LLFloaterPathfindingObjects::updateSelection() +{ + mObjectsSelection.clear(); + LLSelectMgr::getInstance()->deselectAll(); + + std::vector<LLScrollListItem *> selectedItems = mObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + + std::vector<LLViewerObject *>viewerObjects; + viewerObjects.reserve(numSelectedItems); + + for (std::vector<LLScrollListItem *>::const_iterator selectedItemIter = selectedItems.begin(); + selectedItemIter != selectedItems.end(); ++selectedItemIter) + { + const LLScrollListItem *selectedItem = *selectedItemIter; + + LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID()); + if (viewerObject != NULL) + { + viewerObjects.push_back(viewerObject); + } + } + + if (!viewerObjects.empty()) + { + mObjectsSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); + } + } + + updateControls(); +} + +S32 LLFloaterPathfindingObjects::getNameColumnIndex() const +{ + return 0; +} + +const LLColor4 &LLFloaterPathfindingObjects::getBeaconColor() const +{ + return mDefaultBeaconColor; +} + +const LLColor4 &LLFloaterPathfindingObjects::getBeaconTextColor() const +{ + return mDefaultBeaconTextColor; +} + +S32 LLFloaterPathfindingObjects::getBeaconWidth() const +{ + return DEFAULT_BEACON_WIDTH; +} + +BOOL LLFloaterPathfindingObjects::isShowBeacons() const +{ + return mShowBeaconCheckBox->get(); +} + +void LLFloaterPathfindingObjects::clearAllObjects() +{ + selectNoneObjects(); + mObjectsScrollList->clear(); + mObjectList.reset(); +} + +void LLFloaterPathfindingObjects::selectAllObjects() +{ + mObjectsScrollList->selectAll(); +} + +void LLFloaterPathfindingObjects::selectNoneObjects() +{ + mObjectsScrollList->deselectAllItems(); +} + +void LLFloaterPathfindingObjects::teleportToSelectedObject() +{ + std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected(); + llassert(selectedItems.size() == 1); + if (selectedItems.size() == 1) + { + std::vector<LLScrollListItem*>::const_reference selectedItemRef = selectedItems.front(); + const LLScrollListItem *selectedItem = selectedItemRef; + llassert(mObjectList != NULL); + const LLPathfindingObjectPtr objectPtr = mObjectList->find(selectedItem->getUUID().asString()); + const LLVector3 &objectLocation = objectPtr->getLocation(); + + LLViewerRegion* region = gAgent.getRegion(); + if (region != NULL) + { + gAgent.teleportRequest(region->getHandle(), objectLocation, true); + } + } +} + +LLPathfindingObjectListPtr LLFloaterPathfindingObjects::getEmptyObjectList() const +{ + llassert(0); + LLPathfindingObjectListPtr objectListPtr(new LLPathfindingObjectList()); + return objectListPtr; +} + +int LLFloaterPathfindingObjects::getNumSelectedObjects() const +{ + return mObjectsScrollList->getNumSelected(); +} + +LLPathfindingObjectListPtr LLFloaterPathfindingObjects::getSelectedObjects() const +{ + LLPathfindingObjectListPtr selectedObjects = getEmptyObjectList(); + + std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin(); + itemIter != selectedItems.end(); ++itemIter) + { + LLPathfindingObjectPtr objectPtr = findObject(*itemIter); + if (objectPtr != NULL) + { + selectedObjects->update(objectPtr); + } + } + } + + return selectedObjects; +} + +LLPathfindingObjectPtr LLFloaterPathfindingObjects::getFirstSelectedObject() const +{ + LLPathfindingObjectPtr objectPtr; + + std::vector<LLScrollListItem*> selectedItems = mObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + objectPtr = findObject(selectedItems.front()); + } + + return objectPtr; +} + +LLFloaterPathfindingObjects::EMessagingState LLFloaterPathfindingObjects::getMessagingState() const +{ + return mMessagingState; +} + +void LLFloaterPathfindingObjects::setMessagingState(EMessagingState pMessagingState) +{ + mMessagingState = pMessagingState; + updateControls(); +} + +void LLFloaterPathfindingObjects::onRefreshObjectsClicked() +{ + requestGetObjects(); +} + +void LLFloaterPathfindingObjects::onSelectAllObjectsClicked() +{ + selectAllObjects(); +} + +void LLFloaterPathfindingObjects::onSelectNoneObjectsClicked() +{ + selectNoneObjects(); +} + +void LLFloaterPathfindingObjects::onTakeClicked() +{ + handle_take(); +} + +void LLFloaterPathfindingObjects::onTakeCopyClicked() +{ + handle_take_copy(); +} + +void LLFloaterPathfindingObjects::onReturnClicked() +{ + handle_object_return(); +} + +void LLFloaterPathfindingObjects::onDeleteClicked() +{ + handle_object_delete(); +} + +void LLFloaterPathfindingObjects::onTeleportClicked() +{ + teleportToSelectedObject(); +} + +void LLFloaterPathfindingObjects::onScrollListSelectionChanged() +{ + updateSelection(); +} + +void LLFloaterPathfindingObjects::onSelectionListChanged() +{ + updateControls(); +} + +void LLFloaterPathfindingObjects::onRegionBoundaryCrossed() +{ + requestGetObjects(); +} + +void LLFloaterPathfindingObjects::updateMessagingStatus() +{ + std::string statusText(""); + LLStyle::Params styleParams; + + switch (getMessagingState()) + { + case kMessagingUnknown: + statusText = getString("messaging_initial"); + styleParams.color = mErrorTextColor; + break; + case kMessagingGetRequestSent : + statusText = getString("messaging_get_inprogress"); + styleParams.color = mWarningTextColor; + break; + case kMessagingGetError : + statusText = getString("messaging_get_error"); + styleParams.color = mErrorTextColor; + break; + case kMessagingSetRequestSent : + statusText = getString("messaging_set_inprogress"); + styleParams.color = mWarningTextColor; + break; + case kMessagingSetError : + statusText = getString("messaging_set_error"); + styleParams.color = mErrorTextColor; + break; + case kMessagingComplete : + if (mObjectsScrollList->isEmpty()) + { + statusText = getString("messaging_complete_none_found"); + } + else + { + S32 numItems = mObjectsScrollList->getItemCount(); + S32 numSelectedItems = mObjectsScrollList->getNumSelected(); + + LLLocale locale(LLStringUtil::getLocale()); + std::string numItemsString; + LLResMgr::getInstance()->getIntegerString(numItemsString, numItems); + + std::string numSelectedItemsString; + LLResMgr::getInstance()->getIntegerString(numSelectedItemsString, numSelectedItems); + + LLStringUtil::format_map_t string_args; + string_args["[NUM_SELECTED]"] = numSelectedItemsString; + string_args["[NUM_TOTAL]"] = numItemsString; + statusText = getString("messaging_complete_available", string_args); + } + break; + case kMessagingNotEnabled : + statusText = getString("messaging_not_enabled"); + styleParams.color = mErrorTextColor; + break; + default: + statusText = getString("messaging_initial"); + styleParams.color = mErrorTextColor; + llassert(0); + break; + } + + mMessagingStatus->setText((LLStringExplicit)statusText, styleParams); +} + +void LLFloaterPathfindingObjects::updateStateOnListActionControls() +{ + switch (getMessagingState()) + { + case kMessagingUnknown: + case kMessagingGetRequestSent : + case kMessagingSetRequestSent : + mRefreshListButton->setEnabled(FALSE); + mSelectAllButton->setEnabled(FALSE); + mSelectNoneButton->setEnabled(FALSE); + break; + case kMessagingGetError : + case kMessagingSetError : + case kMessagingNotEnabled : + mRefreshListButton->setEnabled(TRUE); + mSelectAllButton->setEnabled(FALSE); + mSelectNoneButton->setEnabled(FALSE); + break; + case kMessagingComplete : + { + int numItems = mObjectsScrollList->getItemCount(); + int numSelectedItems = mObjectsScrollList->getNumSelected(); + mRefreshListButton->setEnabled(TRUE); + mSelectAllButton->setEnabled(numSelectedItems < numItems); + mSelectNoneButton->setEnabled(numSelectedItems > 0); + } + break; + default: + llassert(0); + break; + } +} + +void LLFloaterPathfindingObjects::updateStateOnEditFields() +{ + int numSelectedItems = mObjectsScrollList->getNumSelected(); + bool isEditEnabled = (numSelectedItems > 0); + + mShowBeaconCheckBox->setEnabled(isEditEnabled); + mTakeButton->setEnabled(isEditEnabled && visible_take_object()); + mTakeCopyButton->setEnabled(isEditEnabled && enable_object_take_copy()); + mReturnButton->setEnabled(isEditEnabled && enable_object_return()); + mDeleteButton->setEnabled(isEditEnabled && enable_object_delete()); + mTeleportButton->setEnabled(numSelectedItems == 1); +} + +LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollListItem *pListItem) const +{ + LLPathfindingObjectPtr objectPtr; + + LLUUID uuid = pListItem->getUUID(); + const std::string &uuidString = uuid.asString(); + llassert(mObjectList != NULL); + objectPtr = mObjectList->find(uuidString); + + return objectPtr; +} diff --git a/indra/newview/llfloaterpathfindingobjects.h b/indra/newview/llfloaterpathfindingobjects.h new file mode 100644 index 0000000000..7fa7f89f51 --- /dev/null +++ b/indra/newview/llfloaterpathfindingobjects.h @@ -0,0 +1,152 @@ +/** +* @file llfloaterpathfindingobjects.h +* @brief Header file for llfloaterpathfindingobjects +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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$ +*/ +#ifndef LL_LLFLOATERPATHFINDINGOBJECTS_H +#define LL_LLFLOATERPATHFINDINGOBJECTS_H + +#include <boost/signals2.hpp> + +#include "llfloater.h" +#include "llpathfindingmanager.h" +#include "llpathfindingobject.h" +#include "llpathfindingobjectlist.h" +#include "llselectmgr.h" +#include "v4color.h" + +class LLButton; +class LLCheckBoxCtrl; +class LLScrollListCtrl; +class LLSD; +class LLTextBase; + +class LLFloaterPathfindingObjects : public LLFloater +{ +public: + virtual void onOpen(const LLSD &pKey); + virtual void onClose(bool pIsAppQuitting); + virtual void draw(); + +protected: + friend class LLFloaterReg; + + typedef enum + { + kMessagingUnknown, + kMessagingGetRequestSent, + kMessagingGetError, + kMessagingSetRequestSent, + kMessagingSetError, + kMessagingComplete, + kMessagingNotEnabled + } EMessagingState; + + LLFloaterPathfindingObjects(const LLSD &pSeed); + virtual ~LLFloaterPathfindingObjects(); + + virtual BOOL postBuild(); + + virtual void requestGetObjects(); + LLPathfindingManager::request_id_t getNewRequestId(); + void handleNewObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList); + void handleUpdateObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList); + + void rebuildObjectsScrollList(); + virtual LLSD convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const; + + virtual void updateControls(); + virtual void updateSelection(); + + virtual S32 getNameColumnIndex() const; + virtual const LLColor4 &getBeaconColor() const; + virtual const LLColor4 &getBeaconTextColor() const; + virtual S32 getBeaconWidth() const; + + BOOL isShowBeacons() const; + void clearAllObjects(); + void selectAllObjects(); + void selectNoneObjects(); + void teleportToSelectedObject(); + + virtual LLPathfindingObjectListPtr getEmptyObjectList() const; + int getNumSelectedObjects() const; + LLPathfindingObjectListPtr getSelectedObjects() const; + LLPathfindingObjectPtr getFirstSelectedObject() const; + + EMessagingState getMessagingState() const; + +private: + LLFloaterPathfindingObjects(const LLFloaterPathfindingObjects &pOther); + + void setMessagingState(EMessagingState pMessagingState); + + void onRefreshObjectsClicked(); + void onSelectAllObjectsClicked(); + void onSelectNoneObjectsClicked(); + void onTakeClicked(); + void onTakeCopyClicked(); + void onReturnClicked(); + void onDeleteClicked(); + void onTeleportClicked(); + + void onScrollListSelectionChanged(); + void onSelectionListChanged(); + void onRegionBoundaryCrossed(); + + void updateMessagingStatus(); + void updateStateOnListActionControls(); + void updateStateOnEditFields(); + + LLPathfindingObjectPtr findObject(const LLScrollListItem *pListItem) const; + + LLScrollListCtrl *mObjectsScrollList; + LLTextBase *mMessagingStatus; + LLButton *mRefreshListButton; + LLButton *mSelectAllButton; + LLButton *mSelectNoneButton; + LLCheckBoxCtrl *mShowBeaconCheckBox; + LLButton *mTakeButton; + LLButton *mTakeCopyButton; + LLButton *mReturnButton; + LLButton *mDeleteButton; + LLButton *mTeleportButton; + + LLColor4 mDefaultBeaconColor; + LLColor4 mDefaultBeaconTextColor; + LLColor4 mErrorTextColor; + LLColor4 mWarningTextColor; + + EMessagingState mMessagingState; + LLPathfindingManager::request_id_t mMessagingRequestId; + + LLPathfindingObjectListPtr mObjectList; + + LLObjectSelectionHandle mObjectsSelection; + + boost::signals2::connection mSelectionUpdateSlot; + boost::signals2::connection mRegionBoundaryCrossingSlot; +}; + +#endif // LL_LLFLOATERPATHFINDINGOBJECTS_H diff --git a/indra/newview/llpathfindingcharacter.cpp b/indra/newview/llpathfindingcharacter.cpp index 0a3d737b73..61c2e39d63 100644 --- a/indra/newview/llpathfindingcharacter.cpp +++ b/indra/newview/llpathfindingcharacter.cpp @@ -3,9 +3,9 @@ * @author William Todd Stinson * @brief Definition of a pathfinding character that contains various properties required for havok pathfinding. * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2012, 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 @@ -26,62 +26,28 @@ */ #include "llviewerprecompiledheaders.h" + #include "llpathfindingcharacter.h" + +#include "llpathfindingobject.h" #include "llsd.h" -#include "v3math.h" -#include "lluuid.h" -#include "llavatarname.h" -#include "llavatarnamecache.h" -#define CHARACTER_NAME_FIELD "name" -#define CHARACTER_DESCRIPTION_FIELD "description" -#define CHARACTER_OWNER_FIELD "owner" -#define CHARACTER_CPU_TIME_FIELD "cpu_time" -#define CHARACTER_POSITION_FIELD "position" +#define CHARACTER_CPU_TIME_FIELD "cpu_time" //--------------------------------------------------------------------------- // LLPathfindingCharacter //--------------------------------------------------------------------------- -LLPathfindingCharacter::LLPathfindingCharacter(const std::string &pUUID, const LLSD& pCharacterItem) - : mUUID(pUUID), - mName(), - mDescription(), - mOwnerUUID(), - mOwnerName(), - mCPUTime(0U), - mLocation(LLVector3::zero) +LLPathfindingCharacter::LLPathfindingCharacter(const std::string &pUUID, const LLSD& pCharacterData) + : LLPathfindingObject(pUUID, pCharacterData), + mCPUTime(0U) { - llassert(pCharacterItem.has(CHARACTER_NAME_FIELD)); - llassert(pCharacterItem.get(CHARACTER_NAME_FIELD).isString()); - mName = pCharacterItem.get(CHARACTER_NAME_FIELD).asString(); - - llassert(pCharacterItem.has(CHARACTER_DESCRIPTION_FIELD)); - llassert(pCharacterItem.get(CHARACTER_DESCRIPTION_FIELD).isString()); - mDescription = pCharacterItem.get(CHARACTER_DESCRIPTION_FIELD).asString(); - - llassert(pCharacterItem.has(CHARACTER_OWNER_FIELD)); - llassert(pCharacterItem.get(CHARACTER_OWNER_FIELD).isUUID()); - mOwnerUUID = pCharacterItem.get(CHARACTER_OWNER_FIELD).asUUID(); - LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); - - llassert(pCharacterItem.has(CHARACTER_CPU_TIME_FIELD)); - llassert(pCharacterItem.get(CHARACTER_CPU_TIME_FIELD).isReal()); - mCPUTime = pCharacterItem.get(CHARACTER_CPU_TIME_FIELD).asReal(); - - llassert(pCharacterItem.has(CHARACTER_POSITION_FIELD)); - llassert(pCharacterItem.get(CHARACTER_POSITION_FIELD).isArray()); - mLocation.setValue(pCharacterItem.get(CHARACTER_POSITION_FIELD)); + parseCharacterData(pCharacterData); } LLPathfindingCharacter::LLPathfindingCharacter(const LLPathfindingCharacter& pOther) - : mUUID(pOther.mUUID), - mName(pOther.mName), - mDescription(pOther.mDescription), - mOwnerUUID(pOther.mOwnerUUID), - mOwnerName(pOther.mOwnerName), - mCPUTime(pOther.mCPUTime), - mLocation(pOther.mLocation) + : LLPathfindingObject(pOther), + mCPUTime(pOther.mCPUTime) { } @@ -91,13 +57,16 @@ LLPathfindingCharacter::~LLPathfindingCharacter() LLPathfindingCharacter& LLPathfindingCharacter::operator =(const LLPathfindingCharacter& pOther) { - mUUID = pOther.mUUID; - mName = pOther.mName; - mDescription = pOther.mDescription; - mOwnerUUID = pOther.mOwnerUUID; - mOwnerName = pOther.mOwnerName; + dynamic_cast<LLPathfindingObject &>(*this) = pOther; + mCPUTime = pOther.mCPUTime; - mLocation = pOther.mLocation; return *this; } + +void LLPathfindingCharacter::parseCharacterData(const LLSD &pCharacterData) +{ + llassert(pCharacterData.has(CHARACTER_CPU_TIME_FIELD)); + llassert(pCharacterData.get(CHARACTER_CPU_TIME_FIELD).isReal()); + mCPUTime = pCharacterData.get(CHARACTER_CPU_TIME_FIELD).asReal(); +} diff --git a/indra/newview/llpathfindingcharacter.h b/indra/newview/llpathfindingcharacter.h index 3e40343831..b030959274 100644 --- a/indra/newview/llpathfindingcharacter.h +++ b/indra/newview/llpathfindingcharacter.h @@ -28,43 +28,27 @@ #ifndef LL_LLPATHFINDINGCHARACTER_H #define LL_LLPATHFINDINGCHARACTER_H -#include "v3math.h" -#include "lluuid.h" -#include "llavatarname.h" - -#include <boost/shared_ptr.hpp> +#include "llpathfindingobject.h" class LLSD; -class LLPathfindingCharacter; - -typedef boost::shared_ptr<LLPathfindingCharacter> LLPathfindingCharacterPtr; -class LLPathfindingCharacter +class LLPathfindingCharacter : public LLPathfindingObject { public: - LLPathfindingCharacter(const std::string &pUUID, const LLSD &pCharacterItem); + LLPathfindingCharacter(const std::string &pUUID, const LLSD &pCharacterData); LLPathfindingCharacter(const LLPathfindingCharacter& pOther); virtual ~LLPathfindingCharacter(); - LLPathfindingCharacter& operator = (const LLPathfindingCharacter& pOther); + LLPathfindingCharacter& operator =(const LLPathfindingCharacter& pOther); - inline const LLUUID& getUUID() const {return mUUID;}; - inline const std::string& getName() const {return mName;}; - inline const std::string& getDescription() const {return mDescription;}; - inline const std::string getOwnerName() const {return mOwnerName.getCompleteName();}; - inline F32 getCPUTime() const {return mCPUTime;}; - inline const LLVector3& getLocation() const {return mLocation;}; + inline F32 getCPUTime() const {return mCPUTime;}; protected: private: - LLUUID mUUID; - std::string mName; - std::string mDescription; - LLUUID mOwnerUUID; - LLAvatarName mOwnerName; - F32 mCPUTime; - LLVector3 mLocation; + void parseCharacterData(const LLSD &pCharacterData); + + F32 mCPUTime; }; #endif // LL_LLPATHFINDINGCHARACTER_H diff --git a/indra/newview/llpathfindingcharacterlist.cpp b/indra/newview/llpathfindingcharacterlist.cpp index 5ab4a8910f..53b21f436d 100644 --- a/indra/newview/llpathfindingcharacterlist.cpp +++ b/indra/newview/llpathfindingcharacterlist.cpp @@ -27,37 +27,42 @@ #include "llviewerprecompiledheaders.h" -#include <string> -#include <map> +#include "llpathfindingcharacterlist.h" #include "llsd.h" -#include "lluuid.h" #include "llpathfindingcharacter.h" -#include "llpathfindingcharacterlist.h" +#include "llpathfindingobject.h" +#include "llpathfindingobjectlist.h" //--------------------------------------------------------------------------- // LLPathfindingCharacterList //--------------------------------------------------------------------------- LLPathfindingCharacterList::LLPathfindingCharacterList() - : LLPathfindingCharacterMap() + : LLPathfindingObjectList() { } -LLPathfindingCharacterList::LLPathfindingCharacterList(const LLSD& pCharacterItems) - : LLPathfindingCharacterMap() +LLPathfindingCharacterList::LLPathfindingCharacterList(const LLSD& pCharacterListData) + : LLPathfindingObjectList() { - for (LLSD::map_const_iterator characterItemIter = pCharacterItems.beginMap(); - characterItemIter != pCharacterItems.endMap(); ++characterItemIter) - { - const std::string& uuid(characterItemIter->first); - const LLSD& characterData = characterItemIter->second; - LLPathfindingCharacterPtr character(new LLPathfindingCharacter(uuid, characterData)); - insert(std::pair<std::string, LLPathfindingCharacterPtr>(uuid, character)); - } + parseCharacterListData(pCharacterListData); } LLPathfindingCharacterList::~LLPathfindingCharacterList() { - clear(); +} + +void LLPathfindingCharacterList::parseCharacterListData(const LLSD& pCharacterListData) +{ + LLPathfindingObjectMap &objectMap = getObjectMap(); + + for (LLSD::map_const_iterator characterDataIter = pCharacterListData.beginMap(); + characterDataIter != pCharacterListData.endMap(); ++characterDataIter) + { + const std::string& uuid(characterDataIter->first); + const LLSD& characterData = characterDataIter->second; + LLPathfindingObjectPtr character(new LLPathfindingCharacter(uuid, characterData)); + objectMap.insert(std::pair<std::string, LLPathfindingObjectPtr>(uuid, character)); + } } diff --git a/indra/newview/llpathfindingcharacterlist.h b/indra/newview/llpathfindingcharacterlist.h index 601c89626d..a80db08c87 100644 --- a/indra/newview/llpathfindingcharacterlist.h +++ b/indra/newview/llpathfindingcharacterlist.h @@ -28,29 +28,22 @@ #ifndef LL_LLPATHFINDINGCHARACTERLIST_H #define LL_LLPATHFINDINGCHARACTERLIST_H -#include <string> -#include <map> #include "llpathfindingcharacter.h" - -#include <boost/shared_ptr.hpp> +#include "llpathfindingobjectlist.h" class LLSD; -class LLPathfindingCharacterList; - -typedef boost::shared_ptr<LLPathfindingCharacterList> LLPathfindingCharacterListPtr; -typedef std::map<std::string, LLPathfindingCharacterPtr> LLPathfindingCharacterMap; -class LLPathfindingCharacterList : public LLPathfindingCharacterMap +class LLPathfindingCharacterList : public LLPathfindingObjectList { public: LLPathfindingCharacterList(); - LLPathfindingCharacterList(const LLSD& pCharacterItems); + LLPathfindingCharacterList(const LLSD& pCharacterListData); virtual ~LLPathfindingCharacterList(); protected: private: - + void parseCharacterListData(const LLSD& pCharacterListData); }; #endif // LL_LLPATHFINDINGCHARACTERLIST_H diff --git a/indra/newview/llpathfindinglinkset.cpp b/indra/newview/llpathfindinglinkset.cpp index e2ece8794f..dca5b6c93d 100644 --- a/indra/newview/llpathfindinglinkset.cpp +++ b/indra/newview/llpathfindinglinkset.cpp @@ -29,15 +29,9 @@ #include "llpathfindinglinkset.h" -#include "v3math.h" -#include "llavatarname.h" -#include "llavatarnamecache.h" +#include "llpathfindingobject.h" #include "llsd.h" -#include "lluuid.h" -#define LINKSET_NAME_FIELD "name" -#define LINKSET_DESCRIPTION_FIELD "description" -#define LINKSET_OWNER_FIELD "owner" #define LINKSET_LAND_IMPACT_FIELD "landimpact" #define LINKSET_MODIFIABLE_FIELD "modifiable" #ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS @@ -51,7 +45,6 @@ #define LINKSET_WALKABILITY_B_FIELD "B" #define LINKSET_WALKABILITY_C_FIELD "C" #define LINKSET_WALKABILITY_D_FIELD "D" -#define LINKSET_POSITION_FIELD "position" #define LINKSET_CATEGORY_VALUE_INCLUDE 0 #define LINKSET_CATEGORY_VALUE_EXCLUDE 1 @@ -64,15 +57,10 @@ const S32 LLPathfindingLinkset::MIN_WALKABILITY_VALUE(0); const S32 LLPathfindingLinkset::MAX_WALKABILITY_VALUE(100); -LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) - : mUUID(), +LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainData) + : LLPathfindingObject(), mIsTerrain(true), - mName(), - mDescription(), - mOwnerUUID(), - mOwnerName(), mLandImpact(0U), - mLocation(LLVector3::zero), #ifdef MISSING_MODIFIABLE_FIELD_WAR mHasModifiable(true), #endif // MISSING_MODIFIABLE_FIELD_WAR @@ -84,18 +72,13 @@ LLPathfindingLinkset::LLPathfindingLinkset(const LLSD& pTerrainLinksetItem) mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) { - parsePathfindingData(pTerrainLinksetItem); + parsePathfindingData(pTerrainData); } -LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetItem) - : mUUID(pUUID), +LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& pLinksetData) + : LLPathfindingObject(pUUID, pLinksetData), mIsTerrain(false), - mName(), - mDescription(), - mOwnerUUID(), - mOwnerName(), mLandImpact(0U), - mLocation(LLVector3::zero), #ifdef MISSING_MODIFIABLE_FIELD_WAR mHasModifiable(false), #endif // MISSING_MODIFIABLE_FIELD_WAR @@ -107,18 +90,14 @@ LLPathfindingLinkset::LLPathfindingLinkset(const std::string &pUUID, const LLSD& mWalkabilityCoefficientC(MIN_WALKABILITY_VALUE), mWalkabilityCoefficientD(MIN_WALKABILITY_VALUE) { - parseObjectData(pLinksetItem); - parsePathfindingData(pLinksetItem); + parseLinksetData(pLinksetData); + parsePathfindingData(pLinksetData); } LLPathfindingLinkset::LLPathfindingLinkset(const LLPathfindingLinkset& pOther) - : mUUID(pOther.mUUID), - mName(pOther.mName), - mDescription(pOther.mDescription), - mOwnerUUID(pOther.mOwnerUUID), - mOwnerName(pOther.mOwnerName), + : LLPathfindingObject(pOther), + mIsTerrain(pOther.mIsTerrain), mLandImpact(pOther.mLandImpact), - mLocation(pOther.mLocation), #ifdef MISSING_MODIFIABLE_FIELD_WAR mHasModifiable(pOther.mHasModifiable), mIsModifiable(pOther.mHasModifiable ? pOther.mIsModifiable : TRUE), @@ -140,13 +119,10 @@ LLPathfindingLinkset::~LLPathfindingLinkset() LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkset& pOther) { - mUUID = pOther.mUUID; - mName = pOther.mName; - mDescription = pOther.mDescription; - mOwnerUUID = pOther.mOwnerUUID; - mOwnerName = pOther.mOwnerName; + dynamic_cast<LLPathfindingObject &>(*this) = pOther; + + mIsTerrain = pOther.mIsTerrain; mLandImpact = pOther.mLandImpact; - mLocation = pOther.mLocation; #ifdef MISSING_MODIFIABLE_FIELD_WAR if (pOther.mHasModifiable) { @@ -166,18 +142,6 @@ LLPathfindingLinkset& LLPathfindingLinkset::operator =(const LLPathfindingLinkse return *this; } -std::string LLPathfindingLinkset::getOwnerName() const -{ - std::string ownerName; - - if (hasOwnerName()) - { - ownerName = mOwnerName.getCompleteName(); - } - - return ownerName; -} - BOOL LLPathfindingLinkset::isPhantom() const { return isPhantom(getLinksetUse()); @@ -243,111 +207,85 @@ LLSD LLPathfindingLinkset::encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, return itemData; } -void LLPathfindingLinkset::parseObjectData(const LLSD &pLinksetItem) +void LLPathfindingLinkset::parseLinksetData(const LLSD &pLinksetData) { - llassert(pLinksetItem.has(LINKSET_NAME_FIELD)); - llassert(pLinksetItem.get(LINKSET_NAME_FIELD).isString()); - mName = pLinksetItem.get(LINKSET_NAME_FIELD).asString(); - - llassert(pLinksetItem.has(LINKSET_DESCRIPTION_FIELD)); - llassert(pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).isString()); - mDescription = pLinksetItem.get(LINKSET_DESCRIPTION_FIELD).asString(); - -#ifdef SERVER_SIDE_OWNER_ROLLOUT_COMPLETE - llassert(pLinksetItem.has(LINKSET_OWNER_FIELD)); - llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID()); - mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID(); - LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); -#else // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE - if (pLinksetItem.has(LINKSET_OWNER_FIELD)) - { - llassert(pLinksetItem.get(LINKSET_OWNER_FIELD).isUUID()); - mOwnerUUID = pLinksetItem.get(LINKSET_OWNER_FIELD).asUUID(); - LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); - } -#endif // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE - - llassert(pLinksetItem.has(LINKSET_LAND_IMPACT_FIELD)); - llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).isInteger()); - llassert(pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); - mLandImpact = pLinksetItem.get(LINKSET_LAND_IMPACT_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_LAND_IMPACT_FIELD)); + llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).isInteger()); + llassert(pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger() >= 0); + mLandImpact = pLinksetData.get(LINKSET_LAND_IMPACT_FIELD).asInteger(); #ifdef MISSING_MODIFIABLE_FIELD_WAR - mHasModifiable = pLinksetItem.has(LINKSET_MODIFIABLE_FIELD); + mHasModifiable = pLinksetData.has(LINKSET_MODIFIABLE_FIELD); if (mHasModifiable) { - llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); } #else // MISSING_MODIFIABLE_FIELD_WAR - llassert(pLinksetItem.has(LINKSET_MODIFIABLE_FIELD)); - llassert(pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); - mIsModifiable = pLinksetItem.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); + llassert(pLinksetData.has(LINKSET_MODIFIABLE_FIELD)); + llassert(pLinksetData.get(LINKSET_MODIFIABLE_FIELD).isBoolean()); + mIsModifiable = pLinksetData.get(LINKSET_MODIFIABLE_FIELD).asBoolean(); #endif // MISSING_MODIFIABLE_FIELD_WAR - - llassert(pLinksetItem.has(LINKSET_POSITION_FIELD)); - llassert(pLinksetItem.get(LINKSET_POSITION_FIELD).isArray()); - mLocation.setValue(pLinksetItem.get(LINKSET_POSITION_FIELD)); } -void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetItem) +void LLPathfindingLinkset::parsePathfindingData(const LLSD &pLinksetData) { bool isPhantom = false; - if (pLinksetItem.has(LINKSET_PHANTOM_FIELD)) + if (pLinksetData.has(LINKSET_PHANTOM_FIELD)) { - llassert(pLinksetItem.get(LINKSET_PHANTOM_FIELD).isBoolean()); - isPhantom = pLinksetItem.get(LINKSET_PHANTOM_FIELD).asBoolean(); + llassert(pLinksetData.get(LINKSET_PHANTOM_FIELD).isBoolean()); + isPhantom = pLinksetData.get(LINKSET_PHANTOM_FIELD).asBoolean(); } #ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - if (pLinksetItem.has(LINKSET_CATEGORY_FIELD)) + if (pLinksetData.has(LINKSET_CATEGORY_FIELD)) { - mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); + mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD))); } else { - llassert(pLinksetItem.has(DEPRECATED_LINKSET_PERMANENT_FIELD)); - llassert(pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean()); - bool isPermanent = pLinksetItem.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean(); + llassert(pLinksetData.has(DEPRECATED_LINKSET_PERMANENT_FIELD)); + llassert(pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).isBoolean()); + bool isPermanent = pLinksetData.get(DEPRECATED_LINKSET_PERMANENT_FIELD).asBoolean(); - llassert(pLinksetItem.has(DEPRECATED_LINKSET_WALKABLE_FIELD)); - llassert(pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean()); - bool isWalkable = pLinksetItem.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean(); + llassert(pLinksetData.has(DEPRECATED_LINKSET_WALKABLE_FIELD)); + llassert(pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).isBoolean()); + bool isWalkable = pLinksetData.get(DEPRECATED_LINKSET_WALKABLE_FIELD).asBoolean(); mLinksetUse = getLinksetUse(isPhantom, isPermanent, isWalkable); } #else // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - llassert(pLinksetItem.has(LINKSET_CATEGORY_FIELD)); - mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetItem.get(LINKSET_CATEGORY_FIELD))); + llassert(pLinksetData.has(LINKSET_CATEGORY_FIELD)); + mLinksetUse = getLinksetUse(isPhantom, convertCategoryFromLLSD(pLinksetData.get(LINKSET_CATEGORY_FIELD))); #endif // DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS - if (pLinksetItem.has(LINKSET_CAN_BE_VOLUME)) + if (pLinksetData.has(LINKSET_CAN_BE_VOLUME)) { - llassert(pLinksetItem.get(LINKSET_CAN_BE_VOLUME).isBoolean()); - mCanBeVolume = pLinksetItem.get(LINKSET_CAN_BE_VOLUME).asBoolean(); + llassert(pLinksetData.get(LINKSET_CAN_BE_VOLUME).isBoolean()); + mCanBeVolume = pLinksetData.get(LINKSET_CAN_BE_VOLUME).asBoolean(); } - llassert(pLinksetItem.has(LINKSET_WALKABILITY_A_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); - mWalkabilityCoefficientA = pLinksetItem.get(LINKSET_WALKABILITY_A_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_WALKABILITY_A_FIELD)); + llassert(pLinksetData.get(LINKSET_WALKABILITY_A_FIELD).isInteger()); + mWalkabilityCoefficientA = pLinksetData.get(LINKSET_WALKABILITY_A_FIELD).asInteger(); llassert(mWalkabilityCoefficientA >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientA <= MAX_WALKABILITY_VALUE); - llassert(pLinksetItem.has(LINKSET_WALKABILITY_B_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).isInteger()); - mWalkabilityCoefficientB = pLinksetItem.get(LINKSET_WALKABILITY_B_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_WALKABILITY_B_FIELD)); + llassert(pLinksetData.get(LINKSET_WALKABILITY_B_FIELD).isInteger()); + mWalkabilityCoefficientB = pLinksetData.get(LINKSET_WALKABILITY_B_FIELD).asInteger(); llassert(mWalkabilityCoefficientB >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientB <= MAX_WALKABILITY_VALUE); - llassert(pLinksetItem.has(LINKSET_WALKABILITY_C_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).isInteger()); - mWalkabilityCoefficientC = pLinksetItem.get(LINKSET_WALKABILITY_C_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_WALKABILITY_C_FIELD)); + llassert(pLinksetData.get(LINKSET_WALKABILITY_C_FIELD).isInteger()); + mWalkabilityCoefficientC = pLinksetData.get(LINKSET_WALKABILITY_C_FIELD).asInteger(); llassert(mWalkabilityCoefficientC >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientC <= MAX_WALKABILITY_VALUE); - llassert(pLinksetItem.has(LINKSET_WALKABILITY_D_FIELD)); - llassert(pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).isInteger()); - mWalkabilityCoefficientD = pLinksetItem.get(LINKSET_WALKABILITY_D_FIELD).asInteger(); + llassert(pLinksetData.has(LINKSET_WALKABILITY_D_FIELD)); + llassert(pLinksetData.get(LINKSET_WALKABILITY_D_FIELD).isInteger()); + mWalkabilityCoefficientD = pLinksetData.get(LINKSET_WALKABILITY_D_FIELD).asInteger(); llassert(mWalkabilityCoefficientD >= MIN_WALKABILITY_VALUE); llassert(mWalkabilityCoefficientD <= MAX_WALKABILITY_VALUE); } diff --git a/indra/newview/llpathfindinglinkset.h b/indra/newview/llpathfindinglinkset.h index a729743739..cda71dffb3 100644 --- a/indra/newview/llpathfindinglinkset.h +++ b/indra/newview/llpathfindinglinkset.h @@ -28,21 +28,14 @@ #ifndef LL_LLPATHFINDINGLINKSET_H #define LL_LLPATHFINDINGLINKSET_H -#include "v3math.h" -#include "llavatarname.h" -#include "lluuid.h" - -#include <boost/shared_ptr.hpp> - -class LLSD; -class LLPathfindingLinkset; - -typedef boost::shared_ptr<LLPathfindingLinkset> LLPathfindingLinksetPtr; +#include "llpathfindingobject.h" #define DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS #define MISSING_MODIFIABLE_FIELD_WAR -class LLPathfindingLinkset +class LLSD; + +class LLPathfindingLinkset : public LLPathfindingObject { public: typedef enum @@ -56,21 +49,15 @@ public: kDynamicPhantom } ELinksetUse; - LLPathfindingLinkset(const LLSD &pTerrainLinksetItem); - LLPathfindingLinkset(const std::string &pUUID, const LLSD &pLinksetItem); + LLPathfindingLinkset(const LLSD &pTerrainData); + LLPathfindingLinkset(const std::string &pUUID, const LLSD &pLinksetData); LLPathfindingLinkset(const LLPathfindingLinkset& pOther); virtual ~LLPathfindingLinkset(); LLPathfindingLinkset& operator = (const LLPathfindingLinkset& pOther); inline bool isTerrain() const {return mIsTerrain;}; - inline const LLUUID& getUUID() const {return mUUID;}; - inline const std::string& getName() const {return mName;}; - inline const std::string& getDescription() const {return mDescription;}; - inline BOOL hasOwnerName() const {return mOwnerUUID.notNull();}; - std::string getOwnerName() const; inline U32 getLandImpact() const {return mLandImpact;}; - inline const LLVector3& getLocation() const {return mLocation;}; BOOL isModifiable() const {return mIsModifiable;}; BOOL isPhantom() const; BOOL canBeVolume() const {return mCanBeVolume;}; @@ -100,8 +87,8 @@ private: kNavMeshGenerationExclude } ENavMeshGenerationCategory; - void parseObjectData(const LLSD &pLinksetItem); - void parsePathfindingData(const LLSD &pLinksetItem); + void parseLinksetData(const LLSD &pLinksetData); + void parsePathfindingData(const LLSD &pLinksetData); #ifdef DEPRECATED_NAVMESH_PERMANENT_WALKABLE_FLAGS static ELinksetUse getLinksetUse(bool pIsPhantom, bool pIsPermanent, bool pIsWalkable); @@ -114,14 +101,8 @@ private: static LLSD convertCategoryToLLSD(ENavMeshGenerationCategory pNavMeshGenerationCategory); static ENavMeshGenerationCategory convertCategoryFromLLSD(const LLSD &llsd); - LLUUID mUUID; bool mIsTerrain; - std::string mName; - std::string mDescription; - LLUUID mOwnerUUID; - LLAvatarName mOwnerName; U32 mLandImpact; - LLVector3 mLocation; #ifdef MISSING_MODIFIABLE_FIELD_WAR bool mHasModifiable; #endif // MISSING_MODIFIABLE_FIELD_WAR diff --git a/indra/newview/llpathfindinglinksetlist.cpp b/indra/newview/llpathfindinglinksetlist.cpp index 19a99ef444..0ba6ef07f3 100644 --- a/indra/newview/llpathfindinglinksetlist.cpp +++ b/indra/newview/llpathfindinglinksetlist.cpp @@ -27,72 +27,44 @@ #include "llviewerprecompiledheaders.h" -#include <string> -#include <map> +#include "llpathfindinglinksetlist.h" #include "llsd.h" -#include "lluuid.h" #include "llpathfindinglinkset.h" -#include "llpathfindinglinksetlist.h" +#include "llpathfindingobject.h" +#include "llpathfindingobjectlist.h" //--------------------------------------------------------------------------- // LLPathfindingLinksetList //--------------------------------------------------------------------------- LLPathfindingLinksetList::LLPathfindingLinksetList() - : LLPathfindingLinksetMap() + : LLPathfindingObjectList() { } -LLPathfindingLinksetList::LLPathfindingLinksetList(const LLSD& pLinksetItems) - : LLPathfindingLinksetMap() +LLPathfindingLinksetList::LLPathfindingLinksetList(const LLSD& pLinksetListData) + : LLPathfindingObjectList() { - for (LLSD::map_const_iterator linksetItemIter = pLinksetItems.beginMap(); - linksetItemIter != pLinksetItems.endMap(); ++linksetItemIter) - { - const std::string& uuid(linksetItemIter->first); - const LLSD& linksetData = linksetItemIter->second; - LLPathfindingLinksetPtr linkset(new LLPathfindingLinkset(uuid, linksetData)); - insert(std::pair<std::string, LLPathfindingLinksetPtr>(uuid, linkset)); - } + parseLinksetListData(pLinksetListData); } LLPathfindingLinksetList::~LLPathfindingLinksetList() { - clear(); -} - -void LLPathfindingLinksetList::update(const LLPathfindingLinksetList &pUpdateLinksetList) -{ - for (LLPathfindingLinksetList::const_iterator updateLinksetIter = pUpdateLinksetList.begin(); - updateLinksetIter != pUpdateLinksetList.end(); ++updateLinksetIter) - { - const std::string &uuid = updateLinksetIter->first; - const LLPathfindingLinksetPtr updateLinksetPtr = updateLinksetIter->second; - - LLPathfindingLinksetList::iterator linksetIter = find(uuid); - if (linksetIter == end()) - { - insert(std::pair<std::string, LLPathfindingLinksetPtr>(uuid, updateLinksetPtr)); - } - else - { - LLPathfindingLinksetPtr linksetPtr = linksetIter->second; - *linksetPtr = *updateLinksetPtr; - } - } } LLSD LLPathfindingLinksetList::encodeObjectFields(LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const { LLSD listData; - for (LLPathfindingLinksetMap::const_iterator linksetIter = begin(); linksetIter != end(); ++linksetIter) + for (const_iterator linksetIter = begin(); linksetIter != end(); ++linksetIter) { - const LLPathfindingLinksetPtr linksetPtr = linksetIter->second; - if (!linksetPtr->isTerrain()) + const LLPathfindingObjectPtr objectPtr = linksetIter->second; + const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get()); + + if (!linkset->isTerrain()) { - LLSD linksetData = linksetPtr->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD); + LLSD linksetData = linkset->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD); if (!linksetData.isUndefined()) { const std::string& uuid(linksetIter->first); @@ -107,16 +79,114 @@ LLSD LLPathfindingLinksetList::encodeObjectFields(LLPathfindingLinkset::ELinkset LLSD LLPathfindingLinksetList::encodeTerrainFields(LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const { LLSD terrainData; - - for (LLPathfindingLinksetMap::const_iterator linksetIter = begin(); linksetIter != end(); ++linksetIter) + + for (const_iterator linksetIter = begin(); linksetIter != end(); ++linksetIter) { - const LLPathfindingLinksetPtr linksetPtr = linksetIter->second; - if (linksetPtr->isTerrain()) + const LLPathfindingObjectPtr objectPtr = linksetIter->second; + const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get()); + + if (linkset->isTerrain()) { - terrainData = linksetPtr->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD); + terrainData = linkset->encodeAlteredFields(pLinksetUse, pA, pB, pC, pD); break; } } return terrainData; } + +bool LLPathfindingLinksetList::isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const +{ + bool isShowWarning = false; + + for (const_iterator objectIter = begin(); !isShowWarning && (objectIter != end()); ++objectIter) + { + const LLPathfindingObjectPtr objectPtr = objectIter->second; + const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get()); + isShowWarning = linkset->isShowUnmodifiablePhantomWarning(pLinksetUse); + } + + return isShowWarning; +} + +bool LLPathfindingLinksetList::isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const +{ + bool isShowWarning = false; + + for (const_iterator objectIter = begin(); !isShowWarning && (objectIter != end()); ++objectIter) + { + const LLPathfindingObjectPtr objectPtr = objectIter->second; + const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get()); + isShowWarning = linkset->isShowCannotBeVolumeWarning(pLinksetUse); + } + + return isShowWarning; +} + +void LLPathfindingLinksetList::determinePossibleStates(BOOL &pCanBeWalkable, BOOL &pCanBeStaticObstacle, BOOL &pCanBeDynamicObstacle, + BOOL &pCanBeMaterialVolume, BOOL &pCanBeExclusionVolume, BOOL &pCanBeDynamicPhantom) const +{ + pCanBeWalkable = FALSE; + pCanBeStaticObstacle = FALSE; + pCanBeDynamicObstacle = FALSE; + pCanBeMaterialVolume = FALSE; + pCanBeExclusionVolume = FALSE; + pCanBeDynamicPhantom = FALSE; + + for (const_iterator objectIter = begin(); + !(pCanBeWalkable && pCanBeStaticObstacle && pCanBeDynamicObstacle && pCanBeMaterialVolume && pCanBeExclusionVolume && pCanBeDynamicPhantom) && (objectIter != end()); + ++objectIter) + { + const LLPathfindingObjectPtr objectPtr = objectIter->second; + const LLPathfindingLinkset *linkset = dynamic_cast<const LLPathfindingLinkset *>(objectPtr.get()); + + if (linkset->isTerrain()) + { + pCanBeWalkable = TRUE; + } + else + { + if (linkset->isModifiable()) + { + pCanBeWalkable = TRUE; + pCanBeStaticObstacle = TRUE; + pCanBeDynamicObstacle = TRUE; + pCanBeDynamicPhantom = TRUE; + if (linkset->canBeVolume()) + { + pCanBeMaterialVolume = TRUE; + pCanBeExclusionVolume = TRUE; + } + } + else if (linkset->isPhantom()) + { + pCanBeDynamicPhantom = TRUE; + if (linkset->canBeVolume()) + { + pCanBeMaterialVolume = TRUE; + pCanBeExclusionVolume = TRUE; + } + } + else + { + pCanBeWalkable = TRUE; + pCanBeStaticObstacle = TRUE; + pCanBeDynamicObstacle = TRUE; + } + } + } +} + +void LLPathfindingLinksetList::parseLinksetListData(const LLSD& pLinksetListData) +{ + LLPathfindingObjectMap &objectMap = getObjectMap(); + + for (LLSD::map_const_iterator linksetDataIter = pLinksetListData.beginMap(); + linksetDataIter != pLinksetListData.endMap(); ++linksetDataIter) + { + const std::string& uuid(linksetDataIter->first); + const LLSD& linksetData = linksetDataIter->second; + LLPathfindingObjectPtr linksetPtr(new LLPathfindingLinkset(uuid, linksetData)); + objectMap.insert(std::pair<std::string, LLPathfindingObjectPtr>(uuid, linksetPtr)); + } +} diff --git a/indra/newview/llpathfindinglinksetlist.h b/indra/newview/llpathfindinglinksetlist.h index 855b1cc451..7bd6986094 100644 --- a/indra/newview/llpathfindinglinksetlist.h +++ b/indra/newview/llpathfindinglinksetlist.h @@ -28,34 +28,32 @@ #ifndef LL_LLPATHFINDINGLINKSETLIST_H #define LL_LLPATHFINDINGLINKSETLIST_H -#include <string> -#include <map> #include "llpathfindinglinkset.h" - -#include <boost/shared_ptr.hpp> +#include "llpathfindingobjectlist.h" class LLSD; -class LLPathfindingLinksetList; - -typedef boost::shared_ptr<LLPathfindingLinksetList> LLPathfindingLinksetListPtr; -typedef std::map<std::string, LLPathfindingLinksetPtr> LLPathfindingLinksetMap; +class LLVector3; -class LLPathfindingLinksetList : public LLPathfindingLinksetMap +class LLPathfindingLinksetList : public LLPathfindingObjectList { public: LLPathfindingLinksetList(); - LLPathfindingLinksetList(const LLSD& pLinksetItems); + LLPathfindingLinksetList(const LLSD& pLinksetListData); virtual ~LLPathfindingLinksetList(); - void update(const LLPathfindingLinksetList &pUpdateLinksetList); - LLSD encodeObjectFields(LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const; LLSD encodeTerrainFields(LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const; + bool isShowUnmodifiablePhantomWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const; + bool isShowCannotBeVolumeWarning(LLPathfindingLinkset::ELinksetUse pLinksetUse) const; + + void determinePossibleStates(BOOL &pCanBeWalkable, BOOL &pCanBeStaticObstacle, BOOL &pCanBeDynamicObstacle, + BOOL &pCanBeMaterialVolume, BOOL &pCanBeExclusionVolume, BOOL &pCanBeDynamicPhantom) const; + protected: private: - + void parseLinksetListData(const LLSD& pLinksetListData); }; #endif // LL_LLPATHFINDINGLINKSETLIST_H diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index e01466569e..b8b9dff51c 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -25,30 +25,35 @@ * $/LicenseInfo$ */ +#include "llviewerprecompiledheaders.h" + +#include "llpathfindingmanager.h" + #include <string> #include <vector> -#include "llviewerprecompiledheaders.h" -#include "llsd.h" -#include "lluuid.h" -#include "llpathfindingmanager.h" -#include "llsingleton.h" -#include "llhttpclient.h" +#include <boost/function.hpp> +#include <boost/signals2.hpp> + #include "llagent.h" -#include "llviewerregion.h" +#include "llhttpclient.h" +#include "llhttpnode.h" +#include "llnotificationsutil.h" +#include "llpathfindingcharacter.h" +#include "llpathfindingcharacterlist.h" +#include "llpathfindinglinkset.h" +#include "llpathfindinglinksetlist.h" #include "llpathfindingnavmesh.h" #include "llpathfindingnavmeshstatus.h" -#include "llpathfindinglinkset.h" +#include "llpathfindingobject.h" #include "llpathfindinglinksetlist.h" -#include "llpathfindingcharacterlist.h" -#include "llhttpnode.h" -#include "llnotificationsutil.h" +#include "llsingleton.h" +#include "llsd.h" #include "lltrans.h" +#include "lluuid.h" +#include "llviewerregion.h" #include "llweb.h" -#include <boost/function.hpp> -#include <boost/signals2.hpp> - #define CAP_SERVICE_RETRIEVE_NAVMESH "RetrieveNavMeshSrc" #define CAP_SERVICE_NAVMESH_STATUS "NavMeshGenerationStatus" @@ -159,7 +164,7 @@ private: class LinksetsResponder { public: - LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); + LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested); virtual ~LinksetsResponder(); void handleObjectLinksetsResult(const LLSD &pContent); @@ -180,14 +185,14 @@ private: kReceivedError } EMessagingState; - LLPathfindingManager::request_id_t mRequestId; - LLPathfindingManager::linksets_callback_t mLinksetsCallback; + LLPathfindingManager::request_id_t mRequestId; + LLPathfindingManager::object_request_callback_t mLinksetsCallback; - EMessagingState mObjectMessagingState; - EMessagingState mTerrainMessagingState; + EMessagingState mObjectMessagingState; + EMessagingState mTerrainMessagingState; - LLPathfindingLinksetListPtr mObjectLinksetListPtr; - LLPathfindingLinksetPtr mTerrainLinksetPtr; + LLPathfindingObjectListPtr mObjectLinksetListPtr; + LLPathfindingObjectPtr mTerrainLinksetPtr; }; typedef boost::shared_ptr<LinksetsResponder> LinksetsResponderPtr; @@ -239,7 +244,7 @@ private: class CharactersResponder : public LLHTTPClient::Responder { public: - CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback); + CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pCharactersCallback); virtual ~CharactersResponder(); virtual void result(const LLSD &pContent); @@ -248,9 +253,9 @@ public: protected: private: - std::string mCapabilityURL; - LLPathfindingManager::request_id_t mRequestId; - LLPathfindingManager::characters_callback_t mCharactersCallback; + std::string mCapabilityURL; + LLPathfindingManager::request_id_t mRequestId; + LLPathfindingManager::object_request_callback_t mCharactersCallback; }; //--------------------------------------------------------------------------- @@ -397,9 +402,9 @@ void LLPathfindingManager::requestSetAgentState(EAgentState pRequestedAgentState } } -void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const +void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const { - LLPathfindingLinksetListPtr emptyLinksetListPtr; + LLPathfindingObjectListPtr emptyLinksetListPtr; LLViewerRegion *currentRegion = getCurrentRegion(); if (currentRegion == NULL) @@ -438,9 +443,9 @@ void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, linksets_ } } -void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const +void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLPathfindingObjectListPtr &pLinksetListPtr, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, object_request_callback_t pLinksetsCallback) const { - LLPathfindingLinksetListPtr emptyLinksetListPtr; + LLPathfindingObjectListPtr emptyLinksetListPtr; std::string objectLinksetsURL = getObjectLinksetsURLForCurrentRegion(); std::string terrainLinksetsURL = getTerrainLinksetsURLForCurrentRegion(); @@ -448,13 +453,19 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfin { pLinksetsCallback(pRequestId, kRequestNotEnabled, emptyLinksetListPtr); } - else + else if ((pLinksetListPtr == NULL) || pLinksetListPtr->isEmpty()) { - LLSD objectPostData = pLinksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD); + pLinksetsCallback(pRequestId, kRequestCompleted, emptyLinksetListPtr); + } + else + { + const LLPathfindingLinksetList *linksetList = dynamic_cast<const LLPathfindingLinksetList *>(pLinksetListPtr.get()); + + LLSD objectPostData = linksetList->encodeObjectFields(pLinksetUse, pA, pB, pC, pD); LLSD terrainPostData; if (isAllowViewTerrainProperties()) { - terrainPostData = pLinksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); + terrainPostData = linksetList->encodeTerrainFields(pLinksetUse, pA, pB, pC, pD); } if (objectPostData.isUndefined() && terrainPostData.isUndefined()) @@ -482,9 +493,9 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, LLPathfin } } -void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const +void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_request_callback_t pCharactersCallback) const { - LLPathfindingCharacterListPtr emptyCharacterListPtr; + LLPathfindingObjectListPtr emptyCharacterListPtr; LLViewerRegion *currentRegion = getCurrentRegion(); @@ -549,7 +560,7 @@ void LLPathfindingManager::handleDeferredGetNavMeshForRegion(const LLUUID &pRegi } } -void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const +void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const { LLViewerRegion *currentRegion = getCurrentRegion(); @@ -559,7 +570,7 @@ void LLPathfindingManager::handleDeferredGetLinksetsForRegion(const LLUUID &pReg } } -void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, characters_callback_t pCharactersCallback) const +void LLPathfindingManager::handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const { LLViewerRegion *currentRegion = getCurrentRegion(); @@ -898,7 +909,7 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) // LinksetsResponder //--------------------------------------------------------------------------- -LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::linksets_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) +LinksetsResponder::LinksetsResponder(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pLinksetsCallback, bool pIsObjectRequested, bool pIsTerrainRequested) : mRequestId(pRequestId), mLinksetsCallback(pLinksetsCallback), mObjectMessagingState(pIsObjectRequested ? kWaiting : kNotRequested), @@ -914,7 +925,7 @@ LinksetsResponder::~LinksetsResponder() void LinksetsResponder::handleObjectLinksetsResult(const LLSD &pContent) { - mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList(pContent)); + mObjectLinksetListPtr = LLPathfindingObjectListPtr(new LLPathfindingLinksetList(pContent)); mObjectMessagingState = kReceivedGood; if (mTerrainMessagingState != kWaiting) @@ -935,7 +946,7 @@ void LinksetsResponder::handleObjectLinksetsError(U32 pStatus, const std::string void LinksetsResponder::handleTerrainLinksetsResult(const LLSD &pContent) { - mTerrainLinksetPtr = LLPathfindingLinksetPtr(new LLPathfindingLinkset(pContent)); + mTerrainLinksetPtr = LLPathfindingObjectPtr(new LLPathfindingLinkset(pContent)); mTerrainMessagingState = kReceivedGood; if (mObjectMessagingState != kWaiting) @@ -964,12 +975,12 @@ void LinksetsResponder::sendCallback() if (mObjectMessagingState != kReceivedGood) { - mObjectLinksetListPtr = LLPathfindingLinksetListPtr(new LLPathfindingLinksetList()); + mObjectLinksetListPtr = LLPathfindingObjectListPtr(new LLPathfindingLinksetList()); } if (mTerrainMessagingState == kReceivedGood) { - mObjectLinksetListPtr->insert(std::pair<std::string, LLPathfindingLinksetPtr>(mTerrainLinksetPtr->getUUID().asString(), mTerrainLinksetPtr)); + mObjectLinksetListPtr->update(mTerrainLinksetPtr); } mLinksetsCallback(mRequestId, requestStatus, mObjectLinksetListPtr); @@ -1029,7 +1040,7 @@ void TerrainLinksetsResponder::error(U32 pStatus, const std::string &pReason) // CharactersResponder //--------------------------------------------------------------------------- -CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::characters_callback_t pCharactersCallback) +CharactersResponder::CharactersResponder(const std::string &pCapabilityURL, LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::object_request_callback_t pCharactersCallback) : LLHTTPClient::Responder(), mCapabilityURL(pCapabilityURL), mRequestId(pRequestId), @@ -1043,7 +1054,7 @@ CharactersResponder::~CharactersResponder() void CharactersResponder::result(const LLSD &pContent) { - LLPathfindingCharacterListPtr characterListPtr = LLPathfindingCharacterListPtr(new LLPathfindingCharacterList(pContent)); + LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList(pContent)); mCharactersCallback(mRequestId, LLPathfindingManager::kRequestCompleted, characterListPtr); } @@ -1051,7 +1062,6 @@ void CharactersResponder::error(U32 pStatus, const std::string &pReason) { llwarns << "error with request to URL '" << mCapabilityURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - LLPathfindingCharacterListPtr characterListPtr; + LLPathfindingObjectListPtr characterListPtr = LLPathfindingObjectListPtr(new LLPathfindingCharacterList()); mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr); } - diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index ad4dbe9adc..172670cdf8 100644 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -28,19 +28,18 @@ #ifndef LL_LLPATHFINDINGMANAGER_H #define LL_LLPATHFINDINGMANAGER_H -#include "llsingleton.h" -#include "lluuid.h" -#include "llpathfindingnavmesh.h" -#include "llpathfindinglinkset.h" -#include "llpathfindinglinksetlist.h" -#include "llpathfindingcharacterlist.h" - #include <string> #include <map> #include <boost/function.hpp> #include <boost/signals2.hpp> +#include "llpathfindinglinkset.h" +#include "llpathfindingobjectlist.h" +#include "llpathfindingnavmesh.h" +#include "llsingleton.h" +#include "lluuid.h" + class LLFloater; class LLViewerRegion; class LLPathfindingNavMeshStatus; @@ -73,11 +72,6 @@ public: kRequestError } ERequestStatus; - typedef U32 request_id_t; - - typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingLinksetListPtr)> linksets_callback_t; - typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingCharacterListPtr)> characters_callback_t; - LLPathfindingManager(); virtual ~LLPathfindingManager(); @@ -98,10 +92,13 @@ public: EAgentState getLastKnownNonErrorAgentState() const; void requestSetAgentState(EAgentState pAgentState); - void requestGetLinksets(request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const; - void requestSetLinksets(request_id_t pRequestId, LLPathfindingLinksetListPtr pLinksetList, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, linksets_callback_t pLinksetsCallback) const; + typedef U32 request_id_t; + typedef boost::function<void (request_id_t, ERequestStatus, LLPathfindingObjectListPtr)> object_request_callback_t; + + void requestGetLinksets(request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const; + void requestSetLinksets(request_id_t pRequestId, const LLPathfindingObjectListPtr &pLinksetListPtr, LLPathfindingLinkset::ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD, object_request_callback_t pLinksetsCallback) const; - void requestGetCharacters(request_id_t pRequestId, characters_callback_t pCharactersCallback) const; + void requestGetCharacters(request_id_t pRequestId, object_request_callback_t pCharactersCallback) const; protected: @@ -109,8 +106,8 @@ private: void sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPtr navMeshPtr, LLViewerRegion *pRegion, const LLPathfindingNavMeshStatus &pNavMeshStatus); void handleDeferredGetNavMeshForRegion(const LLUUID &pRegionUUID); - void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, linksets_callback_t pLinksetsCallback) const; - void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, characters_callback_t pCharactersCallback) const; + void handleDeferredGetLinksetsForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pLinksetsCallback) const; + void handleDeferredGetCharactersForRegion(const LLUUID &pRegionUUID, request_id_t pRequestId, object_request_callback_t pCharactersCallback) const; void handleNavMeshStatusRequest(const LLPathfindingNavMeshStatus &pNavMeshStatus, LLViewerRegion *pRegion); void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus &pNavMeshStatus); diff --git a/indra/newview/llpathfindingobject.cpp b/indra/newview/llpathfindingobject.cpp new file mode 100644 index 0000000000..cde3777414 --- /dev/null +++ b/indra/newview/llpathfindingobject.cpp @@ -0,0 +1,136 @@ +/** +* @file llpathfindingobject.cpp +* @brief Implementation of llpathfindingobject +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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 "llpathfindingobject.h" + +#include <string> + +#include "v3math.h" +#include "llavatarname.h" +#include "llavatarnamecache.h" +#include "llsd.h" +#include "lluuid.h" + +#define PATHFINDING_OBJECT_NAME_FIELD "name" +#define PATHFINDING_OBJECT_DESCRIPTION_FIELD "description" +#define PATHFINDING_OBJECT_OWNER_FIELD "owner" +#define PATHFINDING_OBJECT_POSITION_FIELD "position" + +//--------------------------------------------------------------------------- +// LLPathfindingObject +//--------------------------------------------------------------------------- + +LLPathfindingObject::LLPathfindingObject() + : mUUID(), + mName(), + mDescription(), + mOwnerUUID(), + mOwnerName(), + mLocation() +{ +} + +LLPathfindingObject::LLPathfindingObject(const std::string &pUUID, const LLSD &pObjectData) + : mUUID(pUUID), + mName(), + mDescription(), + mOwnerUUID(), + mOwnerName(), + mLocation() +{ + parseObjectData(pObjectData); +} + +LLPathfindingObject::LLPathfindingObject(const LLPathfindingObject& pOther) + : mUUID(pOther.mUUID), + mName(pOther.mName), + mDescription(pOther.mDescription), + mOwnerUUID(pOther.mOwnerUUID), + mOwnerName(pOther.mOwnerName), + mLocation(pOther.mLocation) +{ +} + +LLPathfindingObject::~LLPathfindingObject() +{ +} + +LLPathfindingObject &LLPathfindingObject::operator =(const LLPathfindingObject& pOther) +{ + mUUID = pOther.mUUID; + mName = pOther.mName; + mDescription = pOther.mDescription; + mOwnerUUID = pOther.mOwnerUUID; + mOwnerName = pOther.mOwnerName; + mLocation = pOther.mLocation; + + return *this; +} + +std::string LLPathfindingObject::getOwnerName() const +{ + std::string ownerName; + + if (hasOwnerName()) + { + ownerName = mOwnerName.getCompleteName(); + } + + return ownerName; +} + +void LLPathfindingObject::parseObjectData(const LLSD &pObjectData) +{ + llassert(pObjectData.has(PATHFINDING_OBJECT_NAME_FIELD)); + llassert(pObjectData.get(PATHFINDING_OBJECT_NAME_FIELD).isString()); + mName = pObjectData.get(PATHFINDING_OBJECT_NAME_FIELD).asString(); + + llassert(pObjectData.has(PATHFINDING_OBJECT_DESCRIPTION_FIELD)); + llassert(pObjectData.get(PATHFINDING_OBJECT_DESCRIPTION_FIELD).isString()); + mDescription = pObjectData.get(PATHFINDING_OBJECT_DESCRIPTION_FIELD).asString(); + +#ifdef SERVER_SIDE_OWNER_ROLLOUT_COMPLETE + llassert(pObjectData.has(PATHFINDING_OBJECT_OWNER_FIELD)); + llassert(pObjectData.get(PATHFINDING_OBJECT_OWNER_FIELD).isUUID()); + mOwnerUUID = pObjectData.get(PATHFINDING_OBJECT_OWNER_FIELD).asUUID(); + LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); +#else // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE + if (pObjectData.has(PATHFINDING_OBJECT_OWNER_FIELD)) + { + llassert(pObjectData.get(PATHFINDING_OBJECT_OWNER_FIELD).isUUID()); + mOwnerUUID = pObjectData.get(PATHFINDING_OBJECT_OWNER_FIELD).asUUID(); + LLAvatarNameCache::get(mOwnerUUID, &mOwnerName); + } +#endif // SERVER_SIDE_OWNER_ROLLOUT_COMPLETE + + llassert(pObjectData.has(PATHFINDING_OBJECT_POSITION_FIELD)); + llassert(pObjectData.get(PATHFINDING_OBJECT_POSITION_FIELD).isArray()); + mLocation.setValue(pObjectData.get(PATHFINDING_OBJECT_POSITION_FIELD)); +} diff --git a/indra/newview/llpathfindingobject.h b/indra/newview/llpathfindingobject.h new file mode 100644 index 0000000000..9dc114b40f --- /dev/null +++ b/indra/newview/llpathfindingobject.h @@ -0,0 +1,73 @@ +/** +* @file llpathfindingobject.h +* @brief Header file for llpathfindingobject +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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$ +*/ +#ifndef LL_LLPATHFINDINGOBJECT_H +#define LL_LLPATHFINDINGOBJECT_H + +#include "v3math.h" +#include "llavatarname.h" +#include "lluuid.h" + +#include <string> + +#include <boost/shared_ptr.hpp> + +class LLPathfindingObject; +class LLSD; + +typedef boost::shared_ptr<LLPathfindingObject> LLPathfindingObjectPtr; + +class LLPathfindingObject +{ +public: + LLPathfindingObject(); + LLPathfindingObject(const std::string &pUUID, const LLSD &pObjectData); + LLPathfindingObject(const LLPathfindingObject& pOther); + virtual ~LLPathfindingObject(); + + LLPathfindingObject& operator =(const LLPathfindingObject& pOther); + + inline const LLUUID& getUUID() const {return mUUID;}; + inline const std::string& getName() const {return mName;}; + inline const std::string& getDescription() const {return mDescription;}; + inline BOOL hasOwnerName() const {return mOwnerUUID.notNull();}; + std::string getOwnerName() const; + inline const LLVector3& getLocation() const {return mLocation;}; + +protected: + +private: + void parseObjectData(const LLSD &pObjectData); + + LLUUID mUUID; + std::string mName; + std::string mDescription; + LLUUID mOwnerUUID; + LLAvatarName mOwnerName; + LLVector3 mLocation; +}; + +#endif // LL_LLPATHFINDINGOBJECT_H diff --git a/indra/newview/llpathfindingobjectlist.cpp b/indra/newview/llpathfindingobjectlist.cpp new file mode 100644 index 0000000000..cad3a0a00f --- /dev/null +++ b/indra/newview/llpathfindingobjectlist.cpp @@ -0,0 +1,110 @@ +/** +* @file llpathfindingobjectlist.cpp +* @brief Implementation of llpathfindingobjectlist +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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 "llpathfindingobjectlist.h" + +#include <string> +#include <map> + +//--------------------------------------------------------------------------- +// LLPathfindingObjectList +//--------------------------------------------------------------------------- + +LLPathfindingObjectList::LLPathfindingObjectList() + : mObjectMap() +{ +} + +LLPathfindingObjectList::~LLPathfindingObjectList() +{ +} + +bool LLPathfindingObjectList::isEmpty() const +{ + return mObjectMap.empty(); +} + +void LLPathfindingObjectList::update(LLPathfindingObjectPtr pUpdateObjectPtr) +{ + if (pUpdateObjectPtr != NULL) + { + std::string updateObjectId = pUpdateObjectPtr->getUUID().asString(); + + LLPathfindingObjectMap::iterator foundObjectIter = mObjectMap.find(updateObjectId); + if (foundObjectIter == mObjectMap.end()) + { + mObjectMap.insert(std::pair<std::string, LLPathfindingObjectPtr>(updateObjectId, pUpdateObjectPtr)); + } + else + { + foundObjectIter->second = pUpdateObjectPtr; + } + } +} + +void LLPathfindingObjectList::update(LLPathfindingObjectListPtr pUpdateObjectListPtr) +{ + if ((pUpdateObjectListPtr != NULL) && !pUpdateObjectListPtr->isEmpty()) + { + for (LLPathfindingObjectMap::const_iterator updateObjectIter = pUpdateObjectListPtr->begin(); + updateObjectIter != pUpdateObjectListPtr->end(); ++updateObjectIter) + { + const LLPathfindingObjectPtr updateObjectPtr = updateObjectIter->second; + update(updateObjectPtr); + } + } +} + +LLPathfindingObjectPtr LLPathfindingObjectList::find(const std::string &pObjectId) const +{ + LLPathfindingObjectPtr objectPtr; + + LLPathfindingObjectMap::const_iterator objectIter = mObjectMap.find(pObjectId); + if (objectIter != mObjectMap.end()) + { + objectPtr = objectIter->second; + } + + return objectPtr; +} + +LLPathfindingObjectList::const_iterator LLPathfindingObjectList::begin() const +{ + return mObjectMap.begin(); +} + +LLPathfindingObjectList::const_iterator LLPathfindingObjectList::end() const +{ + return mObjectMap.end(); +} + +LLPathfindingObjectMap &LLPathfindingObjectList::getObjectMap() +{ + return mObjectMap; +} diff --git a/indra/newview/llpathfindingobjectlist.h b/indra/newview/llpathfindingobjectlist.h new file mode 100644 index 0000000000..94c53f3aba --- /dev/null +++ b/indra/newview/llpathfindingobjectlist.h @@ -0,0 +1,68 @@ +/** +* @file llpathfindingobjectlist.h +* @brief Header file for llpathfindingobjectlist +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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$ +*/ +#ifndef LL_LLPATHFINDINGOBJECTLIST_H +#define LL_LLPATHFINDINGOBJECTLIST_H + +#include <string> +#include <map> + +#include <boost/shared_ptr.hpp> + +#include "llpathfindingobject.h" + +class LLSD; +class LLPathfindingObjectList; + +typedef boost::shared_ptr<LLPathfindingObjectList> LLPathfindingObjectListPtr; +typedef std::map<std::string, LLPathfindingObjectPtr> LLPathfindingObjectMap; + +class LLPathfindingObjectList +{ +public: + LLPathfindingObjectList(); + virtual ~LLPathfindingObjectList(); + + bool isEmpty() const; + + void update(LLPathfindingObjectPtr pUpdateObjectPtr); + void update(LLPathfindingObjectListPtr pUpdateObjectListPtr); + + LLPathfindingObjectPtr find(const std::string &pObjectId) const; + + typedef LLPathfindingObjectMap::const_iterator const_iterator; + const_iterator begin() const; + const_iterator end() const; + + +protected: + LLPathfindingObjectMap &getObjectMap(); + +private: + LLPathfindingObjectMap mObjectMap; +}; + +#endif // LL_LLPATHFINDINGOBJECTLIST_H diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index a39e1a0511..9bf2922033 100644 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -104,6 +104,15 @@ <color name="LtGreen" value="0.2 1 0.2 1" /> + <color + name="Red_80" + value="1 0 0 0.8" /> + <color + name="Green_80" + value="0 1 0 0.8" /> + <color + name="Blue_80" + value="0 0 1 0.8" /> <!-- This color name makes potentially unused colors show up bright purple. Leave this here until all Unused? are removed below, otherwise @@ -636,6 +645,18 @@ name="PathfindingGoodColor" reference="LtGreen" /> <color + name="PathfindingDefaultBeaconColor" + reference="Red_80" /> + <color + name="PathfindingDefaultBeaconTextColor" + reference="White" /> + <color + name="PathfindingLinksetBeaconColor" + reference="Blue_80" /> + <color + name="PathfindingCharacterBeaconColor" + reference="Red_80" /> + <color name="PieMenuBgColor" value="0.24 0.24 0.24 0.59" /> <color diff --git a/indra/newview/skins/default/xui/en/floater_pathfinding_characters.xml b/indra/newview/skins/default/xui/en/floater_pathfinding_characters.xml index 16b4a70b93..a81c4cb891 100644 --- a/indra/newview/skins/default/xui/en/floater_pathfinding_characters.xml +++ b/indra/newview/skins/default/xui/en/floater_pathfinding_characters.xml @@ -14,12 +14,14 @@ save_rect="false" single_instance="true" title="Pathfinding characters"> - <floater.string name="characters_messaging_initial"></floater.string> - <floater.string name="characters_messaging_get_inprogress">Querying for pathfinding characters ...</floater.string> - <floater.string name="characters_messaging_get_error">Error detected while querying for pathfinding characters.</floater.string> - <floater.string name="characters_messaging_complete_none_found">No pathfinding characters.</floater.string> - <floater.string name="characters_messaging_complete_available">[NUM_SELECTED] characters selected out of [NUM_TOTAL].</floater.string> - <floater.string name="characters_messaging_not_enabled">This region is not enabled for pathfinding.</floater.string> + <floater.string name="messaging_initial"></floater.string> + <floater.string name="messaging_get_inprogress">Querying for pathfinding characters ...</floater.string> + <floater.string name="messaging_get_error">Error detected while querying for pathfinding characters.</floater.string> + <floater.string name="messaging_set_inprogress"></floater.string> + <floater.string name="messaging_set_error"></floater.string> + <floater.string name="messaging_complete_none_found">No pathfinding characters.</floater.string> + <floater.string name="messaging_complete_available">[NUM_SELECTED] characters selected out of [NUM_TOTAL].</floater.string> + <floater.string name="messaging_not_enabled">This region is not enabled for pathfinding.</floater.string> <floater.string name="character_cpu_time">[CPU_TIME] µs</floater.string> <panel border="false" @@ -38,7 +40,7 @@ top_pad="10" tab_stop="false" multi_select="true" - name="pathfinding_characters" + name="objects_scroll_list" width="600"> <scroll_list.columns label="Name" @@ -70,7 +72,7 @@ length="1" follows="left|bottom|right" layout="topleft" - name="characters_status" + name="messaging_status" top_pad="17" width="238"> Characters: @@ -80,7 +82,7 @@ height="21" label="Refresh list" layout="topleft" - name="refresh_characters_list" + name="refresh_objects_list" top_pad="-29" left_pad="0" width="115"/> @@ -89,7 +91,7 @@ height="21" label="Select all" layout="topleft" - name="select_all_characters" + name="select_all_objects" top_pad="-21" left_pad="8" width="115"/> @@ -98,7 +100,7 @@ height="21" label="Select none" layout="topleft" - name="select_none_characters" + name="select_none_objects" top_pad="-21" left_pad="8" width="115"/> @@ -150,7 +152,7 @@ height="22" label="Take" layout="topleft" - name="take_characters" + name="take_objects" top_pad="9" left="18" width="94"/> @@ -159,7 +161,7 @@ height="22" label="Take copy" layout="topleft" - name="take_copy_characters" + name="take_copy_objects" top_pad="-22" left_pad="6" width="94"/> @@ -168,7 +170,7 @@ height="22" label="Return" layout="topleft" - name="return_characters" + name="return_objects" top_pad="-22" left_pad="6" width="94"/> @@ -177,7 +179,7 @@ height="22" label="Delete" layout="topleft" - name="delete_characters" + name="delete_objects" top_pad="-22" left_pad="6" width="94"/> @@ -186,7 +188,7 @@ height="22" label="Teleport me to it" layout="topleft" - name="teleport_to_character" + name="teleport_me_to_object" tool_tip="Enabled only when one character is selected." top_pad="-22" left_pad="6" diff --git a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml index b4e367690c..3ae5301cc2 100644 --- a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml +++ b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml @@ -14,14 +14,14 @@ save_rect="false" single_instance="true" title="Pathfinding linksets"> - <floater.string name="linksets_messaging_initial"></floater.string> - <floater.string name="linksets_messaging_get_inprogress">Querying for pathfinding linksets ...</floater.string> - <floater.string name="linksets_messaging_get_error">Error detected while querying for pathfinding linksets.</floater.string> - <floater.string name="linksets_messaging_set_inprogress">Modifying selected pathfinding linksets ...</floater.string> - <floater.string name="linksets_messaging_set_error">Error detected while modifying selected pathfinding linksets.</floater.string> - <floater.string name="linksets_messaging_complete_none_found">No pathfinding linksets.</floater.string> - <floater.string name="linksets_messaging_complete_available">[NUM_SELECTED] linksets selected out of [NUM_TOTAL].</floater.string> - <floater.string name="linksets_messaging_not_enabled">This region is not enabled for pathfinding.</floater.string> + <floater.string name="messaging_initial"></floater.string> + <floater.string name="messaging_get_inprogress">Querying for pathfinding linksets ...</floater.string> + <floater.string name="messaging_get_error">Error detected while querying for pathfinding linksets.</floater.string> + <floater.string name="messaging_set_inprogress">Modifying selected pathfinding linksets ...</floater.string> + <floater.string name="messaging_set_error">Error detected while modifying selected pathfinding linksets.</floater.string> + <floater.string name="messaging_complete_none_found">No pathfinding linksets.</floater.string> + <floater.string name="messaging_complete_available">[NUM_SELECTED] linksets selected out of [NUM_TOTAL].</floater.string> + <floater.string name="messaging_not_enabled">This region is not enabled for pathfinding.</floater.string> <floater.string name="linkset_terrain_name">[Terrain]</floater.string> <floater.string name="linkset_terrain_description">--</floater.string> <floater.string name="linkset_terrain_owner">--</floater.string> @@ -174,7 +174,7 @@ top_pad="15" tab_stop="false" multi_select="true" - name="pathfinding_linksets" + name="objects_scroll_list" width="980"> <scroll_list.columns label="Name (root prim)" @@ -226,7 +226,7 @@ length="1" follows="left|bottom|right" layout="topleft" - name="linksets_status" + name="messaging_status" top_pad="17" width="619"> Linksets: @@ -236,7 +236,7 @@ height="21" label="Refresh list" layout="topleft" - name="refresh_linksets_list" + name="refresh_objects_list" top_pad="-16" left_pad="0" width="115"/> @@ -245,7 +245,7 @@ height="21" label="Select all" layout="topleft" - name="select_all_linksets" + name="select_all_objects" top_pad="-21" left_pad="8" width="115"/> @@ -254,7 +254,7 @@ height="21" label="Select none" layout="topleft" - name="select_none_linksets" + name="select_none_objects" top_pad="-21" left_pad="8" width="115"/> @@ -305,7 +305,7 @@ height="21" label="Take" layout="topleft" - name="take_linksets" + name="take_objects" top_pad="9" left="18" width="95"/> @@ -314,7 +314,7 @@ height="21" label="Take copy" layout="topleft" - name="take_copy_linksets" + name="take_copy_objects" top_pad="-21" left_pad="6" width="95"/> @@ -323,7 +323,7 @@ height="21" label="Return" layout="topleft" - name="return_linksets" + name="return_objects" top_pad="-21" left_pad="6" width="95"/> @@ -332,7 +332,7 @@ height="21" label="Delete" layout="topleft" - name="delete_linksets" + name="delete_objects" top_pad="-21" left_pad="6" width="95"/> @@ -341,7 +341,7 @@ height="21" label="Teleport me to it" layout="topleft" - name="teleport_me_to_linkset" + name="teleport_me_to_object" top_pad="-21" left_pad="6" width="160"/> |