PATH-341: BUGFIX Clamping the walkability coefficient text inputs to maximum value.

master
William Todd Stinson 2012-02-25 23:49:41 -08:00
parent 460a58bfc4
commit 3b4e4f8bc9
3 changed files with 24 additions and 3 deletions

View File

@ -141,6 +141,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild()
mEditA = findChild<LLLineEditor>("edit_a_value");
llassert(mEditA != NULL);
mEditA->setPrevalidate(LLTextValidate::validateNonNegativeS32);
mEditA->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1));
mLabelEditB = findChild<LLTextBase>("edit_b_label");
llassert(mLabelEditB != NULL);
@ -148,6 +149,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild()
mEditB = findChild<LLLineEditor>("edit_b_value");
llassert(mEditB != NULL);
mEditB->setPrevalidate(LLTextValidate::validateNonNegativeS32);
mEditB->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1));
mLabelEditC = findChild<LLTextBase>("edit_c_label");
llassert(mLabelEditC != NULL);
@ -155,6 +157,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild()
mEditC = findChild<LLLineEditor>("edit_c_value");
llassert(mEditC != NULL);
mEditC->setPrevalidate(LLTextValidate::validateNonNegativeS32);
mEditC->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1));
mLabelEditD = findChild<LLTextBase>("edit_d_label");
llassert(mLabelEditD != NULL);
@ -162,6 +165,7 @@ BOOL LLFloaterPathfindingLinksets::postBuild()
mEditD = findChild<LLLineEditor>("edit_d_value");
llassert(mEditD != NULL);
mEditD->setPrevalidate(LLTextValidate::validateNonNegativeS32);
mEditD->setCommitCallback(boost::bind(&LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered, this, _1));
mApplyEditsButton = findChild<LLButton>("apply_edit_values");
llassert(mApplyEditsButton != NULL);
@ -496,6 +500,21 @@ void LLFloaterPathfindingLinksets::onTeleportClicked()
}
}
void LLFloaterPathfindingLinksets::onWalkabilityCoefficientEntered(LLUICtrl *pUICtrl)
{
LLLineEditor *pLineEditor = static_cast<LLLineEditor *>(pUICtrl);
llassert(pLineEditor != NULL);
const std::string &valueString = pLineEditor->getText();
S32 value = static_cast<S32>(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();

View File

@ -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);

View File

@ -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;