From 17f35293ee9d83605db7d73e7213d206d507a587 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Apr 2009 16:10:43 +0000 Subject: [PATCH] PropertyActuator toggle option didnt run when the Value field was empty. --- source/blender/src/buttons_logic.c | 2 +- .../GameLogic/SCA_PropertyActuator.cpp | 40 +++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 1f604aa8480..97f07c7553c 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -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"); diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 37df8a5c401..359ab8adac6 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -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: {