BGE API cleanup: action actuator.
authorBenoit Bolsee <benoit.bolsee@online.be>
Wed, 21 Jan 2009 13:54:53 +0000 (13:54 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Wed, 21 Jan 2009 13:54:53 +0000 (13:54 +0000)
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ActionActuator.h
source/gameengine/PyDoc/BL_ActionActuator.py

index 4d748948c27170bf5f2dc3fcbcc1ef3f824ac9d9..c05f763cacbfe47725e2997fa4334b709ce36d8d 100644 (file)
@@ -52,6 +52,8 @@
 #include "FloatValue.h"
 #include "PyObjectPlus.h"
 
+#include "blendef.h"
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -418,67 +420,6 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
 /* Python functions                                                          */
 /* ------------------------------------------------------------------------- */
 
-/* Integration hooks ------------------------------------------------------- */
-
-PyTypeObject BL_ActionActuator::Type = {
-       PyObject_HEAD_INIT(&PyType_Type)
-               0,
-               "BL_ActionActuator",
-               sizeof(BL_ActionActuator),
-               0,
-               PyDestructor,
-               0,
-               __getattr,
-               __setattr,
-               0, //&MyPyCompare,
-               __repr,
-               0, //&cvalue_as_number,
-               0,
-               0,
-               0,
-               0
-};
-
-PyParentObject BL_ActionActuator::Parents[] = {
-       &BL_ActionActuator::Type,
-               &SCA_IActuator::Type,
-               &SCA_ILogicBrick::Type,
-               &CValue::Type,
-               NULL
-};
-
-PyMethodDef BL_ActionActuator::Methods[] = {
-       {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
-       {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
-       {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc},
-       {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc},
-       {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc},
-       {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc},
-       {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
-       {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc},
-       {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc},
-
-       {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc},
-       {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc},
-       {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc},
-       {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc},
-       {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc},
-       {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc},
-       {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
-       {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc},
-       {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, (PY_METHODCHAR)SetChannel_doc},
-//     {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
-       {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
-       {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
-       {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0},       
-       {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0},
-       {NULL,NULL} //Sentinel
-};
-
-PyObject* BL_ActionActuator::_getattr(const STR_String& attr) {
-       _getattr_up(SCA_IActuator);
-}
-
 /*     setStart                                                              */
 const char BL_ActionActuator::GetAction_doc[] = 
 "getAction()\n"
@@ -487,6 +428,8 @@ const char BL_ActionActuator::GetAction_doc[] =
 PyObject* BL_ActionActuator::PyGetAction(PyObject* self, 
                                                                                 PyObject* args, 
                                                                                 PyObject* kwds) {
+       ShowDeprecationWarning("getAction()", "the action property");
+
        if (m_action){
                return PyString_FromString(m_action->id.name+2);
        }
@@ -501,6 +444,8 @@ const char BL_ActionActuator::GetProperty_doc[] =
 PyObject* BL_ActionActuator::PyGetProperty(PyObject* self, 
                                                                                   PyObject* args, 
                                                                                   PyObject* kwds) {
+       ShowDeprecationWarning("getProperty()", "the property property");
+
        PyObject *result;
        
        result = Py_BuildValue("s", (const char *)m_propname);
@@ -516,6 +461,8 @@ const char BL_ActionActuator::GetFrameProperty_doc[] =
 PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* self, 
                                                                                   PyObject* args, 
                                                                                   PyObject* kwds) {
+       ShowDeprecationWarning("getFrameProperty()", "the frameProperty property");
+
        PyObject *result;
        
        result = Py_BuildValue("s", (const char *)m_framepropname);
@@ -531,6 +478,8 @@ const char BL_ActionActuator::GetFrame_doc[] =
 PyObject* BL_ActionActuator::PyGetFrame(PyObject* self, 
                                                                                PyObject* args, 
                                                                                PyObject* kwds) {
+       ShowDeprecationWarning("getFrame()", "the frame property");
+
        PyObject *result;
        
        result = Py_BuildValue("f", m_localtime);
@@ -546,6 +495,8 @@ const char BL_ActionActuator::GetEnd_doc[] =
 PyObject* BL_ActionActuator::PyGetEnd(PyObject* self, 
                                                                          PyObject* args, 
                                                                          PyObject* kwds) {
+       ShowDeprecationWarning("getEnd()", "the end property");
+
        PyObject *result;
        
        result = Py_BuildValue("f", m_endframe);
@@ -561,6 +512,8 @@ const char BL_ActionActuator::GetStart_doc[] =
 PyObject* BL_ActionActuator::PyGetStart(PyObject* self, 
                                                                                PyObject* args, 
                                                                                PyObject* kwds) {
+       ShowDeprecationWarning("getStart()", "the start property");
+
        PyObject *result;
        
        result = Py_BuildValue("f", m_startframe);
@@ -577,6 +530,8 @@ const char BL_ActionActuator::GetBlendin_doc[] =
 PyObject* BL_ActionActuator::PyGetBlendin(PyObject* self, 
                                                                                  PyObject* args, 
                                                                                  PyObject* kwds) {
+       ShowDeprecationWarning("getBlendin()", "the blendin property");
+
        PyObject *result;
        
        result = Py_BuildValue("f", m_blendin);
@@ -593,6 +548,8 @@ const char BL_ActionActuator::GetPriority_doc[] =
 PyObject* BL_ActionActuator::PyGetPriority(PyObject* self, 
                                                                                   PyObject* args, 
                                                                                   PyObject* kwds) {
+       ShowDeprecationWarning("getPriority()", "the priority property");
+
        PyObject *result;
        
        result = Py_BuildValue("i", m_priority);
@@ -613,6 +570,8 @@ const char BL_ActionActuator::SetAction_doc[] =
 PyObject* BL_ActionActuator::PySetAction(PyObject* self, 
                                                                                 PyObject* args, 
                                                                                 PyObject* kwds) {
+       ShowDeprecationWarning("setAction()", "the action property");
+
        char *string;
        int     reset = 1;
 
@@ -647,6 +606,8 @@ const char BL_ActionActuator::SetStart_doc[] =
 PyObject* BL_ActionActuator::PySetStart(PyObject* self, 
                                                                                PyObject* args, 
                                                                                PyObject* kwds) {
+       ShowDeprecationWarning("setStart()", "the start property");
+
        float start;
        
        if (PyArg_ParseTuple(args,"f",&start))
@@ -668,6 +629,8 @@ const char BL_ActionActuator::SetEnd_doc[] =
 PyObject* BL_ActionActuator::PySetEnd(PyObject* self, 
                                                                          PyObject* args, 
                                                                          PyObject* kwds) {
+       ShowDeprecationWarning("setEnd()", "the end property");
+
        float end;
        
        if (PyArg_ParseTuple(args,"f",&end))
@@ -690,6 +653,8 @@ const char BL_ActionActuator::SetBlendin_doc[] =
 PyObject* BL_ActionActuator::PySetBlendin(PyObject* self, 
                                                                                  PyObject* args, 
                                                                                  PyObject* kwds) {
+       ShowDeprecationWarning("setBlendin()", "the blendin property");
+
        float blendin;
        
        if (PyArg_ParseTuple(args,"f",&blendin))
@@ -713,6 +678,8 @@ const char BL_ActionActuator::SetBlendtime_doc[] =
 PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self, 
                                                                                  PyObject* args, 
                                                                                  PyObject* kwds) {
+       ShowDeprecationWarning("setBlendtime()", "the blendtime property");
+
        float blendframe;
        
        if (PyArg_ParseTuple(args,"f",&blendframe))
@@ -740,6 +707,8 @@ const char BL_ActionActuator::SetPriority_doc[] =
 PyObject* BL_ActionActuator::PySetPriority(PyObject* self, 
                                                                                   PyObject* args, 
                                                                                   PyObject* kwds) {
+       ShowDeprecationWarning("setPriority()", "the priority property");
+
        int priority;
        
        if (PyArg_ParseTuple(args,"i",&priority))
@@ -761,6 +730,8 @@ const char BL_ActionActuator::SetFrame_doc[] =
 PyObject* BL_ActionActuator::PySetFrame(PyObject* self, 
                                                                                PyObject* args, 
                                                                                PyObject* kwds) {
+       ShowDeprecationWarning("setFrame()", "the frame property");
+
        float frame;
        
        if (PyArg_ParseTuple(args,"f",&frame))
@@ -787,6 +758,8 @@ const char BL_ActionActuator::SetProperty_doc[] =
 PyObject* BL_ActionActuator::PySetProperty(PyObject* self, 
                                                                                   PyObject* args, 
                                                                                   PyObject* kwds) {
+       ShowDeprecationWarning("setProperty()", "the property property");
+
        char *string;
        
        if (PyArg_ParseTuple(args,"s",&string))
@@ -808,6 +781,8 @@ const char BL_ActionActuator::SetFrameProperty_doc[] =
 PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self, 
                                                                                   PyObject* args, 
                                                                                   PyObject* kwds) {
+       ShowDeprecationWarning("setFrameProperty()", "the frameProperty property");
+
        char *string;
        
        if (PyArg_ParseTuple(args,"s",&string))
@@ -839,16 +814,80 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self,
 }
 */
 
-/*     setChannel                                                            */
-const char BL_ActionActuator::SetChannel_doc[] = 
+/* getType */
+const char BL_ActionActuator::GetType_doc[] =
+"getType()\n"
+"\tReturns the operation mode of the actuator.\n";
+PyObject* BL_ActionActuator::PyGetType(PyObject* self,
+                                       PyObject* args, 
+                                       PyObject* kwds) {
+       ShowDeprecationWarning("getType()", "the type property");
+
+    return Py_BuildValue("h", m_playtype);
+}
+
+/* setType */
+const char BL_ActionActuator::SetType_doc[] =
+"setType(mode)\n"
+"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n"
+"\tSet the operation mode of the actuator.\n";
+PyObject* BL_ActionActuator::PySetType(PyObject* self,
+                                       PyObject* args,
+                                       PyObject* kwds) {
+       ShowDeprecationWarning("setType()", "the type property");
+
+       short typeArg;
+                                                                                                             
+    if (!PyArg_ParseTuple(args, "h", &typeArg)) {
+        return NULL;
+    }
+
+       switch (typeArg) {
+       case KX_ACT_ACTION_PLAY:
+       case KX_ACT_ACTION_FLIPPER:
+       case KX_ACT_ACTION_LOOPSTOP:
+       case KX_ACT_ACTION_LOOPEND:
+       case KX_ACT_ACTION_PROPERTY:
+               m_playtype = typeArg;
+               break;
+       default:
+               printf("Invalid type for action actuator: %d\n", typeArg); /* error */
+    }
+       Py_RETURN_NONE;
+}
+
+PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) {
+       ShowDeprecationWarning("getContinue()", "the continue property");
+
+    return PyInt_FromLong((long)(m_end_reset==0));
+}
+
+PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) {
+       ShowDeprecationWarning("setContinue()", "the continue property");
+
+       int param = PyObject_IsTrue( value );
+       
+       if( param == -1 ) {
+               PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" );
+               return NULL;
+       }
+
+       if (param) {
+               m_end_reset = 0;
+       } else {
+               m_end_reset = 1;
+       }
+    Py_RETURN_NONE;
+}
+
+//<-----Deprecated
+
+/*     setChannel                                                         */
+KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
 "setChannel(channel, matrix)\n"
 "\t - channel   : A string specifying the name of the bone channel.\n"
 "\t - matrix    : A 4x4 matrix specifying the overriding transformation\n"
-"\t               as an offset from the bone's rest position.\n";
-
-PyObject* BL_ActionActuator::PySetChannel(PyObject* self, 
-                                                                                  PyObject* args, 
-                                                                                  PyObject* kwds) 
+"\t               as an offset from the bone's rest position.\n")
 {
        float matrix[4][4];
        char *string;
@@ -923,61 +962,123 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self,
        Py_RETURN_NONE;
 }
 
-/* getType */
-const char BL_ActionActuator::GetType_doc[] =
-"getType()\n"
-"\tReturns the operation mode of the actuator.\n";
-PyObject* BL_ActionActuator::PyGetType(PyObject* self,
-                                       PyObject* args, 
-                                       PyObject* kwds) {
-    return Py_BuildValue("h", m_playtype);
-}
+/* ------------------------------------------------------------------------- */
+/* Python Integration Hooks                                                                     */
+/* ------------------------------------------------------------------------- */
 
-/* setType */
-const char BL_ActionActuator::SetType_doc[] =
-"setType(mode)\n"
-"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n"
-"\tSet the operation mode of the actuator.\n";
-PyObject* BL_ActionActuator::PySetType(PyObject* self,
-                                       PyObject* args,
-                                       PyObject* kwds) {
-       short typeArg;
-                                                                                                             
-    if (!PyArg_ParseTuple(args, "h", &typeArg)) {
-        return NULL;
-    }
+PyTypeObject BL_ActionActuator::Type = {
+       PyObject_HEAD_INIT(&PyType_Type)
+               0,
+               "BL_ActionActuator",
+               sizeof(BL_ActionActuator),
+               0,
+               PyDestructor,
+               0,
+               __getattr,
+               __setattr,
+               0, //&MyPyCompare,
+               __repr,
+               0, //&cvalue_as_number,
+               0,
+               0,
+               0,
+               0
+};
 
-       switch (typeArg) {
-       case KX_ACT_ACTION_PLAY:
-       case KX_ACT_ACTION_FLIPPER:
-       case KX_ACT_ACTION_LOOPSTOP:
-       case KX_ACT_ACTION_LOOPEND:
-       case KX_ACT_ACTION_PROPERTY:
-               m_playtype = typeArg;
-               break;
-       default:
-               printf("Invalid type for action actuator: %d\n", typeArg); /* error */
-    }
-       Py_RETURN_NONE;
-}
+PyParentObject BL_ActionActuator::Parents[] = {
+       &BL_ActionActuator::Type,
+               &SCA_IActuator::Type,
+               &SCA_ILogicBrick::Type,
+               &CValue::Type,
+               NULL
+};
 
-PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) {
-    return PyInt_FromLong((long)(m_end_reset==0));
-}
+PyMethodDef BL_ActionActuator::Methods[] = {
+       //Deprecated ----->
+       {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
+       {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
+       {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc},
+       {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc},
+       {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc},
+       {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc},
+       {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+       {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc},
+       {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc},
 
-PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) {
-       int param = PyObject_IsTrue( value );
-       
-       if( param == -1 ) {
-               PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" );
-               return NULL;
-       }
+       {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc},
+       {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc},
+       {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc},
+       {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc},
+       {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc},
+       {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc},
+       {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+       {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc},
+//     {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
+       {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
+       {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
+       {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0},       
+       {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0},
+       //<------
+       KX_PYMETHODTABLE(BL_ActionActuator, setChannel),
+       {NULL,NULL} //Sentinel
+};
 
-       if (param) {
-               m_end_reset = 0;
-       } else {
-               m_end_reset = 1;
-       }
-    Py_RETURN_NONE;
+PyAttributeDef BL_ActionActuator::Attributes[] = {
+       KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
+       KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
+       KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
+       KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
+       KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ActionActuator, m_localtime, CheckFrame),
+       KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ActionActuator, m_propname),
+       KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ActionActuator, m_framepropname),
+       KX_PYATTRIBUTE_BOOL_RW("continue", BL_ActionActuator, m_end_reset),
+       KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
+       KX_PYATTRIBUTE_ENUM_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType),
+       { NULL }        //Sentinel
+};
+
+PyObject* BL_ActionActuator::_getattr(const STR_String& attr) {
+       if (attr == "action")
+               return PyString_FromString(m_action->id.name+2);
+       PyObject* object = _getattr_self(Attributes, this, attr);
+       if (object != NULL)
+               return object;
+       _getattr_up(SCA_IActuator);
 }
 
+int BL_ActionActuator::_setattr(const STR_String& attr, PyObject* value) {
+       if (attr == "action")
+       {
+               if (!PyString_Check(value))
+               {
+                       PyErr_SetString(PyExc_ValueError, "expected a string");
+                       return 1;
+               }
+
+               STR_String val = PyString_AsString(value);
+               
+               if (val == "")
+               {
+                       m_action = NULL;
+                       return 0;
+               }
+
+               bAction *action;
+               
+               action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
+               
+
+               if (!action)
+               {
+                       PyErr_SetString(PyExc_ValueError, "action not found!");
+                       return 1;
+               }
+
+               m_action = action;
+               return 0;
+       }
+       int ret = _setattr_self(Attributes, this, attr, value);
+       if (ret >= 0)
+               return ret;
+       return SCA_IActuator::_setattr(attr, value);
+}
\ No newline at end of file
index a67b6d29b7453abdc366916f12467cfcc927da1a..04bd9c803c5757f3f12f4d5b16f8759775929c7f 100644 (file)
@@ -81,6 +81,7 @@ public:
        
        void SetBlendTime (float newtime);
 
+       //Deprecated ----->
        KX_PYMETHOD_DOC(BL_ActionActuator,SetAction);
        KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendin);
        KX_PYMETHOD_DOC(BL_ActionActuator,SetPriority);
@@ -90,7 +91,6 @@ public:
        KX_PYMETHOD_DOC(BL_ActionActuator,SetProperty);
        KX_PYMETHOD_DOC(BL_ActionActuator,SetFrameProperty);
        KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendtime);
-       KX_PYMETHOD_DOC(BL_ActionActuator,SetChannel);
 
        KX_PYMETHOD_DOC(BL_ActionActuator,GetAction);
        KX_PYMETHOD_DOC(BL_ActionActuator,GetBlendin);
@@ -105,8 +105,12 @@ public:
        KX_PYMETHOD_DOC(BL_ActionActuator,SetType);
        KX_PYMETHOD_NOARGS(BL_ActionActuator,GetContinue);
        KX_PYMETHOD_O(BL_ActionActuator,SetContinue);
+       //<-----
+
+       KX_PYMETHOD_DOC(BL_ActionActuator,setChannel);
 
        virtual PyObject* _getattr(const STR_String& attr);
+       virtual int _setattr(const STR_String& attr, PyObject* value);
 
        enum ActionActType
        {
@@ -117,6 +121,46 @@ public:
                KX_ACT_ACTION_PROPERTY = 6
        };
 
+       /* attribute check */
+       static int CheckFrame(void *self, const PyAttributeDef*)
+       {
+               BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
+
+               if (act->m_localtime < act->m_startframe)
+                       act->m_localtime = act->m_startframe;
+               else if (act->m_localtime > act->m_endframe)
+                       act->m_localtime = act->m_endframe;
+
+               return 0;
+       }
+
+       static int CheckBlendTime(void *self, const PyAttributeDef*)
+       {
+               BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
+
+               if (act->m_blendframe < act->m_blendin)
+                       act->m_blendframe = act->m_blendin;
+
+               return 0;
+       }
+
+       static int CheckType(void *self, const PyAttributeDef*)
+       {
+               BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
+
+               switch (act->m_playtype) {
+                       case KX_ACT_ACTION_PLAY:
+                       case KX_ACT_ACTION_FLIPPER:
+                       case KX_ACT_ACTION_LOOPSTOP:
+                       case KX_ACT_ACTION_LOOPEND:
+                       case KX_ACT_ACTION_PROPERTY:
+                               return 0;
+                       default:
+                               PyErr_SetString(PyExc_ValueError, "invalid type supplied");
+                               return 1;
+               }
+
+       }
 protected:
 
        void SetStartTime(float curtime);
@@ -141,7 +185,7 @@ protected:
        float   m_stridelength;
        short   m_playtype;
        short   m_priority;
-       short   m_end_reset;
+       bool    m_end_reset;
        struct bPose* m_pose;
        struct bPose* m_blendpose;
        struct bPose* m_userpose;
index b68d301411545e8587fb178a6e47c5b0cbafda09..5d6ea51060bb4172e978628af2e645e48ed64da8 100644 (file)
@@ -5,7 +5,49 @@ from SCA_IActuator import *
 class BL_ActionActuator(SCA_IActuator):
        """
        Action Actuators apply an action to an actor.
+       
+       @ivar action: The name of the action to set as the current action.
+       @type action: string
+       @ivar start: Specifies the starting frame of the animation.
+       @type start: float
+       @type end: Specifies the ending frame of the animation.
+       @type end: float
+       @ivar blendin: Specifies the number of frames of animation to generate when making transitions between actions.
+       @type blendin: float
+       @ivar priority: Sets the priority of this actuator. Actuators will lower
+                                priority numbers will override actuators with higher
+                                numbers.
+       @type priority: integer
+       @ivar frame: Sets the current frame for the animation.
+       @type frame: float
+       @ivar property: Sets the property to be used in FromProp playback mode.
+       @type property: string
+       @ivar blendTime: Sets the internal frame timer. This property must be in
+                                               the range from 0.0 to 1.0.
+       @type blendTime: float
+       @ivar type: The operation mode of the actuator.
+                                       KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER,
+                                       KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+       @type type: integer
+       @ivar continue: The actions continue option, True or False.
+                                       When True, the action will always play from where last left off,
+                                       otherwise negative events to this actuator will reset it to its start frame.
+       @type: boolean
+       @ivar frameProperty: The name of the property that is set to the current frame number.
+       @type frameProperty: string
        """
+       def setChannel(channel, matrix, mode = False):
+               """
+               @param channel: A string specifying the name of the bone channel.
+               @type channel: string
+               @param matrix: A 4x4 matrix specifying the overriding transformation
+                              as an offset from the bone's rest position.
+               @type matrix: list [[float]]
+               @param mode: True for armature/world space, False for bone space
+               @type mode: boolean
+               """
+
+       #--The following methods are deprecated--
        def setAction(action, reset = True):
                """
                Sets the current action.
@@ -154,16 +196,6 @@ class BL_ActionActuator(SCA_IActuator):
                
                @rtype: string
                """
-       def setChannel(channel, matrix, mode = False):
-               """
-               @param channel: A string specifying the name of the bone channel.
-               @type channel: string
-               @param matrix: A 4x4 matrix specifying the overriding transformation
-                              as an offset from the bone's rest position.
-               @type matrix: list [[float]]
-               @param mode: True for armature/world space, False for bone space
-               @type mode: boolean
-               """
        def setFrameProperty(prop):
                """
                @param prop: A string specifying the property of the object that will be updated with the action frame number.