From dee32d0b3f409007f5a392668068b92c3810026a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Apr 2009 09:13:59 +0000 Subject: BGE Python API - initialize pythons sys.argv in the blenderplayer - ignore all arguments after a single " - " in the blenderplayer (like in blender), so args can be passed to the game. - add a utility function PyOrientationTo() - to take a Py euler, quat or 3x3 matrix and convert into a C++ MT_Matrix3x3. - add utility function ConvertPythonToMesh to get a RAS_MeshObject from a KX_MeshProxy or a name. - Added error prefix arguments to ConvertPythonToGameObject, ConvertPythonToMesh and PyOrientationTo so the error messages can include what function they came from. - deprecated brick.getOwner() for the "owner" attribute. --- source/gameengine/GameLogic/SCA_ILogicBrick.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'source/gameengine/GameLogic/SCA_ILogicBrick.cpp') diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index b3045402c2c..3cd750ff63b 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -246,8 +246,8 @@ PyParentObject SCA_ILogicBrick::Parents[] = { PyMethodDef SCA_ILogicBrick::Methods[] = { + // --> Deprecated {"getOwner", (PyCFunction) SCA_ILogicBrick::sPyGetOwner, METH_NOARGS}, - // --> Deprecated {"getExecutePriority", (PyCFunction) SCA_ILogicBrick::sPyGetExecutePriority, METH_NOARGS}, {"setExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_VARARGS}, // <-- Deprecated @@ -255,6 +255,7 @@ PyMethodDef SCA_ILogicBrick::Methods[] = { }; PyAttributeDef SCA_ILogicBrick::Attributes[] = { + KX_PYATTRIBUTE_RO_FUNCTION("owner", SCA_ILogicBrick, pyattr_get_owner), KX_PYATTRIBUTE_INT_RW("executePriority",0,100000,false,SCA_ILogicBrick,m_Execute_Ueber_Priority), {NULL} //Sentinel }; @@ -291,6 +292,8 @@ int SCA_ILogicBrick::py_setattro(PyObject *attr, PyObject *value) PyObject* SCA_ILogicBrick::PyGetOwner() { + ShowDeprecationWarning("getOwner()", "the owner property"); + CValue* parent = GetParent(); if (parent) { @@ -327,6 +330,19 @@ PyObject* SCA_ILogicBrick::PyGetExecutePriority() } +/*Attribute functions */ +PyObject* SCA_ILogicBrick::pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + SCA_ILogicBrick* self= static_cast(self_v); + CValue* parent = self->GetParent(); + + if (parent) + return parent->GetProxy(); + + Py_RETURN_NONE; +} + + /* Conversions for making life better. */ bool SCA_ILogicBrick::PyArgToBool(int boolArg) @@ -338,8 +354,6 @@ bool SCA_ILogicBrick::PyArgToBool(int boolArg) } } - - PyObject* SCA_ILogicBrick::BoolToPyArg(bool boolarg) { return PyInt_FromLong(boolarg? KX_TRUE: KX_FALSE); -- cgit v1.2.3