diff options
author | Todd Stinson <stinson@lindenlab.com> | 2012-02-17 19:03:16 -0800 |
---|---|---|
committer | Todd Stinson <stinson@lindenlab.com> | 2012-02-17 19:03:16 -0800 |
commit | 516ad5b3c234321daf01294d6e03bdc4be019d36 (patch) | |
tree | 3b54deb5a43aad06967b6a29e933514f32b9206b /indra/newview/llfloaterpathfindingbasic.cpp | |
parent | 35b09a722e72a397a1e1e7aacbda8f39f4c1faa5 (diff) |
PATH-292: Implementing the new freeze/unfreeze functionality on the basic panel.
Diffstat (limited to 'indra/newview/llfloaterpathfindingbasic.cpp')
-rw-r--r-- | indra/newview/llfloaterpathfindingbasic.cpp | 122 |
1 files changed, 69 insertions, 53 deletions
diff --git a/indra/newview/llfloaterpathfindingbasic.cpp b/indra/newview/llfloaterpathfindingbasic.cpp index a1c333989e..fc46a75259 100644 --- a/indra/newview/llfloaterpathfindingbasic.cpp +++ b/indra/newview/llfloaterpathfindingbasic.cpp @@ -25,14 +25,14 @@ * $/LicenseInfo$
*/
+#include <boost/bind.hpp>
+
#include "llviewerprecompiledheaders.h"
#include "llfloaterpathfindingbasic.h"
-
#include "llsd.h"
-#include "llagent.h"
#include "lltextbase.h"
#include "llbutton.h"
-#include "llviewerregion.h"
+#include "llpathfindingmanager.h"
//---------------------------------------------------------------------------
// LLFloaterPathfindingBasic
@@ -40,8 +40,8 @@ BOOL LLFloaterPathfindingBasic::postBuild()
{
- mRegionNotEnabledText = findChild<LLTextBase>("disabled_warning_label");
- llassert(mRegionNotEnabledText != NULL);
+ mStatusText = findChild<LLTextBase>("status_label");
+ llassert(mStatusText != NULL);
mUnfreezeLabel = findChild<LLTextBase>("unfreeze_label");
llassert(mUnfreezeLabel != NULL);
@@ -57,23 +57,32 @@ BOOL LLFloaterPathfindingBasic::postBuild() llassert(mFreezeButton != NULL);
mFreezeButton->setCommitCallback(boost::bind(&LLFloaterPathfindingBasic::onFreezeClicked, this));
- updateOnFrozenState();
-
return LLFloater::postBuild();
}
void LLFloaterPathfindingBasic::onOpen(const LLSD& key)
{
+ LLPathfindingManager *pathfindingManager = LLPathfindingManager::getInstance();
+ if (pathfindingManager->isPathfindingEnabledForCurrentRegion())
+ {
+ LLPathfindingManager::getInstance()->requestGetAgentState(boost::bind(&LLFloaterPathfindingBasic::onAgentStateCB, this, _1));
+ }
+ else
+ {
+ setAgentState(LLPathfindingManager::kAgentStateNotEnabled);
+ }
+
+ LLFloater::onOpen(key);
}
LLFloaterPathfindingBasic::LLFloaterPathfindingBasic(const LLSD& pSeed)
: LLFloater(pSeed),
- mRegionNotEnabledText(NULL),
+ mStatusText(NULL),
mUnfreezeLabel(NULL),
mUnfreezeButton(NULL),
mFreezeLabel(NULL),
mFreezeButton(NULL),
- mIsRegionFrozenXXX(true)
+ mAgentState(LLPathfindingManager::kAgentStateNotEnabled)
{
}
@@ -81,61 +90,68 @@ LLFloaterPathfindingBasic::~LLFloaterPathfindingBasic() {
}
-std::string LLFloaterPathfindingBasic::getCapabilityURL() const
+void LLFloaterPathfindingBasic::onUnfreezeClicked()
{
- std::string capURL("");
+ mUnfreezeButton->setEnabled(FALSE);
+ LLPathfindingManager::getInstance()->requestSetAgentState(LLPathfindingManager::kAgentStateUnfrozen, boost::bind(&LLFloaterPathfindingBasic::onAgentStateCB, this, _1));
+}
- LLViewerRegion *region = gAgent.getRegion();
- if (region != NULL)
- {
- capURL = region->getCapability("RetrieveNavMeshSrc");
- }
+void LLFloaterPathfindingBasic::onFreezeClicked()
+{
+ mUnfreezeButton->setEnabled(FALSE);
+ LLPathfindingManager::getInstance()->requestSetAgentState(LLPathfindingManager::kAgentStateFrozen, boost::bind(&LLFloaterPathfindingBasic::onAgentStateCB, this, _1));
+}
- return capURL;
+void LLFloaterPathfindingBasic::onAgentStateCB(LLPathfindingManager::EAgentState pAgentState)
+{
+ setAgentState(pAgentState);
}
-void LLFloaterPathfindingBasic::updateOnFrozenState()
+void LLFloaterPathfindingBasic::setAgentState(LLPathfindingManager::EAgentState pAgentState)
{
- std::string capURL = getCapabilityURL();
+ switch (pAgentState)
+ {
+ case LLPathfindingManager::kAgentStateNotEnabled :
+ mStatusText->setVisible(TRUE);
+ mStatusText->setText((LLStringExplicit)getString("pathfinding_not_enabled"));
+ mAgentState = pAgentState;
+ break;
+ case LLPathfindingManager::kAgentStateError :
+ mStatusText->setVisible(TRUE);
+ mStatusText->setText((LLStringExplicit)getString("unable_to_change_state"));
+ // Do not actually change the current state in the error case allowing user to retry previous command
+ break;
+ default :
+ mStatusText->setVisible(FALSE);
+ mAgentState = pAgentState;
+ break;
+ }
- if (capURL.empty())
+ switch (mAgentState)
{
- mRegionNotEnabledText->setVisible(TRUE);
+ case LLPathfindingManager::kAgentStateNotEnabled :
mUnfreezeLabel->setEnabled(FALSE);
mUnfreezeButton->setEnabled(FALSE);
mFreezeLabel->setEnabled(FALSE);
mFreezeButton->setEnabled(FALSE);
+ break;
+ case LLPathfindingManager::kAgentStateFrozen :
+ mUnfreezeLabel->setEnabled(TRUE);
+ mUnfreezeButton->setEnabled(TRUE);
+ mFreezeLabel->setEnabled(FALSE);
+ mFreezeButton->setEnabled(FALSE);
+ break;
+ case LLPathfindingManager::kAgentStateUnfrozen :
+ mUnfreezeLabel->setEnabled(FALSE);
+ mUnfreezeButton->setEnabled(FALSE);
+ mFreezeLabel->setEnabled(TRUE);
+ mFreezeButton->setEnabled(TRUE);
+ break;
+ case LLPathfindingManager::kAgentStateError :
+ llassert(0);
+ break;
+ default :
+ llassert(0);
+ break;
}
- else
- {
- mRegionNotEnabledText->setVisible(FALSE);
- if (mIsRegionFrozenXXX)
- {
- mUnfreezeLabel->setEnabled(TRUE);
- mUnfreezeButton->setEnabled(TRUE);
- mFreezeLabel->setEnabled(FALSE);
- mFreezeButton->setEnabled(FALSE);
- }
- else
- {
- mUnfreezeLabel->setEnabled(FALSE);
- mUnfreezeButton->setEnabled(FALSE);
- mFreezeLabel->setEnabled(TRUE);
- mFreezeButton->setEnabled(TRUE);
- }
- }
-}
-
-void LLFloaterPathfindingBasic::onUnfreezeClicked()
-{
- mIsRegionFrozenXXX = false;
- updateOnFrozenState();
- llwarns << "functionality has not yet been implemented to set unfrozen state" << llendl;
-}
-
-void LLFloaterPathfindingBasic::onFreezeClicked()
-{
- mIsRegionFrozenXXX = true;
- updateOnFrozenState();
- llwarns << "functionality has not yet been implemented to set frozen state" << llendl;
}
|