PropertyActuator toggle option didnt run when the Value field was empty.

This commit is contained in:
Campbell Barton 2009-04-12 16:10:43 +00:00
parent 332032fb99
commit 17f35293ee
2 changed files with 20 additions and 22 deletions

@ -1970,7 +1970,7 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
pa= act->data;
str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle%x3";
str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle (bool/int/float/timer)%x3";
uiDefButI(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &pa->type, 0, 31, 0, 0, "Type");
uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name");

@ -77,11 +77,25 @@ bool SCA_PropertyActuator::Update()
CParser parser;
parser.SetContext( propowner->AddRef());
CExpression* userexpr = parser.ProcessText(m_exprtxt);
if (userexpr)
CExpression* userexpr= NULL;
if (m_type==KX_ACT_PROP_TOGGLE)
{
/* dont use */
CValue* newval;
CValue* oldprop = propowner->GetProperty(m_propname);
if (oldprop)
{
newval = new CBoolValue((oldprop->GetNumber()==0.0) ? true:false);
oldprop->SetValue(newval);
} else
{ /* as not been assigned, evaluate as false, so assign true */
newval = new CBoolValue(true);
propowner->SetProperty(m_propname,newval);
}
newval->Release();
}
else if (userexpr = parser.ProcessText(m_exprtxt)) {
switch (m_type)
{
@ -135,23 +149,7 @@ bool SCA_PropertyActuator::Update()
}
break;
}
case KX_ACT_PROP_TOGGLE:
{
CValue* newval;
CValue* oldprop = propowner->GetProperty(m_propname);
if (oldprop)
{
newval = new CBoolValue((oldprop->GetNumber()==0.0) ? true:false);
oldprop->SetValue(newval);
} else
{ /* as not been assigned, evaluate as false, so assign true */
newval = new CBoolValue(true);
propowner->SetProperty(m_propname,newval);
}
newval->Release();
break;
}
/* case KX_ACT_PROP_TOGGLE: */ /* accounted for above, no need for userexpr */
default:
{