added "toggle" an option for the property actuator.

much less hassle then setting up a property sensor and 2 assignment actuators, or through python.
This commit is contained in:
Campbell Barton 2009-04-12 07:24:04 +00:00
parent 33170295c8
commit 55d2b184ec
4 changed files with 26 additions and 2 deletions

@ -357,6 +357,7 @@ typedef struct FreeCamera {
#define ACT_PROP_ASSIGN 0
#define ACT_PROP_ADD 1
#define ACT_PROP_COPY 2
#define ACT_PROP_TOGGLE 3
/* constraint flag */
#define ACT_CONST_LOCX 1

@ -1970,12 +1970,17 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
pa= act->data;
str= "Type %t|Assign %x0|Add %x1|Copy %x2";
str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle%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");
if(pa->type==ACT_PROP_COPY) {
if(pa->type==ACT_PROP_TOGGLE) {
/* no ui */
ysize -= 22;
}
else if(pa->type==ACT_PROP_COPY) {
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object");
uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, 31, 0, 0, "Copy this property");
}

@ -135,6 +135,23 @@ 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;
}
default:
{

@ -43,6 +43,7 @@ class SCA_PropertyActuator : public SCA_IActuator
KX_ACT_PROP_ASSIGN,
KX_ACT_PROP_ADD,
KX_ACT_PROP_COPY,
KX_ACT_PROP_TOGGLE,
KX_ACT_PROP_MAX
};