Initial revision
[blender.git] / source / gameengine / GameLogic / SCA_PythonController.h
1 /**
2  * Execute Python scripts
3  *
4  * $Id$
5  *
6  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version. The Blender
12  * Foundation also sells licenses for use in proprietary software under
13  * the Blender License.  See http://www.blender.org/BL/ for information
14  * about this.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  *
25  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
26  * All rights reserved.
27  *
28  * The Original Code is: all of this file.
29  *
30  * Contributor(s): none yet.
31  *
32  * ***** END GPL/BL DUAL LICENSE BLOCK *****
33  */
34
35 #ifndef KX_PYTHONCONTROLLER_H
36 #define KX_PYTHONCONTROLLER_H
37               
38 #include "SCA_IController.h"
39 #include "SCA_LogicManager.h"
40 #include "BoolValue.h"
41
42 class SCA_IObject;
43 class SCA_PythonController : public SCA_IController
44 {
45         Py_Header;
46         struct _object *                m_bytecode;
47         bool                                    m_bModified;
48
49  protected:
50         STR_String                              m_scriptText;
51         STR_String                              m_scriptName;
52         PyObject*                               m_pythondictionary;
53
54  public: 
55         static SCA_PythonController* m_sCurrentController; // protected !!!
56
57         SCA_PythonController(SCA_IObject* gameobj,PyTypeObject* T = &Type);
58         virtual ~SCA_PythonController();
59
60         virtual CValue* GetReplica();
61         virtual void  Trigger(class SCA_LogicManager* logicmgr);
62   
63         void    SetScriptText(const STR_String& text);
64         void    SetScriptName(const STR_String& name);
65         void    SetDictionary(PyObject* pythondictionary);
66
67         static char* sPyGetCurrentController__doc__;
68         static PyObject* sPyGetCurrentController(PyObject* self, 
69                                                                                          PyObject* args, 
70                                                                                          PyObject* kwds);
71         static char* sPyAddActiveActuator__doc__;
72         static PyObject* sPyAddActiveActuator(PyObject* self, 
73                                                                                   PyObject* args, 
74                                                                                   PyObject* kwds);
75         virtual PyObject*  _getattr(char *attr);
76
77         KX_PYMETHOD_DOC(SCA_PythonController,GetSensors);
78         KX_PYMETHOD_DOC(SCA_PythonController,GetSensor);
79         KX_PYMETHOD_DOC(SCA_PythonController,GetActuator);
80         KX_PYMETHOD_DOC(SCA_PythonController,GetActuators);
81         KX_PYMETHOD(SCA_PythonController,SetScript);
82         KX_PYMETHOD(SCA_PythonController,GetScript);
83         
84
85 };
86
87 #endif //KX_PYTHONCONTROLLER_H
88