Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / gameengine / Ketsji / KX_SceneActuator.cpp
index ea1be7b..a0b7664 100644 (file)
@@ -245,6 +245,14 @@ PyTypeObject KX_SceneActuator::Type = {
 
 PyMethodDef KX_SceneActuator::Methods[] =
 {
+       //Deprecated functions ------>
+       {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (const char *)SetUseRestart_doc},
+       {"setScene",      (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (const char *)SetScene_doc},
+       {"setCamera",     (PyCFunction) KX_SceneActuator::sPySetCamera, METH_O, (const char *)SetCamera_doc},
+       {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_NOARGS, (const char *)GetUseRestart_doc},
+       {"getScene",      (PyCFunction) KX_SceneActuator::sPyGetScene, METH_NOARGS, (const char *)GetScene_doc},
+       {"getCamera",     (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_NOARGS, (const char *)GetCamera_doc},
+       //<----- Deprecated
        {NULL,NULL} //Sentinel
 };
 
@@ -287,4 +295,117 @@ int KX_SceneActuator::pyattr_set_camera(void *self, const struct KX_PYATTRIBUTE_
        return PY_SET_ATTR_SUCCESS;
 }
 
+
+/* 2. setUseRestart--------------------------------------------------------- */
+const char KX_SceneActuator::SetUseRestart_doc[] = 
+"setUseRestart(flag)\n"
+"\t- flag: 0 or 1.\n"
+"\tSet flag to 1 to restart the scene.\n" ;
+PyObject* KX_SceneActuator::PySetUseRestart(PyObject* args)
+{
+       ShowDeprecationWarning("setUseRestart()", "the useRestart property");
+       int boolArg;
+       
+       if (!PyArg_ParseTuple(args, "i:setUseRestart", &boolArg))
+       {
+               return NULL;
+       }
+       
+       m_restart = boolArg != 0;
+       
+       Py_RETURN_NONE;
+}
+
+
+
+/* 3. getUseRestart:                                                         */
+const char KX_SceneActuator::GetUseRestart_doc[] = 
+"getUseRestart()\n"
+"\tReturn whether the scene will be restarted.\n" ;
+PyObject* KX_SceneActuator::PyGetUseRestart()
+{
+       ShowDeprecationWarning("getUseRestart()", "the useRestart property");
+       return PyLong_FromSsize_t(!(m_restart == 0));
+}
+
+
+
+/* 4. set scene------------------------------------------------------------- */
+const char KX_SceneActuator::SetScene_doc[] = 
+"setScene(scene)\n"
+"\t- scene: string\n"
+"\tSet the name of scene the actuator will switch to.\n" ;
+PyObject* KX_SceneActuator::PySetScene(PyObject* args)
+{
+       ShowDeprecationWarning("setScene()", "the scene property");
+       /* one argument: a scene, ignore the rest */
+       char *scene_name;
+
+       if(!PyArg_ParseTuple(args, "s:setScene", &scene_name))
+       {
+               return NULL;
+       }
+
+       /* Scene switch is done by name. */
+       m_nextSceneName = scene_name;
+
+       Py_RETURN_NONE;
+}
+
+
+
+/* 5. getScene:                                                              */
+const char KX_SceneActuator::GetScene_doc[] = 
+"getScene()\n"
+"\tReturn the name of the scene the actuator wants to switch to.\n" ;
+PyObject* KX_SceneActuator::PyGetScene()
+{
+       ShowDeprecationWarning("getScene()", "the scene property");
+       return PyUnicode_FromString(m_nextSceneName);
+}
+
+
+
+/* 6. set camera------------------------------------------------------------ */
+const char KX_SceneActuator::SetCamera_doc[] = 
+"setCamera(camera)\n"
+"\t- camera: string\n"
+"\tSet the camera to switch to.\n" ;
+PyObject* KX_SceneActuator::PySetCamera(PyObject* value)
+{
+       ShowDeprecationWarning("setCamera()", "the camera property");
+       KX_Camera *camOb;
+       
+       if (!ConvertPythonToCamera(value, &camOb, true, "actu.setCamera(value): KX_SceneActuator"))
+               return NULL;
+       
+       if (m_camera)
+               m_camera->UnregisterActuator(this);
+       
+       if(camOb==NULL) {
+               m_camera= NULL;
+       }
+       else {  
+               m_camera = camOb;
+               m_camera->RegisterActuator(this);
+       }
+       Py_RETURN_NONE;
+}
+
+
+
+/* 7. getCamera:                                                             */
+const char KX_SceneActuator::GetCamera_doc[] = 
+"getCamera()\n"
+"\tReturn the name of the camera to switch to.\n" ;
+PyObject* KX_SceneActuator::PyGetCamera()
+{
+       ShowDeprecationWarning("getCamera()", "the camera property");
+       if (m_camera) {
+               return PyUnicode_FromString(m_camera->GetName());
+       }
+       else {
+               Py_RETURN_NONE;
+       }
+}
 /* eof */