diff options
author | prep <prep@lindenlab.com> | 2012-01-05 17:02:53 -0500 |
---|---|---|
committer | prep <prep@lindenlab.com> | 2012-01-05 17:02:53 -0500 |
commit | a5a2b2b0202ab89f5116ef1b02f8adc67f35eab9 (patch) | |
tree | b41f63b71ac197ef49aefc9d3f09b922d2cc5795 /indra/newview | |
parent | 22b877e70a6f72256ff585465232bed93792571d (diff) | |
parent | fcdfd631238e22186b11be5275747e37eff65d1f (diff) |
merge
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterpathfindinglinksets.cpp | 308 | ||||
-rw-r--r-- | indra/newview/llfloaterpathfindinglinksets.h | 32 | ||||
-rw-r--r-- | indra/newview/llstartup.cpp | 10 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_pathfinding_linksets.xml | 110 |
4 files changed, 356 insertions, 104 deletions
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<LLScrollListCtrl>("pathfinding_linksets");
+ llassert(mLinksetsScrollList != NULL);
+ mLinksetsScrollList->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onLinksetsSelectionChange, this));
+ mLinksetsScrollList->setCommitOnSelectionChange(true);
+
+ mLinksetsStatus = findChild<LLUICtrl>("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<LLFloaterPathfindingLinksets>("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, LLFloater::Params> - { - 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"> + <floater.string name="linksets_fetching">Finking pathfinding linksets ...</floater.string> + <floater.string name="linksets_none_found">No pathfinding linksets</floater.string> + <floater.string name="linksets_available">[NUM_SELECTED] linksets selected out of [NUM_TOTAL]</floater.string> <text height="13" word_wrap="false" @@ -107,7 +112,7 @@ top="11" left="851" width="73"/> - <name_list + <scroll_list column_padding="0" draw_heading="true" follows="all" @@ -115,54 +120,54 @@ layout="topleft" left="18" top="48" - name="owner list" - name_column="name" + multi_select="true" + name="pathfinding_linksets" width="910"> - <name_list.columns - label="Name (root prim)" - name="name" - width="152" /> - <name_list.columns - label="Description (root prim)" - name="description" - width="191" /> - <name_list.columns - label="Land impact" - name="land_impact" - width="85" /> - <name_list.columns - label="Dist from you" - name="dist_from_you" - width="87" /> - <name_list.columns - label="Fixed" - name="fixed" - width="63" /> - <name_list.columns - label="Walkable" - name="walkable" - width="73" /> - <name_list.columns - label="Phantom" - name="phantom" - width="74" /> - <name_list.columns - label="A %" - name="a_percent" - width="41" /> - <name_list.columns - label="B %" - name="b_percent" - width="41" /> - <name_list.columns - label="C %" - name="c_percent" - width="41" /> - <name_list.columns - label="D %" - name="d_percent" - width="41" /> - </name_list> + <scroll_list.columns + label="Name (root prim)" + name="name" + width="152" /> + <scroll_list.columns + label="Description (root prim)" + name="description" + width="191" /> + <scroll_list.columns + label="Land impact" + name="land_impact" + width="85" /> + <scroll_list.columns + label="Dist from you" + name="dist_from_you" + width="87" /> + <scroll_list.columns + label="Fixed" + name="fixed" + width="63" /> + <scroll_list.columns + label="Walkable" + name="walkable" + width="73" /> + <scroll_list.columns + label="Phantom" + name="phantom" + width="74" /> + <scroll_list.columns + label="A %" + name="a_percent" + width="41" /> + <scroll_list.columns + label="B %" + name="b_percent" + width="41" /> + <scroll_list.columns + label="C %" + name="c_percent" + width="41" /> + <scroll_list.columns + label="D %" + name="d_percent" + width="41" /> + </scroll_list> <text height="13" word_wrap="false" @@ -172,16 +177,17 @@ length="1" follows="left|top" layout="topleft" + name="linksets_status" top="200" width="500"> - 0 linsets selected out of 2 + Linksets: </text> <button follows="right|top" height="21" label="Refresh list" layout="topleft" - name="linksets" + name="refresh_linksets_list" top="200" left="568" width="115"/> @@ -190,7 +196,7 @@ height="21" label="Select all" layout="topleft" - name="linksets" + name="select_all_linksets" top="200" left="690" width="115"/> @@ -199,7 +205,7 @@ height="21" label="Select none" layout="topleft" - name="linksets" + name="select_none_linksets" top="200" left="812" width="115"/> |