[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16691] trunk/blender/source/gameengine/ BlenderRoutines/BL_KetsjiEmbedStart.cpp: Make GameLogic work for python autocomplete ( after running the BGE once at least)
Campbell Barton
ideasman42 at gmail.com
Tue Sep 23 02:37:19 CEST 2008
Revision: 16691
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16691
Author: campbellbarton
Date: 2008-09-23 02:37:19 +0200 (Tue, 23 Sep 2008)
Log Message:
-----------
Make GameLogic work for python autocomplete (after running the BGE once at least)
only clear newly added items from the gameLogic dictionary rather then the whole dictionary.
Modified Paths:
--------------
trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
Modified: trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
===================================================================
--- trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp 2008-09-22 22:48:44 UTC (rev 16690)
+++ trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp 2008-09-23 00:37:19 UTC (rev 16691)
@@ -326,8 +326,10 @@
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
PyObject *gameLogic = initGameLogic(ketsjiengine, startscene);
+ PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
+ PyObject *gameLogic_keys = PyDict_Keys(PyModule_GetDict(gameLogic));
PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module.
- PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
+
initGameKeys();
initPythonConstraintBinding();
initMathutils();
@@ -401,9 +403,21 @@
// inside the GameLogic dictionary when the python interpreter is finalized.
// which allows the scene to safely delete them :)
// see: (space.c)->start_game
- PyDict_Clear(PyModule_GetDict(gameLogic));
- PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict);
+ //PyDict_Clear(PyModule_GetDict(gameLogic));
+
+ // Keep original items, means python plugins will autocomplete members
+ int listIndex;
+ PyObject *gameLogic_keys_new = PyDict_Keys(PyModule_GetDict(gameLogic));
+ for (listIndex=0; listIndex < PyList_Size(gameLogic_keys_new); listIndex++) {
+ PyObject* item = PyList_GET_ITEM(gameLogic_keys_new, listIndex);
+ if (!PySequence_Contains(gameLogic_keys, item)) {
+ PyDict_DelItem( PyModule_GetDict(gameLogic), item);
+ }
+ }
+ Py_DECREF(gameLogic_keys_new);
+ gameLogic_keys_new = NULL;
+
ketsjiengine->StopEngine();
exitGamePythonScripting();
networkdevice->Disconnect();
@@ -413,6 +427,9 @@
delete sceneconverter;
sceneconverter = NULL;
}
+
+ Py_DECREF(gameLogic_keys);
+ gameLogic_keys = NULL;
}
// set the cursor back to normal
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
More information about the Bf-blender-cvs
mailing list