From 10614ebd917f4dbb8a16e8a0473409c42f8d7608 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 4 Jan 2012 15:52:20 -0800 Subject: Hijaking the land status messaging for temporary development of the pathfinding linksets floater. --- indra/newview/llstartup.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 36d6ff3ef2..2e4b8cd2c5 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -186,6 +186,12 @@ #include "llappearancemgr.h" #include "llavatariconctrl.h" #include "llvoicechannel.h" +// Uncomment the following define to enable hijaking of the LandStatReply message to test the pathfinding linkset floater. +// For development purposes only until the pathfinding linksets service is built on the server-side. +//#define XXX_STINSON_PATHFINDING_HIJAK_XXX +#ifdef XXX_STINSON_PATHFINDING_HIJAK_XXX +#include "llfloaterpathfindinglinksets.h" +#endif // XXX_STINSON_PATHFINDING_HIJAK_XXX #include "lllogin.h" #include "llevents.h" @@ -2480,7 +2486,11 @@ void register_viewer_callbacks(LLMessageSystem* msg) msg->setHandlerFunc("ParcelObjectOwnersReply", LLPanelLandObjects::processParcelObjectOwnersReply); msg->setHandlerFunc("InitiateDownload", process_initiate_download); +#ifdef XXX_STINSON_PATHFINDING_HIJAK_XXX + msg->setHandlerFunc("LandStatReply", LLFloaterPathfindingLinksets::handleLandStatReply); // XXX stinson +#else // XXX_STINSON_PATHFINDING_HIJAK_XXX msg->setHandlerFunc("LandStatReply", LLFloaterTopObjects::handle_land_reply); +#endif // XXX_STINSON_PATHFINDING_HIJAK_XXX msg->setHandlerFunc("GenericMessage", process_generic_message); msg->setHandlerFuncFast(_PREHASH_FeatureDisabled, process_feature_disabled_message); -- cgit v1.3 From 1eea77add246604315711e9e2635078dc038d42f Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 9 Jan 2012 17:05:06 -0800 Subject: PATH-142: Initial pass at hooking up the NavmeshData GET service to the UI. --- indra/newview/llfloaterpathfindinglinksets.cpp | 372 ++++++++++++--------- indra/newview/llfloaterpathfindinglinksets.h | 19 +- indra/newview/llstartup.cpp | 10 - indra/newview/llviewerregion.cpp | 1 + .../xui/en/floater_pathfinding_linksets.xml | 16 +- 5 files changed, 240 insertions(+), 178 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index efcb5a1c80..c16fd8fee6 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -27,16 +27,35 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterpathfindinglinksets.h" -#include "message.h" -#include "lluuid.h" #include "llsd.h" #include "llagent.h" -#include "lluictrl.h" #include "llfloater.h" #include "llfloaterreg.h" #include "llscrolllistctrl.h" -#include "llavatarnamecache.h" #include "llresmgr.h" +#include "llviewerregion.h" +#include "llhttpclient.h" +#include "lltextbase.h" + +//--------------------------------------------------------------------------- +// NavmeshDataGetResponder +//--------------------------------------------------------------------------- + +class NavmeshDataGetResponder : public LLHTTPClient::Responder +{ +public: + NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater); + virtual ~NavmeshDataGetResponder(); + + virtual void result(const LLSD& pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +private: + NavmeshDataGetResponder(const NavmeshDataGetResponder& pOther); + + std::string mNavmeshDataGetURL; + LLFloaterPathfindingLinksets *mLinksetsFloater; +}; //--------------------------------------------------------------------------- // LLFloaterPathfindingLinksets @@ -53,7 +72,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild() mLinksetsScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onLinksetsSelectionChange, this)); mLinksetsScrollList->setCommitOnSelectionChange(true); - mLinksetsStatus = findChild("linksets_status"); + mLinksetsStatus = findChild("linksets_status"); llassert(mLinksetsStatus != NULL); updateLinksetsStatus(); @@ -63,16 +82,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild() void LLFloaterPathfindingLinksets::onOpen(const LLSD& pKey) { - sendLandStatRequest(); -} - -void LLFloaterPathfindingLinksets::handleLandStatReply(LLMessageSystem* pMsg, void** pData) -{ - LLFloaterPathfindingLinksets *instance = LLFloaterReg::findTypedInstance("pathfinding_linksets"); - if (instance != NULL) - { - instance->handleLandStatReply(pMsg); - } + sendNavmeshDataGetRequest(); } void LLFloaterPathfindingLinksets::openLinksetsEditor() @@ -83,127 +93,141 @@ void LLFloaterPathfindingLinksets::openLinksetsEditor() LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed) : LLFloater(pSeed), mLinksetsScrollList(NULL), - mLinksetsStatus(NULL) + mLinksetsStatus(NULL), + mNavmeshDataGetResponder(NULL) { } LLFloaterPathfindingLinksets::~LLFloaterPathfindingLinksets() { + clearNavmeshDataResponder(); } -void LLFloaterPathfindingLinksets::sendLandStatRequest() +void LLFloaterPathfindingLinksets::sendNavmeshDataGetRequest() { - clearLinksetsList(); - updateLinksetsStatusForFetch(); - - U32 mode = 0; - U32 flags = 0; - std::string filter = ""; - - LLMessageSystem *msg = gMessageSystem; - msg->newMessageFast(_PREHASH_LandStatRequest); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_RequestData); - msg->addU32Fast(_PREHASH_ReportType, mode); - msg->addU32Fast(_PREHASH_RequestFlags, flags); - msg->addStringFast(_PREHASH_Filter, filter); - msg->addS32Fast(_PREHASH_ParcelLocalID, 0); - - msg->sendReliable(gAgent.getRegionHost()); + if (mNavmeshDataGetResponder != NULL) + { + updateLinksetsStatusForFetchInProgress(); + } + else + { + clearLinksetsList(); + + LLViewerRegion* region = gAgent.getRegion(); + if (region != NULL) + { + std::string navmeshDataURL = region->getCapability("ObjectNavmesh"); + if (navmeshDataURL.empty()) + { + llinfos << "cannot query navmesh data from current region '" << region->getName() << "'" << llendl; + } + else + { + updateLinksetsStatusForFetch(); + mNavmeshDataGetResponder = new NavmeshDataGetResponder(navmeshDataURL, this); + LLHTTPClient::get(navmeshDataURL, mNavmeshDataGetResponder); + } + } + } } -void LLFloaterPathfindingLinksets::handleLandStatReply(LLMessageSystem *pMsg) +void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmeshData) { - U32 request_flags; - U32 total_count; - U32 current_mode; - - pMsg->getU32Fast(_PREHASH_RequestData, _PREHASH_RequestFlags, request_flags); - pMsg->getU32Fast(_PREHASH_RequestData, _PREHASH_TotalObjectCount, total_count); - pMsg->getU32Fast(_PREHASH_RequestData, _PREHASH_ReportType, current_mode); - + clearNavmeshDataResponder(); clearLinksetsList(); const LLVector3& avatarPosition = gAgent.getPositionAgent(); - S32 block_count = pMsg->getNumberOfBlocks("ReportData"); - for (S32 block = 0; block < block_count; ++block) + for (LLSD::map_const_iterator itemsIter = pNavmeshData.beginMap(); + itemsIter != pNavmeshData.endMap(); ++itemsIter) { - U32 task_local_id; - U32 time_stamp = 0; - LLUUID task_id; - F32 location_x, location_y, location_z; - F32 score; - std::string name_buf; - std::string owner_buf; - F32 mono_score = 0.f; - bool have_extended_data = false; - S32 public_urls = 0; - - pMsg->getU32Fast(_PREHASH_ReportData, _PREHASH_TaskLocalID, task_local_id, block); - pMsg->getUUIDFast(_PREHASH_ReportData, _PREHASH_TaskID, task_id, block); - pMsg->getF32Fast(_PREHASH_ReportData, _PREHASH_LocationX, location_x, block); - pMsg->getF32Fast(_PREHASH_ReportData, _PREHASH_LocationY, location_y, block); - pMsg->getF32Fast(_PREHASH_ReportData, _PREHASH_LocationZ, location_z, block); - pMsg->getF32Fast(_PREHASH_ReportData, _PREHASH_Score, score, block); - pMsg->getStringFast(_PREHASH_ReportData, _PREHASH_TaskName, name_buf, block); - pMsg->getStringFast(_PREHASH_ReportData, _PREHASH_OwnerName, owner_buf, block); - if(pMsg->has("DataExtended")) - { - have_extended_data = true; - pMsg->getU32("DataExtended", "TimeStamp", time_stamp, block); - pMsg->getF32("DataExtended", "MonoScore", mono_score, block); - pMsg->getS32("DataExtended", "PublicURLs", public_urls, block); - } - - LLSD element; - - element["id"] = task_id; + const std::string& uuid = itemsIter->first; + const LLSD& itemData = itemsIter->second; + + const LLSD::String& itemName = itemData.get("name").asString(); + const LLSD::String& itemDescription = itemData.get("description").asString(); + LLSD::Integer itemLandImpact = itemData.get("landimpact").asInteger(); + LLSD::Boolean isItemFixed = itemData.get("fixed").asBoolean(); + LLSD::Boolean isItemWalkable = true; // XXX stinson: walkable data not coming from service yet + LLSD::Boolean isItemPhantom = itemData.get("phantom").asBoolean(); + LLSD::Real itemA = itemData.get("A").asReal(); + LLSD::Real itemB = itemData.get("B").asReal(); + LLSD::Real itemC = itemData.get("C").asReal(); + LLSD::Real itemD = itemData.get("D").asReal(); + + F32 location_x = 50.0f, location_y = 50.0f, location_z = 50.0f; // XXX stinson: use real location later + LLVector3 itemLocation(location_x, location_y, location_z); + F32 itemDistance = dist_vec(avatarPosition, itemLocation); LLSD columns; columns[0]["column"] = "name"; - columns[0]["value"] = name_buf; + columns[0]["value"] = itemName; columns[0]["font"] = "SANSSERIF"; - // Owner names can have trailing spaces sent from server - LLStringUtil::trim(owner_buf); - - if (LLAvatarNameCache::useDisplayNames()) - { - // ...convert hard-coded name from server to a username - // *TODO: Send owner_id from server and look up display name - owner_buf = LLCacheName::buildUsername(owner_buf); - } - else - { - // ...just strip out legacy "Resident" name - owner_buf = LLCacheName::cleanFullName(owner_buf); - } columns[1]["column"] = "description"; - columns[1]["value"] = owner_buf; + columns[1]["value"] = itemDescription; columns[1]["font"] = "SANSSERIF"; columns[2]["column"] = "land_impact"; - columns[2]["value"] = llformat("%0.1f", 55.679); + columns[2]["value"] = llformat("%1d m", itemLandImpact); columns[2]["font"] = "SANSSERIF"; - LLVector3 location(location_x, location_y, location_z); - F32 distance = dist_vec(avatarPosition, location); - columns[3]["column"] = "dist_from_you"; - columns[3]["value"] = llformat("%1.0f m", distance); + columns[3]["value"] = llformat("%1.0f m", itemDistance); columns[3]["font"] = "SANSSERIF"; - element["columns"] = columns; + columns[4]["column"] = "is_fixed"; + columns[4]["value"] = getString(isItemFixed ? "linkset_is_fixed" : "linkset_is_not_fixed"); + columns[4]["font"] = "SANSSERIF"; + + columns[5]["column"] = "is_walkable"; + columns[5]["value"] = getString(isItemWalkable ? "linkset_is_walkable" : "linkset_is_not_walkable"); + columns[5]["font"] = "SANSSERIF"; + + columns[6]["column"] = "is_phantom"; + columns[6]["value"] = getString(isItemPhantom ? "linkset_is_phantom" : "linkset_is_not_phantom"); + columns[6]["font"] = "SANSSERIF"; + + columns[7]["column"] = "a_percent"; + columns[7]["value"] = llformat("%2.0f", itemA); + columns[7]["font"] = "SANSSERIF"; + + columns[8]["column"] = "b_percent"; + columns[8]["value"] = llformat("%2.0f", itemB); + columns[8]["font"] = "SANSSERIF"; + + columns[9]["column"] = "c_percent"; + columns[9]["value"] = llformat("%2.0f", itemC); + columns[9]["font"] = "SANSSERIF"; + + columns[10]["column"] = "d_percent"; + columns[10]["value"] = llformat("%2.0f", itemD); + columns[10]["font"] = "SANSSERIF"; + + LLSD element; + element["id"] = uuid; + element["column"] = columns; + mLinksetsScrollList->addElement(element); } - updateLinksetsStatus(); + updateLinksetsStatus(); } +void LLFloaterPathfindingLinksets::handleNavmeshDataGetError(const std::string& pURL, const std::string& pErrorReason) +{ + clearNavmeshDataResponder(); + clearLinksetsList(); + updateLinksetsStatusForFetchError(); + llwarns << "Error fetching navmesh data from URL '" << pURL << "' because " << pErrorReason << llendl; +} + +void LLFloaterPathfindingLinksets::clearNavmeshDataResponder() +{ + mNavmeshDataGetResponder = NULL; +} + void LLFloaterPathfindingLinksets::onLinksetsSelectionChange() { updateLinksetsStatus(); @@ -211,65 +235,99 @@ void LLFloaterPathfindingLinksets::onLinksetsSelectionChange() void LLFloaterPathfindingLinksets::onRefreshLinksetsClicked() { - sendLandStatRequest(); + sendNavmeshDataGetRequest(); } -void LLFloaterPathfindingLinksets::onSelectAllLinksetsClicked() -{ - selectAllLinksets(); -} - -void LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked() -{ - selectNoneLinksets(); -} - -void LLFloaterPathfindingLinksets::clearLinksetsList() -{ +void LLFloaterPathfindingLinksets::onSelectAllLinksetsClicked() +{ + selectAllLinksets(); +} + +void LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked() +{ + selectNoneLinksets(); +} + +void LLFloaterPathfindingLinksets::clearLinksetsList() +{ mLinksetsScrollList->deleteAllItems(); - updateLinksetsStatus(); + updateLinksetsStatus(); } -void LLFloaterPathfindingLinksets::selectAllLinksets() -{ - mLinksetsScrollList->selectAll(); -} - -void LLFloaterPathfindingLinksets::selectNoneLinksets() -{ - mLinksetsScrollList->deselectAllItems(); -} - -void LLFloaterPathfindingLinksets::updateLinksetsStatus() -{ - std::string statusText(""); - - if (mLinksetsScrollList->isEmpty()) - { - statusText = getString("linksets_none_found"); - } - else - { - S32 numItems = mLinksetsScrollList->getItemCount(); - S32 numSelectedItems = mLinksetsScrollList->getNumSelected(); - - LLLocale locale(LLStringUtil::getLocale()); - std::string numItemsString; - LLResMgr::getInstance()->getIntegerString(numItemsString, numItems); - - std::string numSelectedItemsString; - LLResMgr::getInstance()->getIntegerString(numSelectedItemsString, numSelectedItems); - - LLStringUtil::format_map_t string_args; - string_args["[NUM_SELECTED]"] = numSelectedItemsString; - string_args["[NUM_TOTAL]"] = numItemsString; - statusText = getString("linksets_available", string_args); - } - - mLinksetsStatus->setValue(statusText); -} - -void LLFloaterPathfindingLinksets::updateLinksetsStatusForFetch() -{ - mLinksetsStatus->setValue(getString("linksets_fetching")); -} +void LLFloaterPathfindingLinksets::selectAllLinksets() +{ + mLinksetsScrollList->selectAll(); +} + +void LLFloaterPathfindingLinksets::selectNoneLinksets() +{ + mLinksetsScrollList->deselectAllItems(); +} + +void LLFloaterPathfindingLinksets::updateLinksetsStatus() +{ + std::string statusText(""); + + if (mLinksetsScrollList->isEmpty()) + { + statusText = getString("linksets_none_found"); + } + else + { + S32 numItems = mLinksetsScrollList->getItemCount(); + S32 numSelectedItems = mLinksetsScrollList->getNumSelected(); + + LLLocale locale(LLStringUtil::getLocale()); + std::string numItemsString; + LLResMgr::getInstance()->getIntegerString(numItemsString, numItems); + + std::string numSelectedItemsString; + LLResMgr::getInstance()->getIntegerString(numSelectedItemsString, numSelectedItems); + + LLStringUtil::format_map_t string_args; + string_args["[NUM_SELECTED]"] = numSelectedItemsString; + string_args["[NUM_TOTAL]"] = numItemsString; + statusText = getString("linksets_available", string_args); + } + + mLinksetsStatus->setText((LLStringExplicit)statusText); +} + +void LLFloaterPathfindingLinksets::updateLinksetsStatusForFetch() +{ + mLinksetsStatus->setText((LLStringExplicit)getString("linksets_fetching")); +} + +void LLFloaterPathfindingLinksets::updateLinksetsStatusForFetchInProgress() +{ + mLinksetsStatus->setText((LLStringExplicit)getString("linksets_fetching_inprogress")); +} + +void LLFloaterPathfindingLinksets::updateLinksetsStatusForFetchError() +{ + LLColor4 warningColor = LLUIColorTable::instance().getColor("DrYellow"); + LLStyle::Params styleParams; + styleParams.color = warningColor; + mLinksetsStatus->setText((LLStringExplicit)getString("linksets_fetching_error"), styleParams); +} + +NavmeshDataGetResponder::NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater) + : mNavmeshDataGetURL(pNavmeshDataGetURL), + mLinksetsFloater(pLinksetsFloater) +{ +} + +NavmeshDataGetResponder::~NavmeshDataGetResponder() +{ + mLinksetsFloater = NULL; +} + +void NavmeshDataGetResponder::result(const LLSD& pContent) +{ + mLinksetsFloater->handleNavmeshDataGetReply(pContent); +} + +void NavmeshDataGetResponder::error(U32 status, const std::string& reason) +{ + mLinksetsFloater->handleNavmeshDataGetError(mNavmeshDataGetURL, reason); +} diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h index 4bde806e4d..395994d37e 100644 --- a/indra/newview/llfloaterpathfindinglinksets.h +++ b/indra/newview/llfloaterpathfindinglinksets.h @@ -31,35 +31,38 @@ #include "llfloater.h" class LLSD; -class LLUICtrl; -class LLMessageSystem; +class LLTextBase; class LLScrollListCtrl; +class NavmeshDataGetResponder; class LLFloaterPathfindingLinksets : public LLFloater { friend class LLFloaterReg; + friend class NavmeshDataGetResponder; public: virtual BOOL postBuild(); virtual void onOpen(const LLSD& pKey); static void openLinksetsEditor(); - static void handleLandStatReply(LLMessageSystem *pMsg, void **pData); protected: private: - LLScrollListCtrl *mLinksetsScrollList; - LLUICtrl *mLinksetsStatus; + LLScrollListCtrl *mLinksetsScrollList; + LLTextBase *mLinksetsStatus; + NavmeshDataGetResponder *mNavmeshDataGetResponder; // Does its own instance management, so clients not allowed // to allocate or destroy. LLFloaterPathfindingLinksets(const LLSD& pSeed); virtual ~LLFloaterPathfindingLinksets(); - void sendLandStatRequest(); - void handleLandStatReply(LLMessageSystem *pMsg); + void sendNavmeshDataGetRequest(); + void handleNavmeshDataGetReply(const LLSD& pNavmeshData); + void handleNavmeshDataGetError(const std::string& pURL, const std::string& pErrorReason); + void clearNavmeshDataResponder(); void onLinksetsSelectionChange(); void onRefreshLinksetsClicked(); @@ -72,6 +75,8 @@ private: void updateLinksetsStatus(); void updateLinksetsStatusForFetch(); + void updateLinksetsStatusForFetchInProgress(); + void updateLinksetsStatusForFetchError(); }; #endif // LL_LLFLOATERPATHFINDINGLINKSETS_H diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index ef599a7144..7e02a41e7e 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -186,12 +186,6 @@ #include "llappearancemgr.h" #include "llavatariconctrl.h" #include "llvoicechannel.h" -// Uncomment the following define to enable hijaking of the LandStatReply message to test the pathfinding linkset floater. -// For development purposes only until the pathfinding linksets service is built on the server-side. -//#define XXX_STINSON_PATHFINDING_HIJAK_XXX -#ifdef XXX_STINSON_PATHFINDING_HIJAK_XXX -#include "llfloaterpathfindinglinksets.h" -#endif // XXX_STINSON_PATHFINDING_HIJAK_XXX #include "lllogin.h" #include "llevents.h" @@ -2486,11 +2480,7 @@ void register_viewer_callbacks(LLMessageSystem* msg) msg->setHandlerFunc("ParcelObjectOwnersReply", LLPanelLandObjects::processParcelObjectOwnersReply); msg->setHandlerFunc("InitiateDownload", process_initiate_download); -#ifdef XXX_STINSON_PATHFINDING_HIJAK_XXX - msg->setHandlerFunc("LandStatReply", LLFloaterPathfindingLinksets::handleLandStatReply); // XXX stinson -#else // XXX_STINSON_PATHFINDING_HIJAK_XXX msg->setHandlerFunc("LandStatReply", LLFloaterTopObjects::handle_land_reply); -#endif // XXX_STINSON_PATHFINDING_HIJAK_XXX msg->setHandlerFunc("GenericMessage", process_generic_message); msg->setHandlerFuncFast(_PREHASH_FeatureDisabled, process_feature_disabled_message); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index d294a4bb47..18d23af971 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1522,6 +1522,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("MeshUploadFlag"); capabilityNames.append("NavMeshUpload"); capabilityNames.append("NewFileAgentInventory"); + capabilityNames.append("ObjectNavmesh"); capabilityNames.append("ParcelPropertiesUpdate"); capabilityNames.append("ParcelMediaURLFilterList"); capabilityNames.append("ParcelNavigateMedia"); diff --git a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml index 587b62377b..06f5d92742 100644 --- a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml +++ b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml @@ -11,9 +11,17 @@ single_instance="true" title="Pathfinding linksets" width="950"> - Finking pathfinding linksets ... + Querying for pathfinding linksets ... + Querying for pathfinding linksets (already in progress) ... + Error detected while querying for pathfinding linksets No pathfinding linksets [NUM_SELECTED] linksets selected out of [NUM_TOTAL] + Fixed + Not fixed + Walkable + -- + Phantom + -- Date: Fri, 20 Jan 2012 18:06:32 +0100 Subject: STORM-276 Basic spellchecking framework --- indra/cmake/Copy3rdPartyLibs.cmake | 3 + indra/cmake/ViewerMiscLibs.cmake | 1 + indra/llui/CMakeLists.txt | 3 + indra/llui/llmenugl.cpp | 6 +- indra/llui/llmenugl.h | 6 +- indra/llui/llspellcheck.cpp | 345 ++++++++++++++++++++++++++++++++ indra/llui/llspellcheck.h | 77 +++++++ indra/llui/llspellcheckmenuhandler.h | 46 +++++ indra/newview/app_settings/settings.xml | 22 ++ indra/newview/llappviewer.cpp | 14 ++ indra/newview/llstartup.cpp | 1 + indra/newview/llviewercontrol.cpp | 24 +++ indra/newview/llviewermenu.cpp | 86 ++++++++ indra/newview/llviewermenu.h | 1 + indra/newview/viewer_manifest.py | 8 + 15 files changed, 641 insertions(+), 2 deletions(-) create mode 100644 indra/llui/llspellcheck.cpp create mode 100644 indra/llui/llspellcheck.h create mode 100644 indra/llui/llspellcheckmenuhandler.h (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake index 394db362b1..ebeae3e5be 100644 --- a/indra/cmake/Copy3rdPartyLibs.cmake +++ b/indra/cmake/Copy3rdPartyLibs.cmake @@ -41,6 +41,7 @@ if(WINDOWS) libeay32.dll libcollada14dom22-d.dll glod.dll + libhunspell.dll ) set(release_src_dir "${ARCH_PREBUILT_DIRS_RELEASE}") @@ -53,6 +54,7 @@ if(WINDOWS) libeay32.dll libcollada14dom22.dll glod.dll + libhunspell.dll ) if(USE_GOOGLE_PERFTOOLS) @@ -215,6 +217,7 @@ elseif(DARWIN) libllqtwebkit.dylib libminizip.a libndofdev.dylib + libhunspell-1.3.dylib libexception_handler.dylib libcollada14dom.dylib ) diff --git a/indra/cmake/ViewerMiscLibs.cmake b/indra/cmake/ViewerMiscLibs.cmake index df013b1665..f907181929 100644 --- a/indra/cmake/ViewerMiscLibs.cmake +++ b/indra/cmake/ViewerMiscLibs.cmake @@ -2,6 +2,7 @@ include(Prebuilt) if (NOT STANDALONE) + use_prebuilt_binary(libhunspell) use_prebuilt_binary(libuuid) use_prebuilt_binary(slvoice) use_prebuilt_binary(fontconfig) diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 772f173f17..1377336bb4 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -87,6 +87,7 @@ set(llui_SOURCE_FILES llsearcheditor.cpp llslider.cpp llsliderctrl.cpp + llspellcheck.cpp llspinctrl.cpp llstatbar.cpp llstatgraph.cpp @@ -192,6 +193,8 @@ set(llui_HEADER_FILES llsdparam.h llsliderctrl.h llslider.h + llspellcheck.h + llspellcheckmenuhandler.h llspinctrl.h llstatbar.h llstatgraph.h diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 95ecbb1c94..2a65262bbb 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -3854,7 +3854,7 @@ void LLContextMenu::setVisible(BOOL visible) } // Takes cursor position in screen space? -void LLContextMenu::show(S32 x, S32 y) +void LLContextMenu::show(S32 x, S32 y, LLView* spawning_view) { if (getChildList()->empty()) { @@ -3908,6 +3908,10 @@ void LLContextMenu::show(S32 x, S32 y) setRect(rect); arrange(); + if (spawning_view) + mSpawningViewHandle = spawning_view->getHandle(); + else + mSpawningViewHandle.markDead(); LLView::setVisible(TRUE); } diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 36f3ba34b9..67b3e1fbe6 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -670,7 +670,7 @@ public: virtual void draw (); - virtual void show (S32 x, S32 y); + virtual void show (S32 x, S32 y, LLView* spawning_view = NULL); virtual void hide (); virtual BOOL handleHover ( S32 x, S32 y, MASK mask ); @@ -683,10 +683,14 @@ public: LLHandle getHandle() { return getDerivedHandle(); } + LLView* getSpawningView() const { return mSpawningViewHandle.get(); } + void setSpawningView(LLHandle spawning_view) { mSpawningViewHandle = spawning_view; } + protected: BOOL mHoveredAnyItem; LLMenuItemGL* mHoverItem; LLRootHandle mHandle; + LLHandle mSpawningViewHandle; }; diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp new file mode 100644 index 0000000000..433ca02852 --- /dev/null +++ b/indra/llui/llspellcheck.cpp @@ -0,0 +1,345 @@ +/** + * @file llspellcheck.cpp + * @brief Spell checking functionality + * + * $LicenseInfo:firstyear=2001&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 "linden_common.h" + +#include "lldir.h" +#include "llsdserialize.h" + +#include "llspellcheck.h" +#if LL_WINDOWS + #include + #pragma comment(lib, "libhunspell.lib") +#else + #include +#endif + +static const std::string DICT_DIR = "dictionaries"; +static const std::string DICT_CUSTOM_SUFFIX = "_custom"; +static const std::string DICT_IGNORE_SUFFIX = "_ignore"; + +LLSpellChecker::settings_change_signal_t LLSpellChecker::sSettingsChangeSignal; + +LLSpellChecker::LLSpellChecker() + : mHunspell(NULL) +{ + // Load initial dictionary information + refreshDictionaryMap(); +} + +LLSpellChecker::~LLSpellChecker() +{ + delete mHunspell; +} + +bool LLSpellChecker::checkSpelling(const std::string& word) const +{ + if ( (!mHunspell) || (word.length() < 3) || (0 != mHunspell->spell(word.c_str())) ) + { + return true; + } + if (mIgnoreList.size() > 0) + { + std::string word_lower(word); + LLStringUtil::toLower(word_lower); + return (mIgnoreList.end() != std::find(mIgnoreList.begin(), mIgnoreList.end(), word_lower)); + } + return false; +} + +S32 LLSpellChecker::getSuggestions(const std::string& word, std::vector& suggestions) const +{ + suggestions.clear(); + if ( (!mHunspell) || (word.length() < 3) ) + return 0; + + char** suggestion_list; int suggestion_cnt = 0; + if ( (suggestion_cnt = mHunspell->suggest(&suggestion_list, word.c_str())) != 0 ) + { + for (int suggestion_index = 0; suggestion_index < suggestion_cnt; suggestion_index++) + suggestions.push_back(suggestion_list[suggestion_index]); + mHunspell->free_list(&suggestion_list, suggestion_cnt); + } + return suggestions.size(); +} + +const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_name) const +{ + for (LLSD::array_const_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it) + { + const LLSD& dict_entry = *it; + if (dict_name == dict_entry["language"].asString()) + return dict_entry; + } + return LLSD(); +} + +void LLSpellChecker::refreshDictionaryMap() +{ + const std::string app_path = getDictionaryAppPath(); + const std::string user_path = getDictionaryUserPath(); + + // Load dictionary information (file name, friendly name, ...) + llifstream user_map(user_path + "dictionaries.xml", std::ios::binary); + if ( (!user_map.is_open()) || (0 == LLSDSerialize::fromXMLDocument(mDictMap, user_map)) || (0 == mDictMap.size()) ) + { + llifstream app_map(app_path + "dictionaries.xml", std::ios::binary); + if ( (!app_map.is_open()) || (0 == LLSDSerialize::fromXMLDocument(mDictMap, app_map)) || (0 == mDictMap.size()) ) + return; + } + + // Look for installed dictionaries + std::string tmp_app_path, tmp_user_path; + for (LLSD::array_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it) + { + LLSD& sdDict = *it; + tmp_app_path = (sdDict.has("name")) ? app_path + sdDict["name"].asString() : LLStringUtil::null; + tmp_user_path = (sdDict.has("name")) ? user_path + sdDict["name"].asString() : LLStringUtil::null; + sdDict["installed"] = + (!tmp_app_path.empty()) && + ( ((gDirUtilp->fileExists(tmp_user_path + ".aff")) && (gDirUtilp->fileExists(tmp_user_path + ".dic"))) || + ((gDirUtilp->fileExists(tmp_app_path + ".aff")) && (gDirUtilp->fileExists(tmp_app_path + ".dic"))) ); + sdDict["has_custom"] = (!tmp_user_path.empty()) && (gDirUtilp->fileExists(tmp_user_path + DICT_CUSTOM_SUFFIX + ".dic")); + sdDict["has_ignore"] = (!tmp_user_path.empty()) && (gDirUtilp->fileExists(tmp_user_path + DICT_IGNORE_SUFFIX + ".dic")); + } +} + +void LLSpellChecker::addToCustomDictionary(const std::string& word) +{ + if (mHunspell) + { + mHunspell->add(word.c_str()); + } + addToDictFile(getDictionaryUserPath() + mDictFile + DICT_CUSTOM_SUFFIX + ".dic", word); + sSettingsChangeSignal(); +} + +void LLSpellChecker::addToIgnoreList(const std::string& word) +{ + std::string word_lower(word); + LLStringUtil::toLower(word_lower); + if (mIgnoreList.end() != std::find(mIgnoreList.begin(), mIgnoreList.end(), word_lower)) + { + mIgnoreList.push_back(word_lower); + addToDictFile(getDictionaryUserPath() + mDictFile + DICT_IGNORE_SUFFIX + ".dic", word_lower); + sSettingsChangeSignal(); + } +} + +void LLSpellChecker::addToDictFile(const std::string& dict_path, const std::string& word) +{ + std::vector word_list; + + if (gDirUtilp->fileExists(dict_path)) + { + llifstream file_in(dict_path, std::ios::in); + if (file_in.is_open()) + { + std::string word; int line_num = 0; + while (getline(file_in, word)) + { + // Skip over the first line since that's just a line count + if (0 != line_num) + word_list.push_back(word); + line_num++; + } + } + else + { + // TODO: show error message? + return; + } + } + + word_list.push_back(word); + + llofstream file_out(dict_path, std::ios::out | std::ios::trunc); + if (file_out.is_open()) + { + file_out << word_list.size() << std::endl; + for (std::vector::const_iterator itWord = word_list.begin(); itWord != word_list.end(); ++itWord) + file_out << *itWord << std::endl; + file_out.close(); + } +} + +void LLSpellChecker::setSecondaryDictionaries(std::list dict_list) +{ + if (!getUseSpellCheck()) + { + return; + } + + // Check if we're only adding secondary dictionaries, or removing them + std::list dict_add(llmax(dict_list.size(), mDictSecondary.size())), dict_rem(llmax(dict_list.size(), mDictSecondary.size())); + dict_list.sort(); + mDictSecondary.sort(); + std::list::iterator end_added = std::set_difference(dict_list.begin(), dict_list.end(), mDictSecondary.begin(), mDictSecondary.end(), dict_add.begin()); + std::list::iterator end_removed = std::set_difference(mDictSecondary.begin(), mDictSecondary.end(), dict_list.begin(), dict_list.end(), dict_rem.begin()); + + if (end_removed != dict_rem.begin()) // We can't remove secondary dictionaries so we need to recreate the Hunspell instance + { + mDictSecondary = dict_list; + + std::string dict_name = mDictName; + initHunspell(dict_name); + } + else if (end_added != dict_add.begin()) // Add the new secondary dictionaries one by one + { + const std::string app_path = getDictionaryAppPath(); + const std::string user_path = getDictionaryUserPath(); + for (std::list::const_iterator it_added = dict_add.begin(); it_added != end_added; ++it_added) + { + const LLSD dict_entry = getDictionaryData(*it_added); + if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) ) + continue; + + const std::string strFileDic = dict_entry["name"].asString() + ".dic"; + if (gDirUtilp->fileExists(user_path + strFileDic)) + mHunspell->add_dic((user_path + strFileDic).c_str()); + else if (gDirUtilp->fileExists(app_path + strFileDic)) + mHunspell->add_dic((app_path + strFileDic).c_str()); + } + mDictSecondary = dict_list; + sSettingsChangeSignal(); + } +} + +void LLSpellChecker::initHunspell(const std::string& dict_name) +{ + if (mHunspell) + { + delete mHunspell; + mHunspell = NULL; + mDictName.clear(); + mDictFile.clear(); + mIgnoreList.clear(); + } + + const LLSD dict_entry = (!dict_name.empty()) ? getDictionaryData(dict_name) : LLSD(); + if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) ) + { + sSettingsChangeSignal(); + return; + } + + const std::string app_path = getDictionaryAppPath(); + const std::string user_path = getDictionaryUserPath(); + if (dict_entry.has("name")) + { + const std::string filename_aff = dict_entry["name"].asString() + ".aff"; + const std::string filename_dic = dict_entry["name"].asString() + ".dic"; + if ( (gDirUtilp->fileExists(user_path + filename_aff)) && (gDirUtilp->fileExists(user_path + filename_dic)) ) + mHunspell = new Hunspell((user_path + filename_aff).c_str(), (user_path + filename_dic).c_str()); + else if ( (gDirUtilp->fileExists(app_path + filename_aff)) && (gDirUtilp->fileExists(app_path + filename_dic)) ) + mHunspell = new Hunspell((app_path + filename_aff).c_str(), (app_path + filename_dic).c_str()); + if (!mHunspell) + return; + + mDictName = dict_name; + mDictFile = dict_entry["name"].asString(); + + if (dict_entry["has_custom"].asBoolean()) + { + const std::string filename_dic = user_path + mDictFile + DICT_CUSTOM_SUFFIX + ".dic"; + mHunspell->add_dic(filename_dic.c_str()); + } + + if (dict_entry["has_ignore"].asBoolean()) + { + llifstream file_in(user_path + mDictFile + DICT_IGNORE_SUFFIX + ".dic", std::ios::in); + if (file_in.is_open()) + { + std::string word; int idxLine = 0; + while (getline(file_in, word)) + { + // Skip over the first line since that's just a line count + if (0 != idxLine) + { + LLStringUtil::toLower(word); + mIgnoreList.push_back(word); + } + idxLine++; + } + } + } + + for (std::list::const_iterator it = mDictSecondary.begin(); it != mDictSecondary.end(); ++it) + { + const LLSD dict_entry = getDictionaryData(*it); + if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) ) + continue; + + const std::string filename_dic = dict_entry["name"].asString() + ".dic"; + if (gDirUtilp->fileExists(user_path + filename_dic)) + mHunspell->add_dic((user_path + filename_dic).c_str()); + else if (gDirUtilp->fileExists(app_path + filename_dic)) + mHunspell->add_dic((app_path + filename_dic).c_str()); + } + } + + sSettingsChangeSignal(); +} + +// static +const std::string LLSpellChecker::getDictionaryAppPath() +{ + std::string dict_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, DICT_DIR, ""); + return dict_path; +} + +// static +const std::string LLSpellChecker::getDictionaryUserPath() +{ + std::string dict_path = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, DICT_DIR, ""); + if (!gDirUtilp->fileExists(dict_path)) + { + LLFile::mkdir(dict_path); + } + return dict_path; +} + +// static +bool LLSpellChecker::getUseSpellCheck() +{ + return (LLSpellChecker::instanceExists()) && (LLSpellChecker::instance().mHunspell); +} + +// static +boost::signals2::connection LLSpellChecker::setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb) +{ + return sSettingsChangeSignal.connect(cb); +} + +// static +void LLSpellChecker::setUseSpellCheck(const std::string& dict_name) +{ + if ( (((dict_name.empty()) && (getUseSpellCheck())) || (!dict_name.empty())) && + (LLSpellChecker::instance().mDictName != dict_name) ) + { + LLSpellChecker::instance().initHunspell(dict_name); + } +} diff --git a/indra/llui/llspellcheck.h b/indra/llui/llspellcheck.h new file mode 100644 index 0000000000..affdac2907 --- /dev/null +++ b/indra/llui/llspellcheck.h @@ -0,0 +1,77 @@ +/** + * @file llspellcheck.h + * @brief Spell checking functionality + * + * $LicenseInfo:firstyear=2001&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$ + */ + +#ifndef LLSPELLCHECK_H +#define LLSPELLCHECK_H + +#include "llsingleton.h" +#include + +class Hunspell; + +class LLSpellChecker : public LLSingleton +{ + friend class LLSingleton; +protected: + LLSpellChecker(); + ~LLSpellChecker(); + +public: + void addToCustomDictionary(const std::string& word); + void addToIgnoreList(const std::string& word); + bool checkSpelling(const std::string& word) const; + S32 getSuggestions(const std::string& word, std::vector& suggestions) const; + +public: + const LLSD getDictionaryData(const std::string& dict_name) const; + const LLSD& getDictionaryMap() const { return mDictMap; } + void refreshDictionaryMap(); + void setSecondaryDictionaries(std::list dictList); +protected: + void addToDictFile(const std::string& dict_path, const std::string& word); + void initHunspell(const std::string& dict_name); + +public: + static const std::string getDictionaryAppPath(); + static const std::string getDictionaryUserPath(); + static bool getUseSpellCheck(); + static void setUseSpellCheck(const std::string& dict_name); + + typedef boost::signals2::signal settings_change_signal_t; + static boost::signals2::connection setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb); + +protected: + Hunspell* mHunspell; + std::string mDictName; + std::string mDictFile; + LLSD mDictMap; + std::list mDictSecondary; + std::vector mIgnoreList; + + static settings_change_signal_t sSettingsChangeSignal; +}; + +#endif // LLSPELLCHECK_H diff --git a/indra/llui/llspellcheckmenuhandler.h b/indra/llui/llspellcheckmenuhandler.h new file mode 100644 index 0000000000..d5c95bad39 --- /dev/null +++ b/indra/llui/llspellcheckmenuhandler.h @@ -0,0 +1,46 @@ +/** + * @file llspellcheckmenuhandler.h + * @brief Interface used by spell check menu handling + * + * $LicenseInfo:firstyear=2001&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$ + */ + +#ifndef LLSPELLCHECKMENUHANDLER_H +#define LLSPELLCHECKMENUHANDLER_H + +class LLSpellCheckMenuHandler +{ +public: + virtual bool getSpellCheck() const { return false; } + + virtual const std::string& getSuggestion(U32 index) const { return LLStringUtil::null; } + virtual U32 getSuggestionCount() const { return 0; } + virtual void replaceWithSuggestion(U32 index){} + + virtual void addToDictionary() {} + virtual bool canAddToDictionary() const { return false; } + + virtual void addToIgnore() {} + virtual bool canAddToIgnore() const { return false; } +}; + +#endif // LLSPELLCHECKMENUHANDLER_H diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 1ea623791d..1ad3ee1dd1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12082,6 +12082,28 @@ Value 10.0 + SpellCheck + + Comment + Enable spellchecking on line and text editors + Persist + 1 + Type + Boolean + Value + 1 + + SpellCheckDictionary + + Comment + Current primary and secondary dictionaries used for spell checking + Persist + 1 + Type + String + Value + English (United States) + UseNewWalkRun Comment diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 0861fe85a8..698f2469a3 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -91,6 +91,7 @@ #include "llsecondlifeurls.h" #include "llupdaterservice.h" #include "llcallfloater.h" +#include "llspellcheck.h" // Linden library includes #include "llavatarnamecache.h" @@ -112,6 +113,7 @@ // Third party library includes #include #include +#include @@ -2488,6 +2490,18 @@ bool LLAppViewer::initConfiguration() //gDirUtilp->setSkinFolder("default"); } + if (gSavedSettings.getBOOL("SpellCheck")) + { + std::list dict_list; + boost::split(dict_list, gSavedSettings.getString("SpellCheckDictionary"), boost::is_any_of(std::string(","))); + if (!dict_list.empty()) + { + LLSpellChecker::setUseSpellCheck(dict_list.front()); + dict_list.pop_front(); + LLSpellChecker::instance().setSecondaryDictionaries(dict_list); + } + } + mYieldTime = gSavedSettings.getS32("YieldTime"); // Read skin/branding settings if specified. diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7e02a41e7e..89360778d1 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -739,6 +739,7 @@ bool idle_startup() { display_startup(); initialize_edit_menu(); + initialize_spellcheck_menu(); display_startup(); init_menus(); display_startup(); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 093b84413a..7b6dbfaa0b 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -71,8 +71,12 @@ #include "llpaneloutfitsinventory.h" #include "llpanellogin.h" #include "llpaneltopinfobar.h" +#include "llspellcheck.h" #include "llupdaterservice.h" +// Third party library includes +#include + #ifdef TOGGLE_HACKED_GODLIKE_VIEWER BOOL gHackGodmode = FALSE; #endif @@ -498,6 +502,24 @@ bool handleForceShowGrid(const LLSD& newvalue) return true; } +bool handleSpellCheckChanged() +{ + if (gSavedSettings.getBOOL("SpellCheck")) + { + std::list dict_list; + boost::split(dict_list, gSavedSettings.getString("SpellCheckDictionary"), boost::is_any_of(std::string(","))); + if (!dict_list.empty()) + { + LLSpellChecker::setUseSpellCheck(dict_list.front()); + dict_list.pop_front(); + LLSpellChecker::instance().setSecondaryDictionaries(dict_list); + return true; + } + } + LLSpellChecker::setUseSpellCheck(LLStringUtil::null); + return true; +} + bool toggle_agent_pause(const LLSD& newvalue) { if ( newvalue.asBoolean() ) @@ -704,6 +726,8 @@ void settings_setup_listeners() gSavedSettings.getControl("UpdaterServiceSetting")->getSignal()->connect(boost::bind(&toggle_updater_service_active, _2)); gSavedSettings.getControl("ForceShowGrid")->getSignal()->connect(boost::bind(&handleForceShowGrid, _2)); gSavedSettings.getControl("RenderTransparentWater")->getSignal()->connect(boost::bind(&handleRenderTransparentWaterChanged, _2)); + gSavedSettings.getControl("SpellCheck")->getSignal()->connect(boost::bind(&handleSpellCheckChanged)); + gSavedSettings.getControl("SpellCheckDictionary")->getSignal()->connect(boost::bind(&handleSpellCheckChanged)); } #if TEST_CACHED_CONTROL diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 0104d35e53..2a11f3cc16 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -81,6 +81,7 @@ #include "llrootview.h" #include "llsceneview.h" #include "llselectmgr.h" +#include "llspellcheckmenuhandler.h" #include "llstatusbar.h" #include "lltextureview.h" #include "lltoolcomp.h" @@ -4984,6 +4985,78 @@ class LLEditDelete : public view_listener_t } }; +void handle_spellcheck_replace_with_suggestion(const LLUICtrl* ctrl, const LLSD& param) +{ + const LLContextMenu* menu = dynamic_cast(ctrl->getParent()); + LLSpellCheckMenuHandler* spellcheck_handler = (menu) ? dynamic_cast(menu->getSpawningView()) : NULL; + if ( (!spellcheck_handler) || (!spellcheck_handler->getSpellCheck()) ) + { + return; + } + + U32 index = 0; + if ( (!LLStringUtil::convertToU32(param.asString(), index)) || (index >= spellcheck_handler->getSuggestionCount()) ) + { + return; + } + + spellcheck_handler->replaceWithSuggestion(index); +} + +bool visible_spellcheck_suggestion(LLUICtrl* ctrl, const LLSD& param) +{ + LLMenuItemGL* item = dynamic_cast(ctrl); + const LLContextMenu* menu = (item) ? dynamic_cast(item->getParent()) : NULL; + const LLSpellCheckMenuHandler* spellcheck_handler = (menu) ? dynamic_cast(menu->getSpawningView()) : NULL; + if ( (!spellcheck_handler) || (!spellcheck_handler->getSpellCheck()) ) + { + return false; + } + + U32 index = 0; + if ( (!LLStringUtil::convertToU32(param.asString(), index)) || (index >= spellcheck_handler->getSuggestionCount()) ) + { + return false; + } + + item->setLabel(spellcheck_handler->getSuggestion(index)); + return true; +} + +void handle_spellcheck_add_to_dictionary(const LLUICtrl* ctrl) +{ + const LLContextMenu* menu = dynamic_cast(ctrl->getParent()); + LLSpellCheckMenuHandler* spellcheck_handler = (menu) ? dynamic_cast(menu->getSpawningView()) : NULL; + if ( (spellcheck_handler) && (spellcheck_handler->canAddToDictionary()) ) + { + spellcheck_handler->addToDictionary(); + } +} + +bool enable_spellcheck_add_to_dictionary(const LLUICtrl* ctrl) +{ + const LLContextMenu* menu = dynamic_cast(ctrl->getParent()); + const LLSpellCheckMenuHandler* spellcheck_handler = (menu) ? dynamic_cast(menu->getSpawningView()) : NULL; + return (spellcheck_handler) && (spellcheck_handler->canAddToDictionary()); +} + +void handle_spellcheck_add_to_ignore(const LLUICtrl* ctrl) +{ + const LLContextMenu* menu = dynamic_cast(ctrl->getParent()); + LLSpellCheckMenuHandler* spellcheck_handler = (menu) ? dynamic_cast(menu->getSpawningView()) : NULL; + if ( (spellcheck_handler) && (spellcheck_handler->canAddToIgnore()) ) + { + spellcheck_handler->addToIgnore(); + } +} + +bool enable_spellcheck_add_to_ignore(const LLUICtrl* ctrl) +{ + const LLContextMenu* menu = dynamic_cast(ctrl->getParent()); + const LLSpellCheckMenuHandler* spellcheck_handler = (menu) ? dynamic_cast(menu->getSpawningView()) : NULL; + return (spellcheck_handler) && (spellcheck_handler->canAddToIgnore()); +} + bool enable_object_delete() { bool new_value = @@ -7933,6 +8006,19 @@ void initialize_edit_menu() } +void initialize_spellcheck_menu() +{ + LLUICtrl::CommitCallbackRegistry::Registrar& commit = LLUICtrl::CommitCallbackRegistry::currentRegistrar(); + LLUICtrl::EnableCallbackRegistry::Registrar& enable = LLUICtrl::EnableCallbackRegistry::currentRegistrar(); + + commit.add("SpellCheck.ReplaceWithSuggestion", boost::bind(&handle_spellcheck_replace_with_suggestion, _1, _2)); + enable.add("SpellCheck.VisibleSuggestion", boost::bind(&visible_spellcheck_suggestion, _1, _2)); + commit.add("SpellCheck.AddToDictionary", boost::bind(&handle_spellcheck_add_to_dictionary, _1)); + enable.add("SpellCheck.EnableAddToDictionary", boost::bind(&enable_spellcheck_add_to_dictionary, _1)); + commit.add("SpellCheck.AddToIgnore", boost::bind(&handle_spellcheck_add_to_ignore, _1)); + enable.add("SpellCheck.EnableAddToIgnore", boost::bind(&enable_spellcheck_add_to_ignore, _1)); +} + void initialize_menus() { // A parameterized event handler used as ctrl-8/9/0 zoom controls below. diff --git a/indra/newview/llviewermenu.h b/indra/newview/llviewermenu.h index 87cb4efbc4..8c40762865 100644 --- a/indra/newview/llviewermenu.h +++ b/indra/newview/llviewermenu.h @@ -39,6 +39,7 @@ class LLObjectSelection; class LLSelectNode; void initialize_edit_menu(); +void initialize_spellcheck_menu(); void init_menus(); void cleanup_menus(); diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 0931c4ec9b..1b732676e4 100644 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -91,6 +91,8 @@ class ViewerManifest(LLManifest): # ... and the entire windlight directory self.path("windlight") + # ... and the pre-installed spell checking dictionaries + self.path("dictionaries") self.end_prefix("app_settings") if self.prefix(src="character"): @@ -393,6 +395,9 @@ class WindowsManifest(ViewerManifest): self.path("ssleay32.dll") self.path("libeay32.dll") + # Hunspell + self.path("libhunspell.dll") + # For google-perftools tcmalloc allocator. try: if self.args['configuration'].lower() == 'debug': @@ -659,6 +664,7 @@ class DarwinManifest(ViewerManifest): # copy additional libs in /Contents/MacOS/ self.path("../packages/lib/release/libndofdev.dylib", dst="Resources/libndofdev.dylib") + self.path("../packages/lib/release/libhunspell-1.3.dylib", dst="Resources/libhunspell-1.3.dylib") self.path("../viewer_components/updater/scripts/darwin/update_install", "MacOS/update_install") @@ -1053,6 +1059,8 @@ class Linux_i686Manifest(LinuxManifest): self.path("libopenjpeg.so.1.4.0") self.path("libopenjpeg.so.1") self.path("libopenjpeg.so") + self.path("libhunspell-1.3.so") + self.path("libhunspell-1.3.so.0") self.path("libalut.so") self.path("libopenal.so", "libopenal.so.1") self.path("libopenal.so", "libvivoxoal.so.1") # vivox's sdk expects this soname -- cgit v1.3 From e76d7d73c5867b6e662672c88244c38b49d34d0d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 23 May 2012 18:58:47 -0700 Subject: Removing cruft code that is no longer used. --- indra/newview/llagent.cpp | 5 -- indra/newview/llagent.h | 2 - indra/newview/llagentaccess.cpp | 13 +--- indra/newview/llagentaccess.h | 9 --- indra/newview/llfloaterland.cpp | 19 +----- indra/newview/llstartup.cpp | 11 ---- .../skins/default/xui/en/floater_about_land.xml | 70 +--------------------- indra/newview/tests/llagentaccess_test.cpp | 12 ---- 8 files changed, 5 insertions(+), 136 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index b822af352c..23a2908ce6 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -2633,11 +2633,6 @@ void LLAgent::setGodLevel(U8 god_level) mAgentAccess->setGodLevel(god_level); } -void LLAgent::setAOTransition() -{ - mAgentAccess->setTransition(); -} - const LLAgentAccess& LLAgent::getAgentAccess() { return *mAgentAccess; diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 18975911de..dcb26efe41 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -654,8 +654,6 @@ public: const LLAgentAccess& getAgentAccess(); BOOL canManageEstate() const; BOOL getAdminOverride() const; - // ! BACKWARDS COMPATIBILITY ! This function can go away after the AO transition (see llstartup.cpp). - void setAOTransition(); private: LLAgentAccess * mAgentAccess; diff --git a/indra/newview/llagentaccess.cpp b/indra/newview/llagentaccess.cpp index 08a33ab04a..bf2a78e7f5 100644 --- a/indra/newview/llagentaccess.cpp +++ b/indra/newview/llagentaccess.cpp @@ -33,8 +33,7 @@ LLAgentAccess::LLAgentAccess(LLControlGroup& savedSettings) : mSavedSettings(savedSettings), mAccess(SIM_ACCESS_PG), mAdminOverride(false), - mGodLevel(GOD_NOT), - mAOTransition(false) + mGodLevel(GOD_NOT) { } @@ -182,16 +181,6 @@ void LLAgentAccess::setMaturity(char text) mSavedSettings.setU32("PreferredMaturity", preferred_access); } -void LLAgentAccess::setTransition() -{ - mAOTransition = true; -} - -bool LLAgentAccess::isInTransition() const -{ - return mAOTransition; -} - bool LLAgentAccess::canSetMaturity(S32 maturity) { if (isGodlike()) // Gods can always set their Maturity level diff --git a/indra/newview/llagentaccess.h b/indra/newview/llagentaccess.h index 2e98e4eea1..90023d7575 100644 --- a/indra/newview/llagentaccess.h +++ b/indra/newview/llagentaccess.h @@ -64,8 +64,6 @@ public: static int convertTextToMaturity(char text); - void setTransition(); // sets the transition bit, which defaults to false - bool isInTransition() const; bool canSetMaturity(S32 maturity); private: @@ -73,13 +71,6 @@ private: U8 mGodLevel; bool mAdminOverride; - // this should be deleted after the 60-day AO transition. - // It should be safe to remove it in Viewer 2009 - // It's set by a special short-term flag in login.cgi - // called ao_transition. When that's gone, this can go, along with - // all of the code that depends on it. - bool mAOTransition; - LLControlGroup& mSavedSettings; }; diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 95da8ff948..6323530648 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -1865,23 +1865,8 @@ BOOL LLPanelLandOptions::postBuild() childSetCommitCallback("ShowDirectoryCheck", onCommitAny, this); - if (gAgent.getAgentAccess().isInTransition()) - { - // during the AO transition, this combo has an Adult item. - // Post-transition, it goes away. We can remove this conditional - // after the transition and just use the "else" clause. - mCategoryCombo = getChild( "land category with adult"); - childSetCommitCallback("land category with adult", onCommitAny, this); - } - else - { - // this is the code that should be preserved post-transition - // you could also change the XML to set visibility and enabled true. - mCategoryCombo = getChild( "land category"); - childSetCommitCallback("land category", onCommitAny, this); - } - mCategoryCombo->setVisible(true); - mCategoryCombo->setEnabled(true); + mCategoryCombo = getChild( "land category"); + childSetCommitCallback("land category", onCommitAny, this); mMatureCtrl = getChild( "MatureCheck"); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 0ac8c1fe39..a24aea25bc 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -3211,17 +3211,6 @@ bool process_login_success_response() gSavedSettings.setU32("PreferredMaturity", preferredMaturity); } - // During the AO transition, this flag will be true. Then the flag will - // go away. After the AO transition, this code and all the code that - // uses it can be deleted. - text = response["ao_transition"].asString(); - if (!text.empty()) - { - if (text == "1") - { - gAgent.setAOTransition(); - } - } text = response["start_location"].asString(); if(!text.empty()) diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml index 795d31689d..fb45e277fc 100644 --- a/indra/newview/skins/default/xui/en/floater_about_land.xml +++ b/indra/newview/skins/default/xui/en/floater_about_land.xml @@ -1354,79 +1354,13 @@ Only large parcels can be listed in search. top="150" width="430" /> - - - - - - - - - - - - - - - - template<> - void agentaccess_object_t::test<6>() - { - LLControlGroup cgr("test"); - cgr.declareU32("PreferredMaturity", SIM_ACCESS_PG, "declared_for_test", FALSE); - LLAgentAccess aa(cgr); - cgr.setU32("PreferredMaturity", SIM_ACCESS_ADULT); aa.setMaturity('M'); ensure("1 preferred maturity pegged to M when maturity is M", cgr.getU32("PreferredMaturity") == SIM_ACCESS_MATURE); -- cgit v1.3 From b912c27bf44a45e607adc3b5c94d3fd8a9bbf53e Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 11 Jun 2012 16:40:53 -0700 Subject: PATH-711: Implementing Leo's changes for the pathfinding console. --- indra/newview/llfloaterpathfindingconsole.cpp | 137 +-------------------- indra/newview/llfloaterpathfindingconsole.h | 18 --- indra/newview/llpathfindingcharacterlist.cpp | 6 +- indra/newview/llpathfindingmanager.cpp | 14 +++ indra/newview/llpathfindingmanager.h | 4 + indra/newview/llpathfindingnavmeshzone.h | 1 + indra/newview/llpathfindingpathtool.cpp | 5 - indra/newview/llstartup.cpp | 4 + indra/newview/llviewermenu.cpp | 11 +- .../default/xui/en/floater_pathfinding_console.xml | 91 +------------- indra/newview/skins/default/xui/en/menu_viewer.xml | 18 +-- 11 files changed, 47 insertions(+), 262 deletions(-) (limited to 'indra/newview/llstartup.cpp') diff --git a/indra/newview/llfloaterpathfindingconsole.cpp b/indra/newview/llfloaterpathfindingconsole.cpp index 54e60ce0f4..59ce330a10 100644 --- a/indra/newview/llfloaterpathfindingconsole.cpp +++ b/indra/newview/llfloaterpathfindingconsole.cpp @@ -64,9 +64,6 @@ #define XUI_CHARACTER_TYPE_C 3 #define XUI_CHARACTER_TYPE_D 4 -#define XUI_EDIT_TAB_INDEX 0 -#define XUI_TEST_TAB_INDEX 1 - #define SET_SHAPE_RENDER_FLAG(_flag,_type) _flag |= (1U << _type) #define CONTROL_NAME_RETRIEVE_NEIGHBOR "RetrieveNeighboringRegion" @@ -138,37 +135,9 @@ BOOL LLFloaterPathfindingConsole::postBuild() llassert(mViewCharactersButton != NULL); mViewCharactersButton->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onViewCharactersClicked, this)); - mEditTestTabContainer = findChild("edit_test_tab_container"); - llassert(mEditTestTabContainer != NULL); - mEditTestTabContainer->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onTabSwitch, this)); - - mEditTab = findChild("edit_panel"); - llassert(mEditTab != NULL); - mTestTab = findChild("test_panel"); llassert(mTestTab != NULL); - mUnfreezeLabel = findChild("unfreeze_label"); - llassert(mUnfreezeLabel != NULL); - - mUnfreezeButton = findChild("enter_unfrozen_mode"); - llassert(mUnfreezeButton != NULL); - mUnfreezeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onUnfreezeClicked, this)); - - mLinksetsLabel = findChild("edit_linksets_label"); - llassert(mLinksetsLabel != NULL); - - mLinksetsButton = findChild("view_and_edit_linksets"); - llassert(mLinksetsButton != NULL); - mLinksetsButton->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onViewEditLinksetClicked, this)); - - mFreezeLabel = findChild("freeze_label"); - llassert(mFreezeLabel != NULL); - - mFreezeButton = findChild("enter_frozen_mode"); - llassert(mFreezeButton != NULL); - mFreezeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onFreezeClicked, this)); - mPathfindingViewerStatus = findChild("pathfinding_viewer_status"); llassert(mPathfindingViewerStatus != NULL); @@ -205,11 +174,6 @@ BOOL LLFloaterPathfindingConsole::postBuild() llassert(mClearPathButton != NULL); mClearPathButton->setCommitCallback(boost::bind(&LLFloaterPathfindingConsole::onClearPathClicked, this)); - if (LLPathingLib::getInstance() == NULL) - { - LLPathingLib::initSystem(); - } - if (LLPathingLib::getInstance() != NULL) { mPathfindingToolset = new LLToolset(); @@ -246,11 +210,6 @@ void LLFloaterPathfindingConsole::onOpen(const LLSD& pKey) fillInColorsForNavMeshVisualization(); } - if (!mAgentStateSlot.connected()) - { - mAgentStateSlot = LLPathfindingManager::getInstance()->registerAgentStateListener(boost::bind(&LLFloaterPathfindingConsole::onAgentStateCB, this, _1)); - } - if (!mRegionBoundarySlot.connected()) { mRegionBoundarySlot = LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterPathfindingConsole::onRegionBoundaryCross, this)); @@ -266,14 +225,10 @@ void LLFloaterPathfindingConsole::onOpen(const LLSD& pKey) mPathEventSlot = LLPathfindingPathTool::getInstance()->registerPathEventListener(boost::bind(&LLFloaterPathfindingConsole::onPathEvent, this)); } - setAgentState(LLPathfindingManager::getInstance()->getAgentState()); setDefaultInputs(); updatePathTestStatus(); - if (mEditTestTabContainer->getCurrentPanelIndex() == XUI_TEST_TAB_INDEX) - { - switchIntoTestPathMode(); - } + switchIntoTestPathMode(); } void LLFloaterPathfindingConsole::onClose(bool pIsAppQuitting) @@ -295,11 +250,6 @@ void LLFloaterPathfindingConsole::onClose(bool pIsAppQuitting) mRegionBoundarySlot.disconnect(); } - if (mAgentStateSlot.connected()) - { - mAgentStateSlot.disconnect(); - } - if (mNavMeshZoneSlot.connected()) { mNavMeshZoneSlot.disconnect(); @@ -501,15 +451,7 @@ LLFloaterPathfindingConsole::LLFloaterPathfindingConsole(const LLSD& pSeed) mPathfindingViewerStatus(NULL), mPathfindingSimulatorStatus(NULL), mViewCharactersButton(NULL), - mEditTestTabContainer(NULL), - mEditTab(NULL), mTestTab(NULL), - mUnfreezeLabel(NULL), - mUnfreezeButton(NULL), - mLinksetsLabel(NULL), - mLinksetsButton(NULL), - mFreezeLabel(NULL), - mFreezeButton(NULL), mCtrlClickLabel(), mShiftClickLabel(), mCharacterWidthLabel(), @@ -522,7 +464,6 @@ LLFloaterPathfindingConsole::LLFloaterPathfindingConsole(const LLSD& pSeed) mNavMeshZoneSlot(), mNavMeshZone(), mIsNavMeshUpdating(false), - mAgentStateSlot(), mRegionBoundarySlot(), mTeleportFailedSlot(), mPathEventSlot(), @@ -577,35 +518,6 @@ void LLFloaterPathfindingConsole::onViewCharactersClicked() LLFloaterPathfindingCharacters::openCharactersViewer(); } -void LLFloaterPathfindingConsole::onTabSwitch() -{ - if (mEditTestTabContainer->getCurrentPanelIndex() == XUI_TEST_TAB_INDEX) - { - switchIntoTestPathMode(); - } - else - { - switchOutOfTestPathMode(); - } -} - -void LLFloaterPathfindingConsole::onUnfreezeClicked() -{ - mUnfreezeButton->setEnabled(FALSE); - LLPathfindingManager::getInstance()->requestSetAgentState(LLPathfindingManager::kAgentStateUnfrozen); -} - -void LLFloaterPathfindingConsole::onFreezeClicked() -{ - mFreezeButton->setEnabled(FALSE); - LLPathfindingManager::getInstance()->requestSetAgentState(LLPathfindingManager::kAgentStateFrozen); -} - -void LLFloaterPathfindingConsole::onViewEditLinksetClicked() -{ - LLFloaterPathfindingLinksets::openLinksetsEditor(); -} - void LLFloaterPathfindingConsole::onCharacterWidthSet() { updateCharacterWidth(); @@ -658,11 +570,6 @@ void LLFloaterPathfindingConsole::onNavMeshZoneCB(LLPathfindingNavMeshZone::ENav } } -void LLFloaterPathfindingConsole::onAgentStateCB(LLPathfindingManager::EAgentState pAgentState) -{ - setAgentState(pAgentState); -} - void LLFloaterPathfindingConsole::onRegionBoundaryCross() { initializeNavMeshZoneForCurrentRegion(); @@ -706,7 +613,6 @@ void LLFloaterPathfindingConsole::onPathEvent() void LLFloaterPathfindingConsole::setDefaultInputs() { - mEditTestTabContainer->selectTab(XUI_EDIT_TAB_INDEX); setRenderWorld(TRUE); setRenderNavMesh(FALSE); setRenderWalkables(FALSE); @@ -776,7 +682,6 @@ void LLFloaterPathfindingConsole::updateControlsOnConsoleState() mShowRenderWaterPlaneCheckBox->setEnabled(FALSE); mShowXRayCheckBox->setEnabled(FALSE); mViewCharactersButton->setEnabled(FALSE); - mEditTestTabContainer->selectTab(0); mTestTab->setEnabled(FALSE); mCtrlClickLabel->setEnabled(FALSE); mShiftClickLabel->setEnabled(FALSE); @@ -802,7 +707,6 @@ void LLFloaterPathfindingConsole::updateControlsOnConsoleState() mShowRenderWaterPlaneCheckBox->setEnabled(FALSE); mShowXRayCheckBox->setEnabled(FALSE); mViewCharactersButton->setEnabled(TRUE); - mEditTestTabContainer->selectTab(0); mTestTab->setEnabled(FALSE); mCtrlClickLabel->setEnabled(FALSE); mShiftClickLabel->setEnabled(FALSE); @@ -830,7 +734,6 @@ void LLFloaterPathfindingConsole::updateControlsOnConsoleState() mShowRenderWaterPlaneCheckBox->setEnabled(FALSE); mShowXRayCheckBox->setEnabled(FALSE); mViewCharactersButton->setEnabled(TRUE); - mEditTestTabContainer->selectTab(0); mTestTab->setEnabled(FALSE); mCtrlClickLabel->setEnabled(FALSE); mShiftClickLabel->setEnabled(FALSE); @@ -1028,44 +931,6 @@ void LLFloaterPathfindingConsole::cleanupRenderableRestoreItems() } } -void LLFloaterPathfindingConsole::setAgentState(LLPathfindingManager::EAgentState pAgentState) -{ - switch (LLPathfindingManager::getInstance()->getLastKnownNonErrorAgentState()) - { - case LLPathfindingManager::kAgentStateUnknown : - case LLPathfindingManager::kAgentStateNotEnabled : - mEditTab->setEnabled(FALSE); - mUnfreezeLabel->setEnabled(FALSE); - mUnfreezeButton->setEnabled(FALSE); - mLinksetsLabel->setEnabled(FALSE); - mLinksetsButton->setEnabled(FALSE); - mFreezeLabel->setEnabled(FALSE); - mFreezeButton->setEnabled(FALSE); - break; - case LLPathfindingManager::kAgentStateFrozen : - mEditTab->setEnabled(TRUE); - mUnfreezeLabel->setEnabled(TRUE); - mUnfreezeButton->setEnabled(TRUE); - mLinksetsLabel->setEnabled(FALSE); - mLinksetsButton->setEnabled(FALSE); - mFreezeLabel->setEnabled(FALSE); - mFreezeButton->setEnabled(FALSE); - break; - case LLPathfindingManager::kAgentStateUnfrozen : - mEditTab->setEnabled(TRUE); - mUnfreezeLabel->setEnabled(FALSE); - mUnfreezeButton->setEnabled(FALSE); - mLinksetsLabel->setEnabled(TRUE); - mLinksetsButton->setEnabled(TRUE); - mFreezeLabel->setEnabled(TRUE); - mFreezeButton->setEnabled(TRUE); - break; - default : - llassert(0); - break; - } -} - void LLFloaterPathfindingConsole::switchIntoTestPathMode() { if (LLPathingLib::getInstance() != NULL) diff --git a/indra/newview/llfloaterpathfindingconsole.h b/indra/newview/llfloaterpathfindingconsole.h index edbeae2012..2529b241bf 100644 --- a/indra/newview/llfloaterpathfindingconsole.h +++ b/indra/newview/llfloaterpathfindingconsole.h @@ -31,7 +31,6 @@ #include "llfloater.h" #include "llhandle.h" #include "llpathinglib.h" -#include "llpathfindingmanager.h" #include "llpathfindingnavmeshzone.h" #include "llpathfindingpathtool.h" @@ -43,7 +42,6 @@ class LLSliderCtrl; class LLLineEditor; class LLTextBase; class LLCheckBoxCtrl; -class LLTabContainer; class LLComboBox; class LLButton; class LLToolset; @@ -120,16 +118,11 @@ private: void onShowNavMeshSet(); void onShowWalkabilitySet(); void onViewCharactersClicked(); - void onTabSwitch(); - void onUnfreezeClicked(); - void onFreezeClicked(); - void onViewEditLinksetClicked(); void onCharacterWidthSet(); void onCharacterTypeSwitch(); void onClearPathClicked(); void onNavMeshZoneCB(LLPathfindingNavMeshZone::ENavMeshZoneRequestStatus pNavMeshZoneRequestStatus); - void onAgentStateCB(LLPathfindingManager::EAgentState pAgentState); void onRegionBoundaryCross(); void onPathEvent(); @@ -145,8 +138,6 @@ private: void initializeNavMeshZoneForCurrentRegion(); - void setAgentState(LLPathfindingManager::EAgentState pAgentState); - void switchIntoTestPathMode(); void switchOutOfTestPathMode(); void updateCharacterWidth(); @@ -177,15 +168,7 @@ private: LLTextBase *mPathfindingViewerStatus; LLTextBase *mPathfindingSimulatorStatus; LLButton *mViewCharactersButton; - LLTabContainer *mEditTestTabContainer; - LLPanel *mEditTab; LLPanel *mTestTab; - LLTextBase *mUnfreezeLabel; - LLButton *mUnfreezeButton; - LLTextBase *mLinksetsLabel; - LLButton *mLinksetsButton; - LLTextBase *mFreezeLabel; - LLButton *mFreezeButton; LLTextBase *mCtrlClickLabel; LLTextBase *mShiftClickLabel; LLTextBase *mCharacterWidthLabel; @@ -200,7 +183,6 @@ private: LLPathfindingNavMeshZone mNavMeshZone; bool mIsNavMeshUpdating; - LLPathfindingManager::agent_state_slot_t mAgentStateSlot; boost::signals2::connection mRegionBoundarySlot; boost::signals2::connection mTeleportFailedSlot; LLPathfindingPathTool::path_event_slot_t mPathEventSlot; diff --git a/indra/newview/llpathfindingcharacterlist.cpp b/indra/newview/llpathfindingcharacterlist.cpp index 15eaac771f..ac1fb15be9 100644 --- a/indra/newview/llpathfindingcharacterlist.cpp +++ b/indra/newview/llpathfindingcharacterlist.cpp @@ -47,12 +47,10 @@ LLPathfindingCharacterList::LLPathfindingCharacterList() LLPathfindingCharacterList::LLPathfindingCharacterList(const LLSD& pCharacterListData) : LLPathfindingObjectList() { - if ( LLPathingLib::getInstance() == NULL ) + if (LLPathingLib::getInstance() != NULL) { - LLPathingLib::initSystem(); + LLPathingLib::getInstance()->cleanupPhysicsCapsuleRepResiduals( ); } - - LLPathingLib::getInstance()->cleanupPhysicsCapsuleRepResiduals( ); parseCharacterListData(pCharacterListData); } diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 5e2a9e1213..ae1c228c69 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -45,6 +45,7 @@ #include "llpathfindingnavmesh.h" #include "llpathfindingnavmeshstatus.h" #include "llpathfindingobject.h" +#include "llpathinglib.h" #include "llsingleton.h" #include "llsd.h" #include "lltrans.h" @@ -273,6 +274,14 @@ LLPathfindingManager::~LLPathfindingManager() { } +void LLPathfindingManager::initSystem() +{ + if (LLPathingLib::getInstance() == NULL) + { + LLPathingLib::initSystem(); + } +} + bool LLPathfindingManager::isPathfindingEnabledForCurrentRegion() const { return isPathfindingEnabledForRegion(getCurrentRegion()); @@ -292,6 +301,11 @@ bool LLPathfindingManager::isPathfindingNavMeshVersioningEnabledForCurrentRegion } #endif // DEPRECATED_UNVERSIONED_NAVMESH +bool LLPathfindingManager::isPathfindingDebugEnabled() const +{ + return (LLPathingLib::getInstance() != NULL); +} + bool LLPathfindingManager::isAllowViewTerrainProperties() const { LLViewerRegion* region = getCurrentRegion(); diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index 1ae6e06b40..24b58d1fe9 100644 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -74,12 +74,16 @@ public: LLPathfindingManager(); virtual ~LLPathfindingManager(); + void initSystem(); + bool isPathfindingEnabledForCurrentRegion() const; bool isPathfindingEnabledForRegion(LLViewerRegion *pRegion) const; #ifdef DEPRECATED_UNVERSIONED_NAVMESH bool isPathfindingNavMeshVersioningEnabledForCurrentRegionXXX() const; #endif // DEPRECATED_UNVERSIONED_NAVMESH + bool isPathfindingDebugEnabled() const; + bool isAllowViewTerrainProperties() const; LLPathfindingNavMesh::navmesh_slot_t registerNavMeshListenerForRegion(LLViewerRegion *pRegion, LLPathfindingNavMesh::navmesh_callback_t pNavMeshCallback); diff --git a/indra/newview/llpathfindingnavmeshzone.h b/indra/newview/llpathfindingnavmeshzone.h index 8c330559a9..1e92f6b131 100644 --- a/indra/newview/llpathfindingnavmeshzone.h +++ b/indra/newview/llpathfindingnavmeshzone.h @@ -32,6 +32,7 @@ #include "lluuid.h" #include "llpathfindingnavmesh.h" #include "llpathfindingnavmeshstatus.h" +#include "llviewerregion.h" #include diff --git a/indra/newview/llpathfindingpathtool.cpp b/indra/newview/llpathfindingpathtool.cpp index bc5a265111..5567869a1c 100644 --- a/indra/newview/llpathfindingpathtool.cpp +++ b/indra/newview/llpathfindingpathtool.cpp @@ -54,11 +54,6 @@ LLPathfindingPathTool::LLPathfindingPathTool() mIsMiddleMouseButtonHeld(false), mIsRightMouseButtonHeld(false) { - if (!LLPathingLib::getInstance()) - { - LLPathingLib::initSystem(); - } - setCharacterWidth(1.0f); setCharacterType(mCharacterType); } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 0ac8c1fe39..6bee373181 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -186,6 +186,7 @@ #include "llappearancemgr.h" #include "llavatariconctrl.h" #include "llvoicechannel.h" +#include "llpathfindingmanager.h" #include "lllogin.h" #include "llevents.h" @@ -1968,6 +1969,9 @@ bool idle_startup() } } + llassert(LLPathfindingManager::getInstance() != NULL); + LLPathfindingManager::getInstance()->initSystem(); + display_startup(); //DEV-17797. get null folder. Any items found here moved to Lost and Found LLInventoryModelBackgroundFetch::instance().findLostItems(); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 5a0239c2e4..69421d240b 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -4802,7 +4802,15 @@ class LLToolsEnablePathfinding : public view_listener_t { bool handleEvent(const LLSD& userdata) { - return LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion(); + return (LLPathfindingManager::getInstance() != NULL) && LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion(); + } +}; + +class LLToolsEnablePathfindingDebug : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + return (LLPathfindingManager::getInstance() != NULL) && LLPathfindingManager::getInstance()->isPathfindingEnabledForCurrentRegion() && LLPathfindingManager::getInstance()->isPathfindingDebugEnabled(); } }; @@ -8201,6 +8209,7 @@ void initialize_menus() view_listener_t::addMenu(new LLToolsEnableSaveToObjectInventory(), "Tools.EnableSaveToObjectInventory"); view_listener_t::addMenu(new LLToolsEnablePathfinding(), "Tools.EnablePathfinding"); + view_listener_t::addMenu(new LLToolsEnablePathfindingDebug(), "Tools.EnablePathfindingDebug"); // Help menu // most items use the ShowFloater method diff --git a/indra/newview/skins/default/xui/en/floater_pathfinding_console.xml b/indra/newview/skins/default/xui/en/floater_pathfinding_console.xml index 54d44be015..a9815dcb00 100644 --- a/indra/newview/skins/default/xui/en/floater_pathfinding_console.xml +++ b/indra/newview/skins/default/xui/en/floater_pathfinding_console.xml @@ -9,7 +9,7 @@ reuse_instance="true" save_rect="true" single_instance="true" - title="Pathfinding edit / test" + title="Pathfinding debug" width="456"> Cannot find pathing library implementation. @@ -233,93 +233,6 @@ top="14" height="268" width="218"> - - - Allow object / terrain changes: - -