diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-20 19:06:46 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-20 19:06:46 +0400 |
commit | 874c29cea8e6f9bc411fccf2d6f4cb07e94328d0 (patch) | |
tree | 5971e577cf7c02e05a1e37b5ad058c71a6744877 /source/gameengine/GameLogic/SCA_PropertyActuator.cpp | |
parent | 7555bfa793a2b0fc187c6211c56986f35b2d7b09 (diff) | |
parent | c5bc4e4fb1a33eda8c31f2ea02e91f32f74c8fa5 (diff) |
2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19323:HEAD
Notes:
* blenderbuttons and ICON_SNAP_PEEL_OBJECT were not merged.
Diffstat (limited to 'source/gameengine/GameLogic/SCA_PropertyActuator.cpp')
-rw-r--r-- | source/gameengine/GameLogic/SCA_PropertyActuator.cpp | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index c9ace081bae..c4db723ee89 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,6 +149,7 @@ bool SCA_PropertyActuator::Update() } break; } + /* case KX_ACT_PROP_TOGGLE: */ /* accounted for above, no need for userexpr */ default: { @@ -218,22 +233,22 @@ void SCA_PropertyActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map) /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_PropertyActuator::Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, "SCA_PropertyActuator", - sizeof(SCA_PropertyActuator), + sizeof(PyObjectPlus_Proxy), 0, - PyDestructor, + py_base_dealloc, 0, - __getattr, - __setattr, - 0, //&MyPyCompare, - __repr, - 0, //&cvalue_as_number, 0, 0, 0, - 0 + py_base_repr, + 0,0,0,0,0,0, + py_base_getattro, + py_base_setattro, + 0,0,0,0,0,0,0,0,0, + Methods }; PyParentObject SCA_PropertyActuator::Parents[] = { @@ -260,18 +275,12 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = { { NULL } //Sentinel }; -PyObject* SCA_PropertyActuator::_getattr(const char *attr) { - PyObject* object = _getattr_self(Attributes, this, attr); - if (object != NULL) - return object; - _getattr_up(SCA_IActuator); +PyObject* SCA_PropertyActuator::py_getattro(PyObject *attr) { + py_getattro_up(SCA_IActuator); } -int SCA_PropertyActuator::_setattr(const char *attr, PyObject *value) { - int ret = _setattr_self(Attributes, this, attr, value); - if (ret >= 0) - return ret; - return SCA_IActuator::_setattr(attr, value); +int SCA_PropertyActuator::py_setattro(PyObject *attr, PyObject *value) { + py_setattro_up(SCA_IActuator); } /* 1. setProperty */ @@ -280,12 +289,12 @@ const char SCA_PropertyActuator::SetProperty_doc[] = "\t- name: string\n" "\tSet the property on which to operate. If there is no property\n" "\tof this name, the call is ignored.\n"; -PyObject* SCA_PropertyActuator::PySetProperty(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_PropertyActuator::PySetProperty(PyObject* args, PyObject* kwds) { ShowDeprecationWarning("setProperty()", "the 'property' property"); /* Check whether the name exists first ! */ char *nameArg; - if (!PyArg_ParseTuple(args, "s", &nameArg)) { + if (!PyArg_ParseTuple(args, "s:setProperty", &nameArg)) { return NULL; } @@ -305,7 +314,7 @@ PyObject* SCA_PropertyActuator::PySetProperty(PyObject* self, PyObject* args, Py const char SCA_PropertyActuator::GetProperty_doc[] = "getProperty(name)\n" "\tReturn the property on which the actuator operates.\n"; -PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* args, PyObject* kwds) { ShowDeprecationWarning("getProperty()", "the 'property' property"); return PyString_FromString(m_propname); @@ -318,11 +327,11 @@ const char SCA_PropertyActuator::SetValue_doc[] = "\tSet the value with which the actuator operates. If the value\n" "\tis not compatible with the type of the property, the subsequent\n" "\t action is ignored.\n"; -PyObject* SCA_PropertyActuator::PySetValue(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_PropertyActuator::PySetValue(PyObject* args, PyObject* kwds) { ShowDeprecationWarning("setValue()", "the value property"); char *valArg; - if(!PyArg_ParseTuple(args, "s", &valArg)) { + if(!PyArg_ParseTuple(args, "s:setValue", &valArg)) { return NULL; } @@ -335,7 +344,7 @@ PyObject* SCA_PropertyActuator::PySetValue(PyObject* self, PyObject* args, PyObj const char SCA_PropertyActuator::GetValue_doc[] = "getValue()\n" "\tReturns the value with which the actuator operates.\n"; -PyObject* SCA_PropertyActuator::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_PropertyActuator::PyGetValue(PyObject* args, PyObject* kwds) { ShowDeprecationWarning("getValue()", "the value property"); return PyString_FromString(m_exprtxt); |