From 3c2be426e5e905076d00b9492c0e66c8b31caf19 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 30 May 2012 18:47:12 -0700 Subject: First pass at refactoring the pathfinding linksets and pathfinding characters classes to reduce code duplication, as both functionalities were heavily duplicated. --- indra/newview/llfloaterpathfindingobjects.cpp | 680 ++++++++++++++++++++++++++ 1 file changed, 680 insertions(+) create mode 100644 indra/newview/llfloaterpathfindingobjects.cpp (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') 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 + +#include +#include + +#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 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 viewerObjects; + viewerObjects.reserve(numSelectedItems); + + for (std::vector::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("objects_scroll_list"); + llassert(mObjectsScrollList != NULL); + mObjectsScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onScrollListSelectionChanged, this)); + mObjectsScrollList->sortByColumnIndex(static_cast(getNameColumnIndex()), TRUE); + + mMessagingStatus = findChild("messaging_status"); + llassert(mMessagingStatus != NULL); + + mRefreshListButton = findChild("refresh_objects_list"); + llassert(mRefreshListButton != NULL); + mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onRefreshObjectsClicked, this)); + + mSelectAllButton = findChild("select_all_objects"); + llassert(mSelectAllButton != NULL); + mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onSelectAllObjectsClicked, this)); + + mSelectNoneButton = findChild("select_none_objects"); + llassert(mSelectNoneButton != NULL); + mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onSelectNoneObjectsClicked, this)); + + mShowBeaconCheckBox = findChild("show_beacon"); + llassert(mShowBeaconCheckBox != NULL); + + mTakeButton = findChild("take_objects"); + llassert(mTakeButton != NULL); + mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeClicked, this)); + + mTakeCopyButton = findChild("take_copy_objects"); + llassert(mTakeCopyButton != NULL); + mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeCopyClicked, this)); + + mReturnButton = findChild("return_objects"); + llassert(mReturnButton != NULL); + mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onReturnClicked, this)); + + mDeleteButton = findChild("delete_objects"); + llassert(mDeleteButton != NULL); + mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onDeleteClicked, this)); + + mTeleportButton = findChild("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 selectedItems = mObjectsScrollList->getAllSelected(); + int numSelectedItems = selectedItems.size(); + uuid_vec_t selectedUUIDs; + if (numSelectedItems > 0) + { + selectedUUIDs.reserve(selectedItems.size()); + for (std::vector::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 selectedItems = mObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + + std::vectorviewerObjects; + viewerObjects.reserve(numSelectedItems); + + for (std::vector::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 selectedItems = mObjectsScrollList->getAllSelected(); + llassert(selectedItems.size() == 1); + if (selectedItems.size() == 1) + { + std::vector::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 selectedItems = mObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + for (std::vector::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 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; +} -- cgit v1.2.3 From 3352a1eac15f752535b636866eeb966ec3900c62 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 30 May 2012 19:39:08 -0700 Subject: Cleaning up some unreferenced headers and classes definitions from previous refactoring. --- indra/newview/llfloaterpathfindingobjects.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 3b3de3f417..e8d80c09d8 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -34,14 +34,10 @@ #include #include -#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" @@ -57,6 +53,7 @@ #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" +#include "v4color.h" #define DEFAULT_BEACON_WIDTH 6 -- cgit v1.2.3 From 938f42ded789dd70b31820d29694256cec3a1572 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 31 May 2012 12:22:47 -0700 Subject: Reloading the the pathfinding object floaters when the god level is changed. --- indra/newview/llfloaterpathfindingobjects.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index e8d80c09d8..3f6c4983d5 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -78,11 +78,21 @@ void LLFloaterPathfindingObjects::onOpen(const LLSD &pKey) mRegionBoundaryCrossingSlot = LLEnvManagerNew::getInstance()->setRegionChangeCallback(boost::bind(&LLFloaterPathfindingObjects::onRegionBoundaryCrossed, this)); } + if (!mGodLevelChangeSlot.connected()) + { + mGodLevelChangeSlot = gAgent.registerGodLevelChanageListener(boost::bind(&LLFloaterPathfindingObjects::onGodLevelChange, this, _1)); + } + requestGetObjects(); } void LLFloaterPathfindingObjects::onClose(bool pIsAppQuitting) { + if (mGodLevelChangeSlot.connected()) + { + mGodLevelChangeSlot.disconnect(); + } + if (mRegionBoundaryCrossingSlot.connected()) { mRegionBoundaryCrossingSlot.disconnect(); @@ -554,6 +564,11 @@ void LLFloaterPathfindingObjects::onRegionBoundaryCrossed() requestGetObjects(); } +void LLFloaterPathfindingObjects::onGodLevelChange(U8 pGodLevel) +{ + requestGetObjects(); +} + void LLFloaterPathfindingObjects::updateMessagingStatus() { std::string statusText(""); -- cgit v1.2.3 From ef75a2e07ec4f26c9126c04af1adfbd28d7eaa9b Mon Sep 17 00:00:00 2001 From: prep Date: Thu, 31 May 2012 16:38:19 -0400 Subject: WIP:Displaying physics capsule for a character - it is currently disabled. --- indra/newview/llfloaterpathfindingobjects.cpp | 91 ++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index e8d80c09d8..572f2f707e 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -54,9 +54,13 @@ #include "llviewerobjectlist.h" #include "llviewerregion.h" #include "v4color.h" +#include "pipeline.h" +#include "llfloaterreg.h" #define DEFAULT_BEACON_WIDTH 6 +LLHandle LLFloaterPathfindingObjects::sInstanceHandle; + //--------------------------------------------------------------------------- // LLFloaterPathfindingObjects //--------------------------------------------------------------------------- @@ -144,6 +148,7 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mSelectAllButton(NULL), mSelectNoneButton(NULL), mShowBeaconCheckBox(NULL), + mShowPhysicsCapsuleCheckBox(NULL), mTakeButton(NULL), mTakeCopyButton(NULL), mReturnButton(NULL), @@ -158,8 +163,10 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mObjectList(), mObjectsSelection(), mSelectionUpdateSlot(), - mRegionBoundaryCrossingSlot() + mRegionBoundaryCrossingSlot(), + mSelfHandle() { + mSelfHandle.bind(this); } LLFloaterPathfindingObjects::~LLFloaterPathfindingObjects() @@ -196,6 +203,10 @@ BOOL LLFloaterPathfindingObjects::postBuild() mShowBeaconCheckBox = findChild("show_beacon"); llassert(mShowBeaconCheckBox != NULL); + mShowPhysicsCapsuleCheckBox = findChild("show_physics_capsule"); + llassert(mShowPhysicsCapsuleCheckBox != NULL); + mShowPhysicsCapsuleCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onShowPhysicsCapsuleClicked, this)); + mTakeButton = findChild("take_objects"); llassert(mTakeButton != NULL); mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeClicked, this)); @@ -657,6 +668,7 @@ void LLFloaterPathfindingObjects::updateStateOnEditFields() bool isEditEnabled = (numSelectedItems > 0); mShowBeaconCheckBox->setEnabled(isEditEnabled); + //prep#mShowPhysicsCapsuleCheckBox->setEnabled( false ); mTakeButton->setEnabled(isEditEnabled && visible_take_object()); mTakeCopyButton->setEnabled(isEditEnabled && enable_object_take_copy()); mReturnButton->setEnabled(isEditEnabled && enable_object_return()); @@ -675,3 +687,80 @@ LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollLis return objectPtr; } + +void LLFloaterPathfindingObjects::onShowPhysicsCapsuleClicked() +{ + if ( mShowPhysicsCapsuleCheckBox->get() ) + { + //We want to hide the VO and display the the objects physics capsule + LLVector3 pos; + LLUUID id = getUUIDFromSelection( pos ); + if ( id.notNull() ) + { + gPipeline.hideObject( id ); + } + } + else + { + //We want to restore the selected objects vo and disable the physics capsule rendering + LLVector3 pos; + LLUUID id = getUUIDFromSelection( pos ); + if ( id.notNull() ) + { + gPipeline.restoreHiddenObject( id ); + } + } +} + +BOOL LLFloaterPathfindingObjects::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) +{ + BOOL result = false; + if ( mShowPhysicsCapsuleCheckBox->get() ) + { + id = getUUIDFromSelection( pos ); + result = true; + } + else + { + id.setNull(); + } + return result; +} + +LLUUID LLFloaterPathfindingObjects::getUUIDFromSelection( LLVector3& pos ) +{ + std::vector selectedItems = mObjectsScrollList->getAllSelected(); + if ( selectedItems.size() > 1 ) + { + return LLUUID::null; + } + if (selectedItems.size() == 1) + { + std::vector::const_reference selectedItemRef = selectedItems.front(); + const LLScrollListItem *selectedItem = selectedItemRef; + llassert(mObjectList != NULL); + LLViewerObject *viewerObject = gObjectList.findObject( selectedItem->getUUID() ); + if ( viewerObject != NULL ) + { + pos = viewerObject->getRenderPosition(); + } + //prep#llinfos<<"id : "<getUUID()<getUUID(); + } + + return LLUUID::null; +} + +LLHandle LLFloaterPathfindingObjects::getInstanceHandle() +{ + if ( sInstanceHandle.isDead() ) + { + LLFloaterPathfindingObjects *floaterInstance = LLFloaterReg::getTypedInstance("pathfinding_characters"); + if (floaterInstance != NULL) + { + sInstanceHandle = floaterInstance->mSelfHandle; + } + } + + return sInstanceHandle; +} -- cgit v1.2.3 From 41bcd567646190cda86ec3ee77041bd84193c377 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 31 May 2012 17:25:41 -0700 Subject: A bit more class clean-up for the LLFloaterPathfindingObjects. --- indra/newview/llfloaterpathfindingobjects.cpp | 72 +++++++++++++-------------- 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 3f6c4983d5..a8f604b970 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -70,7 +70,7 @@ void LLFloaterPathfindingObjects::onOpen(const LLSD &pKey) if (!mSelectionUpdateSlot.connected()) { - mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingObjects::onSelectionListChanged, this)); + mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingObjects::onInWorldSelectionListChanged, this)); } if (!mRegionBoundaryCrossingSlot.connected()) @@ -356,40 +356,6 @@ void LLFloaterPathfindingObjects::updateControls() updateStateOnEditFields(); } -void LLFloaterPathfindingObjects::updateSelection() -{ - mObjectsSelection.clear(); - LLSelectMgr::getInstance()->deselectAll(); - - std::vector selectedItems = mObjectsScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - std::vectorviewerObjects; - viewerObjects.reserve(numSelectedItems); - - for (std::vector::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; @@ -551,10 +517,10 @@ void LLFloaterPathfindingObjects::onTeleportClicked() void LLFloaterPathfindingObjects::onScrollListSelectionChanged() { - updateSelection(); + updateOnScrollListChange(); } -void LLFloaterPathfindingObjects::onSelectionListChanged() +void LLFloaterPathfindingObjects::onInWorldSelectionListChanged() { updateControls(); } @@ -679,6 +645,38 @@ void LLFloaterPathfindingObjects::updateStateOnEditFields() mTeleportButton->setEnabled(numSelectedItems == 1); } +void LLFloaterPathfindingObjects::updateOnScrollListChange() +{ + mObjectsSelection.clear(); + LLSelectMgr::getInstance()->deselectAll(); + + std::vector selectedItems = mObjectsScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + + std::vectorviewerObjects; + viewerObjects.reserve(numSelectedItems); + + for (std::vector::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); + } + } +} + LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollListItem *pListItem) const { LLPathfindingObjectPtr objectPtr; -- cgit v1.2.3 From ed486b3ca00c12aee5b1f594f9f8e507e784996a Mon Sep 17 00:00:00 2001 From: prep Date: Fri, 1 Jun 2012 13:01:13 -0400 Subject: Update to latest llphysics extensions library --- indra/newview/llfloaterpathfindingobjects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index d78ad9d754..8d5674054b 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -757,7 +757,7 @@ LLUUID LLFloaterPathfindingObjects::getUUIDFromSelection( LLVector3& pos ) { pos = viewerObject->getRenderPosition(); } - //prep#llinfos<<"id : "<getUUID()<getUUID()<getUUID(); } -- cgit v1.2.3 From a8ff37b95609148c60ddda9acfca65b2b89d6b9d Mon Sep 17 00:00:00 2001 From: prep Date: Fri, 1 Jun 2012 15:48:19 -0400 Subject: Migrated physics capsule logic into pathing character object --- indra/newview/llfloaterpathfindingobjects.cpp | 92 ++++----------------------- 1 file changed, 12 insertions(+), 80 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 8d5674054b..da7c51599f 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -59,8 +59,6 @@ #define DEFAULT_BEACON_WIDTH 6 -LLHandle LLFloaterPathfindingObjects::sInstanceHandle; - //--------------------------------------------------------------------------- // LLFloaterPathfindingObjects //--------------------------------------------------------------------------- @@ -92,6 +90,8 @@ void LLFloaterPathfindingObjects::onOpen(const LLSD &pKey) void LLFloaterPathfindingObjects::onClose(bool pIsAppQuitting) { + unhideAnyCharacters(); + if (mGodLevelChangeSlot.connected()) { mGodLevelChangeSlot.disconnect(); @@ -158,7 +158,6 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mSelectAllButton(NULL), mSelectNoneButton(NULL), mShowBeaconCheckBox(NULL), - mShowPhysicsCapsuleCheckBox(NULL), mTakeButton(NULL), mTakeCopyButton(NULL), mReturnButton(NULL), @@ -173,10 +172,8 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mObjectList(), mObjectsSelection(), mSelectionUpdateSlot(), - mRegionBoundaryCrossingSlot(), - mSelfHandle() + mRegionBoundaryCrossingSlot() { - mSelfHandle.bind(this); } LLFloaterPathfindingObjects::~LLFloaterPathfindingObjects() @@ -213,10 +210,6 @@ BOOL LLFloaterPathfindingObjects::postBuild() mShowBeaconCheckBox = findChild("show_beacon"); llassert(mShowBeaconCheckBox != NULL); - mShowPhysicsCapsuleCheckBox = findChild("show_physics_capsule"); - llassert(mShowPhysicsCapsuleCheckBox != NULL); - mShowPhysicsCapsuleCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onShowPhysicsCapsuleClicked, this)); - mTakeButton = findChild("take_objects"); llassert(mTakeButton != NULL); mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingObjects::onTakeClicked, this)); @@ -649,7 +642,6 @@ void LLFloaterPathfindingObjects::updateStateOnEditFields() bool isEditEnabled = (numSelectedItems > 0); mShowBeaconCheckBox->setEnabled(isEditEnabled); - //prep#mShowPhysicsCapsuleCheckBox->setEnabled( false ); mTakeButton->setEnabled(isEditEnabled && visible_take_object()); mTakeCopyButton->setEnabled(isEditEnabled && enable_object_take_copy()); mReturnButton->setEnabled(isEditEnabled && enable_object_return()); @@ -701,79 +693,19 @@ LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollLis return objectPtr; } -void LLFloaterPathfindingObjects::onShowPhysicsCapsuleClicked() -{ - if ( mShowPhysicsCapsuleCheckBox->get() ) - { - //We want to hide the VO and display the the objects physics capsule - LLVector3 pos; - LLUUID id = getUUIDFromSelection( pos ); - if ( id.notNull() ) - { - gPipeline.hideObject( id ); - } - } - else - { - //We want to restore the selected objects vo and disable the physics capsule rendering - LLVector3 pos; - LLUUID id = getUUIDFromSelection( pos ); - if ( id.notNull() ) - { - gPipeline.restoreHiddenObject( id ); - } - } -} - -BOOL LLFloaterPathfindingObjects::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) -{ - BOOL result = false; - if ( mShowPhysicsCapsuleCheckBox->get() ) - { - id = getUUIDFromSelection( pos ); - result = true; - } - else - { - id.setNull(); - } - return result; -} -LLUUID LLFloaterPathfindingObjects::getUUIDFromSelection( LLVector3& pos ) -{ - std::vector selectedItems = mObjectsScrollList->getAllSelected(); - if ( selectedItems.size() > 1 ) - { - return LLUUID::null; - } - if (selectedItems.size() == 1) - { - std::vector::const_reference selectedItemRef = selectedItems.front(); - const LLScrollListItem *selectedItem = selectedItemRef; - llassert(mObjectList != NULL); - LLViewerObject *viewerObject = gObjectList.findObject( selectedItem->getUUID() ); - if ( viewerObject != NULL ) - { - pos = viewerObject->getRenderPosition(); - } - //llinfos<<"id : "<getUUID()<getUUID(); - } - - return LLUUID::null; -} - -LLHandle LLFloaterPathfindingObjects::getInstanceHandle() +void LLFloaterPathfindingObjects::unhideAnyCharacters( ) { - if ( sInstanceHandle.isDead() ) + std::vector selectedItems = mObjectsScrollList->getAllSelected(); + int numSelectedItems = selectedItems.size(); + uuid_vec_t selectedUUIDs; + if (numSelectedItems > 0) { - LLFloaterPathfindingObjects *floaterInstance = LLFloaterReg::getTypedInstance("pathfinding_characters"); - if (floaterInstance != NULL) + for (std::vector::const_iterator itemIter = selectedItems.begin(); + itemIter != selectedItems.end(); ++itemIter) { - sInstanceHandle = floaterInstance->mSelfHandle; + const LLScrollListItem *listItem = *itemIter; + gPipeline.restoreHiddenObject( listItem->getUUID() ); } } - - return sInstanceHandle; } -- cgit v1.2.3 From bf8d3e1d304007cbd2a723808193e172b3e56c8a Mon Sep 17 00:00:00 2001 From: prep Date: Fri, 1 Jun 2012 16:02:12 -0400 Subject: Migrated restoration of physics capsule into pathing character --- indra/newview/llfloaterpathfindingobjects.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index da7c51599f..002849695a 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -90,8 +90,7 @@ void LLFloaterPathfindingObjects::onOpen(const LLSD &pKey) void LLFloaterPathfindingObjects::onClose(bool pIsAppQuitting) { - unhideAnyCharacters(); - + if (mGodLevelChangeSlot.connected()) { mGodLevelChangeSlot.disconnect(); @@ -693,19 +692,3 @@ LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollLis return objectPtr; } - -void LLFloaterPathfindingObjects::unhideAnyCharacters( ) -{ - std::vector selectedItems = mObjectsScrollList->getAllSelected(); - int numSelectedItems = selectedItems.size(); - uuid_vec_t selectedUUIDs; - if (numSelectedItems > 0) - { - for (std::vector::const_iterator itemIter = selectedItems.begin(); - itemIter != selectedItems.end(); ++itemIter) - { - const LLScrollListItem *listItem = *itemIter; - gPipeline.restoreHiddenObject( listItem->getUUID() ); - } - } -} -- cgit v1.2.3 From 372391403d3a7ca3c67d7a6256ab3e4c44018bd0 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 1 Jun 2012 16:34:42 -0700 Subject: Adding an automatic refresh to the pathfinding object floaters. --- indra/newview/llfloaterpathfindingobjects.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 002849695a..8aaeb299f1 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -234,6 +234,7 @@ BOOL LLFloaterPathfindingObjects::postBuild() void LLFloaterPathfindingObjects::requestGetObjects() { + llassert(0); } LLPathfindingManager::request_id_t LLFloaterPathfindingObjects::getNewRequestId() @@ -496,6 +497,7 @@ void LLFloaterPathfindingObjects::onSelectNoneObjectsClicked() void LLFloaterPathfindingObjects::onTakeClicked() { handle_take(); + requestGetObjects(); } void LLFloaterPathfindingObjects::onTakeCopyClicked() @@ -506,11 +508,13 @@ void LLFloaterPathfindingObjects::onTakeCopyClicked() void LLFloaterPathfindingObjects::onReturnClicked() { handle_object_return(); + requestGetObjects(); } void LLFloaterPathfindingObjects::onDeleteClicked() { handle_object_delete(); + requestGetObjects(); } void LLFloaterPathfindingObjects::onTeleportClicked() -- cgit v1.2.3 From ea23285f8b728bf52c8490610c610f4abd2d6957 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 4 Jun 2012 14:36:43 -0700 Subject: Ensuring that the scroll list is rebuilt after any missing avatar names are loaded into cache. --- indra/newview/llfloaterpathfindingobjects.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 8aaeb299f1..7ac0d05bac 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -35,6 +35,8 @@ #include #include "llagent.h" +#include "llavatarname.h" +#include "llavatarnamecache.h" #include "llbutton.h" #include "llcheckboxctrl.h" #include "llenvmanager.h" @@ -162,6 +164,7 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mReturnButton(NULL), mDeleteButton(NULL), mTeleportButton(NULL), + mLoadingAvatarNames(), mDefaultBeaconColor(), mDefaultBeaconTextColor(), mErrorTextColor(), @@ -346,13 +349,23 @@ void LLFloaterPathfindingObjects::rebuildObjectsScrollList() updateControls(); } -LLSD LLFloaterPathfindingObjects::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const +LLSD LLFloaterPathfindingObjects::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) { llassert(0); LLSD nullObjs = LLSD::emptyArray(); return nullObjs; } +void LLFloaterPathfindingObjects::rebuildScrollListAfterAvatarNameLoads(const LLUUID &pAvatarId) +{ + std::set::const_iterator iter = mLoadingAvatarNames.find(pAvatarId); + if (iter == mLoadingAvatarNames.end()) + { + mLoadingAvatarNames.insert(pAvatarId); + LLAvatarNameCache::get(pAvatarId, boost::bind(&LLFloaterPathfindingObjects::handleAvatarNameLoads, this, _1, _2)); + } +} + void LLFloaterPathfindingObjects::updateControls() { updateMessagingStatus(); @@ -542,6 +555,16 @@ void LLFloaterPathfindingObjects::onGodLevelChange(U8 pGodLevel) requestGetObjects(); } +void LLFloaterPathfindingObjects::handleAvatarNameLoads(const LLUUID &pAvatarId, const LLAvatarName &pAvatarName) +{ + llassert(mLoadingAvatarNames.find(pAvatarId) != mLoadingAvatarNames.end()); + mLoadingAvatarNames.erase(pAvatarId); + if (mLoadingAvatarNames.empty()) + { + rebuildObjectsScrollList(); + } +} + void LLFloaterPathfindingObjects::updateMessagingStatus() { std::string statusText(""); -- cgit v1.2.3 From 527fb080f5352ad3c96d9fb40d737a45fc5ad33d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 4 Jun 2012 18:22:35 -0700 Subject: BUGFIX: Correcting selection behavior where the floater edit fields were not being updated if the object selected was not in range of the viewer. --- indra/newview/llfloaterpathfindingobjects.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 7ac0d05bac..56f45a886f 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -538,6 +538,7 @@ void LLFloaterPathfindingObjects::onTeleportClicked() void LLFloaterPathfindingObjects::onScrollListSelectionChanged() { updateOnScrollListChange(); + updateControls(); } void LLFloaterPathfindingObjects::onInWorldSelectionListChanged() -- cgit v1.2.3 From 9762c5c98c90f8bb42f1c39bb4879710e0f0b457 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 5 Jun 2012 18:19:08 -0700 Subject: PATH-682: Correcting behavior for the case where setting the linksets and the response returned is an error, and this causes the viewer to crash. This commit should remove the viewer crash. --- indra/newview/llfloaterpathfindingobjects.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 56f45a886f..6f183c78b1 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -304,10 +304,12 @@ void LLFloaterPathfindingObjects::handleUpdateObjectList(LLPathfindingManager::r setMessagingState(kMessagingNotEnabled); break; case LLPathfindingManager::kRequestError : - setMessagingState(kMessagingGetError); + clearAllObjects(); + setMessagingState(kMessagingSetError); break; default : - setMessagingState(kMessagingGetError); + clearAllObjects(); + setMessagingState(kMessagingSetError); llassert(0); break; } @@ -401,7 +403,7 @@ BOOL LLFloaterPathfindingObjects::isShowBeacons() const void LLFloaterPathfindingObjects::clearAllObjects() { selectNoneObjects(); - mObjectsScrollList->clear(); + mObjectsScrollList->deleteAllItems(); mObjectList.reset(); } -- cgit v1.2.3 From e78266e9378bdd19ea4a8f7833cf39e59d2faecc Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 15 Jun 2012 12:45:41 -0700 Subject: BUGFIX: Correcting a behavior where moving the cursor over a selected object inappropriately called updateControls(). Fix was to break the updateControl() functionality into two separate handlers updateControlsOnScrollListChange() and updateControlsOnInWorldSelectionChange(). --- indra/newview/llfloaterpathfindingobjects.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 6f183c78b1..14fa0ac428 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -348,7 +348,7 @@ void LLFloaterPathfindingObjects::rebuildObjectsScrollList() mObjectsScrollList->selectMultiple(selectedUUIDs); mObjectsScrollList->setScrollPos(origScrollPosition); - updateControls(); + updateControlsOnScrollListChange(); } LLSD LLFloaterPathfindingObjects::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) @@ -368,11 +368,17 @@ void LLFloaterPathfindingObjects::rebuildScrollListAfterAvatarNameLoads(const LL } } -void LLFloaterPathfindingObjects::updateControls() +void LLFloaterPathfindingObjects::updateControlsOnScrollListChange() { updateMessagingStatus(); - updateStateOnListActionControls(); - updateStateOnEditFields(); + updateStateOnListControls(); + selectScrollListItemsInWorld(); + updateStateOnActionControls(); +} + +void LLFloaterPathfindingObjects::updateControlsOnInWorldSelectionChange() +{ + updateStateOnActionControls(); } S32 LLFloaterPathfindingObjects::getNameColumnIndex() const @@ -491,7 +497,7 @@ LLFloaterPathfindingObjects::EMessagingState LLFloaterPathfindingObjects::getMes void LLFloaterPathfindingObjects::setMessagingState(EMessagingState pMessagingState) { mMessagingState = pMessagingState; - updateControls(); + updateControlsOnScrollListChange(); } void LLFloaterPathfindingObjects::onRefreshObjectsClicked() @@ -539,13 +545,12 @@ void LLFloaterPathfindingObjects::onTeleportClicked() void LLFloaterPathfindingObjects::onScrollListSelectionChanged() { - updateOnScrollListChange(); - updateControls(); + updateControlsOnScrollListChange(); } void LLFloaterPathfindingObjects::onInWorldSelectionListChanged() { - updateControls(); + updateControlsOnInWorldSelectionChange(); } void LLFloaterPathfindingObjects::onRegionBoundaryCrossed() @@ -632,7 +637,7 @@ void LLFloaterPathfindingObjects::updateMessagingStatus() mMessagingStatus->setText((LLStringExplicit)statusText, styleParams); } -void LLFloaterPathfindingObjects::updateStateOnListActionControls() +void LLFloaterPathfindingObjects::updateStateOnListControls() { switch (getMessagingState()) { @@ -665,7 +670,7 @@ void LLFloaterPathfindingObjects::updateStateOnListActionControls() } } -void LLFloaterPathfindingObjects::updateStateOnEditFields() +void LLFloaterPathfindingObjects::updateStateOnActionControls() { int numSelectedItems = mObjectsScrollList->getNumSelected(); bool isEditEnabled = (numSelectedItems > 0); @@ -678,7 +683,7 @@ void LLFloaterPathfindingObjects::updateStateOnEditFields() mTeleportButton->setEnabled(numSelectedItems == 1); } -void LLFloaterPathfindingObjects::updateOnScrollListChange() +void LLFloaterPathfindingObjects::selectScrollListItemsInWorld() { mObjectsSelection.clear(); LLSelectMgr::getInstance()->deselectAll(); -- cgit v1.2.3 From 328322436c046bf229de83041b29ebe5ce7c4029 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 22 Jun 2012 16:12:32 -0700 Subject: PATH-764,PATH-765: Adding in a context menu option on right-click of an object to show in the linksets floater if all objects are non-characters, or to show in the characters floater if all objects are characters. --- indra/newview/llfloaterpathfindingobjects.cpp | 75 +++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 11 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 14fa0ac428..cd6d0851b9 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -173,6 +173,8 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mMessagingRequestId(0U), mObjectList(), mObjectsSelection(), + mHasObjectsToBeSelected(false), + mObjectsToBeSelected(), mSelectionUpdateSlot(), mRegionBoundaryCrossingSlot() { @@ -318,17 +320,19 @@ void LLFloaterPathfindingObjects::handleUpdateObjectList(LLPathfindingManager::r void LLFloaterPathfindingObjects::rebuildObjectsScrollList() { - std::vector selectedItems = mObjectsScrollList->getAllSelected(); - int numSelectedItems = selectedItems.size(); - uuid_vec_t selectedUUIDs; - if (numSelectedItems > 0) + if (!mHasObjectsToBeSelected) { - selectedUUIDs.reserve(selectedItems.size()); - for (std::vector::const_iterator itemIter = selectedItems.begin(); - itemIter != selectedItems.end(); ++itemIter) + std::vector selectedItems = mObjectsScrollList->getAllSelected(); + int numSelectedItems = selectedItems.size(); + if (numSelectedItems > 0) { - const LLScrollListItem *listItem = *itemIter; - selectedUUIDs.push_back(listItem->getUUID()); + mObjectsToBeSelected.reserve(selectedItems.size()); + for (std::vector::const_iterator itemIter = selectedItems.begin(); + itemIter != selectedItems.end(); ++itemIter) + { + const LLScrollListItem *listItem = *itemIter; + mObjectsToBeSelected.push_back(listItem->getUUID()); + } } } @@ -346,8 +350,19 @@ void LLFloaterPathfindingObjects::rebuildObjectsScrollList() } } - mObjectsScrollList->selectMultiple(selectedUUIDs); - mObjectsScrollList->setScrollPos(origScrollPosition); + mObjectsScrollList->selectMultiple(mObjectsToBeSelected); + if (mHasObjectsToBeSelected) + { + mObjectsScrollList->scrollToShowSelected(); + } + else + { + mObjectsScrollList->setScrollPos(origScrollPosition); + } + + mObjectsToBeSelected.clear(); + mHasObjectsToBeSelected = false; + updateControlsOnScrollListChange(); } @@ -401,6 +416,44 @@ S32 LLFloaterPathfindingObjects::getBeaconWidth() const return DEFAULT_BEACON_WIDTH; } +void LLFloaterPathfindingObjects::showFloaterWithSelectionObjects() +{ + mObjectsToBeSelected.clear(); + + LLObjectSelectionHandle selectedObjectsHandle = LLSelectMgr::getInstance()->getSelection(); + if (selectedObjectsHandle.notNull()) + { + LLObjectSelection *selectedObjects = selectedObjectsHandle.get(); + if (!selectedObjects->isEmpty()) + { + for (LLObjectSelection::valid_iterator objectIter = selectedObjects->valid_begin(); + objectIter != selectedObjects->valid_end(); ++objectIter) + { + LLSelectNode *object = *objectIter; + LLViewerObject *viewerObject = object->getObject(); + mObjectsToBeSelected.push_back(viewerObject->getID()); + } + } + } + mHasObjectsToBeSelected = true; + + if (!isShown()) + { + openFloater(); + setVisibleAndFrontmost(); + } + else + { + rebuildObjectsScrollList(); + if (isMinimized()) + { + setMinimized(FALSE); + } + setVisibleAndFrontmost(); + } + setFocus(TRUE); +} + BOOL LLFloaterPathfindingObjects::isShowBeacons() const { return mShowBeaconCheckBox->get(); -- cgit v1.2.3 From bf86a697313869627f8b7025ecd68032f2556f6f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 25 Jun 2012 15:37:18 -0700 Subject: PATH-717: Minor UI changes from Leo. Also, adding a notification when attempting to return or delete multiple items. --- indra/newview/llfloaterpathfindingobjects.cpp | 56 +++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index cd6d0851b9..ea93955a5c 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -41,6 +41,8 @@ #include "llcheckboxctrl.h" #include "llenvmanager.h" #include "llfloater.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" #include "llpathfindingmanager.h" #include "llresmgr.h" #include "llscrolllistctrl.h" @@ -581,14 +583,42 @@ void LLFloaterPathfindingObjects::onTakeCopyClicked() void LLFloaterPathfindingObjects::onReturnClicked() { - handle_object_return(); - requestGetObjects(); + LLNotification::Params params("PathfindingReturnMultipleItems"); + params.functor.function(boost::bind(&LLFloaterPathfindingObjects::handleReturnItemsResponse, this, _1, _2)); + + LLSD substitutions; + int numItems = getNumSelectedObjects(); + substitutions["NUM_ITEMS"] = static_cast(numItems); + params.substitutions = substitutions; + + if (numItems == 1) + { + LLNotifications::getInstance()->forceResponse(params, 0); + } + else if (numItems > 1) + { + LLNotifications::getInstance()->add(params); + } } void LLFloaterPathfindingObjects::onDeleteClicked() { - handle_object_delete(); - requestGetObjects(); + LLNotification::Params params("PathfindingDeleteMultipleItems"); + params.functor.function(boost::bind(&LLFloaterPathfindingObjects::handleDeleteItemsResponse, this, _1, _2)); + + LLSD substitutions; + int numItems = getNumSelectedObjects(); + substitutions["NUM_ITEMS"] = static_cast(numItems); + params.substitutions = substitutions; + + if (numItems == 1) + { + LLNotifications::getInstance()->forceResponse(params, 0); + } + else if (numItems > 1) + { + LLNotifications::getInstance()->add(params); + } } void LLFloaterPathfindingObjects::onTeleportClicked() @@ -768,6 +798,24 @@ void LLFloaterPathfindingObjects::selectScrollListItemsInWorld() } } +void LLFloaterPathfindingObjects::handleReturnItemsResponse(const LLSD &pNotification, const LLSD &pResponse) +{ + if (LLNotificationsUtil::getSelectedOption(pNotification, pResponse) == 0) + { + handle_object_return(); + requestGetObjects(); + } +} + +void LLFloaterPathfindingObjects::handleDeleteItemsResponse(const LLSD &pNotification, const LLSD &pResponse) +{ + if (LLNotificationsUtil::getSelectedOption(pNotification, pResponse) == 0) + { + handle_object_delete(); + requestGetObjects(); + } +} + LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollListItem *pListItem) const { LLPathfindingObjectPtr objectPtr; -- cgit v1.2.3 From b3ccf0f2adb666d558cddd3cad1e548a99ea401f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 25 Jun 2012 18:24:03 -0700 Subject: Correcting a state message when setting values on the linkset floater. --- indra/newview/llfloaterpathfindingobjects.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index ea93955a5c..9bfbc582bd 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -283,13 +283,14 @@ void LLFloaterPathfindingObjects::handleNewObjectList(LLPathfindingManager::requ void LLFloaterPathfindingObjects::handleUpdateObjectList(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pRequestStatus, LLPathfindingObjectListPtr pObjectList) { + // We current assume that handleUpdateObjectList is called only when objects are being SET llassert(pRequestId <= mMessagingRequestId); if (pRequestId == mMessagingRequestId) { switch (pRequestStatus) { case LLPathfindingManager::kRequestStarted : - setMessagingState(kMessagingGetRequestSent); + setMessagingState(kMessagingSetRequestSent); break; case LLPathfindingManager::kRequestCompleted : if (mObjectList == NULL) -- cgit v1.2.3 From 16ba7ae82cb2e9323e7bf527a57079bf4cfeb634 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 26 Jun 2012 14:47:50 -0700 Subject: Updating the teleport-me-to-it behavior for the characters and linksets. Firstly, to remove the direct call to gAgent.teleportRequest() which is being made into a private function. Secondly, to check the viewer object list to see if the object exists there, and if so, to use that location as the teleport destination. --- indra/newview/llfloaterpathfindingobjects.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 9bfbc582bd..eb18fa00d5 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -57,9 +57,10 @@ #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" -#include "v4color.h" #include "pipeline.h" -#include "llfloaterreg.h" +#include "v3dmath.h" +#include "v3math.h" +#include "v4color.h" #define DEFAULT_BEACON_WIDTH 6 @@ -488,14 +489,20 @@ void LLFloaterPathfindingObjects::teleportToSelectedObject() std::vector::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) + LLVector3d teleportLocation; + LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID()); + if (viewerObject == NULL) + { + // If we cannot find the object in the viewer list, teleport to the last reported position + const LLPathfindingObjectPtr objectPtr = mObjectList->find(selectedItem->getUUID().asString()); + teleportLocation = gAgent.getPosGlobalFromAgent(objectPtr->getLocation()); + } + else { - gAgent.teleportRequest(region->getHandle(), objectLocation, true); + // If we can find the object in the viewer list, teleport to the known current position + teleportLocation = viewerObject->getPositionGlobal(); } + gAgent.teleportViaLocationLookAt(teleportLocation); } } -- cgit v1.2.3 From 78910cf3016fc55eaf8214640b348df0f8bcdeda Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 26 Jun 2012 18:04:19 -0700 Subject: Updating the header licensing comments. --- indra/newview/llfloaterpathfindingobjects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index eb18fa00d5..da664038cf 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -1,6 +1,6 @@ /** * @file llfloaterpathfindingobjects.cpp -* @brief Implementation of llfloaterpathfindingobjects +* @brief Base class for both the pathfinding linksets and characters floater. * @author Stinson@lindenlab.com * * $LicenseInfo:firstyear=2012&license=viewerlgpl$ -- cgit v1.2.3 From 685a672b74550ca0dbf8a816257c84c9c44fd34d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 28 Jun 2012 15:37:55 -0700 Subject: Cleaning up new files in preparation for merge into viewer-release. --- indra/newview/llfloaterpathfindingobjects.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index da664038cf..847997836b 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -57,7 +57,6 @@ #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llviewerregion.h" -#include "pipeline.h" #include "v3dmath.h" #include "v3math.h" #include "v4color.h" @@ -835,4 +834,3 @@ LLPathfindingObjectPtr LLFloaterPathfindingObjects::findObject(const LLScrollLis return objectPtr; } - -- cgit v1.2.3 From 9366a7775c811b8f2e0ac24872d7d744ff2b54c5 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 29 Jun 2012 17:36:40 -0700 Subject: PATH-797: BUGFIX Altering how the rows are being added to the scrolllist widget to avoid a regression that occurred after merging from viewer-release recently caused the time to load a large number of elements to increase substainally. --- indra/newview/llfloaterpathfindingobjects.cpp | 36 ++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index 847997836b..e246265be9 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -41,10 +41,12 @@ #include "llcheckboxctrl.h" #include "llenvmanager.h" #include "llfloater.h" +#include "llfontgl.h" #include "llnotifications.h" #include "llnotificationsutil.h" #include "llpathfindingmanager.h" #include "llresmgr.h" +#include "llscrolllistcell.h" #include "llscrolllistctrl.h" #include "llscrolllistitem.h" #include "llselectmgr.h" @@ -346,10 +348,38 @@ void LLFloaterPathfindingObjects::rebuildObjectsScrollList() { LLSD scrollListData = convertObjectsIntoScrollListData(mObjectList); llassert(scrollListData.isArray()); - for (LLSD::array_const_iterator elementIter = scrollListData.beginArray(); elementIter != scrollListData.endArray(); ++elementIter) + + LLScrollListCell::Params cellParams; + cellParams.font = LLFontGL::getFontSansSerif(); + + for (LLSD::array_const_iterator rowElementIter = scrollListData.beginArray(); rowElementIter != scrollListData.endArray(); ++rowElementIter) { - const LLSD &element = *elementIter; - mObjectsScrollList->addElement(element); + const LLSD &rowElement = *rowElementIter; + + LLScrollListItem::Params rowParams; + llassert(rowElement.has("id")); + llassert(rowElement.get("id").isString()); + rowParams.value = rowElement.get("id"); + + llassert(rowElement.has("column")); + llassert(rowElement.get("column").isArray()); + const LLSD &columnElement = rowElement.get("column"); + for (LLSD::array_const_iterator cellIter = columnElement.beginArray(); cellIter != columnElement.endArray(); ++cellIter) + { + const LLSD &cellElement = *cellIter; + + llassert(cellElement.has("column")); + llassert(cellElement.get("column").isString()); + cellParams.column = cellElement.get("column").asString(); + + llassert(cellElement.has("value")); + llassert(cellElement.get("value").isString()); + cellParams.value = cellElement.get("value").asString(); + + rowParams.columns.add(cellParams); + } + + mObjectsScrollList->addRow(rowParams); } } -- cgit v1.2.3 From 683a96a5f1e9111d62710fe621d52192d34079ed Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 14 Aug 2012 14:54:29 -0700 Subject: PATH-849: Refactoring the behavior after loading the owner name of a pathfinding object into the avatar name cache so that each object can simply update its respective row in the scroll list rather than rebuilding from scratch after all names are loaded. --- indra/newview/llfloaterpathfindingobjects.cpp | 124 ++++++++++++++------------ 1 file changed, 67 insertions(+), 57 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index e246265be9..b3ac18e106 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -29,6 +29,8 @@ #include "llfloaterpathfindingobjects.h" +#include +#include #include #include @@ -96,7 +98,6 @@ void LLFloaterPathfindingObjects::onOpen(const LLSD &pKey) void LLFloaterPathfindingObjects::onClose(bool pIsAppQuitting) { - if (mGodLevelChangeSlot.connected()) { mGodLevelChangeSlot.disconnect(); @@ -119,6 +120,11 @@ void LLFloaterPathfindingObjects::onClose(bool pIsAppQuitting) { mObjectsSelection.clear(); } + + if (pIsAppQuitting) + { + clearAllObjects(); + } } void LLFloaterPathfindingObjects::draw() @@ -168,13 +174,13 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) mReturnButton(NULL), mDeleteButton(NULL), mTeleportButton(NULL), - mLoadingAvatarNames(), mDefaultBeaconColor(), mDefaultBeaconTextColor(), mErrorTextColor(), mWarningTextColor(), mMessagingState(kMessagingUnknown), mMessagingRequestId(0U), + mMissingNameObjectsScrollListItems(), mObjectList(), mObjectsSelection(), mHasObjectsToBeSelected(false), @@ -186,6 +192,7 @@ LLFloaterPathfindingObjects::LLFloaterPathfindingObjects(const LLSD &pSeed) LLFloaterPathfindingObjects::~LLFloaterPathfindingObjects() { + clearAllObjects(); } BOOL LLFloaterPathfindingObjects::postBuild() @@ -343,54 +350,21 @@ void LLFloaterPathfindingObjects::rebuildObjectsScrollList() S32 origScrollPosition = mObjectsScrollList->getScrollPos(); mObjectsScrollList->deleteAllItems(); + mMissingNameObjectsScrollListItems.clear(); if ((mObjectList != NULL) && !mObjectList->isEmpty()) { - LLSD scrollListData = convertObjectsIntoScrollListData(mObjectList); - llassert(scrollListData.isArray()); + buildObjectsScrollList(mObjectList); - LLScrollListCell::Params cellParams; - cellParams.font = LLFontGL::getFontSansSerif(); - - for (LLSD::array_const_iterator rowElementIter = scrollListData.beginArray(); rowElementIter != scrollListData.endArray(); ++rowElementIter) + mObjectsScrollList->selectMultiple(mObjectsToBeSelected); + if (mHasObjectsToBeSelected) { - const LLSD &rowElement = *rowElementIter; - - LLScrollListItem::Params rowParams; - llassert(rowElement.has("id")); - llassert(rowElement.get("id").isString()); - rowParams.value = rowElement.get("id"); - - llassert(rowElement.has("column")); - llassert(rowElement.get("column").isArray()); - const LLSD &columnElement = rowElement.get("column"); - for (LLSD::array_const_iterator cellIter = columnElement.beginArray(); cellIter != columnElement.endArray(); ++cellIter) - { - const LLSD &cellElement = *cellIter; - - llassert(cellElement.has("column")); - llassert(cellElement.get("column").isString()); - cellParams.column = cellElement.get("column").asString(); - - llassert(cellElement.has("value")); - llassert(cellElement.get("value").isString()); - cellParams.value = cellElement.get("value").asString(); - - rowParams.columns.add(cellParams); - } - - mObjectsScrollList->addRow(rowParams); + mObjectsScrollList->scrollToShowSelected(); + } + else + { + mObjectsScrollList->setScrollPos(origScrollPosition); } - } - - mObjectsScrollList->selectMultiple(mObjectsToBeSelected); - if (mHasObjectsToBeSelected) - { - mObjectsScrollList->scrollToShowSelected(); - } - else - { - mObjectsScrollList->setScrollPos(origScrollPosition); } mObjectsToBeSelected.clear(); @@ -399,20 +373,42 @@ void LLFloaterPathfindingObjects::rebuildObjectsScrollList() updateControlsOnScrollListChange(); } -LLSD LLFloaterPathfindingObjects::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) +void LLFloaterPathfindingObjects::buildObjectsScrollList(const LLPathfindingObjectListPtr pObjectListPtr) { llassert(0); - LLSD nullObjs = LLSD::emptyArray(); - return nullObjs; } -void LLFloaterPathfindingObjects::rebuildScrollListAfterAvatarNameLoads(const LLUUID &pAvatarId) +void LLFloaterPathfindingObjects::addObjectToScrollList(const LLPathfindingObjectPtr pObjectPtr, const LLSD &pScrollListItemData) { - std::set::const_iterator iter = mLoadingAvatarNames.find(pAvatarId); - if (iter == mLoadingAvatarNames.end()) + LLScrollListCell::Params cellParams; + cellParams.font = LLFontGL::getFontSansSerif(); + + LLScrollListItem::Params rowParams; + rowParams.value = pObjectPtr->getUUID().asString(); + + llassert(pScrollListItemData.isArray()); + for (LLSD::array_const_iterator cellIter = pScrollListItemData.beginArray(); + cellIter != pScrollListItemData.endArray(); ++cellIter) + { + const LLSD &cellElement = *cellIter; + + llassert(cellElement.has("column")); + llassert(cellElement.get("column").isString()); + cellParams.column = cellElement.get("column").asString(); + + llassert(cellElement.has("value")); + llassert(cellElement.get("value").isString()); + cellParams.value = cellElement.get("value").asString(); + + rowParams.columns.add(cellParams); + } + + LLScrollListItem *scrollListItem = mObjectsScrollList->addRow(rowParams); + + if (pObjectPtr->hasOwner() && !pObjectPtr->hasOwnerName()) { - mLoadingAvatarNames.insert(pAvatarId); - LLAvatarNameCache::get(pAvatarId, boost::bind(&LLFloaterPathfindingObjects::handleAvatarNameLoads, this, _1, _2)); + mMissingNameObjectsScrollListItems.insert(std::make_pair(pObjectPtr->getUUID().asString(), scrollListItem)); + pObjectPtr->registerOwnerNameListener(boost::bind(&LLFloaterPathfindingObjects::handleObjectNameResponse, this, _1, _2)); } } @@ -434,6 +430,11 @@ S32 LLFloaterPathfindingObjects::getNameColumnIndex() const return 0; } +S32 LLFloaterPathfindingObjects::getOwnerNameColumnIndex() const +{ + return 2; +} + const LLColor4 &LLFloaterPathfindingObjects::getBeaconColor() const { return mDefaultBeaconColor; @@ -496,6 +497,7 @@ void LLFloaterPathfindingObjects::clearAllObjects() { selectNoneObjects(); mObjectsScrollList->deleteAllItems(); + mMissingNameObjectsScrollListItems.clear(); mObjectList.reset(); } @@ -683,13 +685,21 @@ void LLFloaterPathfindingObjects::onGodLevelChange(U8 pGodLevel) requestGetObjects(); } -void LLFloaterPathfindingObjects::handleAvatarNameLoads(const LLUUID &pAvatarId, const LLAvatarName &pAvatarName) +void LLFloaterPathfindingObjects::handleObjectNameResponse(const LLUUID &pObjectUUID, const std::string &pOwnerName) { - llassert(mLoadingAvatarNames.find(pAvatarId) != mLoadingAvatarNames.end()); - mLoadingAvatarNames.erase(pAvatarId); - if (mLoadingAvatarNames.empty()) + const std::string uuid = pObjectUUID.asString(); + scroll_list_item_map::iterator scrollListItemIter = mMissingNameObjectsScrollListItems.find(uuid); + if (scrollListItemIter != mMissingNameObjectsScrollListItems.end()) { - rebuildObjectsScrollList(); + LLScrollListItem *scrollListItem = scrollListItemIter->second; + llassert(scrollListItem != NULL); + + LLScrollListCell *scrollListCell = scrollListItem->getColumn(getOwnerNameColumnIndex()); + LLSD ownerName = pOwnerName; + + scrollListCell->setValue(ownerName); + + mMissingNameObjectsScrollListItems.erase(scrollListItemIter); } } -- cgit v1.2.3 From fddaf38f892aa608f9db9c034f6c583d638b6fcf Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 14 Aug 2012 16:04:12 -0700 Subject: PATH-849: Group objects were losing their [group] identifier following the last commit. This should fix that issue. --- indra/newview/llfloaterpathfindingobjects.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfloaterpathfindingobjects.cpp') diff --git a/indra/newview/llfloaterpathfindingobjects.cpp b/indra/newview/llfloaterpathfindingobjects.cpp index b3ac18e106..20c1215bcb 100644 --- a/indra/newview/llfloaterpathfindingobjects.cpp +++ b/indra/newview/llfloaterpathfindingobjects.cpp @@ -408,7 +408,7 @@ void LLFloaterPathfindingObjects::addObjectToScrollList(const LLPathfindingObjec if (pObjectPtr->hasOwner() && !pObjectPtr->hasOwnerName()) { mMissingNameObjectsScrollListItems.insert(std::make_pair(pObjectPtr->getUUID().asString(), scrollListItem)); - pObjectPtr->registerOwnerNameListener(boost::bind(&LLFloaterPathfindingObjects::handleObjectNameResponse, this, _1, _2)); + pObjectPtr->registerOwnerNameListener(boost::bind(&LLFloaterPathfindingObjects::handleObjectNameResponse, this, _1)); } } @@ -435,6 +435,13 @@ S32 LLFloaterPathfindingObjects::getOwnerNameColumnIndex() const return 2; } +std::string LLFloaterPathfindingObjects::getOwnerName(const LLPathfindingObject *pObject) const +{ + llassert(0); + std::string returnVal; + return returnVal; +} + const LLColor4 &LLFloaterPathfindingObjects::getBeaconColor() const { return mDefaultBeaconColor; @@ -685,9 +692,10 @@ void LLFloaterPathfindingObjects::onGodLevelChange(U8 pGodLevel) requestGetObjects(); } -void LLFloaterPathfindingObjects::handleObjectNameResponse(const LLUUID &pObjectUUID, const std::string &pOwnerName) +void LLFloaterPathfindingObjects::handleObjectNameResponse(const LLPathfindingObject *pObject) { - const std::string uuid = pObjectUUID.asString(); + llassert(pObject != NULL); + const std::string uuid = pObject->getUUID().asString(); scroll_list_item_map::iterator scrollListItemIter = mMissingNameObjectsScrollListItems.find(uuid); if (scrollListItemIter != mMissingNameObjectsScrollListItems.end()) { @@ -695,7 +703,7 @@ void LLFloaterPathfindingObjects::handleObjectNameResponse(const LLUUID &pObject llassert(scrollListItem != NULL); LLScrollListCell *scrollListCell = scrollListItem->getColumn(getOwnerNameColumnIndex()); - LLSD ownerName = pOwnerName; + LLSD ownerName = getOwnerName(pObject); scrollListCell->setValue(ownerName); -- cgit v1.2.3