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/llfloaterpathfindinglinksets.cpp | 308 ++++++++++++++++++--- indra/newview/llfloaterpathfindinglinksets.h | 32 ++- indra/newview/llstartup.cpp | 10 + .../xui/en/floater_pathfinding_linksets.xml | 110 ++++---- 4 files changed, 356 insertions(+), 104 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index 4f98834dde..efcb5a1c80 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -1,55 +1,275 @@ -/** - * @file llfloaterpathfindinglinksets.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 "llfloaterpathfindinglinksets.h" -#include "llsd.h" -#include "llfloater.h" -#include "llfloaterreg.h" - -//--------------------------------------------------------------------------- -// LLFloaterPathfindingLinksets -//--------------------------------------------------------------------------- - -BOOL LLFloaterPathfindingLinksets::postBuild() +/** + * @file llfloaterpathfindinglinksets.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 "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" + +//--------------------------------------------------------------------------- +// LLFloaterPathfindingLinksets +//--------------------------------------------------------------------------- + +BOOL LLFloaterPathfindingLinksets::postBuild() +{ + childSetAction("refresh_linksets_list", boost::bind(&LLFloaterPathfindingLinksets::onRefreshLinksetsClicked, this)); + childSetAction("select_all_linksets", boost::bind(&LLFloaterPathfindingLinksets::onSelectAllLinksetsClicked, this)); + childSetAction("select_none_linksets", boost::bind(&LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked, this)); + + mLinksetsScrollList = findChild("pathfinding_linksets"); + llassert(mLinksetsScrollList != NULL); + mLinksetsScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onLinksetsSelectionChange, this)); + mLinksetsScrollList->setCommitOnSelectionChange(true); + + mLinksetsStatus = findChild("linksets_status"); + llassert(mLinksetsStatus != NULL); + + updateLinksetsStatus(); + + return LLFloater::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); + } +} + +void LLFloaterPathfindingLinksets::openLinksetsEditor() +{ + LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_linksets"); +} + +LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& pSeed) + : LLFloater(pSeed), + mLinksetsScrollList(NULL), + mLinksetsStatus(NULL) +{ +} + +LLFloaterPathfindingLinksets::~LLFloaterPathfindingLinksets() +{ +} + +void LLFloaterPathfindingLinksets::sendLandStatRequest() +{ + 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()); +} + +void LLFloaterPathfindingLinksets::handleLandStatReply(LLMessageSystem *pMsg) +{ + 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); + + clearLinksetsList(); + + const LLVector3& avatarPosition = gAgent.getPositionAgent(); + + S32 block_count = pMsg->getNumberOfBlocks("ReportData"); + for (S32 block = 0; block < block_count; ++block) + { + 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; + + LLSD columns; + + columns[0]["column"] = "name"; + columns[0]["value"] = name_buf; + 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]["font"] = "SANSSERIF"; + + columns[2]["column"] = "land_impact"; + columns[2]["value"] = llformat("%0.1f", 55.679); + 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]["font"] = "SANSSERIF"; + + element["columns"] = columns; + mLinksetsScrollList->addElement(element); + } + + updateLinksetsStatus(); +} + +void LLFloaterPathfindingLinksets::onLinksetsSelectionChange() +{ + updateLinksetsStatus(); +} + +void LLFloaterPathfindingLinksets::onRefreshLinksetsClicked() +{ + sendLandStatRequest(); +} + +void LLFloaterPathfindingLinksets::onSelectAllLinksetsClicked() { - return LLFloater::postBuild(); + selectAllLinksets(); } -void LLFloaterPathfindingLinksets::openLinksetsEditor() +void LLFloaterPathfindingLinksets::onSelectNoneLinksetsClicked() { - LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_linksets"); + selectNoneLinksets(); } -LLFloaterPathfindingLinksets::LLFloaterPathfindingLinksets(const LLSD& seed) - : LLFloater(seed) +void LLFloaterPathfindingLinksets::clearLinksetsList() { + mLinksetsScrollList->deleteAllItems(); + 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); } -LLFloaterPathfindingLinksets::~LLFloaterPathfindingLinksets() +void LLFloaterPathfindingLinksets::updateLinksetsStatusForFetch() { + mLinksetsStatus->setValue(getString("linksets_fetching")); } diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h index de32951462..4bde806e4d 100644 --- a/indra/newview/llfloaterpathfindinglinksets.h +++ b/indra/newview/llfloaterpathfindinglinksets.h @@ -31,6 +31,9 @@ #include "llfloater.h" class LLSD; +class LLUICtrl; +class LLMessageSystem; +class LLScrollListCtrl; class LLFloaterPathfindingLinksets : public LLFloater @@ -39,23 +42,36 @@ class LLFloaterPathfindingLinksets public: virtual BOOL postBuild(); + virtual void onOpen(const LLSD& pKey); static void openLinksetsEditor(); - - struct Params : public LLInitParam::Block - { - Params(); - }; + static void handleLandStatReply(LLMessageSystem *pMsg, void **pData); protected: private: + LLScrollListCtrl *mLinksetsScrollList; + LLUICtrl *mLinksetsStatus; + // Does its own instance management, so clients not allowed // to allocate or destroy. - LLFloaterPathfindingLinksets(const LLSD& seed); + LLFloaterPathfindingLinksets(const LLSD& pSeed); virtual ~LLFloaterPathfindingLinksets(); - - void onVisibilityChange(const LLSD& visible); + + void sendLandStatRequest(); + void handleLandStatReply(LLMessageSystem *pMsg); + + void onLinksetsSelectionChange(); + void onRefreshLinksetsClicked(); + void onSelectAllLinksetsClicked(); + void onSelectNoneLinksetsClicked(); + + void clearLinksetsList(); + void selectAllLinksets(); + void selectNoneLinksets(); + + void updateLinksetsStatus(); + void updateLinksetsStatusForFetch(); }; #endif // LL_LLFLOATERPATHFINDINGLINKSETS_H 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); 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 f8da37fe6f..587b62377b 100644 --- a/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml +++ b/indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml @@ -6,9 +6,14 @@ layout="topleft" name="floater_pathfinding_linksets" help_topic="floater_pathfinding_linksets" + reuse_instance="true" save_rect="true" + single_instance="true" title="Pathfinding linksets" width="950"> + Finking pathfinding linksets ... + No pathfinding linksets + [NUM_SELECTED] linksets selected out of [NUM_TOTAL] - - - - - - - - - - - - - + + + + + + + + + + + + - 0 linsets selected out of 2 + Linksets: