Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-04-12 11:24:04 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-12 11:24:04 +0400
commit55d2b184ec1b2c1adfe182ead937cedae1a8208d (patch)
tree580d5d4efa458f2e834708bac799902b6c5e997f
parent33170295c8a2f3eb815b6086f47147113fd3de13 (diff)
added "toggle" an option for the property actuator.
much less hassle then setting up a property sensor and 2 assignment actuators, or through python.
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h1
-rw-r--r--source/blender/src/buttons_logic.c9
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h1
4 files changed, 26 insertions, 2 deletions
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index 48432b8c6e2..2252126b46c 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -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
diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c
index 56879f80198..1f604aa8480 100644
--- a/source/blender/src/buttons_logic.c
+++ b/source/blender/src/buttons_logic.c
@@ -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");
}
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 444c616870d..37df8a5c401 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -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:
{
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index 6a975716ed0..bb841cf88ad 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -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
};