From 7d5c4d20b9f99b3e7d5781433ed6046678292627 Mon Sep 17 00:00:00 2001 From: prep Date: Wed, 13 Jun 2012 13:30:26 -0400 Subject: WIP: path-722. Posting and responders for navmesh rebaking --- indra/newview/llpanelnavmeshrebake.cpp | 3 +- indra/newview/llpathfindingmanager.cpp | 95 ++++++++++++++++++++++++++++++---- indra/newview/llpathfindingmanager.h | 8 +++ 3 files changed, 95 insertions(+), 11 deletions(-) diff --git a/indra/newview/llpanelnavmeshrebake.cpp b/indra/newview/llpanelnavmeshrebake.cpp index 9281c08059..92a082467f 100644 --- a/indra/newview/llpanelnavmeshrebake.cpp +++ b/indra/newview/llpanelnavmeshrebake.cpp @@ -96,7 +96,6 @@ BOOL LLPanelNavMeshRebake::postBuild() //Baking mNavMeshBakingButton = getChild("navmesh_btn_baking"); - mNavMeshBakingButton->setCommitCallback(boost::bind(&LLPanelNavMeshRebake::onNavMeshRebakeClick, this)); mNavMeshBakingButton->setVisible( FALSE ); LLHints::registerHintTarget("navmesh_btn_baking", mNavMeshBakingButton->getHandle()); return TRUE; @@ -146,6 +145,8 @@ void LLPanelNavMeshRebake::onNavMeshRebakeClick() setFocus(FALSE); mNavMeshRebakeButton->setVisible( FALSE ); mNavMeshBakingButton->setVisible( TRUE ); + mNavMeshBakingButton->setForcePressedState( TRUE ); + //post } /** diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp index 278269b2fa..fc296a4b83 100644 --- a/indra/newview/llpathfindingmanager.cpp +++ b/indra/newview/llpathfindingmanager.cpp @@ -162,6 +162,23 @@ private: }; #endif // XXX_STINSON_AGENT_STATE_DELETE_ME +//--------------------------------------------------------------------------- +// NavMeshRebakeResponder +//--------------------------------------------------------------------------- +class NavMeshRebakeResponder : public LLHTTPClient::Responder +{ +public: + NavMeshRebakeResponder( const std::string &pCapabilityURL ); + virtual ~NavMeshRebakeResponder(); + + virtual void result( const LLSD &pContent ); + virtual void error( U32 pStatus, const std::string& pReason ); + +protected: + +private: + std::string mCapabilityURL; +}; //--------------------------------------------------------------------------- // LinksetsResponder //--------------------------------------------------------------------------- @@ -269,7 +286,7 @@ private: LLPathfindingManager::LLPathfindingManager() : LLSingleton(), - mNavMeshMap(),mShowNavMeshRebake(false) + mNavMeshMap(), mShowNavMeshRebake(false) { } @@ -316,15 +333,7 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingManager::registerNavMeshListen void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion) { LLPathfindingNavMeshPtr navMeshPtr = getNavMeshForRegion(pRegion); - //prep#s#test - LLView* rootp = LLUI::getRootView(); - LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); - LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); - panel_nmr_container->addChild( panel_namesh_rebake ); - panel_nmr_container->setVisible( TRUE ); - panel_namesh_rebake->reparent( rootp ); - LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); - //prep#e + if (pRegion == NULL) { navMeshPtr->handleNavMeshNotEnabled(); @@ -684,6 +693,50 @@ LLViewerRegion *LLPathfindingManager::getCurrentRegion() const return gAgent.getRegion(); } +void LLPathfindingManager::displayNavMeshRebakePanel() +{ + LLView* rootp = LLUI::getRootView(); + LLPanel* panel_nmr_container = rootp->getChild("navmesh_rebake_container"); + LLPanelNavMeshRebake* panel_namesh_rebake = LLPanelNavMeshRebake::getInstance(); + panel_nmr_container->addChild( panel_namesh_rebake ); + panel_nmr_container->setVisible( TRUE ); + panel_namesh_rebake->reparent( rootp ); + LLPanelNavMeshRebake::getInstance()->setVisible( TRUE ); +} + +void LLPathfindingManager::hideNavMeshRebakePanel() +{ + LLPanelNavMeshRebake::getInstance()->setVisible( FALSE ); +} + +void LLPathfindingManager::handleNavMeshRebakeResult( const LLSD &pContent ) +{ + +} + +void LLPathfindingManager::handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL) +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; +} +//prep# +void LLPathfindingManager::triggerNavMeshRebuild() +{ + LLSD mPostData; + std::string url = getNavMeshStatusURLForRegion( getCurrentRegion() ); + + if ( url.empty() ) + { + //prep#fix#error? + } + else + { + LLSD mPostData; + mPostData["command"] = "rebuild"; + LLHTTPClient::ResponderPtr responder = new NavMeshRebakeResponder( url ); + LLHTTPClient::post( url, mPostData, responder ); + } + +} //--------------------------------------------------------------------------- // LLNavMeshSimStateChangeNode //--------------------------------------------------------------------------- @@ -804,6 +857,28 @@ void AgentStateResponder::error(U32 pStatus, const std::string &pReason) } #endif // XXX_STINSON_AGENT_STATE_DELETE_ME +//--------------------------------------------------------------------------- +// navmesh rebake responder +//--------------------------------------------------------------------------- +NavMeshRebakeResponder::NavMeshRebakeResponder(const std::string &pCapabilityURL ) +: LLHTTPClient::Responder() +, mCapabilityURL( pCapabilityURL ) +{ +} + +NavMeshRebakeResponder::~NavMeshRebakeResponder() +{ +} + +void NavMeshRebakeResponder::result(const LLSD &pContent) +{ + LLPathfindingManager::getInstance()->handleNavMeshRebakeResult( pContent ); +} + +void NavMeshRebakeResponder::error(U32 pStatus, const std::string &pReason) +{ + LLPathfindingManager::getInstance()->handleNavMeshRebakeError( pStatus, pReason, mCapabilityURL ); +} //--------------------------------------------------------------------------- // LinksetsResponder //--------------------------------------------------------------------------- diff --git a/indra/newview/llpathfindingmanager.h b/indra/newview/llpathfindingmanager.h index 635179e5a0..535c681499 100644 --- a/indra/newview/llpathfindingmanager.h +++ b/indra/newview/llpathfindingmanager.h @@ -92,6 +92,9 @@ public: agent_state_slot_t registerAgentStateListener(agent_state_callback_t pAgentStateCallback); #endif // XXX_STINSON_AGENT_STATE_DELETE_ME + void handleNavMeshRebakeResult( const LLSD &pContent ); + void handleNavMeshRebakeError(U32 pStatus, const std::string &pReason, const std::string &pURL); + protected: private: @@ -117,6 +120,11 @@ private: std::string getCapabilityURLForRegion(LLViewerRegion *pRegion, const std::string &pCapabilityName) const; LLViewerRegion *getCurrentRegion() const; + + void displayNavMeshRebakePanel(); + void hideNavMeshRebakePanel(); + void triggerNavMeshRebuild(); + #ifdef XXX_STINSON_AGENT_STATE_DELETE_ME void requestGetAgentState(); void handleAgentStateResult(const LLSD &pContent, EAgentState pRequestedAgentState); -- cgit v1.2.3