[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16295] branches/apricot/source/gameengine : svn merge -r 16293:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/ blender
Campbell Barton
ideasman42 at gmail.com
Fri Aug 29 05:18:02 CEST 2008
Revision: 16295
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16295
Author: campbellbarton
Date: 2008-08-29 05:18:02 +0200 (Fri, 29 Aug 2008)
Log Message:
-----------
svn merge -r 16293:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
Modified Paths:
--------------
branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
branches/apricot/source/gameengine/Ketsji/KX_PythonInit.cpp
branches/apricot/source/gameengine/PyDoc/GameKeys.py
Modified: branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
===================================================================
--- branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp 2008-08-29 03:15:17 UTC (rev 16294)
+++ branches/apricot/source/gameengine/GamePlayer/ghost/GPG_Application.cpp 2008-08-29 03:18:02 UTC (rev 16295)
@@ -726,6 +726,7 @@
} else {
printf("Error, GameLogic.globalDict could not be marshal'd\n");
}
+ Py_DECREF(gameLogic);
} else {
printf("Error, GameLogic.globalDict was removed\n");
}
Modified: branches/apricot/source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
--- branches/apricot/source/gameengine/Ketsji/KX_PythonInit.cpp 2008-08-29 03:15:17 UTC (rev 16294)
+++ branches/apricot/source/gameengine/Ketsji/KX_PythonInit.cpp 2008-08-29 03:18:02 UTC (rev 16295)
@@ -1129,9 +1129,38 @@
"This modules provides defines for key-codes"
;
+static char gPyEventToString_doc[] =
+"Take a valid event from the GameKeys module or Keyboard Sensor and return a name"
+;
+static PyObject* gPyEventToString(PyObject*, PyObject* value)
+{
+ PyObject* mod, *dict, *key, *val, *ret = NULL;
+ int pos = 0;
+
+ mod = PyImport_ImportModule( "GameKeys" );
+ if (!mod)
+ return NULL;
+
+ dict = PyModule_GetDict(mod);
+
+ while (PyDict_Next(dict, &pos, &key, &val)) {
+ if (PyObject_Compare(value, val)==0) {
+ ret = key;
+ break;
+ }
+ }
+
+ PyErr_Clear(); // incase there was an error clearing
+ Py_DECREF(mod);
+ if (!ret) PyErr_SetString(PyExc_ValueError, "expected a valid int keyboard event");
+ else Py_INCREF(ret);
+
+ return ret;
+}
static struct PyMethodDef gamekeys_methods[] = {
+ {"EventToString", (PyCFunction)gPyEventToString, METH_O, gPyEventToString_doc},
{ NULL, (PyCFunction) NULL, 0, NULL }
};
Modified: branches/apricot/source/gameengine/PyDoc/GameKeys.py
===================================================================
--- branches/apricot/source/gameengine/PyDoc/GameKeys.py 2008-08-29 03:15:17 UTC (rev 16294)
+++ branches/apricot/source/gameengine/PyDoc/GameKeys.py 2008-08-29 03:18:02 UTC (rev 16295)
@@ -164,3 +164,12 @@
# Activate Right!
"""
+
+def EventToString(event):
+ """
+ Return the string name of a key event. Will raise a ValueError error if its invalid.
+
+ @type event: int
+ @param event: key event from GameKeys or the keyboard sensor.
+ @rtype: string
+ """
More information about the Bf-blender-cvs
mailing list