From 3b4e4f8bc98832ac5fdd211dbf4a611e24c076a6 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Sat, 25 Feb 2012 23:49:41 -0800 Subject: PATH-341: BUGFIX Clamping the walkability coefficient text inputs to maximum value. --- indra/newview/llfloaterpathfindinglinksets.cpp | 19 +++++++++++++++++++ indra/newview/llfloaterpathfindinglinksets.h | 2 ++ indra/newview/llpathfindinglinkset.h | 6 +++--- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index ad021c4286..11eae2386a 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -141,6 +141,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild() mEditA = findChild("edit_a_value"); llassert(mEditA != NULL); mEditA->setPrevalidate(LLTextValidate::validateNonNegativeS32); + mEditA->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1)); mLabelEditB = findChild("edit_b_label"); llassert(mLabelEditB != NULL); @@ -148,6 +149,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild() mEditB = findChild("edit_b_value"); llassert(mEditB != NULL); mEditB->setPrevalidate(LLTextValidate::validateNonNegativeS32); + mEditB->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1)); mLabelEditC = findChild("edit_c_label"); llassert(mLabelEditC != NULL); @@ -155,6 +157,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild() mEditC = findChild("edit_c_value"); llassert(mEditC != NULL); mEditC->setPrevalidate(LLTextValidate::validateNonNegativeS32); + mEditC->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1)); mLabelEditD = findChild("edit_d_label"); llassert(mLabelEditD != NULL); @@ -162,6 +165,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild() mEditD = findChild("edit_d_value"); llassert(mEditD != NULL); mEditD->setPrevalidate(LLTextValidate::validateNonNegativeS32); + mEditD->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1)); mApplyEditsButton = findChild("apply_edit_values"); llassert(mApplyEditsButton != NULL); @@ -496,6 +500,21 @@ void LLFloaterPathfindingLinksets::onTeleportClicked() } } +void LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl) +{ + LLLineEditor *pLineEditor = static_cast(pUICtrl); + llassert(pLineEditor != NULL); + + const std::string &valueString = pLineEditor->getText(); + S32 value = static_cast(atoi(valueString.c_str())); + + if ((value < LLPathfindingLinkset::MIN_WALKABILITY_VALUE) || (value > LLPathfindingLinkset::MAX_WALKABILITY_VALUE)) + { + value = llclamp(value, LLPathfindingLinkset::MIN_WALKABILITY_VALUE, LLPathfindingLinkset::MAX_WALKABILITY_VALUE); + pLineEditor->setValue(LLSD(value)); + } +} + void LLFloaterPathfindingLinksets::onApplyChangesClicked() { applyEdit(); diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h index 83c74c8530..1d26c00cd3 100644 --- a/indra/newview/llfloaterpathfindinglinksets.h +++ b/indra/newview/llfloaterpathfindinglinksets.h @@ -36,6 +36,7 @@ #include "llpathfindingmanager.h" class LLSD; +class LLUICtrl; class LLTextBase; class LLScrollListCtrl; class LLLineEditor; @@ -126,6 +127,7 @@ private: void onReturnClicked(); void onDeleteClicked(); void onTeleportClicked(); + void onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl); void onApplyChangesClicked(); void onAgentStateCB(LLPathfindingManager::EAgentState pAgentState); diff --git a/indra/newview/llpathfindinglinkset.h b/indra/newview/llpathfindinglinkset.h index 3f9217fa3c..590fcd3f1a 100644 --- a/indra/newview/llpathfindinglinkset.h +++ b/indra/newview/llpathfindinglinkset.h @@ -76,6 +76,9 @@ public: LLSD encodeAlteredFields(ELinksetUse pLinksetUse, S32 pA, S32 pB, S32 pC, S32 pD) const; + static const S32 MIN_WALKABILITY_VALUE; + static const S32 MAX_WALKABILITY_VALUE; + protected: private: @@ -86,9 +89,6 @@ private: static BOOL isPermanent(ELinksetUse pLinksetUse); static BOOL isWalkable(ELinksetUse pLinksetUse); - static const S32 MIN_WALKABILITY_VALUE; - static const S32 MAX_WALKABILITY_VALUE; - LLUUID mUUID; bool mIsTerrain; std::string mName; -- cgit v1.2.3