get rid of annoying duplicate python initialization code, added setupGamePython() which initializes modules

This commit is contained in:
2010-01-10 22:03:26 +00:00
parent 34794eafe4
commit affe84a453
4 changed files with 46 additions and 44 deletions

View File

@@ -1926,6 +1926,38 @@ void exitGamePythonScripting()
PyObjectPlus::ClearDeprecationWarning();
}
/* similar to the above functions except it sets up the namespace
* and other more general things */
void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *blenderdata, PyObject * pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv)
{
PyObject* dictionaryobject;
if(argv) /* player only */
dictionaryobject= initGamePlayerPythonScripting("Ketsji", psl_Lowest, blenderdata, argc, argv);
else
dictionaryobject= initGamePythonScripting("Ketsji", psl_Lowest, blenderdata);
ketsjiengine->SetPyNamespace(dictionaryobject);
initRasterizer(ketsjiengine->GetRasterizer(), ketsjiengine->GetCanvas());
*gameLogic = initGameLogic(ketsjiengine, startscene);
/* is set in initGameLogic so only set here if we want it to persist between scenes */
if(pyGlobalDict)
PyDict_SetItemString(PyModule_GetDict(*gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
*gameLogic_keys = PyDict_Keys(PyModule_GetDict(*gameLogic));
PyDict_SetItemString(dictionaryobject, "GameLogic", *gameLogic); // Same as importing the module.
initGameKeys();
initPythonConstraintBinding();
initMathutils();
initGeometry();
initBGL();
#ifdef WITH_FFMPEG
initVideoTexture();
#endif
}
static struct PyModuleDef Rasterizer_module_def = {
{}, /* m_base */