Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-09-23 04:37:19 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-09-23 04:37:19 +0400
commit7a28ca4398465be1d6d57079e4b27c3a03418745 (patch)
tree24cbd48a8504e87bb434641ccd8ba83e5262ae4d
parent18c954e95ba8181a67a6e67246d5f507246db007 (diff)
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.
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 74fe6c68863..6a296a3e244 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -326,8 +326,10 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
PyObject *gameLogic = initGameLogic(ketsjiengine, startscene);
- PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module.
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.
+
initGameKeys();
initPythonConstraintBinding();
initMathutils();
@@ -401,8 +403,20 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
// 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();
@@ -413,6 +427,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
delete sceneconverter;
sceneconverter = NULL;
}
+
+ Py_DECREF(gameLogic_keys);
+ gameLogic_keys = NULL;
}
// set the cursor back to normal
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);