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:
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInit.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp133
1 files changed, 67 insertions, 66 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 472ae759d65..5d2126ca37a 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -30,7 +30,13 @@
#include "GL/glew.h"
+// directory header for py function getBlendFileList
#include <stdlib.h>
+#ifndef WIN32
+ #include <dirent.h>
+#else
+ #include "BLI_winstuff.h"
+#endif
#ifdef WIN32
#pragma warning (disable : 4786)
@@ -112,9 +118,7 @@ static PyObject* gPyGetRandomFloat(PyObject*)
return PyFloat_FromDouble(MT_random());
}
-static PyObject* gPySetGravity(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetGravity(PyObject*, PyObject* args)
{
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
if (PyVecArgTo(args, vec))
@@ -138,9 +142,7 @@ file to make a full path name (doesn't change during the game, even if you load\
other .blend).\n\
The function also converts the directory separator to the local file system format.";
-static PyObject* gPyExpandPath(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyExpandPath(PyObject*, PyObject* args)
{
char expanded[FILE_MAXDIR + FILE_MAXFILE];
char* filename;
@@ -185,9 +187,7 @@ static PyObject* gPyGetSpectrum(PyObject*)
-static PyObject* gPyStartDSP(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyStartDSP(PyObject*, PyObject* args)
{
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
@@ -205,9 +205,7 @@ static PyObject* gPyStartDSP(PyObject*,
-static PyObject* gPyStopDSP(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyStopDSP(PyObject*, PyObject* args)
{
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
@@ -223,9 +221,7 @@ static PyObject* gPyStopDSP(PyObject*,
return NULL;
}
-static PyObject* gPySetLogicTicRate(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args)
{
float ticrate;
if (PyArg_ParseTuple(args, "f", &ticrate))
@@ -242,9 +238,7 @@ static PyObject* gPyGetLogicTicRate(PyObject*)
return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate());
}
-static PyObject* gPySetPhysicsTicRate(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args)
{
float ticrate;
if (PyArg_ParseTuple(args, "f", &ticrate))
@@ -257,9 +251,7 @@ static PyObject* gPySetPhysicsTicRate(PyObject*,
return NULL;
}
-static PyObject* gPySetPhysicsDebug(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetPhysicsDebug(PyObject*, PyObject* args)
{
int debugMode;
if (PyArg_ParseTuple(args, "i", &debugMode))
@@ -278,6 +270,44 @@ static PyObject* gPyGetPhysicsTicRate(PyObject*)
return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep());
}
+static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args)
+{
+ char cpath[sizeof(G.sce)];
+ char *searchpath = NULL;
+ PyObject* list;
+
+ DIR *dp;
+ struct dirent *dirp;
+
+ if (!PyArg_ParseTuple(args, "|s", &searchpath))
+ return NULL;
+
+ list = PyList_New(0);
+
+ if (searchpath) {
+ BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE);
+ BLI_convertstringcode(cpath, G.sce);
+ } else {
+ /* Get the dir only */
+ BLI_split_dirfile_basic(G.sce, cpath, NULL);
+ }
+
+ if((dp = opendir(cpath)) == NULL) {
+ /* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */
+ fprintf(stderr, "Could not read directoty () failed, code %d (%s)\n", cpath, errno, strerror(errno));
+ return list;
+ }
+
+ while ((dirp = readdir(dp)) != NULL) {
+ if (BLI_testextensie(dirp->d_name, ".blend")) {
+ PyList_Append(list, PyString_FromString(dirp->d_name));
+ }
+ }
+
+ closedir(dp);
+ return list;
+}
+
static STR_String gPyGetCurrentScene_doc =
"getCurrentScene()\n"
"Gets a reference to the current scene.\n";
@@ -377,14 +407,13 @@ static struct PyMethodDef game_methods[] = {
{"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"},
{"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, "Gets the physics tic rate"},
{"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"},
+ {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, "Gets a list of blend files in the same directory as the current blend file"},
{"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, "Prints GL Extension Info"},
{NULL, (PyCFunction) NULL, 0, NULL }
};
-static PyObject* gPyGetWindowHeight(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyGetWindowHeight(PyObject*, PyObject* args)
{
int height = (gp_Canvas ? gp_Canvas->GetHeight() : 0);
@@ -394,9 +423,7 @@ static PyObject* gPyGetWindowHeight(PyObject*,
-static PyObject* gPyGetWindowWidth(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyGetWindowWidth(PyObject*, PyObject* args)
{
@@ -411,9 +438,7 @@ static PyObject* gPyGetWindowWidth(PyObject*,
// temporarility visibility thing, will be moved to rasterizer/renderer later
bool gUseVisibilityTemp = false;
-static PyObject* gPyEnableVisibility(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyEnableVisibility(PyObject*, PyObject* args)
{
int visible;
if (PyArg_ParseTuple(args,"i",&visible))
@@ -429,9 +454,7 @@ static PyObject* gPyEnableVisibility(PyObject*,
-static PyObject* gPyShowMouse(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyShowMouse(PyObject*, PyObject* args)
{
int visible;
if (PyArg_ParseTuple(args,"i",&visible))
@@ -455,9 +478,7 @@ static PyObject* gPyShowMouse(PyObject*,
-static PyObject* gPySetMousePosition(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetMousePosition(PyObject*, PyObject* args)
{
int x,y;
if (PyArg_ParseTuple(args,"ii",&x,&y))
@@ -472,9 +493,7 @@ static PyObject* gPySetMousePosition(PyObject*,
Py_Return;
}
-static PyObject* gPySetEyeSeparation(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args)
{
float sep;
if (PyArg_ParseTuple(args, "f", &sep))
@@ -496,9 +515,7 @@ static PyObject* gPyGetEyeSeparation(PyObject*, PyObject*, PyObject*)
return NULL;
}
-static PyObject* gPySetFocalLength(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetFocalLength(PyObject*, PyObject* args)
{
float focus;
if (PyArg_ParseTuple(args, "f", &focus))
@@ -518,9 +535,7 @@ static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*)
return NULL;
}
-static PyObject* gPySetBackgroundColor(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetBackgroundColor(PyObject*, PyObject* args)
{
MT_Vector4 vec = MT_Vector4(0., 0., 0.3, 0.);
@@ -538,9 +553,7 @@ static PyObject* gPySetBackgroundColor(PyObject*,
-static PyObject* gPySetMistColor(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetMistColor(PyObject*, PyObject* args)
{
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
@@ -558,9 +571,7 @@ static PyObject* gPySetMistColor(PyObject*,
-static PyObject* gPySetMistStart(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetMistStart(PyObject*, PyObject* args)
{
float miststart;
@@ -579,9 +590,7 @@ static PyObject* gPySetMistStart(PyObject*,
-static PyObject* gPySetMistEnd(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetMistEnd(PyObject*, PyObject* args)
{
float mistend;
@@ -599,9 +608,7 @@ static PyObject* gPySetMistEnd(PyObject*,
}
-static PyObject* gPySetAmbientColor(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetAmbientColor(PyObject*, PyObject* args)
{
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
@@ -620,9 +627,7 @@ static PyObject* gPySetAmbientColor(PyObject*,
-static PyObject* gPyMakeScreenshot(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyMakeScreenshot(PyObject*, PyObject* args)
{
char* filename;
if (PyArg_ParseTuple(args,"s",&filename))
@@ -638,9 +643,7 @@ static PyObject* gPyMakeScreenshot(PyObject*,
Py_Return;
}
-static PyObject* gPyEnableMotionBlur(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args)
{
float motionblurvalue;
if (PyArg_ParseTuple(args,"f",&motionblurvalue))
@@ -656,9 +659,7 @@ static PyObject* gPyEnableMotionBlur(PyObject*,
Py_Return;
}
-static PyObject* gPyDisableMotionBlur(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyDisableMotionBlur(PyObject*, PyObject* args)
{
if(gp_Rasterizer)
{