From 525343b9e5f39dafafe2a16e8173ad7f69acb0d6 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 2 Feb 2012 18:30:35 -0800 Subject: PATH-245: First pass at laying out the characters floater. Functionality is mostly stubbed in. The data is currently tied to the same cap service as the linkset data, so that will need to change as soon as the new service is available. --- indra/newview/llfloaterpathfindingcharacters.cpp | 491 +++++++++++++++++++++++ 1 file changed, 491 insertions(+) create mode 100644 indra/newview/llfloaterpathfindingcharacters.cpp (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp new file mode 100644 index 0000000000..021b48f0a0 --- /dev/null +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -0,0 +1,491 @@ +/** + * @file llfloaterpathfindingcharacters.cpp + * @author William Todd Stinson + * @brief "Pathfinding linksets" floater, allowing manipulation of the Havok AI pathfinding settings. + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llfloater.h" +#include "llfloaterpathfindingcharacters.h" +#include "llpathfindingcharacter.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" + +//--------------------------------------------------------------------------- +// CharactersGetResponder +//--------------------------------------------------------------------------- + +class CharactersGetResponder : public LLHTTPClient::Responder +{ +public: + CharactersGetResponder(const std::string& pCharactersDataGetURL, + const LLHandle &pCharactersFloaterHandle); + virtual ~CharactersGetResponder(); + + virtual void result(const LLSD& pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +private: + CharactersGetResponder(const CharactersGetResponder& pOther); + + std::string mCharactersDataGetURL; + LLHandle mCharactersFloaterHandle; +}; + +//--------------------------------------------------------------------------- +// LLFloaterPathfindingCharacters +//--------------------------------------------------------------------------- + +BOOL LLFloaterPathfindingCharacters::postBuild() +{ + childSetAction("refresh_characters_list", boost::bind(&LLFloaterPathfindingCharacters::onRefreshCharactersClicked, this)); + childSetAction("select_all_characters", boost::bind(&LLFloaterPathfindingCharacters::onSelectAllCharactersClicked, this)); + childSetAction("select_none_characters", boost::bind(&LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked, this)); + + mCharactersScrollList = findChild("pathfinding_characters"); + llassert(mCharactersScrollList != NULL); + mCharactersScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onCharactersSelectionChange, this)); + mCharactersScrollList->setCommitOnSelectionChange(true); + mCharactersScrollList->sortByColumnIndex(0, true); + + mCharactersStatus = findChild("characters_status"); + llassert(mCharactersStatus != NULL); + + mLabelActions = findChild("actions_label"); + llassert(mLabelActions != NULL); + + mShowBeaconCheckBox = findChild("show_beacon"); + llassert(mShowBeaconCheckBox != NULL); + mShowBeaconCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onShowBeaconToggled, this)); + + mTakeBtn = findChild("take_characters"); + llassert(mTakeBtn != NULL) + mTakeBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCharactersClicked, this)); + + mTakeCopyBtn = findChild("take_copy_characters"); + llassert(mTakeCopyBtn != NULL) + mTakeCopyBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked, this)); + + mReturnBtn = findChild("return_characters"); + llassert(mReturnBtn != NULL) + mReturnBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onReturnCharactersClicked, this)); + + mDeleteBtn = findChild("delete_characters"); + llassert(mDeleteBtn != NULL) + mDeleteBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onDeleteCharactersClicked, this)); + + mTeleportBtn = findChild("teleport_to_character"); + llassert(mTeleportBtn != NULL) + mTeleportBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked, this)); + + setEnableActionFields(false); + setMessagingState(kMessagingInitial); + + return LLFloater::postBuild(); +} + +void LLFloaterPathfindingCharacters::onOpen(const LLSD& pKey) +{ + sendCharactersDataGetRequest(); +} + +LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const +{ + return mMessagingState; +} + +BOOL LLFloaterPathfindingCharacters::isMessagingInProgress() const +{ + BOOL retVal; + switch (getMessagingState()) + { + case kMessagingFetchStarting : + case kMessagingFetchRequestSent : + case kMessagingFetchRequestSent_MultiRequested : + case kMessagingFetchReceived : + retVal = true; + break; + default : + retVal = false; + break; + } + + return retVal; +} + +LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) + : LLFloater(pSeed), + mSelfHandle(), + mPathfindingCharacters(), + mMessagingState(kMessagingInitial), + mCharactersScrollList(NULL), + mCharactersStatus(NULL), + mLabelActions(NULL), + mShowBeaconCheckBox(NULL), + mTakeBtn(NULL), + mTakeCopyBtn(NULL), + mReturnBtn(NULL), + mDeleteBtn(NULL), + mTeleportBtn(NULL) +{ + mSelfHandle.bind(this); +} + +LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() +{ + mPathfindingCharacters.clear(); +} + +void LLFloaterPathfindingCharacters::sendCharactersDataGetRequest() +{ + if (isMessagingInProgress()) + { + if (getMessagingState() == kMessagingFetchRequestSent) + { + setMessagingState(kMessagingFetchRequestSent_MultiRequested); + } + } + else + { + setMessagingState(kMessagingFetchStarting); + mPathfindingCharacters.clear(); + updateCharactersList(); + + std::string charactersDataURL = getCapabilityURL(); + if (charactersDataURL.empty()) + { + setMessagingState(kMessagingComplete); + llwarns << "cannot query pathfinding characters from current region '" << getRegionName() << "'" << llendl; + } + else + { + setMessagingState(kMessagingFetchRequestSent); + LLHTTPClient::get(charactersDataURL, new CharactersGetResponder(charactersDataURL, mSelfHandle)); + } + } +} + +void LLFloaterPathfindingCharacters::handleCharactersDataGetReply(const LLSD& pCharactersData) +{ + setMessagingState(kMessagingFetchReceived); + mPathfindingCharacters.clear(); + parseCharactersData(pCharactersData); + updateCharactersList(); + setMessagingState(kMessagingComplete); +} + +void LLFloaterPathfindingCharacters::handleCharactersDataGetError(const std::string& pURL, const std::string& pErrorReason) +{ + setMessagingState(kMessagingFetchError); + mPathfindingCharacters.clear(); + updateCharactersList(); + llwarns << "Error fetching pathfinding characters from URL '" << pURL << "' because " << pErrorReason << llendl; +} + +std::string LLFloaterPathfindingCharacters::getRegionName() const +{ + std::string regionName(""); + + LLViewerRegion* region = gAgent.getRegion(); + if (region != NULL) + { + regionName = region->getName(); + } + + return regionName; +} + +std::string LLFloaterPathfindingCharacters::getCapabilityURL() const +{ + std::string charactersDataURL(""); + + LLViewerRegion* region = gAgent.getRegion(); + if (region != NULL) + { + charactersDataURL = region->getCapability("ObjectNavMeshProperties"); + } + + return charactersDataURL; +} + +void LLFloaterPathfindingCharacters::parseCharactersData(const LLSD &pCharactersData) +{ + for (LLSD::map_const_iterator characterItemIter = pCharactersData.beginMap(); + characterItemIter != pCharactersData.endMap(); ++characterItemIter) + { + const std::string &uuid(characterItemIter->first); + const LLSD &characterData(characterItemIter->second); + LLPathfindingCharacter character(uuid, characterData); + + mPathfindingCharacters.insert(std::pair(uuid, character)); + } +} + +void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagingState) +{ + mMessagingState = pMessagingState; + updateCharactersList(); + updateActionFields(); +} + +void LLFloaterPathfindingCharacters::onCharactersSelectionChange() +{ + updateCharactersStatusMessage(); + updateActionFields(); +} + +void LLFloaterPathfindingCharacters::onRefreshCharactersClicked() +{ + sendCharactersDataGetRequest(); +} + +void LLFloaterPathfindingCharacters::onSelectAllCharactersClicked() +{ + selectAllCharacters(); +} + +void LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked() +{ + selectNoneCharacters(); +} + +void LLFloaterPathfindingCharacters::onShowBeaconToggled() +{ + llwarns << "functionality has not yet been implemented to toggle show beacon" << llendl; +} + +void LLFloaterPathfindingCharacters::onTakeCharactersClicked() +{ + llwarns << "functionality has not yet been implemented to take characters" << llendl; +} + +void LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked() +{ + llwarns << "functionality has not yet been implemented to take a copy of characters" << llendl; +} + +void LLFloaterPathfindingCharacters::onReturnCharactersClicked() +{ + llwarns << "functionality has not yet been implemented to return characters" << llendl; +} + +void LLFloaterPathfindingCharacters::onDeleteCharactersClicked() +{ + llwarns << "functionality has not yet been implemented to delete characters" << llendl; +} + +void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() +{ + llwarns << "functionality has not yet been implemented to teleport me tothe character" << llendl; +} + +void LLFloaterPathfindingCharacters::updateCharactersList() +{ + std::vector selectedItems = mCharactersScrollList->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()); + } + } + + mCharactersScrollList->deleteAllItems(); + updateCharactersStatusMessage(); + + for (PathfindingCharacterMap::const_iterator characterIter = mPathfindingCharacters.begin(); + characterIter != mPathfindingCharacters.end(); ++characterIter) + { + const LLPathfindingCharacter& character(characterIter->second); + + LLSD columns; + + columns[0]["column"] = "name"; + columns[0]["value"] = character.getName(); + columns[0]["font"] = "SANSSERIF"; + + columns[1]["column"] = "description"; + columns[1]["value"] = character.getDescription(); + columns[1]["font"] = "SANSSERIF"; + + columns[2]["column"] = "owner"; + columns[2]["value"] = character.getOwner(); + columns[2]["font"] = "SANSSERIF"; + + columns[3]["column"] = "cpu_time"; + columns[3]["value"] = llformat("%3d ms", character.getCPUTime()); + columns[3]["font"] = "SANSSERIF"; + + columns[4]["column"] = "altitude"; + columns[4]["value"] = llformat("%1.0f m", character.getLocation()[2]); + columns[4]["font"] = "SANSSERIF"; + + LLSD element; + element["id"] = character.getUUID().asString(); + element["column"] = columns; + + mCharactersScrollList->addElement(element); + } + + mCharactersScrollList->selectMultiple(selectedUUIDs); + updateCharactersStatusMessage(); + updateActionFields(); +} + +void LLFloaterPathfindingCharacters::selectAllCharacters() +{ + mCharactersScrollList->selectAll(); +} + +void LLFloaterPathfindingCharacters::selectNoneCharacters() +{ + mCharactersScrollList->deselectAllItems(); +} + +void LLFloaterPathfindingCharacters::updateCharactersStatusMessage() +{ + static const LLColor4 warningColor = LLUIColorTable::instance().getColor("DrYellow"); + + std::string statusText(""); + LLStyle::Params styleParams; + + switch (getMessagingState()) + { + case kMessagingInitial: + statusText = getString("characters_messaging_initial"); + break; + case kMessagingFetchStarting : + statusText = getString("characters_messaging_fetch_starting"); + break; + case kMessagingFetchRequestSent : + statusText = getString("characters_messaging_fetch_inprogress"); + break; + case kMessagingFetchRequestSent_MultiRequested : + statusText = getString("characters_messaging_fetch_inprogress_multi_request"); + break; + case kMessagingFetchReceived : + statusText = getString("characters_messaging_fetch_received"); + break; + case kMessagingFetchError : + statusText = getString("characters_messaging_fetch_error"); + styleParams.color = warningColor; + 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; + default: + statusText = getString("characters_messaging_initial"); + llassert(0); + break; + } + + mCharactersStatus->setText((LLStringExplicit)statusText, styleParams); +} + +void LLFloaterPathfindingCharacters::updateActionFields() +{ + std::vector selectedItems = mCharactersScrollList->getAllSelected(); + setEnableActionFields(!selectedItems.empty()); +} + +void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) +{ + mLabelActions->setEnabled(pEnabled); + mShowBeaconCheckBox->setEnabled(pEnabled); + mTakeBtn->setEnabled(pEnabled); + mTakeCopyBtn->setEnabled(pEnabled); + mReturnBtn->setEnabled(pEnabled); + mDeleteBtn->setEnabled(pEnabled); + mTeleportBtn->setEnabled(pEnabled && (mCharactersScrollList->getNumSelected() == 1)); +} + +//--------------------------------------------------------------------------- +// CharactersGetResponder +//--------------------------------------------------------------------------- + +CharactersGetResponder::CharactersGetResponder(const std::string& pCharactersDataGetURL, + const LLHandle &pCharactersFloaterHandle) + : mCharactersDataGetURL(pCharactersDataGetURL), + mCharactersFloaterHandle(pCharactersFloaterHandle) +{ +} + +CharactersGetResponder::~CharactersGetResponder() +{ +} + +void CharactersGetResponder::result(const LLSD& pContent) +{ + LLFloaterPathfindingCharacters *charactersFloater = mCharactersFloaterHandle.get(); + if (charactersFloater != NULL) + { + charactersFloater->handleCharactersDataGetReply(pContent); + } +} + +void CharactersGetResponder::error(U32 status, const std::string& reason) +{ + LLFloaterPathfindingCharacters *charactersFloater = mCharactersFloaterHandle.get(); + if (charactersFloater != NULL) + { + charactersFloater->handleCharactersDataGetError(mCharactersDataGetURL, reason); + } +} -- cgit v1.2.3 From fa46459cdb6d63fea6a76d8c11eee5503edf5bb1 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 7 Feb 2012 14:13:57 -0800 Subject: PATH-245: Hooking the characters floater up to the character service. Also, adding in an additional state to handle the floater when the service does not exist. --- indra/newview/llfloaterpathfindingcharacters.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 021b48f0a0..86b7e86f9e 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -187,7 +187,7 @@ void LLFloaterPathfindingCharacters::sendCharactersDataGetRequest() std::string charactersDataURL = getCapabilityURL(); if (charactersDataURL.empty()) { - setMessagingState(kMessagingComplete); + setMessagingState(kMessagingServiceNotAvailable); llwarns << "cannot query pathfinding characters from current region '" << getRegionName() << "'" << llendl; } else @@ -235,7 +235,7 @@ std::string LLFloaterPathfindingCharacters::getCapabilityURL() const LLViewerRegion* region = gAgent.getRegion(); if (region != NULL) { - charactersDataURL = region->getCapability("ObjectNavMeshProperties"); + charactersDataURL = region->getCapability("CharacterProperties"); } return charactersDataURL; @@ -431,6 +431,10 @@ void LLFloaterPathfindingCharacters::updateCharactersStatusMessage() statusText = getString("characters_messaging_complete_available", string_args); } break; + case kMessagingServiceNotAvailable: + statusText = getString("characters_messaging_service_not_available"); + styleParams.color = warningColor; + break; default: statusText = getString("characters_messaging_initial"); llassert(0); -- cgit v1.2.3 From e64ec7e60c9f24cc3dff21f4215624a86670b8d6 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 7 Feb 2012 17:09:44 -0800 Subject: PATH-245: Integrating with the working sim-side cap service. --- indra/newview/llfloaterpathfindingcharacters.cpp | 38 ++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 86b7e86f9e..fe65ee3159 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -43,6 +43,9 @@ #include "llviewerregion.h" #include "llhttpclient.h" #include "lluuid.h" +#include "llviewerobject.h" +#include "llviewerobjectlist.h" +#include "llselectmgr.h" //--------------------------------------------------------------------------- // CharactersGetResponder @@ -159,7 +162,8 @@ LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed mTakeCopyBtn(NULL), mReturnBtn(NULL), mDeleteBtn(NULL), - mTeleportBtn(NULL) + mTeleportBtn(NULL), + mSelection() { mSelfHandle.bind(this); } @@ -167,6 +171,7 @@ LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() { mPathfindingCharacters.clear(); + mSelection.clear(); } void LLFloaterPathfindingCharacters::sendCharactersDataGetRequest() @@ -263,6 +268,35 @@ void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagin void LLFloaterPathfindingCharacters::onCharactersSelectionChange() { + std::vector selectedItems = mCharactersScrollList->getAllSelected(); + + LLSelectMgr::getInstance()->deselectAll(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + + 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) + { + viewerObject->setSelected(true); + viewerObjects.push_back(viewerObject); + } + } + + if (!viewerObjects.empty()) + { + mSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); + } + } + updateCharactersStatusMessage(); updateActionFields(); } @@ -347,7 +381,7 @@ void LLFloaterPathfindingCharacters::updateCharactersList() columns[1]["font"] = "SANSSERIF"; columns[2]["column"] = "owner"; - columns[2]["value"] = character.getOwner(); + columns[2]["value"] = character.getOwnerName(); columns[2]["font"] = "SANSSERIF"; columns[3]["column"] = "cpu_time"; -- cgit v1.2.3 From e21b685172046c4895a2a48376b485fbafedf66c Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 7 Feb 2012 18:10:55 -0800 Subject: PATH-245: Adding functionality to teleport avatar to the last known position of the character. Might still need to refresh the characters current position before teleport, as future enhancement. --- indra/newview/llfloaterpathfindingcharacters.cpp | 27 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index fe65ee3159..9788fe5760 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -343,7 +343,22 @@ void LLFloaterPathfindingCharacters::onDeleteCharactersClicked() void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() { - llwarns << "functionality has not yet been implemented to teleport me tothe character" << llendl; + std::vector selectedItems = mCharactersScrollList->getAllSelected(); + llassert(selectedItems.size() == 1); + if (selectedItems.size() == 1) + { + std::vector::const_reference selectedItemRef = selectedItems.front(); + const LLScrollListItem *selectedItem = selectedItemRef; + PathfindingCharacterMap::const_iterator characterIter = mPathfindingCharacters.find(selectedItem->getUUID().asString()); + const LLPathfindingCharacter &character = characterIter->second; + LLVector3 characterLocation = character.getLocation(); + + LLViewerRegion* region = gAgent.getRegion(); + if (region != NULL) + { + gAgent.teleportRequest(region->getHandle(), characterLocation, true); + } + } } void LLFloaterPathfindingCharacters::updateCharactersList() @@ -487,11 +502,11 @@ void LLFloaterPathfindingCharacters::updateActionFields() void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) { mLabelActions->setEnabled(pEnabled); - mShowBeaconCheckBox->setEnabled(pEnabled); - mTakeBtn->setEnabled(pEnabled); - mTakeCopyBtn->setEnabled(pEnabled); - mReturnBtn->setEnabled(pEnabled); - mDeleteBtn->setEnabled(pEnabled); + mShowBeaconCheckBox->setEnabled(false && pEnabled); + mTakeBtn->setEnabled(false && pEnabled); + mTakeCopyBtn->setEnabled(false && pEnabled); + mReturnBtn->setEnabled(false && pEnabled); + mDeleteBtn->setEnabled(false && pEnabled); mTeleportBtn->setEnabled(pEnabled && (mCharactersScrollList->getNumSelected() == 1)); } -- cgit v1.2.3 From 5c652e5f614807b8efc45819df1588c0508e9d34 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 7 Feb 2012 18:45:34 -0800 Subject: PATH-245: Disabling character selection through the character floater as it is seeming to cause weird artifacts in its current state. --- indra/newview/llfloaterpathfindingcharacters.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 9788fe5760..de431bbf89 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -268,6 +268,7 @@ void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagin void LLFloaterPathfindingCharacters::onCharactersSelectionChange() { +#if 0 std::vector selectedItems = mCharactersScrollList->getAllSelected(); LLSelectMgr::getInstance()->deselectAll(); @@ -296,6 +297,7 @@ void LLFloaterPathfindingCharacters::onCharactersSelectionChange() mSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); } } +#endif updateCharactersStatusMessage(); updateActionFields(); -- cgit v1.2.3 From bf7ef74f1e736ee3c098dd193022953113ca204f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 9 Feb 2012 10:16:24 -0800 Subject: PATH-245: Fixing an issue with character selection. --- indra/newview/llfloaterpathfindingcharacters.cpp | 45 +++++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index de431bbf89..33fc1efd8e 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -45,6 +45,7 @@ #include "lluuid.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" +#include "llviewermenu.h" #include "llselectmgr.h" //--------------------------------------------------------------------------- @@ -81,7 +82,6 @@ BOOL LLFloaterPathfindingCharacters::postBuild() mCharactersScrollList = findChild("pathfinding_characters"); llassert(mCharactersScrollList != NULL); mCharactersScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onCharactersSelectionChange, this)); - mCharactersScrollList->setCommitOnSelectionChange(true); mCharactersScrollList->sortByColumnIndex(0, true); mCharactersStatus = findChild("characters_status"); @@ -123,6 +123,35 @@ BOOL LLFloaterPathfindingCharacters::postBuild() void LLFloaterPathfindingCharacters::onOpen(const LLSD& pKey) { sendCharactersDataGetRequest(); + selectNoneCharacters(); + mCharactersScrollList->setCommitOnSelectionChange(true); +} + +void LLFloaterPathfindingCharacters::onClose(bool app_quitting) +{ + mCharactersScrollList->setCommitOnSelectionChange(false); + selectNoneCharacters(); + if (mCharacterSelection.notNull()) + { + std::vector selectedObjects; + + LLObjectSelection *charactersSelected = mCharacterSelection.get(); + for (LLObjectSelection::valid_iterator characterIter = charactersSelected->valid_begin(); + characterIter != charactersSelected->valid_end(); ++characterIter) + { + LLSelectNode *characterNode = *characterIter; + selectedObjects.push_back(characterNode->getObject()); + } + + for (std::vector::const_iterator selectedObjectIter = selectedObjects.begin(); + selectedObjectIter != selectedObjects.end(); ++selectedObjectIter) + { + LLViewerObject *selectedObject = *selectedObjectIter; + LLSelectMgr::getInstance()->deselectObjectAndFamily(selectedObject); + } + + mCharacterSelection.clear(); + } } LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const @@ -163,7 +192,7 @@ LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed mReturnBtn(NULL), mDeleteBtn(NULL), mTeleportBtn(NULL), - mSelection() + mCharacterSelection() { mSelfHandle.bind(this); } @@ -171,7 +200,7 @@ LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() { mPathfindingCharacters.clear(); - mSelection.clear(); + mCharacterSelection.clear(); } void LLFloaterPathfindingCharacters::sendCharactersDataGetRequest() @@ -268,10 +297,10 @@ void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagin void LLFloaterPathfindingCharacters::onCharactersSelectionChange() { -#if 0 - std::vector selectedItems = mCharactersScrollList->getAllSelected(); - + mCharacterSelection.clear(); LLSelectMgr::getInstance()->deselectAll(); + + std::vector selectedItems = mCharactersScrollList->getAllSelected(); if (!selectedItems.empty()) { int numSelectedItems = selectedItems.size(); @@ -287,17 +316,15 @@ void LLFloaterPathfindingCharacters::onCharactersSelectionChange() LLViewerObject *viewerObject = gObjectList.findObject(selectedItem->getUUID()); if (viewerObject != NULL) { - viewerObject->setSelected(true); viewerObjects.push_back(viewerObject); } } if (!viewerObjects.empty()) { - mSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); + mCharacterSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); } } -#endif updateCharactersStatusMessage(); updateActionFields(); -- cgit v1.2.3 From 0cbab65345947faddb39993fe8933d13e8886439 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 9 Feb 2012 10:53:46 -0800 Subject: PATH-245: Basic functionality for take, take copy, and delete. --- indra/newview/llfloaterpathfindingcharacters.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 33fc1efd8e..4e47d5af9c 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -352,12 +352,12 @@ void LLFloaterPathfindingCharacters::onShowBeaconToggled() void LLFloaterPathfindingCharacters::onTakeCharactersClicked() { - llwarns << "functionality has not yet been implemented to take characters" << llendl; + handle_take(); } void LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked() { - llwarns << "functionality has not yet been implemented to take a copy of characters" << llendl; + handle_take_copy(); } void LLFloaterPathfindingCharacters::onReturnCharactersClicked() @@ -367,7 +367,7 @@ void LLFloaterPathfindingCharacters::onReturnCharactersClicked() void LLFloaterPathfindingCharacters::onDeleteCharactersClicked() { - llwarns << "functionality has not yet been implemented to delete characters" << llendl; + handle_object_delete(); } void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() @@ -532,10 +532,10 @@ void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) { mLabelActions->setEnabled(pEnabled); mShowBeaconCheckBox->setEnabled(false && pEnabled); - mTakeBtn->setEnabled(false && pEnabled); - mTakeCopyBtn->setEnabled(false && pEnabled); + mTakeBtn->setEnabled(true && pEnabled); + mTakeCopyBtn->setEnabled(true && pEnabled); mReturnBtn->setEnabled(false && pEnabled); - mDeleteBtn->setEnabled(false && pEnabled); + mDeleteBtn->setEnabled(true && pEnabled); mTeleportBtn->setEnabled(pEnabled && (mCharactersScrollList->getNumSelected() == 1)); } -- cgit v1.2.3 From 3a9f437fdfff07264b5c71803541f4dff04f746f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 9 Feb 2012 17:02:16 -0800 Subject: PATH-245: Adding proper toggling of the enabled state for the take, take copy, and delete buttons. --- indra/newview/llfloaterpathfindingcharacters.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 4e47d5af9c..f1f9ef6278 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -532,10 +532,10 @@ void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) { mLabelActions->setEnabled(pEnabled); mShowBeaconCheckBox->setEnabled(false && pEnabled); - mTakeBtn->setEnabled(true && pEnabled); - mTakeCopyBtn->setEnabled(true && pEnabled); + mTakeBtn->setEnabled(pEnabled && tools_visible_take_object()); + mTakeCopyBtn->setEnabled(pEnabled && enable_object_take_copy()); mReturnBtn->setEnabled(false && pEnabled); - mDeleteBtn->setEnabled(true && pEnabled); + mDeleteBtn->setEnabled(pEnabled && enable_object_delete()); mTeleportBtn->setEnabled(pEnabled && (mCharactersScrollList->getNumSelected() == 1)); } -- cgit v1.2.3 From 50ba8b4ac1faffd7d0cd0b25351f1c5a8645e40f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 9 Feb 2012 18:40:23 -0800 Subject: PATH-245: Adding initial functionality for rendering debug beacons for selected pathfinding characters. --- indra/newview/llfloaterpathfindingcharacters.cpp | 39 +++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index f1f9ef6278..561ad9535b 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -92,7 +92,6 @@ BOOL LLFloaterPathfindingCharacters::postBuild() mShowBeaconCheckBox = findChild("show_beacon"); llassert(mShowBeaconCheckBox != NULL); - mShowBeaconCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onShowBeaconToggled, this)); mTakeBtn = findChild("take_characters"); llassert(mTakeBtn != NULL) @@ -345,11 +344,6 @@ void LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked() selectNoneCharacters(); } -void LLFloaterPathfindingCharacters::onShowBeaconToggled() -{ - llwarns << "functionality has not yet been implemented to toggle show beacon" << llendl; -} - void LLFloaterPathfindingCharacters::onTakeCharactersClicked() { handle_take(); @@ -531,7 +525,7 @@ void LLFloaterPathfindingCharacters::updateActionFields() void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) { mLabelActions->setEnabled(pEnabled); - mShowBeaconCheckBox->setEnabled(false && pEnabled); + mShowBeaconCheckBox->setEnabled(pEnabled); mTakeBtn->setEnabled(pEnabled && tools_visible_take_object()); mTakeCopyBtn->setEnabled(pEnabled && enable_object_take_copy()); mReturnBtn->setEnabled(false && pEnabled); @@ -539,6 +533,37 @@ void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) mTeleportBtn->setEnabled(pEnabled && (mCharactersScrollList->getNumSelected() == 1)); } +void LLFloaterPathfindingCharacters::draw() +{ + if (mShowBeaconCheckBox->get()) + { + std::vector selectedItems = mCharactersScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + + std::vector viewerObjects; + viewerObjects.reserve(numSelectedItems); + + for (std::vector::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(); +} + //--------------------------------------------------------------------------- // CharactersGetResponder //--------------------------------------------------------------------------- -- cgit v1.2.3 From e88ed1164adf3797f97ede40def40e0d85fc24f6 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 10 Feb 2012 13:37:37 -0800 Subject: PATH-245: Adding functionality for returning objects to owner from the characters floater. --- indra/newview/llfloaterpathfindingcharacters.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 561ad9535b..25642f0226 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -356,12 +356,12 @@ void LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked() void LLFloaterPathfindingCharacters::onReturnCharactersClicked() { - llwarns << "functionality has not yet been implemented to return characters" << llendl; + handle_object_return(); } void LLFloaterPathfindingCharacters::onDeleteCharactersClicked() { - handle_object_delete(); + handle_object_delete(); } void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() @@ -528,7 +528,7 @@ void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) mShowBeaconCheckBox->setEnabled(pEnabled); mTakeBtn->setEnabled(pEnabled && tools_visible_take_object()); mTakeCopyBtn->setEnabled(pEnabled && enable_object_take_copy()); - mReturnBtn->setEnabled(false && pEnabled); + mReturnBtn->setEnabled(pEnabled && enable_object_return()); mDeleteBtn->setEnabled(pEnabled && enable_object_delete()); mTeleportBtn->setEnabled(pEnabled && (mCharactersScrollList->getNumSelected() == 1)); } -- cgit v1.2.3 From 76959fdb455e5fc3f08b0e1f61f13f14c0d87303 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 13 Feb 2012 18:32:06 -0800 Subject: PATH-284: Hooking up the characters button to open the characters floater. --- indra/newview/llfloaterpathfindingcharacters.cpp | 67 +++++++++++++----------- 1 file changed, 36 insertions(+), 31 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 25642f0226..a64a9f5aa2 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -153,6 +153,42 @@ void LLFloaterPathfindingCharacters::onClose(bool app_quitting) } } +void LLFloaterPathfindingCharacters::draw() +{ + if (mShowBeaconCheckBox->get()) + { + std::vector selectedItems = mCharactersScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + + std::vector viewerObjects; + viewerObjects.reserve(numSelectedItems); + + for (std::vector::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::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const { return mMessagingState; @@ -533,37 +569,6 @@ void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) mTeleportBtn->setEnabled(pEnabled && (mCharactersScrollList->getNumSelected() == 1)); } -void LLFloaterPathfindingCharacters::draw() -{ - if (mShowBeaconCheckBox->get()) - { - std::vector selectedItems = mCharactersScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - std::vector viewerObjects; - viewerObjects.reserve(numSelectedItems); - - for (std::vector::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(); -} - //--------------------------------------------------------------------------- // CharactersGetResponder //--------------------------------------------------------------------------- -- cgit v1.2.3 From 9181229b34e1374f1b564fed637088bca4535ae0 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 13 Feb 2012 18:39:41 -0800 Subject: Updating the pathfinding character initialization to match the new data type for CPU time. --- indra/newview/llfloaterpathfindingcharacters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index a64a9f5aa2..b697de0d04 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -459,7 +459,7 @@ void LLFloaterPathfindingCharacters::updateCharactersList() columns[2]["font"] = "SANSSERIF"; columns[3]["column"] = "cpu_time"; - columns[3]["value"] = llformat("%3d ms", character.getCPUTime()); + columns[3]["value"] = llformat("%3.0f ms", character.getCPUTime()); columns[3]["font"] = "SANSSERIF"; columns[4]["column"] = "altitude"; -- cgit v1.2.3 From 35b09a722e72a397a1e1e7aacbda8f39f4c1faa5 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 17 Feb 2012 11:37:49 -0800 Subject: PATH-310: Switching the cpu time display from milliseconds to microseconds to properly indicate the correct values. --- indra/newview/llfloaterpathfindingcharacters.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index b697de0d04..e2e1921cc6 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -439,6 +439,7 @@ void LLFloaterPathfindingCharacters::updateCharactersList() mCharactersScrollList->deleteAllItems(); updateCharactersStatusMessage(); + LLLocale locale(LLStringUtil::getLocale()); for (PathfindingCharacterMap::const_iterator characterIter = mPathfindingCharacters.begin(); characterIter != mPathfindingCharacters.end(); ++characterIter) { @@ -458,8 +459,15 @@ void LLFloaterPathfindingCharacters::updateCharactersList() columns[2]["value"] = character.getOwnerName(); columns[2]["font"] = "SANSSERIF"; + S32 cpuTime = llround(character.getCPUTime()); + std::string cpuTimeString; + LLResMgr::getInstance()->getIntegerString(cpuTimeString, cpuTime); + + LLStringUtil::format_map_t string_args; + string_args["[CPU_TIME]"] = cpuTimeString; + columns[3]["column"] = "cpu_time"; - columns[3]["value"] = llformat("%3.0f ms", character.getCPUTime()); + columns[3]["value"] = getString("character_cpu_time", string_args); columns[3]["font"] = "SANSSERIF"; columns[4]["column"] = "altitude"; -- cgit v1.2.3 From 2b93f44f197930790e7f81f51ffcdaf684b4a221 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 1 Mar 2012 16:04:18 -0800 Subject: BUGFIX Correcting a problem with the object selection code in the pathfinding characters and linksets floaters. The code was not seeing the callback from the object update message of the selection manager. --- indra/newview/llfloaterpathfindingcharacters.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index e2e1921cc6..ae023bc06e 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -123,12 +123,24 @@ void LLFloaterPathfindingCharacters::onOpen(const LLSD& pKey) { sendCharactersDataGetRequest(); selectNoneCharacters(); + + if (!mSelectionUpdateSlot.connected()) + { + mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingCharacters::updateActionFields, this)); + } + mCharactersScrollList->setCommitOnSelectionChange(true); } void LLFloaterPathfindingCharacters::onClose(bool app_quitting) { mCharactersScrollList->setCommitOnSelectionChange(false); + + if (mSelectionUpdateSlot.connected()) + { + mSelectionUpdateSlot.disconnect(); + } + selectNoneCharacters(); if (mCharacterSelection.notNull()) { @@ -227,7 +239,8 @@ LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed mReturnBtn(NULL), mDeleteBtn(NULL), mTeleportBtn(NULL), - mCharacterSelection() + mCharacterSelection(), + mSelectionUpdateSlot() { mSelfHandle.bind(this); } @@ -570,7 +583,7 @@ void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) { mLabelActions->setEnabled(pEnabled); mShowBeaconCheckBox->setEnabled(pEnabled); - mTakeBtn->setEnabled(pEnabled && tools_visible_take_object()); + mTakeBtn->setEnabled(pEnabled && visible_take_object()); mTakeCopyBtn->setEnabled(pEnabled && enable_object_take_copy()); mReturnBtn->setEnabled(pEnabled && enable_object_return()); mDeleteBtn->setEnabled(pEnabled && enable_object_delete()); -- cgit v1.2.3 From 6fb42d7ae8315885fda23da440dce01aeee8eafb Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 8 Mar 2012 18:01:40 -0800 Subject: PATH-349: BUGFIX Incorrect ordering of CPU time was only occurring in the case that the number of digitis in one of the CPU times exceeded 3 digits. In this scenario, the thousands comma was being inserted, and this comma was disrupting the comparison method. This fix is simply to use the standard integer formatting rather that the locale specific one. --- indra/newview/llfloaterpathfindingcharacters.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index ae023bc06e..fd84af74e1 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -473,9 +473,7 @@ void LLFloaterPathfindingCharacters::updateCharactersList() columns[2]["font"] = "SANSSERIF"; S32 cpuTime = llround(character.getCPUTime()); - std::string cpuTimeString; - LLResMgr::getInstance()->getIntegerString(cpuTimeString, cpuTime); - + std::string cpuTimeString = llformat("%d", cpuTime); LLStringUtil::format_map_t string_args; string_args["[CPU_TIME]"] = cpuTimeString; -- cgit v1.2.3 From 473da43c1bbc20245b3a74c1adc7c92f91d25807 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 27 Mar 2012 19:05:29 -0700 Subject: Refactoring the characters floater code. --- indra/newview/llfloaterpathfindingcharacters.cpp | 490 ++++++++++------------- 1 file changed, 205 insertions(+), 285 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index fd84af74e1..d174d822cd 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -1,7 +1,7 @@ /** * @file llfloaterpathfindingcharacters.cpp * @author William Todd Stinson - * @brief "Pathfinding linksets" floater, allowing manipulation of the Havok AI pathfinding settings. + * @brief "Pathfinding characters" floater, allowing for identification of pathfinding characters and their cpu usage. * * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code @@ -28,7 +28,7 @@ #include "llviewerprecompiledheaders.h" #include "llfloater.h" #include "llfloaterpathfindingcharacters.h" -#include "llpathfindingcharacter.h" +#include "llpathfindingcharacterlist.h" #include "llsd.h" #include "llagent.h" #include "llhandle.h" @@ -48,37 +48,12 @@ #include "llviewermenu.h" #include "llselectmgr.h" -//--------------------------------------------------------------------------- -// CharactersGetResponder -//--------------------------------------------------------------------------- - -class CharactersGetResponder : public LLHTTPClient::Responder -{ -public: - CharactersGetResponder(const std::string& pCharactersDataGetURL, - const LLHandle &pCharactersFloaterHandle); - virtual ~CharactersGetResponder(); - - virtual void result(const LLSD& pContent); - virtual void error(U32 pStatus, const std::string& pReason); - -private: - CharactersGetResponder(const CharactersGetResponder& pOther); - - std::string mCharactersDataGetURL; - LLHandle mCharactersFloaterHandle; -}; - //--------------------------------------------------------------------------- // LLFloaterPathfindingCharacters //--------------------------------------------------------------------------- BOOL LLFloaterPathfindingCharacters::postBuild() { - childSetAction("refresh_characters_list", boost::bind(&LLFloaterPathfindingCharacters::onRefreshCharactersClicked, this)); - childSetAction("select_all_characters", boost::bind(&LLFloaterPathfindingCharacters::onSelectAllCharactersClicked, this)); - childSetAction("select_none_characters", boost::bind(&LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked, this)); - mCharactersScrollList = findChild("pathfinding_characters"); llassert(mCharactersScrollList != NULL); mCharactersScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onCharactersSelectionChange, this)); @@ -87,82 +62,73 @@ BOOL LLFloaterPathfindingCharacters::postBuild() mCharactersStatus = findChild("characters_status"); llassert(mCharactersStatus != NULL); - mLabelActions = findChild("actions_label"); - llassert(mLabelActions != NULL); + mRefreshListButton = findChild("refresh_characters_list"); + llassert(mRefreshListButton != NULL); + mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onRefreshCharactersClicked, this)); + + mSelectAllButton = findChild("select_all_characters"); + llassert(mSelectAllButton != NULL); + mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectAllCharactersClicked, this)); + + mSelectNoneButton = findChild("select_none_characters"); + llassert(mSelectNoneButton != NULL); + mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked, this)); mShowBeaconCheckBox = findChild("show_beacon"); llassert(mShowBeaconCheckBox != NULL); - mTakeBtn = findChild("take_characters"); - llassert(mTakeBtn != NULL) - mTakeBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCharactersClicked, this)); - - mTakeCopyBtn = findChild("take_copy_characters"); - llassert(mTakeCopyBtn != NULL) - mTakeCopyBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked, this)); + mTakeButton = findChild("take_characters"); + llassert(mTakeButton != NULL) + mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCharactersClicked, this)); - mReturnBtn = findChild("return_characters"); - llassert(mReturnBtn != NULL) - mReturnBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onReturnCharactersClicked, this)); + mTakeCopyButton = findChild("take_copy_characters"); + llassert(mTakeCopyButton != NULL) + mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked, this)); - mDeleteBtn = findChild("delete_characters"); - llassert(mDeleteBtn != NULL) - mDeleteBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onDeleteCharactersClicked, this)); + mReturnButton = findChild("return_characters"); + llassert(mReturnButton != NULL) + mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onReturnCharactersClicked, this)); - mTeleportBtn = findChild("teleport_to_character"); - llassert(mTeleportBtn != NULL) - mTeleportBtn->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked, this)); + mDeleteButton = findChild("delete_characters"); + llassert(mDeleteButton != NULL) + mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onDeleteCharactersClicked, this)); - setEnableActionFields(false); - setMessagingState(kMessagingInitial); + mTeleportButton = findChild("teleport_to_character"); + llassert(mTeleportButton != NULL) + mTeleportButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked, this)); return LLFloater::postBuild(); } void LLFloaterPathfindingCharacters::onOpen(const LLSD& pKey) { - sendCharactersDataGetRequest(); + LLFloater::onOpen(pKey); + + requestGetCharacters(); selectNoneCharacters(); + mCharactersScrollList->setCommitOnSelectionChange(true); if (!mSelectionUpdateSlot.connected()) { - mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingCharacters::updateActionFields, this)); + mSelectionUpdateSlot = LLSelectMgr::getInstance()->mUpdateSignal.connect(boost::bind(&LLFloaterPathfindingCharacters::updateControls, this)); } - - mCharactersScrollList->setCommitOnSelectionChange(true); } -void LLFloaterPathfindingCharacters::onClose(bool app_quitting) +void LLFloaterPathfindingCharacters::onClose(bool pAppQuitting) { - mCharactersScrollList->setCommitOnSelectionChange(false); - if (mSelectionUpdateSlot.connected()) { mSelectionUpdateSlot.disconnect(); } + mCharactersScrollList->setCommitOnSelectionChange(false); selectNoneCharacters(); if (mCharacterSelection.notNull()) { - std::vector selectedObjects; - - LLObjectSelection *charactersSelected = mCharacterSelection.get(); - for (LLObjectSelection::valid_iterator characterIter = charactersSelected->valid_begin(); - characterIter != charactersSelected->valid_end(); ++characterIter) - { - LLSelectNode *characterNode = *characterIter; - selectedObjects.push_back(characterNode->getObject()); - } - - for (std::vector::const_iterator selectedObjectIter = selectedObjects.begin(); - selectedObjectIter != selectedObjects.end(); ++selectedObjectIter) - { - LLViewerObject *selectedObject = *selectedObjectIter; - LLSelectMgr::getInstance()->deselectObjectAndFamily(selectedObject); - } - mCharacterSelection.clear(); } + + LLFloater::onClose(pAppQuitting); } void LLFloaterPathfindingCharacters::draw() @@ -208,141 +174,88 @@ LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters:: BOOL LLFloaterPathfindingCharacters::isMessagingInProgress() const { - BOOL retVal; - switch (getMessagingState()) - { - case kMessagingFetchStarting : - case kMessagingFetchRequestSent : - case kMessagingFetchRequestSent_MultiRequested : - case kMessagingFetchReceived : - retVal = true; - break; - default : - retVal = false; - break; - } - - return retVal; + return (mMessagingState == kMessagingGetRequestSent); } LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloater(pSeed), - mSelfHandle(), - mPathfindingCharacters(), - mMessagingState(kMessagingInitial), mCharactersScrollList(NULL), mCharactersStatus(NULL), - mLabelActions(NULL), + mRefreshListButton(NULL), + mSelectAllButton(NULL), + mSelectNoneButton(NULL), mShowBeaconCheckBox(NULL), - mTakeBtn(NULL), - mTakeCopyBtn(NULL), - mReturnBtn(NULL), - mDeleteBtn(NULL), - mTeleportBtn(NULL), + mTakeButton(NULL), + mTakeCopyButton(NULL), + mReturnButton(NULL), + mDeleteButton(NULL), + mTeleportButton(NULL), + mMessagingState(kMessagingUnknown), + mCharacterListPtr(), mCharacterSelection(), mSelectionUpdateSlot() { - mSelfHandle.bind(this); } LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() { - mPathfindingCharacters.clear(); - mCharacterSelection.clear(); -} - -void LLFloaterPathfindingCharacters::sendCharactersDataGetRequest() -{ - if (isMessagingInProgress()) - { - if (getMessagingState() == kMessagingFetchRequestSent) - { - setMessagingState(kMessagingFetchRequestSent_MultiRequested); - } - } - else - { - setMessagingState(kMessagingFetchStarting); - mPathfindingCharacters.clear(); - updateCharactersList(); - - std::string charactersDataURL = getCapabilityURL(); - if (charactersDataURL.empty()) - { - setMessagingState(kMessagingServiceNotAvailable); - llwarns << "cannot query pathfinding characters from current region '" << getRegionName() << "'" << llendl; - } - else - { - setMessagingState(kMessagingFetchRequestSent); - LLHTTPClient::get(charactersDataURL, new CharactersGetResponder(charactersDataURL, mSelfHandle)); - } - } -} - -void LLFloaterPathfindingCharacters::handleCharactersDataGetReply(const LLSD& pCharactersData) -{ - setMessagingState(kMessagingFetchReceived); - mPathfindingCharacters.clear(); - parseCharactersData(pCharactersData); - updateCharactersList(); - setMessagingState(kMessagingComplete); } -void LLFloaterPathfindingCharacters::handleCharactersDataGetError(const std::string& pURL, const std::string& pErrorReason) +void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagingState) { - setMessagingState(kMessagingFetchError); - mPathfindingCharacters.clear(); - updateCharactersList(); - llwarns << "Error fetching pathfinding characters from URL '" << pURL << "' because " << pErrorReason << llendl; + mMessagingState = pMessagingState; + updateControls(); } -std::string LLFloaterPathfindingCharacters::getRegionName() const +void LLFloaterPathfindingCharacters::requestGetCharacters() { - std::string regionName(""); - - LLViewerRegion* region = gAgent.getRegion(); - if (region != NULL) + llassert(!isMessagingInProgress()); + if (!isMessagingInProgress()) { - regionName = region->getName(); + switch (LLPathfindingManager::getInstance()->requestGetCharacters(boost::bind(&LLFloaterPathfindingCharacters::handleNewCharacters, this, _1, _2))) + { + case LLPathfindingManager::kRequestStarted : + setMessagingState(kMessagingGetRequestSent); + break; + case LLPathfindingManager::kRequestCompleted : + clearCharacters(); + setMessagingState(kMessagingComplete); + break; + case LLPathfindingManager::kRequestNotEnabled : + clearCharacters(); + setMessagingState(kMessagingNotEnabled); + break; + case LLPathfindingManager::kRequestError : + setMessagingState(kMessagingGetError); + break; + default : + setMessagingState(kMessagingGetError); + llassert(0); + break; + } } - - return regionName; } -std::string LLFloaterPathfindingCharacters::getCapabilityURL() const +void LLFloaterPathfindingCharacters::handleNewCharacters(LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr) { - std::string charactersDataURL(""); - - LLViewerRegion* region = gAgent.getRegion(); - if (region != NULL) - { - charactersDataURL = region->getCapability("CharacterProperties"); - } - - return charactersDataURL; -} + mCharacterListPtr = pCharacterListPtr; + updateScrollList(); -void LLFloaterPathfindingCharacters::parseCharactersData(const LLSD &pCharactersData) -{ - for (LLSD::map_const_iterator characterItemIter = pCharactersData.beginMap(); - characterItemIter != pCharactersData.endMap(); ++characterItemIter) + switch (pCharacterRequestStatus) { - const std::string &uuid(characterItemIter->first); - const LLSD &characterData(characterItemIter->second); - LLPathfindingCharacter character(uuid, characterData); - - mPathfindingCharacters.insert(std::pair(uuid, character)); + case LLPathfindingManager::kRequestCompleted : + setMessagingState(kMessagingComplete); + break; + case LLPathfindingManager::kRequestError : + setMessagingState(kMessagingGetError); + break; + default : + setMessagingState(kMessagingGetError); + llassert(0); + break; } } -void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagingState) -{ - mMessagingState = pMessagingState; - updateCharactersList(); - updateActionFields(); -} - void LLFloaterPathfindingCharacters::onCharactersSelectionChange() { mCharacterSelection.clear(); @@ -374,13 +287,12 @@ void LLFloaterPathfindingCharacters::onCharactersSelectionChange() } } - updateCharactersStatusMessage(); - updateActionFields(); + updateControls(); } void LLFloaterPathfindingCharacters::onRefreshCharactersClicked() { - sendCharactersDataGetRequest(); + requestGetCharacters(); } void LLFloaterPathfindingCharacters::onSelectAllCharactersClicked() @@ -421,9 +333,9 @@ void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() { std::vector::const_reference selectedItemRef = selectedItems.front(); const LLScrollListItem *selectedItem = selectedItemRef; - PathfindingCharacterMap::const_iterator characterIter = mPathfindingCharacters.find(selectedItem->getUUID().asString()); - const LLPathfindingCharacter &character = characterIter->second; - LLVector3 characterLocation = character.getLocation(); + 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) @@ -433,7 +345,33 @@ void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() } } -void LLFloaterPathfindingCharacters::updateCharactersList() +void LLFloaterPathfindingCharacters::selectAllCharacters() +{ + mCharactersScrollList->selectAll(); +} + +void LLFloaterPathfindingCharacters::selectNoneCharacters() +{ + mCharactersScrollList->deselectAllItems(); +} + +void LLFloaterPathfindingCharacters::clearCharacters() +{ + if (mCharacterListPtr != NULL) + { + mCharacterListPtr->clear(); + } + updateScrollList(); +} + +void LLFloaterPathfindingCharacters::updateControls() +{ + updateStatusMessage(); + updateEnableStateOnListActions(); + updateEnableStateOnEditFields(); +} + +void LLFloaterPathfindingCharacters::updateScrollList() { std::vector selectedItems = mCharactersScrollList->getAllSelected(); int numSelectedItems = selectedItems.size(); @@ -449,65 +387,62 @@ void LLFloaterPathfindingCharacters::updateCharactersList() } } + S32 origScrollPosition = mCharactersScrollList->getScrollPos(); mCharactersScrollList->deleteAllItems(); - updateCharactersStatusMessage(); - LLLocale locale(LLStringUtil::getLocale()); - for (PathfindingCharacterMap::const_iterator characterIter = mPathfindingCharacters.begin(); - characterIter != mPathfindingCharacters.end(); ++characterIter) + if (mCharacterListPtr != NULL) { - const LLPathfindingCharacter& character(characterIter->second); - - LLSD columns; - - columns[0]["column"] = "name"; - columns[0]["value"] = character.getName(); - columns[0]["font"] = "SANSSERIF"; + for (LLPathfindingCharacterList::const_iterator characterIter = mCharacterListPtr->begin(); + characterIter != mCharacterListPtr->end(); ++characterIter) + { + const LLPathfindingCharacterPtr& character(characterIter->second); + LLSD element = buildCharacterScrollListElement(character); + mCharactersScrollList->addElement(element); + } + } - columns[1]["column"] = "description"; - columns[1]["value"] = character.getDescription(); - columns[1]["font"] = "SANSSERIF"; + mCharactersScrollList->selectMultiple(selectedUUIDs); + mCharactersScrollList->setScrollPos(origScrollPosition); + updateControls(); +} - columns[2]["column"] = "owner"; - columns[2]["value"] = character.getOwnerName(); - columns[2]["font"] = "SANSSERIF"; +LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListElement(const LLPathfindingCharacterPtr pCharacterPtr) const +{ + LLSD columns; - S32 cpuTime = llround(character.getCPUTime()); - std::string cpuTimeString = llformat("%d", cpuTime); - LLStringUtil::format_map_t string_args; - string_args["[CPU_TIME]"] = cpuTimeString; + columns[0]["column"] = "name"; + columns[0]["value"] = pCharacterPtr->getName(); + columns[0]["font"] = "SANSSERIF"; - columns[3]["column"] = "cpu_time"; - columns[3]["value"] = getString("character_cpu_time", string_args); - columns[3]["font"] = "SANSSERIF"; + columns[1]["column"] = "description"; + columns[1]["value"] = pCharacterPtr->getDescription(); + columns[1]["font"] = "SANSSERIF"; - columns[4]["column"] = "altitude"; - columns[4]["value"] = llformat("%1.0f m", character.getLocation()[2]); - columns[4]["font"] = "SANSSERIF"; + columns[2]["column"] = "owner"; + columns[2]["value"] = pCharacterPtr->getOwnerName(); + columns[2]["font"] = "SANSSERIF"; - LLSD element; - element["id"] = character.getUUID().asString(); - element["column"] = columns; + S32 cpuTime = llround(pCharacterPtr->getCPUTime()); + std::string cpuTimeString = llformat("%d", cpuTime); + LLStringUtil::format_map_t string_args; + string_args["[CPU_TIME]"] = cpuTimeString; - mCharactersScrollList->addElement(element); - } + columns[3]["column"] = "cpu_time"; + columns[3]["value"] = getString("character_cpu_time", string_args); + columns[3]["font"] = "SANSSERIF"; - mCharactersScrollList->selectMultiple(selectedUUIDs); - updateCharactersStatusMessage(); - updateActionFields(); -} + columns[4]["column"] = "altitude"; + columns[4]["value"] = llformat("%1.0f m", pCharacterPtr->getLocation()[2]); + columns[4]["font"] = "SANSSERIF"; -void LLFloaterPathfindingCharacters::selectAllCharacters() -{ - mCharactersScrollList->selectAll(); -} + LLSD element; + element["id"] = pCharacterPtr->getUUID().asString(); + element["column"] = columns; -void LLFloaterPathfindingCharacters::selectNoneCharacters() -{ - mCharactersScrollList->deselectAllItems(); + return element; } -void LLFloaterPathfindingCharacters::updateCharactersStatusMessage() +void LLFloaterPathfindingCharacters::updateStatusMessage() { static const LLColor4 warningColor = LLUIColorTable::instance().getColor("DrYellow"); @@ -516,23 +451,14 @@ void LLFloaterPathfindingCharacters::updateCharactersStatusMessage() switch (getMessagingState()) { - case kMessagingInitial: + case kMessagingUnknown: statusText = getString("characters_messaging_initial"); break; - case kMessagingFetchStarting : - statusText = getString("characters_messaging_fetch_starting"); - break; - case kMessagingFetchRequestSent : - statusText = getString("characters_messaging_fetch_inprogress"); + case kMessagingGetRequestSent : + statusText = getString("characters_messaging_get_inprogress"); break; - case kMessagingFetchRequestSent_MultiRequested : - statusText = getString("characters_messaging_fetch_inprogress_multi_request"); - break; - case kMessagingFetchReceived : - statusText = getString("characters_messaging_fetch_received"); - break; - case kMessagingFetchError : - statusText = getString("characters_messaging_fetch_error"); + case kMessagingGetError : + statusText = getString("characters_messaging_get_error"); styleParams.color = warningColor; break; case kMessagingComplete : @@ -558,8 +484,8 @@ void LLFloaterPathfindingCharacters::updateCharactersStatusMessage() statusText = getString("characters_messaging_complete_available", string_args); } break; - case kMessagingServiceNotAvailable: - statusText = getString("characters_messaging_service_not_available"); + case kMessagingNotEnabled: + statusText = getString("characters_messaging_not_enabled"); styleParams.color = warningColor; break; default: @@ -571,52 +497,46 @@ void LLFloaterPathfindingCharacters::updateCharactersStatusMessage() mCharactersStatus->setText((LLStringExplicit)statusText, styleParams); } -void LLFloaterPathfindingCharacters::updateActionFields() -{ - std::vector selectedItems = mCharactersScrollList->getAllSelected(); - setEnableActionFields(!selectedItems.empty()); -} - -void LLFloaterPathfindingCharacters::setEnableActionFields(BOOL pEnabled) -{ - mLabelActions->setEnabled(pEnabled); - mShowBeaconCheckBox->setEnabled(pEnabled); - mTakeBtn->setEnabled(pEnabled && visible_take_object()); - mTakeCopyBtn->setEnabled(pEnabled && enable_object_take_copy()); - mReturnBtn->setEnabled(pEnabled && enable_object_return()); - mDeleteBtn->setEnabled(pEnabled && enable_object_delete()); - mTeleportBtn->setEnabled(pEnabled && (mCharactersScrollList->getNumSelected() == 1)); -} - -//--------------------------------------------------------------------------- -// CharactersGetResponder -//--------------------------------------------------------------------------- - -CharactersGetResponder::CharactersGetResponder(const std::string& pCharactersDataGetURL, - const LLHandle &pCharactersFloaterHandle) - : mCharactersDataGetURL(pCharactersDataGetURL), - mCharactersFloaterHandle(pCharactersFloaterHandle) -{ -} - -CharactersGetResponder::~CharactersGetResponder() -{ -} - -void CharactersGetResponder::result(const LLSD& pContent) +void LLFloaterPathfindingCharacters::updateEnableStateOnListActions() { - LLFloaterPathfindingCharacters *charactersFloater = mCharactersFloaterHandle.get(); - if (charactersFloater != NULL) + switch (getMessagingState()) { - charactersFloater->handleCharactersDataGetReply(pContent); + 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 CharactersGetResponder::error(U32 status, const std::string& reason) +void LLFloaterPathfindingCharacters::updateEnableStateOnEditFields() { - LLFloaterPathfindingCharacters *charactersFloater = mCharactersFloaterHandle.get(); - if (charactersFloater != NULL) - { - charactersFloater->handleCharactersDataGetError(mCharactersDataGetURL, reason); - } + 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); } -- cgit v1.2.3 From 9d22b22d962321822a6be6a23150e6d5f939cd50 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 5 Apr 2012 15:59:34 -0700 Subject: PATH-482: BUGFIX Automatically reloading the character and linksets floaters on region crossing. --- indra/newview/llfloaterpathfindingcharacters.cpp | 94 +++++++++++++----------- 1 file changed, 53 insertions(+), 41 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index d174d822cd..6fc1b8f051 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -47,6 +47,7 @@ #include "llviewerobjectlist.h" #include "llviewermenu.h" #include "llselectmgr.h" +#include "llenvmanager.h" //--------------------------------------------------------------------------- // LLFloaterPathfindingCharacters @@ -112,10 +113,20 @@ void LLFloaterPathfindingCharacters::onOpen(const LLSD& pKey) { 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(); @@ -167,16 +178,6 @@ void LLFloaterPathfindingCharacters::openCharactersViewer() LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); } -LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const -{ - return mMessagingState; -} - -BOOL LLFloaterPathfindingCharacters::isMessagingInProgress() const -{ - return (mMessagingState == kMessagingGetRequestSent); -} - LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloater(pSeed), mCharactersScrollList(NULL), @@ -191,6 +192,7 @@ LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed mDeleteButton(NULL), mTeleportButton(NULL), mMessagingState(kMessagingUnknown), + mMessagingRequestId(0U), mCharacterListPtr(), mCharacterSelection(), mSelectionUpdateSlot() @@ -201,6 +203,11 @@ LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() { } +LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const +{ + return mMessagingState; +} + void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagingState) { mMessagingState = pMessagingState; @@ -209,22 +216,42 @@ void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagin void LLFloaterPathfindingCharacters::requestGetCharacters() { - llassert(!isMessagingInProgress()); - if (!isMessagingInProgress()) + switch (LLPathfindingManager::getInstance()->requestGetCharacters(++mMessagingRequestId, boost::bind(&LLFloaterPathfindingCharacters::handleNewCharacters, this, _1, _2, _3))) + { + case LLPathfindingManager::kRequestStarted : + setMessagingState(kMessagingGetRequestSent); + break; + case LLPathfindingManager::kRequestCompleted : + clearCharacters(); + setMessagingState(kMessagingComplete); + break; + case LLPathfindingManager::kRequestNotEnabled : + clearCharacters(); + setMessagingState(kMessagingNotEnabled); + break; + case LLPathfindingManager::kRequestError : + setMessagingState(kMessagingGetError); + break; + default : + setMessagingState(kMessagingGetError); + llassert(0); + break; + } +} + +void LLFloaterPathfindingCharacters::handleNewCharacters(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr) +{ + llassert(pRequestId <= mMessagingRequestId); + if (pRequestId == mMessagingRequestId) { - switch (LLPathfindingManager::getInstance()->requestGetCharacters(boost::bind(&LLFloaterPathfindingCharacters::handleNewCharacters, this, _1, _2))) + mCharacterListPtr = pCharacterListPtr; + updateScrollList(); + + switch (pCharacterRequestStatus) { - case LLPathfindingManager::kRequestStarted : - setMessagingState(kMessagingGetRequestSent); - break; case LLPathfindingManager::kRequestCompleted : - clearCharacters(); setMessagingState(kMessagingComplete); break; - case LLPathfindingManager::kRequestNotEnabled : - clearCharacters(); - setMessagingState(kMessagingNotEnabled); - break; case LLPathfindingManager::kRequestError : setMessagingState(kMessagingGetError); break; @@ -236,26 +263,6 @@ void LLFloaterPathfindingCharacters::requestGetCharacters() } } -void LLFloaterPathfindingCharacters::handleNewCharacters(LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr) -{ - mCharacterListPtr = pCharacterListPtr; - updateScrollList(); - - switch (pCharacterRequestStatus) - { - case LLPathfindingManager::kRequestCompleted : - setMessagingState(kMessagingComplete); - break; - case LLPathfindingManager::kRequestError : - setMessagingState(kMessagingGetError); - break; - default : - setMessagingState(kMessagingGetError); - llassert(0); - break; - } -} - void LLFloaterPathfindingCharacters::onCharactersSelectionChange() { mCharacterSelection.clear(); @@ -345,6 +352,11 @@ void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() } } +void LLFloaterPathfindingCharacters::onRegionBoundaryCross() +{ + requestGetCharacters(); +} + void LLFloaterPathfindingCharacters::selectAllCharacters() { mCharactersScrollList->selectAll(); -- cgit v1.2.3 From 8d9863f4ef039af4f6af7f41909e212b9101ce0f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 6 Apr 2012 13:37:11 -0700 Subject: Altering the layout of the pathfinding console based on feedback. --- indra/newview/llfloaterpathfindingcharacters.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 6fc1b8f051..9998d25c7d 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -456,7 +456,8 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListElement(const LLPat void LLFloaterPathfindingCharacters::updateStatusMessage() { - static const LLColor4 warningColor = LLUIColorTable::instance().getColor("DrYellow"); + static const LLColor4 errorColor = LLUIColorTable::instance().getColor("PathfindingErrorColor"); + static const LLColor4 warningColor = LLUIColorTable::instance().getColor("PathfindingWarningColor"); std::string statusText(""); LLStyle::Params styleParams; @@ -465,13 +466,15 @@ void LLFloaterPathfindingCharacters::updateStatusMessage() { 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 = warningColor; + styleParams.color = errorColor; break; case kMessagingComplete : if (mCharactersScrollList->isEmpty()) @@ -498,10 +501,11 @@ void LLFloaterPathfindingCharacters::updateStatusMessage() break; case kMessagingNotEnabled: statusText = getString("characters_messaging_not_enabled"); - styleParams.color = warningColor; + styleParams.color = errorColor; break; default: statusText = getString("characters_messaging_initial"); + styleParams.color = errorColor; llassert(0); break; } -- cgit v1.2.3 From cbebd682f7b9b0cff120bc36d9db9bb170dc1b2a Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 25 Apr 2012 13:04:13 -0700 Subject: Removing windows line endings from .h and .cpp files. --- indra/newview/llfloaterpathfindingcharacters.cpp | 1116 +++++++++++----------- 1 file changed, 558 insertions(+), 558 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 9998d25c7d..ee97063352 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -1,558 +1,558 @@ -/** - * @file llfloaterpathfindingcharacters.cpp - * @author William Todd Stinson - * @brief "Pathfinding characters" floater, allowing for identification of pathfinding characters and their cpu usage. - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" -#include "llfloater.h" -#include "llfloaterpathfindingcharacters.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" - -//--------------------------------------------------------------------------- -// LLFloaterPathfindingCharacters -//--------------------------------------------------------------------------- - -BOOL LLFloaterPathfindingCharacters::postBuild() -{ - mCharactersScrollList = findChild("pathfinding_characters"); - llassert(mCharactersScrollList != NULL); - mCharactersScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onCharactersSelectionChange, this)); - mCharactersScrollList->sortByColumnIndex(0, true); - - mCharactersStatus = findChild("characters_status"); - llassert(mCharactersStatus != NULL); - - mRefreshListButton = findChild("refresh_characters_list"); - llassert(mRefreshListButton != NULL); - mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onRefreshCharactersClicked, this)); - - mSelectAllButton = findChild("select_all_characters"); - llassert(mSelectAllButton != NULL); - mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectAllCharactersClicked, this)); - - mSelectNoneButton = findChild("select_none_characters"); - llassert(mSelectNoneButton != NULL); - mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked, this)); - - mShowBeaconCheckBox = findChild("show_beacon"); - llassert(mShowBeaconCheckBox != NULL); - - mTakeButton = findChild("take_characters"); - llassert(mTakeButton != NULL) - mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCharactersClicked, this)); - - mTakeCopyButton = findChild("take_copy_characters"); - llassert(mTakeCopyButton != NULL) - mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked, this)); - - mReturnButton = findChild("return_characters"); - llassert(mReturnButton != NULL) - mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onReturnCharactersClicked, this)); - - mDeleteButton = findChild("delete_characters"); - llassert(mDeleteButton != NULL) - mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onDeleteCharactersClicked, this)); - - mTeleportButton = findChild("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 selectedItems = mCharactersScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - std::vector viewerObjects; - viewerObjects.reserve(numSelectedItems); - - for (std::vector::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() -{ -} - -LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() -{ -} - -LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const -{ - return mMessagingState; -} - -void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagingState) -{ - mMessagingState = pMessagingState; - updateControls(); -} - -void LLFloaterPathfindingCharacters::requestGetCharacters() -{ - switch (LLPathfindingManager::getInstance()->requestGetCharacters(++mMessagingRequestId, boost::bind(&LLFloaterPathfindingCharacters::handleNewCharacters, this, _1, _2, _3))) - { - case LLPathfindingManager::kRequestStarted : - setMessagingState(kMessagingGetRequestSent); - break; - case LLPathfindingManager::kRequestCompleted : - clearCharacters(); - setMessagingState(kMessagingComplete); - break; - case LLPathfindingManager::kRequestNotEnabled : - clearCharacters(); - setMessagingState(kMessagingNotEnabled); - break; - case LLPathfindingManager::kRequestError : - setMessagingState(kMessagingGetError); - break; - default : - setMessagingState(kMessagingGetError); - llassert(0); - break; - } -} - -void LLFloaterPathfindingCharacters::handleNewCharacters(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr) -{ - llassert(pRequestId <= mMessagingRequestId); - if (pRequestId == mMessagingRequestId) - { - mCharacterListPtr = pCharacterListPtr; - updateScrollList(); - - switch (pCharacterRequestStatus) - { - case LLPathfindingManager::kRequestCompleted : - setMessagingState(kMessagingComplete); - break; - case LLPathfindingManager::kRequestError : - setMessagingState(kMessagingGetError); - break; - default : - setMessagingState(kMessagingGetError); - llassert(0); - break; - } - } -} - -void LLFloaterPathfindingCharacters::onCharactersSelectionChange() -{ - mCharacterSelection.clear(); - LLSelectMgr::getInstance()->deselectAll(); - - std::vector selectedItems = mCharactersScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - 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) - { - viewerObjects.push_back(viewerObject); - } - } - - if (!viewerObjects.empty()) - { - mCharacterSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); - } - } - - updateControls(); -} - -void LLFloaterPathfindingCharacters::onRefreshCharactersClicked() -{ - requestGetCharacters(); -} - -void LLFloaterPathfindingCharacters::onSelectAllCharactersClicked() -{ - selectAllCharacters(); -} - -void LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked() -{ - selectNoneCharacters(); -} - -void LLFloaterPathfindingCharacters::onTakeCharactersClicked() -{ - handle_take(); -} - -void LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked() -{ - handle_take_copy(); -} - -void LLFloaterPathfindingCharacters::onReturnCharactersClicked() -{ - handle_object_return(); -} - -void LLFloaterPathfindingCharacters::onDeleteCharactersClicked() -{ - handle_object_delete(); -} - -void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() -{ - std::vector selectedItems = mCharactersScrollList->getAllSelected(); - llassert(selectedItems.size() == 1); - if (selectedItems.size() == 1) - { - std::vector::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); - } - } -} - -void LLFloaterPathfindingCharacters::onRegionBoundaryCross() -{ - requestGetCharacters(); -} - -void LLFloaterPathfindingCharacters::selectAllCharacters() -{ - mCharactersScrollList->selectAll(); -} - -void LLFloaterPathfindingCharacters::selectNoneCharacters() -{ - mCharactersScrollList->deselectAllItems(); -} - -void LLFloaterPathfindingCharacters::clearCharacters() -{ - if (mCharacterListPtr != NULL) - { - mCharacterListPtr->clear(); - } - updateScrollList(); -} - -void LLFloaterPathfindingCharacters::updateControls() -{ - updateStatusMessage(); - updateEnableStateOnListActions(); - updateEnableStateOnEditFields(); -} - -void LLFloaterPathfindingCharacters::updateScrollList() -{ - std::vector selectedItems = mCharactersScrollList->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 = 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(); -} - -LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListElement(const LLPathfindingCharacterPtr pCharacterPtr) const -{ - LLSD columns; - - columns[0]["column"] = "name"; - columns[0]["value"] = pCharacterPtr->getName(); - columns[0]["font"] = "SANSSERIF"; - - columns[1]["column"] = "description"; - columns[1]["value"] = pCharacterPtr->getDescription(); - columns[1]["font"] = "SANSSERIF"; - - columns[2]["column"] = "owner"; - columns[2]["value"] = pCharacterPtr->getOwnerName(); - columns[2]["font"] = "SANSSERIF"; - - S32 cpuTime = llround(pCharacterPtr->getCPUTime()); - std::string cpuTimeString = llformat("%d", cpuTime); - LLStringUtil::format_map_t string_args; - string_args["[CPU_TIME]"] = cpuTimeString; - - columns[3]["column"] = "cpu_time"; - columns[3]["value"] = getString("character_cpu_time", string_args); - columns[3]["font"] = "SANSSERIF"; - - columns[4]["column"] = "altitude"; - columns[4]["value"] = llformat("%1.0f m", pCharacterPtr->getLocation()[2]); - columns[4]["font"] = "SANSSERIF"; - - LLSD element; - element["id"] = pCharacterPtr->getUUID().asString(); - element["column"] = columns; - - 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); -} +/** + * @file llfloaterpathfindingcharacters.cpp + * @author William Todd Stinson + * @brief "Pathfinding characters" floater, allowing for identification of pathfinding characters and their cpu usage. + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llfloater.h" +#include "llfloaterpathfindingcharacters.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" + +//--------------------------------------------------------------------------- +// LLFloaterPathfindingCharacters +//--------------------------------------------------------------------------- + +BOOL LLFloaterPathfindingCharacters::postBuild() +{ + mCharactersScrollList = findChild("pathfinding_characters"); + llassert(mCharactersScrollList != NULL); + mCharactersScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onCharactersSelectionChange, this)); + mCharactersScrollList->sortByColumnIndex(0, true); + + mCharactersStatus = findChild("characters_status"); + llassert(mCharactersStatus != NULL); + + mRefreshListButton = findChild("refresh_characters_list"); + llassert(mRefreshListButton != NULL); + mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onRefreshCharactersClicked, this)); + + mSelectAllButton = findChild("select_all_characters"); + llassert(mSelectAllButton != NULL); + mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectAllCharactersClicked, this)); + + mSelectNoneButton = findChild("select_none_characters"); + llassert(mSelectNoneButton != NULL); + mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked, this)); + + mShowBeaconCheckBox = findChild("show_beacon"); + llassert(mShowBeaconCheckBox != NULL); + + mTakeButton = findChild("take_characters"); + llassert(mTakeButton != NULL) + mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCharactersClicked, this)); + + mTakeCopyButton = findChild("take_copy_characters"); + llassert(mTakeCopyButton != NULL) + mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked, this)); + + mReturnButton = findChild("return_characters"); + llassert(mReturnButton != NULL) + mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onReturnCharactersClicked, this)); + + mDeleteButton = findChild("delete_characters"); + llassert(mDeleteButton != NULL) + mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onDeleteCharactersClicked, this)); + + mTeleportButton = findChild("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 selectedItems = mCharactersScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + + std::vector viewerObjects; + viewerObjects.reserve(numSelectedItems); + + for (std::vector::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() +{ +} + +LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() +{ +} + +LLFloaterPathfindingCharacters::EMessagingState LLFloaterPathfindingCharacters::getMessagingState() const +{ + return mMessagingState; +} + +void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagingState) +{ + mMessagingState = pMessagingState; + updateControls(); +} + +void LLFloaterPathfindingCharacters::requestGetCharacters() +{ + switch (LLPathfindingManager::getInstance()->requestGetCharacters(++mMessagingRequestId, boost::bind(&LLFloaterPathfindingCharacters::handleNewCharacters, this, _1, _2, _3))) + { + case LLPathfindingManager::kRequestStarted : + setMessagingState(kMessagingGetRequestSent); + break; + case LLPathfindingManager::kRequestCompleted : + clearCharacters(); + setMessagingState(kMessagingComplete); + break; + case LLPathfindingManager::kRequestNotEnabled : + clearCharacters(); + setMessagingState(kMessagingNotEnabled); + break; + case LLPathfindingManager::kRequestError : + setMessagingState(kMessagingGetError); + break; + default : + setMessagingState(kMessagingGetError); + llassert(0); + break; + } +} + +void LLFloaterPathfindingCharacters::handleNewCharacters(LLPathfindingManager::request_id_t pRequestId, LLPathfindingManager::ERequestStatus pCharacterRequestStatus, LLPathfindingCharacterListPtr pCharacterListPtr) +{ + llassert(pRequestId <= mMessagingRequestId); + if (pRequestId == mMessagingRequestId) + { + mCharacterListPtr = pCharacterListPtr; + updateScrollList(); + + switch (pCharacterRequestStatus) + { + case LLPathfindingManager::kRequestCompleted : + setMessagingState(kMessagingComplete); + break; + case LLPathfindingManager::kRequestError : + setMessagingState(kMessagingGetError); + break; + default : + setMessagingState(kMessagingGetError); + llassert(0); + break; + } + } +} + +void LLFloaterPathfindingCharacters::onCharactersSelectionChange() +{ + mCharacterSelection.clear(); + LLSelectMgr::getInstance()->deselectAll(); + + std::vector selectedItems = mCharactersScrollList->getAllSelected(); + if (!selectedItems.empty()) + { + int numSelectedItems = selectedItems.size(); + + 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) + { + viewerObjects.push_back(viewerObject); + } + } + + if (!viewerObjects.empty()) + { + mCharacterSelection = LLSelectMgr::getInstance()->selectObjectAndFamily(viewerObjects); + } + } + + updateControls(); +} + +void LLFloaterPathfindingCharacters::onRefreshCharactersClicked() +{ + requestGetCharacters(); +} + +void LLFloaterPathfindingCharacters::onSelectAllCharactersClicked() +{ + selectAllCharacters(); +} + +void LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked() +{ + selectNoneCharacters(); +} + +void LLFloaterPathfindingCharacters::onTakeCharactersClicked() +{ + handle_take(); +} + +void LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked() +{ + handle_take_copy(); +} + +void LLFloaterPathfindingCharacters::onReturnCharactersClicked() +{ + handle_object_return(); +} + +void LLFloaterPathfindingCharacters::onDeleteCharactersClicked() +{ + handle_object_delete(); +} + +void LLFloaterPathfindingCharacters::onTeleportCharacterToMeClicked() +{ + std::vector selectedItems = mCharactersScrollList->getAllSelected(); + llassert(selectedItems.size() == 1); + if (selectedItems.size() == 1) + { + std::vector::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); + } + } +} + +void LLFloaterPathfindingCharacters::onRegionBoundaryCross() +{ + requestGetCharacters(); +} + +void LLFloaterPathfindingCharacters::selectAllCharacters() +{ + mCharactersScrollList->selectAll(); +} + +void LLFloaterPathfindingCharacters::selectNoneCharacters() +{ + mCharactersScrollList->deselectAllItems(); +} + +void LLFloaterPathfindingCharacters::clearCharacters() +{ + if (mCharacterListPtr != NULL) + { + mCharacterListPtr->clear(); + } + updateScrollList(); +} + +void LLFloaterPathfindingCharacters::updateControls() +{ + updateStatusMessage(); + updateEnableStateOnListActions(); + updateEnableStateOnEditFields(); +} + +void LLFloaterPathfindingCharacters::updateScrollList() +{ + std::vector selectedItems = mCharactersScrollList->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 = 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(); +} + +LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListElement(const LLPathfindingCharacterPtr pCharacterPtr) const +{ + LLSD columns; + + columns[0]["column"] = "name"; + columns[0]["value"] = pCharacterPtr->getName(); + columns[0]["font"] = "SANSSERIF"; + + columns[1]["column"] = "description"; + columns[1]["value"] = pCharacterPtr->getDescription(); + columns[1]["font"] = "SANSSERIF"; + + columns[2]["column"] = "owner"; + columns[2]["value"] = pCharacterPtr->getOwnerName(); + columns[2]["font"] = "SANSSERIF"; + + S32 cpuTime = llround(pCharacterPtr->getCPUTime()); + std::string cpuTimeString = llformat("%d", cpuTime); + LLStringUtil::format_map_t string_args; + string_args["[CPU_TIME]"] = cpuTimeString; + + columns[3]["column"] = "cpu_time"; + columns[3]["value"] = getString("character_cpu_time", string_args); + columns[3]["font"] = "SANSSERIF"; + + columns[4]["column"] = "altitude"; + columns[4]["value"] = llformat("%1.0f m", pCharacterPtr->getLocation()[2]); + columns[4]["font"] = "SANSSERIF"; + + LLSD element; + element["id"] = pCharacterPtr->getUUID().asString(); + element["column"] = columns; + + 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); +} -- cgit v1.2.3 From 852377c676bc3a8183073e41357499f06f40fb1b Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 1 May 2012 14:22:58 -0700 Subject: Switching the functionality of the linksets and character request handling to no longer return values directly, but rather to report status only through the callbacks. --- indra/newview/llfloaterpathfindingcharacters.cpp | 34 +++++++----------------- 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index ee97063352..d0706b0bc0 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -216,27 +216,7 @@ void LLFloaterPathfindingCharacters::setMessagingState(EMessagingState pMessagin void LLFloaterPathfindingCharacters::requestGetCharacters() { - switch (LLPathfindingManager::getInstance()->requestGetCharacters(++mMessagingRequestId, boost::bind(&LLFloaterPathfindingCharacters::handleNewCharacters, this, _1, _2, _3))) - { - case LLPathfindingManager::kRequestStarted : - setMessagingState(kMessagingGetRequestSent); - break; - case LLPathfindingManager::kRequestCompleted : - clearCharacters(); - setMessagingState(kMessagingComplete); - break; - case LLPathfindingManager::kRequestNotEnabled : - clearCharacters(); - setMessagingState(kMessagingNotEnabled); - break; - case LLPathfindingManager::kRequestError : - setMessagingState(kMessagingGetError); - break; - default : - setMessagingState(kMessagingGetError); - llassert(0); - break; - } + 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) @@ -244,14 +224,20 @@ void LLFloaterPathfindingCharacters::handleNewCharacters(LLPathfindingManager::r llassert(pRequestId <= mMessagingRequestId); if (pRequestId == mMessagingRequestId) { - mCharacterListPtr = pCharacterListPtr; - updateScrollList(); - 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; -- cgit v1.2.3 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/llfloaterpathfindingcharacters.cpp | 466 ++--------------------- 1 file changed, 30 insertions(+), 436 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') 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("pathfinding_characters"); - llassert(mCharactersScrollList != NULL); - mCharactersScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onCharactersSelectionChange, this)); - mCharactersScrollList->sortByColumnIndex(0, true); - - mCharactersStatus = findChild("characters_status"); - llassert(mCharactersStatus != NULL); - - mRefreshListButton = findChild("refresh_characters_list"); - llassert(mRefreshListButton != NULL); - mRefreshListButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onRefreshCharactersClicked, this)); - - mSelectAllButton = findChild("select_all_characters"); - llassert(mSelectAllButton != NULL); - mSelectAllButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectAllCharactersClicked, this)); - - mSelectNoneButton = findChild("select_none_characters"); - llassert(mSelectNoneButton != NULL); - mSelectNoneButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onSelectNoneCharactersClicked, this)); - - mShowBeaconCheckBox = findChild("show_beacon"); - llassert(mShowBeaconCheckBox != NULL); - - mTakeButton = findChild("take_characters"); - llassert(mTakeButton != NULL) - mTakeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCharactersClicked, this)); - - mTakeCopyButton = findChild("take_copy_characters"); - llassert(mTakeCopyButton != NULL) - mTakeCopyButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onTakeCopyCharactersClicked, this)); - - mReturnButton = findChild("return_characters"); - llassert(mReturnButton != NULL) - mReturnButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onReturnCharactersClicked, this)); - - mDeleteButton = findChild("delete_characters"); - llassert(mDeleteButton != NULL) - mDeleteButton->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onDeleteCharactersClicked, this)); - - mTeleportButton = findChild("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 selectedItems = mCharactersScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - std::vector viewerObjects; - viewerObjects.reserve(numSelectedItems); - - for (std::vector::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 selectedItems = mCharactersScrollList->getAllSelected(); - if (!selectedItems.empty()) - { - int numSelectedItems = selectedItems.size(); - - 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) - { - 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 selectedItems = mCharactersScrollList->getAllSelected(); - llassert(selectedItems.size() == 1); - if (selectedItems.size() == 1) + for (LLPathfindingObjectList::const_iterator objectIter = pObjectListPtr->begin(); objectIter != pObjectListPtr->end(); ++objectIter) { - std::vector::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(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 selectedItems = mCharactersScrollList->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 = 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); -} -- 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/llfloaterpathfindingcharacters.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 6599bac6a6..59f54c12bf 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -33,9 +33,10 @@ #include "llfloaterpathfindingobjects.h" #include "llpathfindingcharacter.h" #include "llpathfindingcharacterlist.h" +#include "llpathfindingmanager.h" +#include "llpathfindingobjectlist.h" #include "llsd.h" -#include "lluuid.h" -#include "llviewerregion.h" +#include "lluicolortable.h" //--------------------------------------------------------------------------- // LLFloaterPathfindingCharacters -- 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/llfloaterpathfindingcharacters.cpp | 111 ++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 59f54c12bf..8915683b6d 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -38,6 +38,17 @@ #include "llsd.h" #include "lluicolortable.h" +#include "llbutton.h" +#include "llcheckboxctrl.h" +#include "llfloater.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "llselectmgr.h" +#include "pipeline.h" +#include "llviewerobjectlist.h" + +LLHandle LLFloaterPathfindingCharacters::sInstanceHandle; + //--------------------------------------------------------------------------- // LLFloaterPathfindingCharacters //--------------------------------------------------------------------------- @@ -46,11 +57,17 @@ void LLFloaterPathfindingCharacters::openCharactersViewer() { LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); } +void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) +{ +} LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloaterPathfindingObjects(pSeed), - mBeaconColor() + mBeaconColor(), + mSelfHandle(), + mShowPhysicsCapsuleCheckBox(NULL) { + mSelfHandle.bind(this); } LLFloaterPathfindingCharacters::~LLFloaterPathfindingCharacters() @@ -61,6 +78,10 @@ BOOL LLFloaterPathfindingCharacters::postBuild() { mBeaconColor = LLUIColorTable::getInstance()->getColor("PathfindingCharacterBeaconColor"); + mShowPhysicsCapsuleCheckBox = findChild("show_physics_capsule"); + llassert(mShowPhysicsCapsuleCheckBox != NULL); + mShowPhysicsCapsuleCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked, this)); + return LLFloaterPathfindingObjects::postBuild(); } @@ -137,3 +158,91 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi return element; } + + +void LLFloaterPathfindingCharacters::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 LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) +{ + BOOL result = false; + if ( mShowPhysicsCapsuleCheckBox->get() ) + { + id = getUUIDFromSelection( pos ); + result = true; + } + else + { + id.setNull(); + } + return result; +} + +LLUUID LLFloaterPathfindingCharacters::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 LLFloaterPathfindingCharacters::getInstanceHandle() +{ + if ( sInstanceHandle.isDead() ) + { + LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::getTypedInstance("pathfinding_characters"); + if (floaterInstance != NULL) + { + sInstanceHandle = floaterInstance->mSelfHandle; + } + } + + return sInstanceHandle; +} + +void LLFloaterPathfindingCharacters::updateStateOnEditFields() +{ + int numSelectedItems = mObjectsScrollList->getNumSelected(); + bool isEditEnabled = (numSelectedItems > 0); + + mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); + + LLFloaterPathfindingObjects::updateStateOnEditFields(); +} -- 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/llfloaterpathfindingcharacters.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 8915683b6d..0dbc2a303a 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -57,8 +57,11 @@ void LLFloaterPathfindingCharacters::openCharactersViewer() { LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); } + void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) { + unhideAnyCharacters(); + LLFloaterPathfindingObjects::onClose( pIsAppQuitting ); } LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) @@ -246,3 +249,20 @@ void LLFloaterPathfindingCharacters::updateStateOnEditFields() LLFloaterPathfindingObjects::updateStateOnEditFields(); } + + +void LLFloaterPathfindingCharacters::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 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/llfloaterpathfindingcharacters.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 0dbc2a303a..121cb85a6d 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -93,7 +93,7 @@ void LLFloaterPathfindingCharacters::requestGetObjects() LLPathfindingManager::getInstance()->requestGetCharacters(getNewRequestId(), boost::bind(&LLFloaterPathfindingCharacters::handleNewObjectList, this, _1, _2, _3)); } -LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) const +LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPathfindingObjectListPtr pObjectListPtr) { llassert(pObjectListPtr != NULL); llassert(!pObjectListPtr->isEmpty()); @@ -105,6 +105,11 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa const LLPathfindingCharacter *characterPtr = dynamic_cast(objectIter->second.get()); LLSD element = buildCharacterScrollListData(characterPtr); scrollListData.append(element); + + if (characterPtr->hasOwner() && !characterPtr->hasOwnerName()) + { + rebuildScrollListAfterAvatarNameLoads(characterPtr->getUUID()); + } } return scrollListData; @@ -139,7 +144,9 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi columns[1]["font"] = "SANSSERIF"; columns[2]["column"] = "owner"; - columns[2]["value"] = pCharacterPtr->getOwnerName(); + columns[2]["value"] = (pCharacterPtr->hasOwner() ? + (pCharacterPtr->hasOwnerName() ? pCharacterPtr->getOwnerName() : getString("character_owner_loading")) : + getString("character_owner_unknown")); columns[2]["font"] = "SANSSERIF"; S32 cpuTime = llround(pCharacterPtr->getCPUTime()); -- cgit v1.2.3 From e85909aa9b52ac439f2886ca0048069fb9561893 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 4 Jun 2012 16:22:01 -0700 Subject: Some class refactoring. --- indra/newview/llfloaterpathfindingcharacters.cpp | 174 +++++++++++------------ 1 file changed, 84 insertions(+), 90 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 121cb85a6d..8b6f6aea1f 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -29,6 +29,7 @@ #include "llfloaterpathfindingcharacters.h" +#include "llcheckboxctrl.h" #include "llfloaterreg.h" #include "llfloaterpathfindingobjects.h" #include "llpathfindingcharacter.h" @@ -38,12 +39,6 @@ #include "llsd.h" #include "lluicolortable.h" -#include "llbutton.h" -#include "llcheckboxctrl.h" -#include "llfloater.h" -#include "llscrolllistctrl.h" -#include "llscrolllistitem.h" -#include "llselectmgr.h" #include "pipeline.h" #include "llviewerobjectlist.h" @@ -53,22 +48,46 @@ LLHandle LLFloaterPathfindingCharacters::sInstan // LLFloaterPathfindingCharacters //--------------------------------------------------------------------------- +void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) +{ + unhideAnyCharacters(); + LLFloaterPathfindingObjects::onClose( pIsAppQuitting ); +} + +BOOL LLFloaterPathfindingCharacters::isShowPhysicsCapsule() const +{ + return mShowPhysicsCapsuleCheckBox->get(); +} + +void LLFloaterPathfindingCharacters::setShowPhysicsCapsule(BOOL pIsShowPhysicsCapsule) +{ + mShowPhysicsCapsuleCheckBox->set(pIsShowPhysicsCapsule); +} + void LLFloaterPathfindingCharacters::openCharactersViewer() { LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); } -void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) +LLHandle LLFloaterPathfindingCharacters::getInstanceHandle() { - unhideAnyCharacters(); - LLFloaterPathfindingObjects::onClose( pIsAppQuitting ); + if ( sInstanceHandle.isDead() ) + { + LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::getTypedInstance("pathfinding_characters"); + if (floaterInstance != NULL) + { + sInstanceHandle = floaterInstance->mSelfHandle; + } + } + + return sInstanceHandle; } LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloaterPathfindingObjects(pSeed), + mShowPhysicsCapsuleCheckBox(NULL), mBeaconColor(), - mSelfHandle(), - mShowPhysicsCapsuleCheckBox(NULL) + mSelfHandle() { mSelfHandle.bind(this); } @@ -115,6 +134,12 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa return scrollListData; } +void LLFloaterPathfindingCharacters::updateControls() +{ + LLFloaterPathfindingObjects::updateControls(); + updateStateOnEditFields(); +} + S32 LLFloaterPathfindingCharacters::getNameColumnIndex() const { return 0; @@ -131,6 +156,24 @@ LLPathfindingObjectListPtr LLFloaterPathfindingCharacters::getEmptyObjectList() return objectListPtr; } +void LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked() +{ + LLVector3 pos; + LLUUID id = getUUIDFromSelection( pos ); + if ( id.notNull() ) + { + if ( isShowPhysicsCapsule() ) + { + //We want to hide the VO and display the the objects physics capsule + gPipeline.hideObject( id ); + } + else + { + gPipeline.restoreHiddenObject( id ); + } + } +} + LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfindingCharacter *pCharacterPtr) const { LLSD columns; @@ -169,107 +212,58 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi return element; } - -void LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked() +void LLFloaterPathfindingCharacters::updateStateOnEditFields() { - 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 ); - } - } -} + int numSelectedItems = getNumSelectedObjects();; + bool isEditEnabled = (numSelectedItems == 1); -BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) -{ - BOOL result = false; - if ( mShowPhysicsCapsuleCheckBox->get() ) - { - id = getUUIDFromSelection( pos ); - result = true; - } - else + mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); + if (!isEditEnabled) { - id.setNull(); + setShowPhysicsCapsule(FALSE); } - return result; } LLUUID LLFloaterPathfindingCharacters::getUUIDFromSelection( LLVector3& pos ) -{ - std::vector selectedItems = mObjectsScrollList->getAllSelected(); - if ( selectedItems.size() > 1 ) - { - return LLUUID::null; - } - if (selectedItems.size() == 1) +{ + LLUUID uuid = LLUUID::null; + + if (getNumSelectedObjects() == 1) { - std::vector::const_reference selectedItemRef = selectedItems.front(); - const LLScrollListItem *selectedItem = selectedItemRef; - llassert(mObjectList != NULL); - LLViewerObject *viewerObject = gObjectList.findObject( selectedItem->getUUID() ); + LLPathfindingObjectPtr selectedObjectPtr = getFirstSelectedObject(); + uuid = selectedObjectPtr->getUUID(); + LLViewerObject *viewerObject = gObjectList.findObject(uuid); if ( viewerObject != NULL ) { pos = viewerObject->getRenderPosition(); } - //llinfos<<"id : "<getUUID()<getUUID(); } - return LLUUID::null; + return uuid; } -LLHandle LLFloaterPathfindingCharacters::getInstanceHandle() +void LLFloaterPathfindingCharacters::unhideAnyCharacters() { - if ( sInstanceHandle.isDead() ) + LLPathfindingObjectListPtr objectListPtr = getSelectedObjects(); + for (LLPathfindingObjectList::const_iterator objectIter = objectListPtr->begin(); + objectIter != objectListPtr->end(); ++objectIter) { - LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::getTypedInstance("pathfinding_characters"); - if (floaterInstance != NULL) - { - sInstanceHandle = floaterInstance->mSelfHandle; - } + LLPathfindingObjectPtr objectPtr = objectIter->second; + gPipeline.restoreHiddenObject(objectPtr->getUUID()); } - - return sInstanceHandle; -} - -void LLFloaterPathfindingCharacters::updateStateOnEditFields() -{ - int numSelectedItems = mObjectsScrollList->getNumSelected(); - bool isEditEnabled = (numSelectedItems > 0); - - mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); - - LLFloaterPathfindingObjects::updateStateOnEditFields(); } - -void LLFloaterPathfindingCharacters::unhideAnyCharacters( ) +BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) { - std::vector selectedItems = mObjectsScrollList->getAllSelected(); - int numSelectedItems = selectedItems.size(); - uuid_vec_t selectedUUIDs; - if (numSelectedItems > 0) + BOOL result = false; + if ( isShowPhysicsCapsule() ) + { + id = getUUIDFromSelection( pos ); + result = true; + } + else { - for (std::vector::const_iterator itemIter = selectedItems.begin(); - itemIter != selectedItems.end(); ++itemIter) - { - const LLScrollListItem *listItem = *itemIter; - gPipeline.restoreHiddenObject( listItem->getUUID() ); - } + id.setNull(); } + return result; } -- cgit v1.2.3 From b64700913f3eecd245503b5a0162c9cc5a2df35e Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 4 Jun 2012 17:29:48 -0700 Subject: PATH-676: Correcting selection behavior so that the first selected object does remain invisible after changing the selection. --- indra/newview/llfloaterpathfindingcharacters.cpp | 90 ++++++++++++++---------- 1 file changed, 54 insertions(+), 36 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 8b6f6aea1f..5064812e47 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -50,7 +50,8 @@ LLHandle LLFloaterPathfindingCharacters::sInstan void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) { - unhideAnyCharacters(); + // Hide any capsule that might be showing on floater close + hideCapsule(); LLFloaterPathfindingObjects::onClose( pIsAppQuitting ); } @@ -64,6 +65,14 @@ void LLFloaterPathfindingCharacters::setShowPhysicsCapsule(BOOL pIsShowPhysicsCa mShowPhysicsCapsuleCheckBox->set(pIsShowPhysicsCapsule); } +BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled(LLUUID& id, LLVector3& pos) const +{ + id = mSelectedCharacterId; + // Physics capsule is enable if the checkbox is enabled and if we can get a position + // for any selected object + return (isShowPhysicsCapsule() && getCapsulePosition(pos)); +} + void LLFloaterPathfindingCharacters::openCharactersViewer() { LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); @@ -86,6 +95,7 @@ LLHandle LLFloaterPathfindingCharacters::getInst LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloaterPathfindingObjects(pSeed), mShowPhysicsCapsuleCheckBox(NULL), + mSelectedCharacterId(), mBeaconColor(), mSelfHandle() { @@ -137,6 +147,7 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa void LLFloaterPathfindingCharacters::updateControls() { LLFloaterPathfindingObjects::updateControls(); + updateOnScrollListChange(); updateStateOnEditFields(); } @@ -158,19 +169,13 @@ LLPathfindingObjectListPtr LLFloaterPathfindingCharacters::getEmptyObjectList() void LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked() { - LLVector3 pos; - LLUUID id = getUUIDFromSelection( pos ); - if ( id.notNull() ) + if (mSelectedCharacterId.notNull() && isShowPhysicsCapsule()) { - if ( isShowPhysicsCapsule() ) - { - //We want to hide the VO and display the the objects physics capsule - gPipeline.hideObject( id ); - } - else - { - gPipeline.restoreHiddenObject( id ); - } + showCapsule(); + } + else + { + hideCapsule(); } } @@ -224,46 +229,59 @@ void LLFloaterPathfindingCharacters::updateStateOnEditFields() } } -LLUUID LLFloaterPathfindingCharacters::getUUIDFromSelection( LLVector3& pos ) +void LLFloaterPathfindingCharacters::updateOnScrollListChange() { - LLUUID uuid = LLUUID::null; + // Hide any previous capsule + hideCapsule(); + // Get the only selected object, or set the selected object to null if we do not have exactly + // one object selected if (getNumSelectedObjects() == 1) { LLPathfindingObjectPtr selectedObjectPtr = getFirstSelectedObject(); - uuid = selectedObjectPtr->getUUID(); - LLViewerObject *viewerObject = gObjectList.findObject(uuid); - if ( viewerObject != NULL ) - { - pos = viewerObject->getRenderPosition(); - } + mSelectedCharacterId = selectedObjectPtr->getUUID(); + } + else + { + mSelectedCharacterId.setNull(); } - return uuid; + // Show any capsule if enabled + showCapsule(); } -void LLFloaterPathfindingCharacters::unhideAnyCharacters() +void LLFloaterPathfindingCharacters::showCapsule() const { - LLPathfindingObjectListPtr objectListPtr = getSelectedObjects(); - for (LLPathfindingObjectList::const_iterator objectIter = objectListPtr->begin(); - objectIter != objectListPtr->end(); ++objectIter) + if (mSelectedCharacterId.notNull() && isShowPhysicsCapsule()) { - LLPathfindingObjectPtr objectPtr = objectIter->second; - gPipeline.restoreHiddenObject(objectPtr->getUUID()); + gPipeline.hideObject(mSelectedCharacterId); } } -BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled( LLUUID& id, LLVector3& pos ) +void LLFloaterPathfindingCharacters::hideCapsule() const { - BOOL result = false; - if ( isShowPhysicsCapsule() ) - { - id = getUUIDFromSelection( pos ); - result = true; + if (mSelectedCharacterId.notNull()) + { + gPipeline.restoreHiddenObject(mSelectedCharacterId); } - else +} + +bool LLFloaterPathfindingCharacters::getCapsulePosition(LLVector3 &pPosition) const +{ + bool result = false; + + // If we have a selected object, find the object on the viewer object list and return its + // position. Else, return false indicating that we either do not have a selected object + // or we cannot find the selected object on the viewer object list + if (mSelectedCharacterId.notNull()) { - id.setNull(); + LLViewerObject *viewerObject = gObjectList.findObject(mSelectedCharacterId); + if ( viewerObject != NULL ) + { + pPosition = viewerObject->getRenderPosition(); + result = true; + } } + return result; } -- cgit v1.2.3 From 9d615c1e1d0e52b619972d6003d97681c791711f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 4 Jun 2012 18:08:46 -0700 Subject: BUGFIX: Ensuring that the viewer will still work on regions that have older pathfinding server code with the character shape data. --- indra/newview/llfloaterpathfindingcharacters.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 5064812e47..b97123b1bc 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -57,12 +57,20 @@ void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) BOOL LLFloaterPathfindingCharacters::isShowPhysicsCapsule() const { +#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE + return mHasCharacterShapeData && mShowPhysicsCapsuleCheckBox->get(); +#else // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE return mShowPhysicsCapsuleCheckBox->get(); +#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE } void LLFloaterPathfindingCharacters::setShowPhysicsCapsule(BOOL pIsShowPhysicsCapsule) { +#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE + mShowPhysicsCapsuleCheckBox->set(mHasCharacterShapeData && pIsShowPhysicsCapsule); +#else // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE mShowPhysicsCapsuleCheckBox->set(pIsShowPhysicsCapsule); +#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE } BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled(LLUUID& id, LLVector3& pos) const @@ -95,6 +103,9 @@ LLHandle LLFloaterPathfindingCharacters::getInst LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloaterPathfindingObjects(pSeed), mShowPhysicsCapsuleCheckBox(NULL), +#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE + mHasCharacterShapeData(false), +#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE mSelectedCharacterId(), mBeaconColor(), mSelfHandle() @@ -135,6 +146,10 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa LLSD element = buildCharacterScrollListData(characterPtr); scrollListData.append(element); +#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE + mHasCharacterShapeData = characterPtr->hasShapeData(); +#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE + if (characterPtr->hasOwner() && !characterPtr->hasOwnerName()) { rebuildScrollListAfterAvatarNameLoads(characterPtr->getUUID()); @@ -220,7 +235,11 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi void LLFloaterPathfindingCharacters::updateStateOnEditFields() { int numSelectedItems = getNumSelectedObjects();; +#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE + bool isEditEnabled = mHasCharacterShapeData && (numSelectedItems == 1); +#else // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE bool isEditEnabled = (numSelectedItems == 1); +#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); if (!isEditEnabled) -- cgit v1.2.3 From 546c2583af7e34784a9e970c70fcfe47ba691e4d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 5 Jun 2012 15:35:12 -0700 Subject: Altering the method name. --- indra/newview/llfloaterpathfindingcharacters.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index b97123b1bc..d159cc04f2 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -32,15 +32,16 @@ #include "llcheckboxctrl.h" #include "llfloaterreg.h" #include "llfloaterpathfindingobjects.h" +#include "llhandle.h" #include "llpathfindingcharacter.h" #include "llpathfindingcharacterlist.h" #include "llpathfindingmanager.h" #include "llpathfindingobjectlist.h" #include "llsd.h" #include "lluicolortable.h" - -#include "pipeline.h" +#include "llviewerobject.h" #include "llviewerobjectlist.h" +#include "pipeline.h" LLHandle LLFloaterPathfindingCharacters::sInstanceHandle; @@ -163,7 +164,7 @@ void LLFloaterPathfindingCharacters::updateControls() { LLFloaterPathfindingObjects::updateControls(); updateOnScrollListChange(); - updateStateOnEditFields(); + updateStateOnActionFields(); } S32 LLFloaterPathfindingCharacters::getNameColumnIndex() const @@ -232,7 +233,7 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi return element; } -void LLFloaterPathfindingCharacters::updateStateOnEditFields() +void LLFloaterPathfindingCharacters::updateStateOnActionFields() { int numSelectedItems = getNumSelectedObjects();; #ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE -- cgit v1.2.3 From a48ee0e86ade940014cb5f58b8ab6f4517789455 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 5 Jun 2012 18:32:19 -0700 Subject: BUGFIX: Correcting an assert behavior where the LLSD returned from calls to convertObjectsIntoScrollListData() should be required to be an array type. --- indra/newview/llfloaterpathfindingcharacters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index d159cc04f2..098881544f 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -139,7 +139,7 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa llassert(pObjectListPtr != NULL); llassert(!pObjectListPtr->isEmpty()); - LLSD scrollListData; + LLSD scrollListData = LLSD::emptyArray(); for (LLPathfindingObjectList::const_iterator objectIter = pObjectListPtr->begin(); objectIter != pObjectListPtr->end(); ++objectIter) { -- cgit v1.2.3 From 18509683267385212c6f8652a8da0ab5bf88eb8a Mon Sep 17 00:00:00 2001 From: prep Date: Thu, 7 Jun 2012 11:00:58 -0400 Subject: Physics capsules now inherit the rotations of their parent vo when rendered. API update. --- indra/newview/llfloaterpathfindingcharacters.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 098881544f..b4a1394b06 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -74,12 +74,12 @@ void LLFloaterPathfindingCharacters::setShowPhysicsCapsule(BOOL pIsShowPhysicsCa #endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE } -BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled(LLUUID& id, LLVector3& pos) const +BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled(LLUUID& id, LLVector3& pos, LLQuaternion& rot) const { id = mSelectedCharacterId; - // Physics capsule is enable if the checkbox is enabled and if we can get a position - // for any selected object - return (isShowPhysicsCapsule() && getCapsulePosition(pos)); + // Physics capsule is enable if the checkbox is enabled and if we can get the required render + // parameters for any selected object + return (isShowPhysicsCapsule() && getCapsuleRenderData(pos, rot )); } void LLFloaterPathfindingCharacters::openCharactersViewer() @@ -286,7 +286,7 @@ void LLFloaterPathfindingCharacters::hideCapsule() const } } -bool LLFloaterPathfindingCharacters::getCapsulePosition(LLVector3 &pPosition) const +bool LLFloaterPathfindingCharacters::getCapsuleRenderData(LLVector3& pPosition, LLQuaternion& rot) const { bool result = false; @@ -298,8 +298,9 @@ bool LLFloaterPathfindingCharacters::getCapsulePosition(LLVector3 &pPosition) co LLViewerObject *viewerObject = gObjectList.findObject(mSelectedCharacterId); if ( viewerObject != NULL ) { - pPosition = viewerObject->getRenderPosition(); - result = true; + rot = viewerObject->getRotation() ; + pPosition = viewerObject->getRenderPosition(); + result = true; } } -- 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/llfloaterpathfindingcharacters.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index b4a1394b06..60e66174f3 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -160,11 +160,11 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa return scrollListData; } -void LLFloaterPathfindingCharacters::updateControls() +void LLFloaterPathfindingCharacters::updateControlsOnScrollListChange() { - LLFloaterPathfindingObjects::updateControls(); - updateOnScrollListChange(); - updateStateOnActionFields(); + LLFloaterPathfindingObjects::updateControlsOnScrollListChange(); + updateStateOnDisplayControls(); + showSelectedCharacterCapsules(); } S32 LLFloaterPathfindingCharacters::getNameColumnIndex() const @@ -233,7 +233,7 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi return element; } -void LLFloaterPathfindingCharacters::updateStateOnActionFields() +void LLFloaterPathfindingCharacters::updateStateOnDisplayControls() { int numSelectedItems = getNumSelectedObjects();; #ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE @@ -249,7 +249,7 @@ void LLFloaterPathfindingCharacters::updateStateOnActionFields() } } -void LLFloaterPathfindingCharacters::updateOnScrollListChange() +void LLFloaterPathfindingCharacters::showSelectedCharacterCapsules() { // Hide any previous capsule hideCapsule(); -- cgit v1.2.3 From f5949aaba91d3feb2a56ad40f8d1d34bf07ad388 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 20 Jun 2012 12:34:16 -0700 Subject: PATH-738: Removing SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE ifdef. --- indra/newview/llfloaterpathfindingcharacters.cpp | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 60e66174f3..09fd17855c 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -58,20 +58,12 @@ void LLFloaterPathfindingCharacters::onClose(bool pIsAppQuitting) BOOL LLFloaterPathfindingCharacters::isShowPhysicsCapsule() const { -#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE - return mHasCharacterShapeData && mShowPhysicsCapsuleCheckBox->get(); -#else // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE return mShowPhysicsCapsuleCheckBox->get(); -#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE } void LLFloaterPathfindingCharacters::setShowPhysicsCapsule(BOOL pIsShowPhysicsCapsule) { -#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE - mShowPhysicsCapsuleCheckBox->set(mHasCharacterShapeData && pIsShowPhysicsCapsule); -#else // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE mShowPhysicsCapsuleCheckBox->set(pIsShowPhysicsCapsule); -#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE } BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled(LLUUID& id, LLVector3& pos, LLQuaternion& rot) const @@ -104,9 +96,6 @@ LLHandle LLFloaterPathfindingCharacters::getInst LLFloaterPathfindingCharacters::LLFloaterPathfindingCharacters(const LLSD& pSeed) : LLFloaterPathfindingObjects(pSeed), mShowPhysicsCapsuleCheckBox(NULL), -#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE - mHasCharacterShapeData(false), -#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE mSelectedCharacterId(), mBeaconColor(), mSelfHandle() @@ -147,10 +136,6 @@ LLSD LLFloaterPathfindingCharacters::convertObjectsIntoScrollListData(const LLPa LLSD element = buildCharacterScrollListData(characterPtr); scrollListData.append(element); -#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE - mHasCharacterShapeData = characterPtr->hasShapeData(); -#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE - if (characterPtr->hasOwner() && !characterPtr->hasOwnerName()) { rebuildScrollListAfterAvatarNameLoads(characterPtr->getUUID()); @@ -236,11 +221,7 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi void LLFloaterPathfindingCharacters::updateStateOnDisplayControls() { int numSelectedItems = getNumSelectedObjects();; -#ifndef SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE - bool isEditEnabled = mHasCharacterShapeData && (numSelectedItems == 1); -#else // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE bool isEditEnabled = (numSelectedItems == 1); -#endif // SERVER_SIDE_CHARACTER_SHAPE_ROLLOUT_COMPLETE mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); if (!isEditEnabled) -- 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/llfloaterpathfindingcharacters.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 09fd17855c..caf9fe382b 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -74,9 +74,10 @@ BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled(LLUUID& id, LLVecto return (isShowPhysicsCapsule() && getCapsuleRenderData(pos, rot )); } -void LLFloaterPathfindingCharacters::openCharactersViewer() +void LLFloaterPathfindingCharacters::openCharactersWithSelectedObjects() { - LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_characters"); + LLFloaterPathfindingCharacters *charactersFloater = LLFloaterReg::getTypedInstance("pathfinding_characters"); + charactersFloater->showFloaterWithSelectionObjects(); } LLHandle LLFloaterPathfindingCharacters::getInstanceHandle() -- cgit v1.2.3 From b6d42e0b6223a290f700d9ce9a8aea5f48764610 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 25 Jun 2012 16:41:12 -0700 Subject: PATH-783: Ensuring that the pathfinding console and pathfinding characters floaters cannot be created through getInstanceHandle(). --- indra/newview/llfloaterpathfindingcharacters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index caf9fe382b..7a4c5c81cb 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -84,7 +84,7 @@ LLHandle LLFloaterPathfindingCharacters::getInst { if ( sInstanceHandle.isDead() ) { - LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::getTypedInstance("pathfinding_characters"); + LLFloaterPathfindingCharacters *floaterInstance = LLFloaterReg::findTypedInstance("pathfinding_characters"); if (floaterInstance != NULL) { sInstanceHandle = floaterInstance->mSelfHandle; -- cgit v1.2.3 From ce101172954c9cbc9a089d8796643d545bdee9d5 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 25 Jun 2012 18:02:41 -0700 Subject: PATH-718: Ensuring that the characters panel will work correctly with a stubbed physicsextension library. --- indra/newview/llfloaterpathfindingcharacters.cpp | 40 +++++++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 7a4c5c81cb..5245b78871 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -36,7 +36,9 @@ #include "llpathfindingcharacter.h" #include "llpathfindingcharacterlist.h" #include "llpathfindingmanager.h" +#include "llpathfindingobject.h" #include "llpathfindingobjectlist.h" +#include "llpathinglib.h" #include "llsd.h" #include "lluicolortable.h" #include "llviewerobject.h" @@ -63,7 +65,7 @@ BOOL LLFloaterPathfindingCharacters::isShowPhysicsCapsule() const void LLFloaterPathfindingCharacters::setShowPhysicsCapsule(BOOL pIsShowPhysicsCapsule) { - mShowPhysicsCapsuleCheckBox->set(pIsShowPhysicsCapsule); + mShowPhysicsCapsuleCheckBox->set(pIsShowPhysicsCapsule && (LLPathingLib::getInstance() != NULL)); } BOOL LLFloaterPathfindingCharacters::isPhysicsCapsuleEnabled(LLUUID& id, LLVector3& pos, LLQuaternion& rot) const @@ -115,6 +117,7 @@ BOOL LLFloaterPathfindingCharacters::postBuild() mShowPhysicsCapsuleCheckBox = findChild("show_physics_capsule"); llassert(mShowPhysicsCapsuleCheckBox != NULL); mShowPhysicsCapsuleCheckBox->setCommitCallback(boost::bind(&LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked, this)); + mShowPhysicsCapsuleCheckBox->setEnabled(LLPathingLib::getInstance() != NULL); return LLFloaterPathfindingObjects::postBuild(); } @@ -171,13 +174,23 @@ LLPathfindingObjectListPtr LLFloaterPathfindingCharacters::getEmptyObjectList() void LLFloaterPathfindingCharacters::onShowPhysicsCapsuleClicked() { - if (mSelectedCharacterId.notNull() && isShowPhysicsCapsule()) + if (LLPathingLib::getInstance() == NULL) { - showCapsule(); + if (isShowPhysicsCapsule()) + { + setShowPhysicsCapsule(FALSE); + } } else { - hideCapsule(); + if (mSelectedCharacterId.notNull() && isShowPhysicsCapsule()) + { + showCapsule(); + } + else + { + hideCapsule(); + } } } @@ -222,7 +235,7 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi void LLFloaterPathfindingCharacters::updateStateOnDisplayControls() { int numSelectedItems = getNumSelectedObjects();; - bool isEditEnabled = (numSelectedItems == 1); + bool isEditEnabled = ((numSelectedItems == 1) && (LLPathingLib::getInstance() != NULL)); mShowPhysicsCapsuleCheckBox->setEnabled(isEditEnabled); if (!isEditEnabled) @@ -256,6 +269,19 @@ void LLFloaterPathfindingCharacters::showCapsule() const { if (mSelectedCharacterId.notNull() && isShowPhysicsCapsule()) { + LLPathfindingObjectPtr objectPtr = getFirstSelectedObject(); + llassert(objectPtr != NULL); + if (objectPtr != NULL) + { + const LLPathfindingCharacter *character = dynamic_cast(objectPtr.get()); + llassert(mSelectedCharacterId == character->getUUID()); + if (LLPathingLib::getInstance() != NULL) + { + LLPathingLib::getInstance()->createPhysicsCapsuleRep(character->getLength(), character->getRadius(), + character->isHorizontal(), character->getUUID()); + } + } + gPipeline.hideObject(mSelectedCharacterId); } } @@ -266,6 +292,10 @@ void LLFloaterPathfindingCharacters::hideCapsule() const { gPipeline.restoreHiddenObject(mSelectedCharacterId); } + if (LLPathingLib::getInstance() != NULL) + { + LLPathingLib::getInstance()->cleanupPhysicsCapsuleRepResiduals(); + } } bool LLFloaterPathfindingCharacters::getCapsuleRenderData(LLVector3& pPosition, LLQuaternion& rot) const -- 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/llfloaterpathfindingcharacters.cpp | 51 ++++++++++++------------ 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 5245b78871..c20e78ade1 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -1,29 +1,30 @@ /** - * @file llfloaterpathfindingcharacters.cpp - * @author William Todd Stinson - * @brief "Pathfinding characters" floater, allowing for identification of pathfinding characters and their cpu usage. - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ +* @file llfloaterpathfindingcharacters.cpp +* @brief "Pathfinding characters" floater, allowing for identification of pathfinding characters and their cpu usage. +* @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" -- 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/llfloaterpathfindingcharacters.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index c20e78ade1..739e56a7c3 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -40,11 +40,15 @@ #include "llpathfindingobject.h" #include "llpathfindingobjectlist.h" #include "llpathinglib.h" +#include "llquaternion.h" #include "llsd.h" #include "lluicolortable.h" +#include "lluuid.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "pipeline.h" +#include "v3math.h" +#include "v4color.h" LLHandle LLFloaterPathfindingCharacters::sInstanceHandle; -- 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/llfloaterpathfindingcharacters.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index 739e56a7c3..ef6388642a 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -205,17 +205,14 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi columns[0]["column"] = "name"; columns[0]["value"] = pCharacterPtr->getName(); - columns[0]["font"] = "SANSSERIF"; columns[1]["column"] = "description"; columns[1]["value"] = pCharacterPtr->getDescription(); - columns[1]["font"] = "SANSSERIF"; columns[2]["column"] = "owner"; columns[2]["value"] = (pCharacterPtr->hasOwner() ? (pCharacterPtr->hasOwnerName() ? pCharacterPtr->getOwnerName() : getString("character_owner_loading")) : getString("character_owner_unknown")); - columns[2]["font"] = "SANSSERIF"; S32 cpuTime = llround(pCharacterPtr->getCPUTime()); std::string cpuTimeString = llformat("%d", cpuTime); @@ -224,11 +221,9 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi columns[3]["column"] = "cpu_time"; columns[3]["value"] = getString("character_cpu_time", string_args); - columns[3]["font"] = "SANSSERIF"; columns[4]["column"] = "altitude"; columns[4]["value"] = llformat("%1.0f m", pCharacterPtr->getLocation()[2]); - columns[4]["font"] = "SANSSERIF"; LLSD element; element["id"] = pCharacterPtr->getUUID().asString(); -- cgit v1.2.3 From b8cca9c6e66fa761fa104645effb1b672a8a99ae Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 24 Jul 2012 17:50:24 -0700 Subject: Adding a group identifier to the group objects in the pathfinding linksets and characters floaters. --- indra/newview/llfloaterpathfindingcharacters.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'indra/newview/llfloaterpathfindingcharacters.cpp') diff --git a/indra/newview/llfloaterpathfindingcharacters.cpp b/indra/newview/llfloaterpathfindingcharacters.cpp index ef6388642a..99d262344c 100644 --- a/indra/newview/llfloaterpathfindingcharacters.cpp +++ b/indra/newview/llfloaterpathfindingcharacters.cpp @@ -30,6 +30,8 @@ #include "llfloaterpathfindingcharacters.h" +#include + #include "llcheckboxctrl.h" #include "llfloaterreg.h" #include "llfloaterpathfindingobjects.h" @@ -210,9 +212,13 @@ LLSD LLFloaterPathfindingCharacters::buildCharacterScrollListData(const LLPathfi columns[1]["value"] = pCharacterPtr->getDescription(); columns[2]["column"] = "owner"; - columns[2]["value"] = (pCharacterPtr->hasOwner() ? - (pCharacterPtr->hasOwnerName() ? pCharacterPtr->getOwnerName() : getString("character_owner_loading")) : - getString("character_owner_unknown")); + columns[2]["value"] = (pCharacterPtr->hasOwner() + ? (pCharacterPtr->hasOwnerName() + ? (pCharacterPtr->isGroupOwned() + ? (pCharacterPtr->getOwnerName() + " " + getString("character_owner_group")) + : pCharacterPtr->getOwnerName()) + : getString("character_owner_loading")) + : getString("character_owner_unknown")); S32 cpuTime = llround(pCharacterPtr->getCPUTime()); std::string cpuTimeString = llformat("%d", cpuTime); -- cgit v1.2.3