summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2011-03-29 16:47:53 (GMT)
committer Simon <simon@hardwired.org.uk>2011-03-29 16:47:53 (GMT)
commit812798d70dc5c95e34e4e896d2b10d979b2d6d2e (patch)
treebd1dd55078194b10555bd405526a30800c2c6698 /src
parentd17694dcc6be7252b0099cb0779e6e88e233ada8 (diff)
parentf4804c19cc3a2f4ed37a00b1f66f5afd1bdb6f60 (diff)
downloadpowder-812798d70dc5c95e34e4e896d2b10d979b2d6d2e.zip
powder-812798d70dc5c95e34e4e896d2b10d979b2d6d2e.tar.gz
64bit fixes and other
Diffstat (limited to 'src')
-rw-r--r--src/main.c63
-rw-r--r--src/python/tpt_console.py5
2 files changed, 66 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index b7888c8..55908f3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -29,6 +29,8 @@
#ifdef PYCONSOLE
#include "Python.h"
#include "pyconsole.h"
+//#include "pystdlib.h"
+#include <marshal.h>
char pyready=1;
char pygood=1;
#endif
@@ -1939,6 +1941,63 @@ static PyObject* emb_disable_python(PyObject *self, PyObject *args)
return Py_BuildValue("i",1);
}
+int bsx = 2, bsy = 2, sl=1, sr=0;
+static PyObject*
+emb_get_tool(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":get_tool"))
+ return NULL;
+ return Py_BuildValue("((ii)(ii)i)",bsx,bsy,sl,sr,CURRENT_BRUSH);
+}
+
+static PyObject*
+emb_set_tool(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, "((ii)(ii)i):set_tool",&bsx,&bsy,&sl,&sr,&CURRENT_BRUSH))
+ return NULL;
+ return Py_BuildValue("i",1);
+}
+
+/*
+static PyObject*
+emb_press_mouse(PyObject *self, PyObject *args)
+{
+ int x,y,b;
+ SDL_Event* ev;
+ b=0;
+ if(!PyArg_ParseTuple(args, "ii|i:handle_tool",&x,&y,&b))
+ return NULL;
+ ev.type=SDL_MOUSEBUTTONDOWN;
+ if(b==2)
+ ev.button.button=SDL_BUTTON_RIGHT;
+ else
+ ev.button.button=SDL_BUTTON_LEFT;
+ ev.button.state=SDL_PRESSED;
+ ev.button.x=x;
+ ev.button.y=y;
+ return Py_BuildValue("i",SDL_PushEvent(ev));
+}
+
+static PyObject*
+emb_release_mouse(PyObject *self, PyObject *args)
+{
+ int x,y,b;
+ SDL_MouseButtonEvent ev;
+ b=0;
+ if(!PyArg_ParseTuple(args, "ii|i:handle_tool",&x,&y,&b))
+ return NULL;
+ ev.type=SDL_MOUSEBUTTONUP;
+ if(b==2)
+ ev.button.button=SDL_BUTTON_RIGHT;
+ else
+ ev.button.button=SDL_BUTTON_LEFT;
+ ev.button.state=SDL_RELEASED;
+ ev.button.x=x;
+ ev.button.y=y;
+ return Py_BuildValue("i",SDL_PushEvent(ev));
+}*/
+
+
static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your function here!
{"create", (PyCFunction)emb_create, METH_VARARGS|METH_KEYWORDS, "create a particle."},
{"log", (PyCFunction)emb_log, METH_VARARGS, "logs an error string to the console."},
@@ -1979,6 +2038,8 @@ static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your fun
{"set_pressure", (PyCFunction)emb_set_pressure, METH_VARARGS, "set pressure"},
{"set_velocity", (PyCFunction)emb_set_velocity, METH_VARARGS, "set velocity"},
{"disable_python", (PyCFunction)emb_disable_python, METH_VARARGS, "switch back to the old console."},
+ {"get_tool", (PyCFunction)emb_get_tool, METH_VARARGS, "get tool size/type and selected particles"},
+ {"set_tool", (PyCFunction)emb_set_tool, METH_VARARGS, "set tool size/type and selected particles"},
{NULL, NULL, 0, NULL}
};
#endif
@@ -3248,7 +3309,7 @@ int main(int argc, char *argv[])
lb = 0;
}
}
- else if (y<YRES)
+ else if (y<YRES)//mouse handling
{
int signi;
diff --git a/src/python/tpt_console.py b/src/python/tpt_console.py
index 315267e..c4b870c 100644
--- a/src/python/tpt_console.py
+++ b/src/python/tpt_console.py
@@ -12,7 +12,10 @@ class logger:
def write(self,txt):
txt=txt.strip().split("\n")[-1]
repr(txt)
- tpt.log(txt)
+ try:
+ tpt.log(txt)
+ except:#yeah, this happens.
+ pass
if(DEBUG==False):
sys.stdout=logger()
sys.stderr=logger()