Revision: 19673
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19673
Author:   campbellbarton
Date:     2009-04-12 09:24:04 +0200 (Sun, 12 Apr 2009)

Log Message:
-----------
added "toggle" an option for the property actuator.
much less hassle then setting up a property sensor and 2 assignment actuators, 
or through python.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_actuator_types.h
    trunk/blender/source/blender/src/buttons_logic.c
    trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.h

Modified: trunk/blender/source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_actuator_types.h  2009-04-12 
07:12:59 UTC (rev 19672)
+++ trunk/blender/source/blender/makesdna/DNA_actuator_types.h  2009-04-12 
07:24:04 UTC (rev 19673)
@@ -357,6 +357,7 @@
 #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

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c    2009-04-12 07:12:59 UTC 
(rev 19672)
+++ trunk/blender/source/blender/src/buttons_logic.c    2009-04-12 07:24:04 UTC 
(rev 19673)
@@ -1970,12 +1970,17 @@
                        
                        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");
                        }

Modified: trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.cpp  
2009-04-12 07:12:59 UTC (rev 19672)
+++ trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.cpp  
2009-04-12 07:24:04 UTC (rev 19673)
@@ -135,6 +135,23 @@
                                }
                                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:
                        {
 

Modified: trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.h
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.h    
2009-04-12 07:12:59 UTC (rev 19672)
+++ trunk/blender/source/gameengine/GameLogic/SCA_PropertyActuator.h    
2009-04-12 07:24:04 UTC (rev 19673)
@@ -43,6 +43,7 @@
                KX_ACT_PROP_ASSIGN,
                KX_ACT_PROP_ADD,
                KX_ACT_PROP_COPY,
+               KX_ACT_PROP_TOGGLE,
                KX_ACT_PROP_MAX
        };
        


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to