BGE API cleanup: StateActuator.
authorBenoit Bolsee <benoit.bolsee@online.be>
Thu, 9 Apr 2009 21:15:44 +0000 (21:15 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Thu, 9 Apr 2009 21:15:44 +0000 (21:15 +0000)
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_StateActuator.cpp
source/gameengine/Ketsji/KX_StateActuator.h
source/gameengine/PyDoc/KX_SoundActuator.py

index 8b8b62e93108ba792332befe6f3a1a04b9e953df..4ad9853f9c45af75d2f30157d1283776fbba97f4 100644 (file)
@@ -58,6 +58,7 @@
 #include "KX_ConstraintActuator.h"
 #include "KX_IpoActuator.h"
 #include "KX_SoundActuator.h"
+#include "KX_StateActuator.h"
 #include "BL_ActionActuator.h"
 #include "RAS_IRasterizer.h"
 #include "RAS_ICanvas.h"
@@ -1154,6 +1155,11 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
        KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL);
        KX_MACRO_addTypesToDict(d, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP, KX_SoundActuator::KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP);
 
+       KX_MACRO_addTypesToDict(d, KX_STATE_OP_CPY, KX_StateActuator::OP_CPY);
+       KX_MACRO_addTypesToDict(d, KX_STATE_OP_SET, KX_StateActuator::OP_SET);
+       KX_MACRO_addTypesToDict(d, KX_STATE_OP_CLR, KX_StateActuator::OP_CLR);
+       KX_MACRO_addTypesToDict(d, KX_STATE_OP_NEG, KX_StateActuator::OP_NEG);
+
 
        // Check for errors
        if (PyErr_Occurred())
index 31457230f60668474606f489a9ad08d0af35b907..e9e3c091ef3d3288f64edc1d294773563553eda8 100644 (file)
@@ -138,14 +138,18 @@ KX_StateActuator::Parents[] = {
 
 PyMethodDef 
 KX_StateActuator::Methods[] = {
+       // deprecated -->
        {"setOperation", (PyCFunction) KX_StateActuator::sPySetOperation, 
         METH_VARARGS, (PY_METHODCHAR)SetOperation_doc},
        {"setMask", (PyCFunction) KX_StateActuator::sPySetMask, 
         METH_VARARGS, (PY_METHODCHAR)SetMask_doc},
+        // <--
        {NULL,NULL} //Sentinel
 };
 
 PyAttributeDef KX_StateActuator::Attributes[] = {
+       KX_PYATTRIBUTE_INT_RW("operation",KX_StateActuator::OP_NOP+1,KX_StateActuator::OP_COUNT-1,false,KX_StateActuator,m_operation),
+       KX_PYATTRIBUTE_INT_RW("mask",0,0x3FFFFFFF,false,KX_StateActuator,m_mask),
        { NULL }        //Sentinel
 };
 
@@ -154,6 +158,10 @@ PyObject* KX_StateActuator::py_getattro(PyObject *attr)
        py_getattro_up(SCA_IActuator);
 };
 
+int KX_StateActuator::py_setattro(PyObject *attr, PyObject* value)
+{
+       py_setattro_up(SCA_IActuator);
+}
 
 
 /* set operation ---------------------------------------------------------- */
@@ -168,6 +176,7 @@ PyObject*
 KX_StateActuator::PySetOperation(PyObject* self, 
                                    PyObject* args, 
                                    PyObject* kwds) {
+       ShowDeprecationWarning("setOperation()", "the operation property");
        int oper;
 
        if(!PyArg_ParseTuple(args, "i", &oper)) {
@@ -193,6 +202,7 @@ PyObject*
 KX_StateActuator::PySetMask(PyObject* self, 
                                    PyObject* args, 
                                    PyObject* kwds) {
+       ShowDeprecationWarning("setMask()", "the mask property");
        int mask;
 
        if(!PyArg_ParseTuple(args, "i", &mask)) {
index b6f1acf4a00b13d6cf406f599e9c59b2dd46f39d..426753dadfd3c0bab740c6d7719002739166804c 100644 (file)
@@ -39,13 +39,15 @@ class KX_StateActuator : public SCA_IActuator
 
        /** Make visible? */
        enum {
+               OP_NOP = -1,
                OP_CPY = 0,
                OP_SET,
                OP_CLR,
-               OP_NEG
+               OP_NEG,
+               OP_COUNT
        };
        int                             m_operation;
-       unsigned int    m_mask;
+       int                             m_mask;
 
  public:
        
@@ -74,6 +76,7 @@ class KX_StateActuator : public SCA_IActuator
        /* --------------------------------------------------------------------- */
 
        virtual PyObject* py_getattro(PyObject *attr);
+       virtual int py_setattro(PyObject *attr, PyObject* value);
        //KX_PYMETHOD_DOC
        KX_PYMETHOD_DOC(KX_StateActuator,SetOperation);
        KX_PYMETHOD_DOC(KX_StateActuator,SetMask);
index 383b45e6eb94797244bf0adcc05cb861d2138ee9..37ae3c6640d2ec666e89782904bcf84fdc6ea382 100644 (file)
@@ -7,7 +7,8 @@ class KX_SoundActuator(SCA_IActuator):
        Sound Actuator.
        
        The L{startSound()}, L{pauseSound()} and L{stopSound()} do not require
-       the actuator to be activated - they act instantly.
+       the actuator to be activated - they act instantly provided that the actuator has
+       been activated once at least.
 
        @ivar filename: Sets the filename of the sound this actuator plays.
        @type filename: string