summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterpathfindinglinksets.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterpathfindinglinksets.cpp')
-rw-r--r--indra/newview/llfloaterpathfindinglinksets.cpp306
1 files changed, 12 insertions, 294 deletions
diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp
index 433e3c9866..e2846d36f3 100644
--- a/indra/newview/llfloaterpathfindinglinksets.cpp
+++ b/indra/newview/llfloaterpathfindinglinksets.cpp
@@ -45,7 +45,8 @@
#include "llviewerregion.h"
#include "llhttpclient.h"
#include "lluuid.h"
-#include "llpathfindinglinksets.h"
+#include "llpathfindinglinkset.h"
+#include "llfilteredpathfindinglinksets.h"
#define XUI_PATH_STATE_WALKABLE 1
#define XUI_PATH_STATE_OBSTACLE 2
@@ -92,289 +93,6 @@ private:
};
//---------------------------------------------------------------------------
-// FilterString
-//---------------------------------------------------------------------------
-
-FilterString::FilterString()
- : mFilter(),
- mUpperFilter()
-{
-}
-
-FilterString::FilterString(const std::string& pFilter)
- : mFilter(pFilter),
- mUpperFilter()
-{
- LLStringUtil::trim(mFilter);
- mUpperFilter = mFilter;
- if (!mUpperFilter.empty())
- {
- LLStringUtil::toUpper(mUpperFilter);
- }
-}
-
-FilterString::FilterString(const FilterString& pOther)
- : mFilter(pOther.mFilter),
- mUpperFilter(pOther.mUpperFilter)
-{
-}
-
-FilterString::~FilterString()
-{
-}
-
-const std::string& FilterString::get() const
-{
- return mFilter;
-}
-
-bool FilterString::set(const std::string& pFilter)
-{
- std::string newFilter(pFilter);
- LLStringUtil::trim(newFilter);
- bool didFilterChange = (mFilter.compare(newFilter) != 0);
- if (didFilterChange)
- {
- mFilter = newFilter;
- mUpperFilter = newFilter;
- LLStringUtil::toUpper(mUpperFilter);
- }
-
- return didFilterChange;
-}
-
-void FilterString::clear()
-{
- mFilter.clear();
- mUpperFilter.clear();
-}
-
-bool FilterString::isActive() const
-{
- return !mFilter.empty();
-}
-
-bool FilterString::doesMatch(const std::string& pTestString) const
-{
- bool doesMatch = true;
-
- if (isActive())
- {
- std::string upperTestString(pTestString);
- LLStringUtil::toUpper(upperTestString);
- doesMatch = (upperTestString.find(mUpperFilter) != std::string::npos);
- }
-
- return doesMatch;
-}
-
-//---------------------------------------------------------------------------
-// PathfindingLinksets
-//---------------------------------------------------------------------------
-
-PathfindingLinksets::PathfindingLinksets()
- : mAllLinksets(),
- mFilteredLinksets(),
- mIsFiltersDirty(false),
- mNameFilter(),
- mDescriptionFilter(),
- mIsWalkableFilter(true),
- mIsObstacleFilter(true),
- mIsIgnoredFilter(true)
-{
-}
-
-PathfindingLinksets::PathfindingLinksets(const LLSD& pNavMeshData)
- : mAllLinksets(),
- mFilteredLinksets(),
- mIsFiltersDirty(false),
- mNameFilter(),
- mDescriptionFilter(),
- mIsWalkableFilter(true),
- mIsObstacleFilter(true),
- mIsIgnoredFilter(true)
-{
- setNavMeshData(pNavMeshData);
-}
-
-PathfindingLinksets::PathfindingLinksets(const PathfindingLinksets& pOther)
- : mAllLinksets(pOther.mAllLinksets),
- mFilteredLinksets(pOther.mFilteredLinksets),
- mIsFiltersDirty(pOther.mIsFiltersDirty),
- mNameFilter(pOther.mNameFilter),
- mDescriptionFilter(pOther.mDescriptionFilter),
- mIsWalkableFilter(pOther.mIsWalkableFilter),
- mIsObstacleFilter(pOther.mIsObstacleFilter),
- mIsIgnoredFilter(pOther.mIsIgnoredFilter)
-{
-}
-
-PathfindingLinksets::~PathfindingLinksets()
-{
- clearLinksets();
-}
-
-void PathfindingLinksets::setNavMeshData(const LLSD& pNavMeshData)
-{
- clearLinksets();
-
- for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap();
- navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter)
- {
- const std::string& uuid(navMeshDataIter->first);
- const LLSD& linksetData = navMeshDataIter->second;
- LLPathfindingLinkset linkset(uuid, linksetData);
-
- mAllLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
- }
-
- mIsFiltersDirty = true;
-}
-
-void PathfindingLinksets::updateNavMeshData(const LLSD& pNavMeshData)
-{
- for (LLSD::map_const_iterator navMeshDataIter = pNavMeshData.beginMap();
- navMeshDataIter != pNavMeshData.endMap(); ++navMeshDataIter)
- {
- const std::string& uuid(navMeshDataIter->first);
- const LLSD& linksetData = navMeshDataIter->second;
- LLPathfindingLinkset linkset(uuid, linksetData);
-
- PathfindingLinksetMap::iterator linksetIter = mAllLinksets.find(uuid);
- if (linksetIter == mAllLinksets.end())
- {
- mAllLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
- }
- else
- {
- linksetIter->second = linkset;
- }
- }
-
- mIsFiltersDirty = true;
-}
-
-void PathfindingLinksets::clearLinksets()
-{
- mAllLinksets.clear();
- mFilteredLinksets.clear();
- mIsFiltersDirty = false;
-}
-
-const PathfindingLinksets::PathfindingLinksetMap& PathfindingLinksets::getAllLinksets() const
-{
- return mAllLinksets;
-}
-
-const PathfindingLinksets::PathfindingLinksetMap& PathfindingLinksets::getFilteredLinksets()
-{
- if (!isFiltersActive())
- {
- return mAllLinksets;
- }
- else
- {
- applyFilters();
- return mFilteredLinksets;
- }
-}
-
-BOOL PathfindingLinksets::isFiltersActive() const
-{
- return (mNameFilter.isActive() || mDescriptionFilter.isActive() || !mIsWalkableFilter || !mIsObstacleFilter || !mIsIgnoredFilter);
-}
-
-void PathfindingLinksets::setNameFilter(const std::string& pNameFilter)
-{
- mIsFiltersDirty = (mNameFilter.set(pNameFilter) || mIsFiltersDirty);
-}
-
-const std::string& PathfindingLinksets::getNameFilter() const
-{
- return mNameFilter.get();
-}
-
-void PathfindingLinksets::setDescriptionFilter(const std::string& pDescriptionFilter)
-{
- mIsFiltersDirty = (mDescriptionFilter.set(pDescriptionFilter) || mIsFiltersDirty);
-}
-
-const std::string& PathfindingLinksets::getDescriptionFilter() const
-{
- return mDescriptionFilter.get();
-}
-
-void PathfindingLinksets::setWalkableFilter(BOOL pWalkableFilter)
-{
- mIsFiltersDirty = (mIsFiltersDirty || (mIsWalkableFilter == pWalkableFilter));
- mIsWalkableFilter = pWalkableFilter;
-}
-
-BOOL PathfindingLinksets::isWalkableFilter() const
-{
- return mIsWalkableFilter;
-}
-
-void PathfindingLinksets::setObstacleFilter(BOOL pObstacleFilter)
-{
- mIsFiltersDirty = (mIsFiltersDirty || (mIsObstacleFilter == pObstacleFilter));
- mIsObstacleFilter = pObstacleFilter;
-}
-
-BOOL PathfindingLinksets::isObstacleFilter() const
-{
- return mIsObstacleFilter;
-}
-
-void PathfindingLinksets::setIgnoredFilter(BOOL pIgnoredFilter)
-{
- mIsFiltersDirty = (mIsFiltersDirty || (mIsIgnoredFilter == pIgnoredFilter));
- mIsIgnoredFilter = pIgnoredFilter;
-}
-
-BOOL PathfindingLinksets::isIgnoredFilter() const
-{
- return mIsIgnoredFilter;
-}
-
-void PathfindingLinksets::clearFilters()
-{
- mNameFilter.clear();
- mDescriptionFilter.clear();
- mIsWalkableFilter = true;
- mIsObstacleFilter = true;
- mIsIgnoredFilter = true;
- mIsFiltersDirty = false;
-}
-
-void PathfindingLinksets::applyFilters()
-{
- mFilteredLinksets.clear();
-
- for (PathfindingLinksetMap::const_iterator linksetIter = mAllLinksets.begin();
- linksetIter != mAllLinksets.end(); ++linksetIter)
- {
- const std::string& uuid(linksetIter->first);
- const LLPathfindingLinkset& linkset(linksetIter->second);
- if (doesMatchFilters(linkset))
- {
- mFilteredLinksets.insert(std::pair<std::string, LLPathfindingLinkset>(uuid, linkset));
- }
- }
-
- mIsFiltersDirty = false;
-}
-
-BOOL PathfindingLinksets::doesMatchFilters(const LLPathfindingLinkset& pLinkset) const
-{
- return (((mIsWalkableFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kWalkable)) ||
- (mIsObstacleFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kObstacle)) ||
- (mIsIgnoredFilter && (pLinkset.getPathState() == LLPathfindingLinkset::kIgnored))) &&
- (!mNameFilter.isActive() || mNameFilter.doesMatch(pLinkset.getName())) &&
- (!mDescriptionFilter.isActive() || mDescriptionFilter.doesMatch(pLinkset.getDescription())));
-}
-
-//---------------------------------------------------------------------------
// LLFloaterPathfindingLinksets
//---------------------------------------------------------------------------
@@ -557,7 +275,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataGetRequest()
else
{
setMessagingState(kMessagingFetchStarting);
- mPathfindingLinksets.clearLinksets();
+ mPathfindingLinksets.clearPathfindingLinksets();
updateLinksetsList();
std::string navMeshDataURL = getCapabilityURL();
@@ -593,7 +311,7 @@ void LLFloaterPathfindingLinksets::sendNavMeshDataPutRequest(const LLSD& pPostDa
void LLFloaterPathfindingLinksets::handleNavMeshDataGetReply(const LLSD& pNavMeshData)
{
setMessagingState(kMessagingFetchReceived);
- mPathfindingLinksets.setNavMeshData(pNavMeshData);
+ mPathfindingLinksets.setPathfindingLinksets(pNavMeshData);
updateLinksetsList();
setMessagingState(kMessagingComplete);
}
@@ -601,7 +319,7 @@ void LLFloaterPathfindingLinksets::handleNavMeshDataGetReply(const LLSD& pNavMes
void LLFloaterPathfindingLinksets::handleNavMeshDataGetError(const std::string& pURL, const std::string& pErrorReason)
{
setMessagingState(kMessagingFetchError);
- mPathfindingLinksets.clearLinksets();
+ mPathfindingLinksets.clearPathfindingLinksets();
updateLinksetsList();
llwarns << "Error fetching object navmesh properties from URL '" << pURL << "' because " << pErrorReason << llendl;
}
@@ -609,7 +327,7 @@ void LLFloaterPathfindingLinksets::handleNavMeshDataGetError(const std::string&
void LLFloaterPathfindingLinksets::handleNavMeshDataPutReply(const LLSD& pModifiedData)
{
setMessagingState(kMessagingModifyReceived);
- mPathfindingLinksets.updateNavMeshData(pModifiedData);
+ mPathfindingLinksets.updatePathfindingLinksets(pModifiedData);
updateLinksetsList();
setMessagingState(kMessagingComplete);
}
@@ -729,9 +447,9 @@ void LLFloaterPathfindingLinksets::updateLinksetsList()
updateLinksetsStatusMessage();
const LLVector3& avatarPosition = gAgent.getPositionAgent();
- const PathfindingLinksets::PathfindingLinksetMap& linksetMap = mPathfindingLinksets.getFilteredLinksets();
+ const LLFilteredPathfindingLinksets::PathfindingLinksetMap& linksetMap = mPathfindingLinksets.getFilteredLinksets();
- for (PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetMap.begin();
+ for (LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetMap.begin();
linksetIter != linksetMap.end(); ++linksetIter)
{
const LLPathfindingLinkset& linkset(linksetIter->second);
@@ -905,8 +623,8 @@ void LLFloaterPathfindingLinksets::updateEditFields()
{
LLScrollListItem *firstItem = selectedItems.front();
- const PathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
- PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(firstItem->getUUID().asString());
+ const LLFilteredPathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
+ LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(firstItem->getUUID().asString());
const LLPathfindingLinkset &linkset(linksetIter->second);
setPathState(linkset.getPathState());
@@ -936,7 +654,7 @@ void LLFloaterPathfindingLinksets::applyEditFields()
S32 dValue = static_cast<S32>(atoi(dString.c_str()));
BOOL isPhantom = mEditPhantom->getValue();
- const PathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
+ const LLFilteredPathfindingLinksets::PathfindingLinksetMap &linksetsMap = mPathfindingLinksets.getAllLinksets();
LLSD editData;
for (std::vector<LLScrollListItem*>::const_iterator itemIter = selectedItems.begin();
@@ -945,7 +663,7 @@ void LLFloaterPathfindingLinksets::applyEditFields()
const LLScrollListItem *listItem = *itemIter;
LLUUID uuid = listItem->getUUID();
- const PathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString());
+ const LLFilteredPathfindingLinksets::PathfindingLinksetMap::const_iterator linksetIter = linksetsMap.find(uuid.asString());
const LLPathfindingLinkset &linkset = linksetIter->second;
LLSD itemData = linkset.getAlteredFields(pathState, aValue, bValue, cValue, dValue, isPhantom);