summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-08-19 12:16:49 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-19 12:16:49 (GMT)
commit88823cf6042e75b5756489ffdc13a5cbb6167bb1 (patch)
tree32d411b0ce22cafe39e56321c5e0531f2b37e3b9
parenta94d249977614abe3dc94a31934ddf9cad989cd9 (diff)
downloadpowder-88823cf6042e75b5756489ffdc13a5cbb6167bb1.zip
powder-88823cf6042e75b5756489ffdc13a5cbb6167bb1.tar.gz
Reorganise a lot of Python console stuff
-rw-r--r--includes/console.h14
-rw-r--r--includes/pythonconsole.h (renamed from includes/pyconsole.h)13
-rw-r--r--src/console.c886
-rw-r--r--src/interface.c9
-rw-r--r--src/main.c109
-rw-r--r--src/pythonconsole.c981
6 files changed, 1018 insertions, 994 deletions
diff --git a/includes/console.h b/includes/console.h
index c1352f4..3b4a483 100644
--- a/includes/console.h
+++ b/includes/console.h
@@ -2,26 +2,14 @@
#define CONSOLE_H
#include <defines.h>
-#ifdef PYCONSOLE
-#include "Python.h"
-//#include "pystdlib.h"
-#include <marshal.h>
-#endif
-
-extern char pyready, pygood, console_more;
+extern char console_more;
extern char console_error[];
extern int file_script;
-#ifdef PYCONSOLE
-extern PyMethodDef EmbMethods[];
-#endif
int console_parse_coords(char *txt, int *x, int *y, char *err);
int console_parse_type(char *txt, int *element, char *err);
int console_parse_partref(char *txt, int *which, char *err);
-#ifdef PYCONSOLE
-int process_command(pixel *vid_buf, char *console, char *console_error, PyObject *pfunc);
-#endif
int process_command_old(pixel *vid_buf, char *console, char *console_error);
#endif
diff --git a/includes/pyconsole.h b/includes/pythonconsole.h
index d5118a5..e1e9a97 100644
--- a/includes/pyconsole.h
+++ b/includes/pythonconsole.h
@@ -1,2 +1,15 @@
+#ifndef PYCONSOLEH
+#define PYCONSOLEH
#include <Python.h>
+#include <marshal.h>
+
+extern char pyready, pygood;
+extern PyMethodDef EmbMethods[];
uns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0x0,0x64,0x1c,0x0,0x36,0x64,0x1d,0x0,0x64,0x1e,0x0,0x36,0x64,0x1f,0x0,0x64,0x20,0x0,0x36,0x64,0x21,0x0,0x64,0x22,0x0,0x36,0x64,0x23,0x0,0x64,0x24,0x0,0x36,0x64,0x25,0x0,0x64,0x26,0x0,0x36,0x64,0x27,0x0,0x64,0x28,0x0,0x36,0x64,0x29,0x0,0x64,0x2a,0x0,0x36,0x64,0x2b,0x0,0x64,0x2c,0x0,0x36,0x64,0x2d,0x0,0x64,0x2e,0x0,0x36,0x64,0x2f,0x0,0x64,0x30,0x0,0x36,0x64,0x31,0x0,0x64,0x32,0x0,0x36,0x64,0x33,0x0,0x64,0x34,0x0,0x36,0x64,0x35,0x0,0x64,0x36,0x0,0x36,0x64,0x37,0x0,0x64,0x38,0x0,0x36,0x64,0x39,0x0,0x64,0x3a,0x0,0x36,0x64,0x3b,0x0,0x64,0x3c,0x0,0x36,0x64,0x3d,0x0,0x64,0x3e,0x0,0x36,0x64,0x3f,0x0,0x64,0x40,0x0,0x36,0x64,0x41,0x0,0x64,0x42,0x0,0x36,0x64,0x43,0x0,0x64,0x44,0x0,0x36,0x64,0x45,0x0,0x64,0x46,0x0,0x36,0x64,0x47,0x0,0x64,0x48,0x0,0x36,0x64,0x49,0x0,0x64,0x4a,0x0,0x36,0x64,0x4b,0x0,0x64,0x4c,0x0,0x36,0x64,0x4d,0x0,0x64,0x4e,0x0,0x36,0x64,0x4f,0x0,0x64,0x50,0x0,0x36,0x64,0x51,0x0,0x64,0x52,0x0,0x36,0x64,0x53,0x0,0x64,0x54,0x0,0x36,0x64,0x55,0x0,0x64,0x56,0x0,0x36,0x64,0x57,0x0,0x64,0x58,0x0,0x36,0x64,0x59,0x0,0x64,0x5a,0x0,0x36,0x64,0x5b,0x0,0x64,0x5c,0x0,0x36,0x64,0x5d,0x0,0x64,0x5e,0x0,0x36,0x64,0x5f,0x0,0x64,0x60,0x0,0x36,0x64,0x61,0x0,0x64,0x62,0x0,0x36,0x64,0x63,0x0,0x64,0x64,0x0,0x36,0x64,0x65,0x0,0x64,0x66,0x0,0x36,0x64,0x67,0x0,0x64,0x68,0x0,0x36,0x64,0x69,0x0,0x64,0x6a,0x0,0x36,0x64,0x6b,0x0,0x64,0x6c,0x0,0x36,0x64,0x6d,0x0,0x64,0x6e,0x0,0x36,0x64,0x6f,0x0,0x64,0x70,0x0,0x36,0x64,0x71,0x0,0x64,0x72,0x0,0x36,0x64,0x73,0x0,0x64,0x74,0x0,0x36,0x64,0x75,0x0,0x64,0x76,0x0,0x36,0x64,0x77,0x0,0x64,0x78,0x0,0x36,0x64,0x79,0x0,0x64,0x7a,0x0,0x36,0x64,0x7b,0x0,0x64,0x7c,0x0,0x36,0x64,0x7d,0x0,0x64,0x7e,0x0,0x36,0x64,0x7f,0x0,0x64,0x80,0x0,0x36,0x64,0x81,0x0,0x64,0x82,0x0,0x36,0x64,0x83,0x0,0x64,0x84,0x0,0x36,0x64,0x85,0x0,0x64,0x86,0x0,0x36,0x64,0x87,0x0,0x64,0x88,0x0,0x36,0x64,0x89,0x0,0x64,0x8a,0x0,0x36,0x64,0x8b,0x0,0x64,0x8c,0x0,0x36,0x64,0x8d,0x0,0x64,0x8e,0x0,0x36,0x64,0x8f,0x0,0x64,0x90,0x0,0x36,0x64,0x91,0x0,0x64,0x92,0x0,0x36,0x64,0x93,0x0,0x64,0x94,0x0,0x36,0x64,0x95,0x0,0x64,0x96,0x0,0x36,0x64,0x97,0x0,0x64,0x98,0x0,0x36,0x64,0x99,0x0,0x64,0x9a,0x0,0x36,0x64,0x9b,0x0,0x64,0x9c,0x0,0x36,0x64,0x9d,0x0,0x64,0x9e,0x0,0x36,0x64,0x9f,0x0,0x64,0xa0,0x0,0x36,0x64,0xa1,0x0,0x64,0xa2,0x0,0x36,0x64,0xa3,0x0,0x64,0xa4,0x0,0x36,0x64,0xa5,0x0,0x64,0xa6,0x0,0x36,0x64,0xa7,0x0,0x64,0xa8,0x0,0x36,0x64,0xa9,0x0,0x64,0xaa,0x0,0x36,0x64,0xab,0x0,0x64,0xac,0x0,0x36,0x64,0xad,0x0,0x64,0xae,0x0,0x36,0x64,0xaf,0x0,0x64,0xb0,0x0,0x36,0x64,0xb1,0x0,0x64,0xb2,0x0,0x36,0x64,0xb3,0x0,0x64,0xb4,0x0,0x36,0x64,0xb5,0x0,0x64,0xb6,0x0,0x36,0x64,0xb7,0x0,0x64,0xb8,0x0,0x36,0x64,0xb9,0x0,0x64,0xba,0x0,0x36,0x64,0xbb,0x0,0x64,0xbc,0x0,0x36,0x64,0xbd,0x0,0x64,0xbe,0x0,0x36,0x64,0xbf,0x0,0x64,0xc0,0x0,0x36,0x64,0xc1,0x0,0x64,0xc2,0x0,0x36,0x64,0xc3,0x0,0x64,0xc4,0x0,0x36,0x64,0xc5,0x0,0x64,0xc6,0x0,0x36,0x64,0xc7,0x0,0x64,0xc8,0x0,0x36,0x64,0xc9,0x0,0x64,0xca,0x0,0x36,0x64,0xcb,0x0,0x64,0xcc,0x0,0x36,0x64,0xcd,0x0,0x64,0xce,0x0,0x36,0x64,0xcf,0x0,0x64,0xd0,0x0,0x36,0x64,0xd1,0x0,0x64,0xd2,0x0,0x36,0x64,0xd3,0x0,0x64,0xd4,0x0,0x36,0x64,0xd5,0x0,0x64,0xd6,0x0,0x36,0x64,0xd7,0x0,0x64,0xd8,0x0,0x36,0x64,0xd9,0x0,0x64,0xda,0x0,0x36,0x64,0xdb,0x0,0x64,0xdc,0x0,0x36,0x64,0xdd,0x0,0x64,0xde,0x0,0x36,0x64,0xdf,0x0,0x64,0xe0,0x0,0x36,0x64,0xe1,0x0,0x64,0xe2,0x0,0x36,0x64,0xe3,0x0,0x64,0xe4,0x0,0x36,0x64,0xe5,0x0,0x64,0xe6,0x0,0x36,0x64,0xe7,0x0,0x64,0xe8,0x0,0x36,0x64,0xe9,0x0,0x64,0xea,0x0,0x36,0x64,0xeb,0x0,0x64,0xec,0x0,0x36,0x64,0xed,0x0,0x64,0xee,0x0,0x36,0x64,0xef,0x0,0x64,0xf0,0x0,0x36,0x64,0xf1,0x0,0x64,0xf2,0x0,0x36,0x64,0xf3,0x0,0x64,0xf4,0x0,0x36,0x64,0xf5,0x0,0x64,0xf6,0x0,0x36,0x64,0xf7,0x0,0x64,0xf8,0x0,0x36,0x64,0xf9,0x0,0x64,0xfa,0x0,0x36,0x64,0xfb,0x0,0x64,0xfc,0x0,0x36,0x64,0xfd,0x0,0x64,0xfe,0x0,0x36,0x64,0xff,0x0,0x64,0x0,0x1,0x36,0x64,0x1,0x1,0x64,0x2,0x1,0x36,0x64,0x3,0x1,0x64,0x4,0x1,0x36,0x64,0x5,0x1,0x64,0x6,0x1,0x36,0x64,0x7,0x1,0x64,0x8,0x1,0x36,0x64,0x9,0x1,0x64,0xa,0x1,0x36,0x64,0xb,0x1,0x64,0xc,0x1,0x36,0x64,0xd,0x1,0x64,0xe,0x1,0x36,0x64,0xf,0x1,0x64,0x10,0x1,0x36,0x64,0x11,0x1,0x64,0x12,0x1,0x36,0x64,0x13,0x1,0x64,0x14,0x1,0x36,0x64,0x15,0x1,0x64,0x16,0x1,0x36,0x64,0x17,0x1,0x64,0x18,0x1,0x36,0x64,0x19,0x1,0x64,0x1a,0x1,0x36,0x64,0x1b,0x1,0x64,0x1c,0x1,0x36,0x64,0x1d,0x1,0x64,0x1e,0x1,0x36,0x64,0x1f,0x1,0x64,0x20,0x1,0x36,0x64,0x21,0x1,0x64,0x22,0x1,0x36,0x64,0x23,0x1,0x64,0x24,0x1,0x36,0x64,0x25,0x1,0x64,0x26,0x1,0x36,0x64,0x27,0x1,0x64,0x28,0x1,0x36,0x64,0x29,0x1,0x64,0x2a,0x1,0x36,0x64,0x2b,0x1,0x64,0x2c,0x1,0x36,0x64,0x2d,0x1,0x64,0x2e,0x1,0x36,0x5a,0xa,0x0,0x64,0x2f,0x1,0x84,0x0,0x0,0x5a,0xb,0x0,0x64,0x30,0x1,0x84,0x0,0x0,0x5a,0xc,0x0,0x64,0x31,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6c,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x69,0x73,0x7a,0x73,0x69,0x6d,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x70,0x72,0x74,0x69,0x69,0x6e,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x70,0x72,0x74,0x6f,0x69,0x6f,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x70,0x73,0x74,0x65,0x69,0x70,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x70,0x73,0x74,0x73,0x69,0x71,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x61,0x6e,0x61,0x72,0x69,0x72,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x76,0x69,0x6e,0x65,0x69,0x73,0x0,0x0,0x0,0x74,0x5,0x0,0x0,0x0,0x69,0x6e,0x76,0x69,0x73,0x69,0x74,0x0,0x0,0x0,0x74,0x8,0x0,0x0,0x0,0x65,0x71,0x75,0x61,0x6c,0x76,0x65,0x6c,0x69,0x75,0x0,0x0,0x0,0x74,0x6,0x0,0x0,0x0,0x73,0x70,0x61,0x77,0x6e,0x32,0x69,0x76,0x0,0x0,0x0,0x74,0x5,0x0,0x0,0x0,0x73,0x70,0x61,0x77,0x6e,0x69,0x77,0x0,0x0,0x0,0x74,0x5,0x0,0x0,0x0,0x73,0x68,0x6c,0x64,0x31,0x69,0x78,0x0,0x0,0x0,0x74,0x5,0x0,0x0,0x0,0x73,0x68,0x6c,0x64,0x32,0x69,0x79,0x0,0x0,0x0,0x74,0x5,0x0,0x0,0x0,0x73,0x68,0x6c,0x64,0x33,0x69,0x7a,0x0,0x0,0x0,0x74,0x5,0x0,0x0,0x0,0x73,0x68,0x6c,0x64,0x34,0x69,0x7b,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x6c,0x6f,0x6c,0x7a,0x69,0x7c,0x0,0x0,0x0,0x74,0x4,0x0,0x0,0x0,0x77,0x69,0x66,0x69,0x69,0x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,0x6e,0x73,0x5f,0x5f,0x22,0x2c,0x22,0x5f,0x5f,0x6e,0x61,0x6d,0x65,0x5f,0x5f,0x22,0x2c,0x22,0x5f,0x5f,0x64,0x6f,0x63,0x5f,0x5f,0x22,0x2c,0x22,0x5f,0x5f,0x70,0x61,0x63,0x6b,0x61,0x67,0x65,0x5f,0x5f,0x22,0x2c,0x27,0x74,0x70,0x74,0x27,0x2c,0x27,0x63,0x6c,0x65,0x61,0x6e,0x27,0x2c,0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x27,0x65,0x6c,0x65,0x6d,0x65,0x6e,0x74,0x27,0x2c,0x27,0x66,0x6f,0x72,0x6b,0x27,0x2c,0x27,0x5f,0x66,0x6f,0x72,0x6b,0x27,0x2c,0x27,0x66,0x6f,0x72,0x6b,0x5f,0x73,0x74,0x61,0x74,0x75,0x73,0x27,0x2c,0x27,0x66,0x6f,0x72,0x6b,0x5f,0x75,0x6e,0x62,0x6c,0x6f,0x63,0x6b,0x27,0x2c,0x27,0x73,0x79,0x73,0x27,0x5d,0xa,0x20,0x20,0x20,0x20,0x68,0x61,0x6e,0x64,0x6c,0x65,0x2e,0x67,0x6c,0x6f,0x62,0x3d,0x7b,0x7d,0xa,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x69,0x74,0x65,0x6d,0x20,0x69,0x6e,0x20,0x63,0x6f,0x70,0x79,0x3a,0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x68,0x61,0x6e,0x64,0x6c,0x65,0x2e,0x67,0x6c,0x6f,0x62,0x5b,0x69,0x74,0x65,0x6d,0x5d,0x3d,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x73,0x28,0x29,0x5b,0x69,0x74,0x65,0x6d,0x5d,0x74,0x0,0x0,0x0,0x0,0x4e,0x28,0x4,0x0,0x0,0x0,0x74,0x7,0x0,0x0,0x0,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x73,0x74,0x6,0x0,0x0,0x0,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x1,0x38,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x31,0x1,0x2a,0x1,0x2a,0x1,0x2a,0x1,0x2a,0x1,0x2a,0x1,0x2a,0x1,0x2a,0x1,0x2a,0x1,0xa,0x3,0x9,0x2,0x9,0x5,0x9,0xa,0x9,0xa,0x9,0xb,0x6,0x1,0x9,0x5,0x9,0xd};
+
+void pycon_open();
+void pycon_step();
+void pycon_keypress(char key, int modifier);
+void pycon_close();
+int process_command_py(pixel *vid_buf, char *console, char *console_error);
+#endif \ No newline at end of file
diff --git a/src/console.c b/src/console.c
index f6ddeb7..da33d98 100644
--- a/src/console.c
+++ b/src/console.c
@@ -2,8 +2,10 @@
#include <console.h>
#include <math.h>
-char pyready=1;
-char pygood=1;
+#ifdef PYCONSOLE
+#include <pythonconsole.h>
+#endif
+
char console_more=0;
char console_error[255] = "";
int file_script = 0;
@@ -78,882 +80,6 @@ int console_parse_partref(char *txt, int *which, char *err)
return 0;
}
-
-
-#ifdef PYCONSOLE
-/*
- * PYTHON FUNCTIONS
- * instructions on making a function callable from python:
- * first you make a function that accepts (PyObject *self, PyObject *args) as arguments
- * then you use PyArg_ParseTuple to parse the arguments, handle everything the function should do.
- * register the function by adding a line to static PyMethodDef EmbMethods[] = {
- * the line should look like this:
- * {"PyFunctionname", Functionname, METH_VARARGS,"short help string"},
- * for more information on the PyWhatever functions look here:
- * http://docs.python.org/extending/extending.html
- */
-
-//functions callable from python:
-
-static PyObject* emb_create(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int x,y,t;
- char *name = "";
- char *kwlist[] = {"x","y","t","name", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "II|Is:create",kwlist, &x,&y,&t,&name))
- return NULL;
- //
- if (strcmp(name,"")!=0)
- console_parse_type(name, &t, console_error);
- return Py_BuildValue("i",create_part(-1,x,y,t));
-}
-
-static PyObject* emb_pause(PyObject *self, PyObject *args)
-{
- int x,y,t;
- if (!PyArg_ParseTuple(args, ":unpause"))
- return NULL;
- //
- sys_pause=1;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_unpause(PyObject *self, PyObject *args)
-{
- int x,y,t;
- if (!PyArg_ParseTuple(args, ":pause"))
- return NULL;
- //
- sys_pause=0;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_toggle_pause(PyObject *self, PyObject *args)
-{
- int x,y,t;
- if (!PyArg_ParseTuple(args, ":toggle_pause"))
- return NULL;
- //
- sys_pause=!sys_pause;
- return Py_BuildValue("i",1);
-}
-
-//console_mode
-static PyObject* emb_toggle_console(PyObject *self, PyObject *args)
-{
- int x,y,t;
- if (!PyArg_ParseTuple(args, ":toggle_console"))
- return NULL;
- //
- console_mode=!console_mode;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_open_console(PyObject *self, PyObject *args)
-{
- int x,y,t;
- if (!PyArg_ParseTuple(args, ":toggle_console"))
- return NULL;
- //
- console_mode=1;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_close_console(PyObject *self, PyObject *args)
-{
- int x,y,t;
- if (!PyArg_ParseTuple(args, ":toggle_console"))
- return NULL;
- //
- console_mode=0;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_log(PyObject *self, PyObject *args)
-{
- char *buffer;
- if (!PyArg_ParseTuple(args, "s:log",&buffer))
- return NULL;
- //
- strcpy(console_error,buffer);
- puts(buffer);
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_console_more(PyObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":log"))
- return NULL;
- //
- console_more=1;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_console_less(PyObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":log"))
- return NULL;
- //
- console_more=0;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_reset_pressure(PyObject *self, PyObject *args)
-{
- int nx, ny;
- if (!PyArg_ParseTuple(args, ":reset_pressure"))
- return NULL;
- //
- for (nx = 0; nx<XRES/CELL; nx++)
- for (ny = 0; ny<YRES/CELL; ny++)
- {
- pv[ny][nx] = 0;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_reset_velocity(PyObject *self, PyObject *args)
-{
- int nx, ny;
- if (!PyArg_ParseTuple(args, ":reset_velocity"))
- return NULL;
- //
- for (nx = 0; nx<XRES/CELL; nx++)
- for (ny = 0; ny<YRES/CELL; ny++)
- {
- vx[ny][nx] = 0;
- vy[ny][nx] = 0;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_reset_sparks(PyObject *self, PyObject *args)
-{
- int i;
- if (!PyArg_ParseTuple(args, ":reset_sparks"))
- return NULL;
- //
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type==PT_SPRK)
- {
- parts[i].type = parts[i].ctype;
- parts[i].life = 4;
- }
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_life(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].life = life;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].life = life;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].life = life;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].life = life;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_type(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,life,j=-1,x=-1,y=-1;
- char *name = "";
- char *type = "";
- char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type,&life,&name,&i,&x,&y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1 && j==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- console_parse_type(type, &life, console_error);
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].type = life;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].type = life;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].type = life;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].type = life;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_temp(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,j,x=-1,y=-1;
- float newval;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type", kwlist, &newval, &name, &i, &x, &y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].temp = newval;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].temp = newval;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].temp = newval;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].temp = newval;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_tmp(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].tmp = life;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].tmp = life;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].tmp = life;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].tmp = life;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_x(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *type = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].x = life;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].x = life;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].x = life;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].x = life;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_y(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].y = life;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].y = life;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].y = life;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].y = life;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_ctype(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *type = "";
- char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type, &life, &name,&i,&x,&y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if (!life)
- console_parse_type(type, &life, console_error);
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].ctype = life;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].ctype = life;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].ctype = life;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].ctype = life;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_vx(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,j,x=-1,y=-1;
- float life;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].vx = life;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].vx = life;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].vx = life;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].vx = life;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_vy(PyObject *self, PyObject *args, PyObject *keywds)
-{
- int i = -1,j,x=-1,y=-1;
- float life;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if (strcmp(name,"all")==0)
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type)
- parts[i].vy = life;
- }
- }
- else if (console_parse_type(name, &j, console_error))
- {
- for (i=0; i<NPART; i++)
- {
- if (parts[i].type == j)
- parts[i].vy = life;
- }
- }
- else if (i!=-1)
- {
- if (parts[i].type != PT_NONE)
- parts[i].vy = life;
-
- }
- else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
- {
- if (parts[pmap[y][x]>>8].type != PT_NONE)
- parts[pmap[y][x]>>8].vy = life;
- }
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_get_pmap(PyObject *self, PyObject *args)
-{
- int x,y;
- if (!PyArg_ParseTuple(args, "II:get_pmap",&x,&y))
- return NULL;
- //
- if (x<0 || y<0 || x>=XRES || y>=YRES)
- return Py_BuildValue("i",-1);
-
- return Py_BuildValue("I",pmap[y][x]);
-}
-
-static PyObject* emb_get_prop(PyObject *self, PyObject *args)
-{
- int i;
- char *prop = "";
- if (!PyArg_ParseTuple(args, "Is:get_pmap",&i,&prop))
- return NULL;
- //
- if (parts[i].type)
- {
- if (strcmp(prop,"type")==0)
- return Py_BuildValue("i",parts[i].type);
- if (strcmp(prop,"life")==0)
- return Py_BuildValue("i",parts[i].life);
- if (strcmp(prop,"ctype")==0)
- return Py_BuildValue("i",parts[i].ctype);
- if (strcmp(prop,"temp")==0)
- return Py_BuildValue("i",parts[i].temp);
- if (strcmp(prop,"tmp")==0)
- return Py_BuildValue("i",parts[i].tmp);
- if (strcmp(prop,"vy")==0)
- return Py_BuildValue("f",parts[i].vy);
- if (strcmp(prop,"vx")==0)
- return Py_BuildValue("f",parts[i].vx);
- if (strcmp(prop,"x")==0)
- return Py_BuildValue("i",parts[i].x);
- if (strcmp(prop,"y")==0)
- return Py_BuildValue("i",parts[i].y);
- }
-
- return Py_BuildValue("i",-1);
-}
-
-static PyObject* emb_draw_pixel(PyObject *self, PyObject *args)
-{
- int x,y,r,g,b,a;
- a=255;
- if (!PyArg_ParseTuple(args, "IIIII|I:draw_pixel",&x,&y,&r,&g,&b,&a))
- return NULL;
-
- if (vid_buf!=NULL)
- {
- drawpixel(vid_buf,x,y,r,g,b,a);
- return Py_BuildValue("i",1);
- }
- return Py_BuildValue("i",-1);
-
-}
-
-static PyObject* emb_draw_text(PyObject *self, PyObject *args)
-{
- int x,y,r,g,b,a;
- char *txt;
- a=255;
- if (!PyArg_ParseTuple(args, "IIsIII|I:draw_text",&x,&y,&txt,&r,&g,&b,&a))
- return NULL;
- if (vid_buf!=NULL)
- {
- drawtext(vid_buf,x,y,txt,r,g,b,a);
- return Py_BuildValue("i",1);
- }
- return Py_BuildValue("i",-1);
-}
-
-static PyObject* emb_draw_rect(PyObject *self, PyObject *args)
-{
- int x,y,w,h,r,g,b,a;
- a=255;
- if (!PyArg_ParseTuple(args, "IIIIIII|I:draw_rect",&x,&y,&w,&h,&r,&g,&b,&a))
- return NULL;
- if (vid_buf!=NULL)
- {
- drawrect(vid_buf,x,y,w,h,r,g,b,a);
- //fillrect
- return Py_BuildValue("i",1);
- }
- return Py_BuildValue("i",-1);
-}
-
-static PyObject* emb_draw_fillrect(PyObject *self, PyObject *args)
-{
- int x,y,w,h,r,g,b,a;
- a=255;
- if (!PyArg_ParseTuple(args, "IIIIIII|I:draw_fillrect",&x,&y,&w,&h,&r,&g,&b,&a))
- return NULL;
- if (vid_buf!=NULL)
- {
- fillrect(vid_buf,x,y,w,h,r,g,b,a);
- //fillrect
- return Py_BuildValue("i",1);
- }
- return Py_BuildValue("i",-1);
-}
-
-static PyObject* emb_get_width(PyObject *self, PyObject *args)
-{
- char *txt;
- if (!PyArg_ParseTuple(args, "s:get_width",&txt))
- return NULL;
- return Py_BuildValue("i",textwidth(txt));
-}
-
-static PyObject* emb_get_mouse(PyObject *self, PyObject *args)
-{
- int x,y,mask,b1,b2,b3;
- if (!PyArg_ParseTuple(args, ":get_mouse"))
- return NULL;
- mask=SDL_GetMouseState(&x, &y);
- b1=mask&SDL_BUTTON(1);
- b2=mask&SDL_BUTTON(2);
- b3=mask&SDL_BUTTON(3);
- return Py_BuildValue("(ii(iii))",x,y,b1,b2,b3);
-}
-
-static PyObject* emb_get_name(PyObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":get_name"))
- return NULL;
- if (svf_login)
- return Py_BuildValue("s",svf_user);
- else
- return Py_BuildValue("s","");
-}
-
-static PyObject* emb_shortcuts_disable(PyObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":shortcuts_disable"))
- return NULL;
- //
- sys_shortcuts=0;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_shortcuts_enable(PyObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":shortcuts_enable"))
- return NULL;
- //
- sys_shortcuts=1;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_get_modifier(PyObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":get_modifier"))
- return NULL;
- return Py_BuildValue("(iiiiii)",sdl_mod&KMOD_LCTRL,sdl_mod&KMOD_RCTRL,sdl_mod&KMOD_LALT,sdl_mod&KMOD_RALT,sdl_mod&KMOD_LSHIFT,sdl_mod&KMOD_RSHIFT);
-}
-
-static PyObject* emb_set_keyrepeat(PyObject *self, PyObject *args)
-{
- int keydelay,keyinterval;
- keydelay=SDL_DEFAULT_REPEAT_DELAY;
- keyinterval=SDL_DEFAULT_REPEAT_INTERVAL;
- if (!PyArg_ParseTuple(args, "|ii:set_keyrepeat",&keydelay,&keyinterval))
- return NULL;
- return Py_BuildValue("i",SDL_EnableKeyRepeat(keydelay,keyinterval));
-}
-
-//delete_part
-static PyObject* emb_delete(PyObject *self, PyObject *args)
-{
- int x,y;
- if (!PyArg_ParseTuple(args, "ii:delete",&x,&y))
- return NULL;
- delete_part(x,y);
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_pressure(PyObject *self, PyObject *args)
-{
- int x,y,press;
- if (!PyArg_ParseTuple(args, "iii:set_pressure",&x,&y,&press))
- return NULL;
- pv[y/CELL][x/CELL]=press;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_set_velocity(PyObject *self, PyObject *args)
-{
- int x,y,xv,yv;
- if (!PyArg_ParseTuple(args, "iiii:set_velocity",&x,&y,&xv,&yv))
- return NULL;
- vx[y/CELL][x/CELL]=xv;
- vy[y/CELL][x/CELL]=yv;
- return Py_BuildValue("i",1);
-}
-
-static PyObject* emb_disable_python(PyObject *self, PyObject *args)
-{
- if (!PyArg_ParseTuple(args, ":disable_python"))
- return NULL;
- pyready=0;
- 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));
-}*/
-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."},
- {"reset_pressure", (PyCFunction)emb_reset_pressure, METH_VARARGS, "resets all the pressure."},
- {"reset_velocity", (PyCFunction)emb_reset_velocity, METH_VARARGS, "resets all the velocity."},
- {"reset_sparks", (PyCFunction)emb_reset_sparks, METH_VARARGS, "resets all the sparks."},
- {"set_life", (PyCFunction)emb_set_life, METH_VARARGS|METH_KEYWORDS, "sets life of a specified particle."},
- {"set_type", (PyCFunction)emb_set_type, METH_VARARGS|METH_KEYWORDS, "sets type of a specified particle."},
- {"set_temp", (PyCFunction)emb_set_temp, METH_VARARGS|METH_KEYWORDS, "sets temp of a specified particle."},
- {"set_tmp", (PyCFunction)emb_set_tmp, METH_VARARGS|METH_KEYWORDS, "sets tmp of a specified particle."},
- {"set_x", (PyCFunction)emb_set_x, METH_VARARGS|METH_KEYWORDS, "sets x of a specified particle."},
- {"set_y", (PyCFunction)emb_set_y, METH_VARARGS|METH_KEYWORDS, "sets y of a specified particle."},
- {"set_ctype", (PyCFunction)emb_set_ctype, METH_VARARGS|METH_KEYWORDS, "sets ctype of a specified particle."},
- {"set_vx", (PyCFunction)emb_set_vx, METH_VARARGS|METH_KEYWORDS, "sets vx of a specified particle."},
- {"set_vy", (PyCFunction)emb_set_vy, METH_VARARGS|METH_KEYWORDS, "sets vy of a specified particle."},
- {"pause", (PyCFunction)emb_pause, METH_VARARGS, "pause the game."},
- {"unpause", (PyCFunction)emb_unpause, METH_VARARGS, "unpause the game."},
- {"pause_toggle", (PyCFunction)emb_toggle_pause, METH_VARARGS, "toggle game pause."},
- {"console_open", (PyCFunction)emb_open_console, METH_VARARGS, "open the game console."},
- {"console_close", (PyCFunction)emb_close_console, METH_VARARGS, "close the game console."},
- {"console_toggle", (PyCFunction)emb_toggle_console, METH_VARARGS, "toggle the game console."},
- {"console_more", (PyCFunction)emb_console_more, METH_VARARGS, "turns the more indicator on."},
- {"console_less", (PyCFunction)emb_console_less, METH_VARARGS, "turns the more indicator off."},
- {"get_pmap", (PyCFunction)emb_get_pmap, METH_VARARGS, "get the pmap value."},
- {"get_prop", (PyCFunction)emb_get_prop, METH_VARARGS, "get some properties."},
- {"draw_pixel", (PyCFunction)emb_draw_pixel, METH_VARARGS, "draw a pixel."},
- {"draw_text", (PyCFunction)emb_draw_text, METH_VARARGS, "draw some text."},
- {"draw_rect", (PyCFunction)emb_draw_rect, METH_VARARGS, "draw a rect."},
- {"draw_fillrect", (PyCFunction)emb_draw_fillrect, METH_VARARGS, "draw a rect."},
- {"get_width", (PyCFunction)emb_get_width, METH_VARARGS, "get string width."},
- {"get_mouse", (PyCFunction)emb_get_mouse, METH_VARARGS, "get mouse status."},
- {"get_name", (PyCFunction)emb_get_name, METH_VARARGS, "get name of logged in user"},
- {"shortcuts_disable", (PyCFunction)emb_shortcuts_disable, METH_VARARGS, "disable keyboard shortcuts"},
- {"shortcuts_enable", (PyCFunction)emb_shortcuts_enable, METH_VARARGS, "enable keyboard shortcuts"},
- {"get_modifier", (PyCFunction)emb_get_modifier, METH_VARARGS, "get pressed modifier keys"},
- {"set_keyrepeat", (PyCFunction)emb_set_keyrepeat, METH_VARARGS, "set key repeat rate."},
- {"delete", (PyCFunction)emb_delete, METH_VARARGS, "delete a particle"},
- {"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
-
-#ifdef PYCONSOLE
-int process_command(pixel *vid_buf, char *console, char *console_error, PyObject *pfunc)
-{
- int y,x,nx,ny,i,j,k,m;
- int do_next = 1;
- char xcoord[10];
- char ycoord[10];
- char console2[15];
- char console3[15];
- char console4[15];
- char console5[15];
- PyObject *pvalue,*pargs;
- //sprintf(console_error, "%s", console);
- if (console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
- {
- sscanf(console,"%14s %14s %14s %14s", console2, console3, console4, console5);//why didn't i know about this function?!
- if (strcmp(console2, "quit")==0)
- {
- return -1;
- } else {
- //handle them command
- pargs=Py_BuildValue("(s)",console);
- pvalue = PyObject_CallObject(pfunc, pargs);
- Py_DECREF(pargs);
- pargs=NULL;
- if (pvalue==NULL)
- strcpy(console_error,"failed to execute code.");
- pvalue=NULL;
- }
- }
- return 1;
-}
-#endif
int process_command_old(pixel *vid_buf, char *console, char *console_error)
{
int y,x,nx,ny,i,j,k,m;
@@ -1068,11 +194,13 @@ int process_command_old(pixel *vid_buf, char *console, char *console_error)
if (sound_enable) play_sound(console3);
else strcpy(console_error, "Audio device not available - cannot play sounds");
}
+#ifdef PYCONSOLE
else if (strcmp(console2, "python")==0)
if (pygood==1)
pyready=1;
else
- strcpy(console_error, "python not ready. check stdout for more info.");
+ strcpy(console_error, "python not ready. check stdout for more info.")
+#endif
else if (strcmp(console2, "load")==0 && console3[0])
{
j = atoi(console3);
diff --git a/src/interface.c b/src/interface.c
index c77141f..3a5662c 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -21,6 +21,9 @@
#else
#include <dirent.h>
#endif
+#ifdef PYCONSOLE
+#include <pythonconsole.h>
+#endif
SDLMod sdl_mod;
int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
@@ -4628,13 +4631,13 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
else
i=0;
if (pyready)
- drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python by Doxin)", 255, i, i, 255);
+ drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, Python enabled)", 255, i, i, 255);
else
- drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python disabled)", 255, i, i, 255);
+ drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, Python disabled)", 255, i, i, 255);
#elif defined(LUACONSOLE)
drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.4 (by cracker64, Lua enabled)", 255, 255, 255, 255);
#else
- drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python disabled)", 255, 255, 255, 255);
+ drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64)", 255, 255, 255, 255);
#endif
cc = 0;
diff --git a/src/main.c b/src/main.c
index 823be5e..1bb2eb0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -56,7 +56,7 @@
#include <icon.h>
#include <console.h>
#ifdef PYCONSOLE
-#include "pyconsole.h"
+#include "pythonconsole.h"
#endif
#ifdef LUACONSOLE
#include "luaconsole.h"
@@ -1632,10 +1632,6 @@ int main(int argc, char *argv[])
unsigned int hsvSave = PIXRGB(0,255,127);//this is hsv format
SDL_AudioSpec fmt;
int username_flash = 0, username_flash_t = 1;
-#ifdef PYCONSOLE
- PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey;
- PyObject *tpt_console_obj;
-#endif
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
pthread_win32_thread_attach_np();
@@ -1667,67 +1663,7 @@ int main(int argc, char *argv[])
luacon_open();
#endif
#ifdef PYCONSOLE
- //initialise python console
- Py_Initialize();
- PyRun_SimpleString("print 'python present.'");
- Py_InitModule("tpt", EmbMethods);
-
- //change the path to find all the correct modules
- PyRun_SimpleString("import sys\nsys.path.append('./tptPython.zip')\nsys.path.append('.')");
- //load the console module and whatnot
-#ifdef PYEXT
- PyRun_SimpleString(tpt_console_py);
- printf("using external python console file.\n");
- pname=PyString_FromString("tpt_console");//create string object
- pmodule = PyImport_Import(pname);//import module
- Py_DECREF(pname);//throw away string
-#else
- tpt_console_obj = PyMarshal_ReadObjectFromString(tpt_console_pyc+8, sizeof(tpt_console_pyc)-8);
- pmodule=PyImport_ExecCodeModule("tpt_console", tpt_console_obj);
-#endif
- if (pmodule!=NULL)
- {
- pfunc=PyObject_GetAttrString(pmodule,"handle");//get the handler function
- if (pfunc && PyCallable_Check(pfunc))//check if it's really a function
- {
- printf("python console ready to go.\n");
- }
- else
- {
- PyErr_Print();
- printf("unable to find handle function, mangled console.py?\n");
- pyready = 0;
- pygood = 0;
- }
-
- pstep=PyObject_GetAttrString(pmodule,"step");//get the handler function
- if (pstep && PyCallable_Check(pstep))//check if it's really a function
- {
- printf("step function found.\n");
- }
- else
- {
- printf("unable to find step function. ignoring.\n");
- }
-
- pkey=PyObject_GetAttrString(pmodule,"keypress");//get the handler function
- if (pstep && PyCallable_Check(pkey))//check if it's really a function
- {
- printf("key function found.\n");
- }
- else
- {
- printf("unable to find key function. ignoring.\n");
- }
- }
- else
- {
- //sys.stderr
- PyErr_Print();
- printf("unable to find console module, missing file or mangled console.py?\n");
- pyready = 0;
- pygood = 0;
- }
+ pycon_open();
#endif
#ifdef MT
@@ -2101,6 +2037,11 @@ int main(int argc, char *argv[])
sdl_key = 0;
}
#endif
+#ifdef PYCONSOLE
+ if(sdl_key){
+ pycon_keypress(sdl_key, sdl_mod);
+ }
+#endif
if (sys_shortcuts==1)//all shortcuts can be disabled by python scripts
{
if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
@@ -2528,19 +2469,6 @@ int main(int argc, char *argv[])
}
}
}
-#ifdef PYCONSOLE
- if (pyready==1 && pygood==1)
- if (pkey!=NULL && sdl_key!=NULL)
- {
- pargs=Py_BuildValue("(c)",sdl_key);
- pvalue = PyObject_CallObject(pkey, pargs);
- Py_DECREF(pargs);
- pargs=NULL;
- if (pvalue==NULL)
- strcpy(console_error,"failed to execute key code.");
- pvalue=NULL;
- }
-#endif
#ifdef INTERNAL
int counterthing;
if (sdl_key=='v'&&!(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))//frame capture
@@ -3535,7 +3463,7 @@ int main(int argc, char *argv[])
console = console_ui(vid_buf,console_error,console_more);
console = mystrdup(console);
strcpy(console_error,"");
- if (process_command(vid_buf, console, console_error,pfunc)==-1)
+ if (process_command_py(vid_buf, console, console_error)==-1)
{
free(console);
break;
@@ -3593,19 +3521,7 @@ int main(int argc, char *argv[])
//execute python step hook
#ifdef PYCONSOLE
- if (pyready==1 && pygood==1)
- if (pstep!=NULL)
- {
- pargs=Py_BuildValue("()");
- pvalue = PyObject_CallObject(pstep, pargs);
- Py_DECREF(pargs);
- pargs=NULL;
- if (pvalue==NULL)
- strcpy(console_error,"failed to execute step code.");
- //Py_DECREF(pvalue);
- //puts("a");
- pvalue=NULL;
- }
+ pycon_step();
#endif
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
@@ -3634,12 +3550,7 @@ int main(int argc, char *argv[])
luacon_close();
#endif
#ifdef PYCONSOLE
-
- PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.py'))\nexcept:\n pass");
- PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyo'))\nexcept:\n pass");
- PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyc'))\nexcept:\n pass");
-
- Py_Finalize();//cleanup any python stuff.
+ pycon_close();
#endif
#ifdef PTW32_STATIC_LIB
pthread_win32_thread_detach_np();
diff --git a/src/pythonconsole.c b/src/pythonconsole.c
new file mode 100644
index 0000000..4dc5072
--- /dev/null
+++ b/src/pythonconsole.c
@@ -0,0 +1,981 @@
+#ifdef PYCONSOLE
+#include <powder.h>
+#include <console.h>
+#include <pythonconsole.h>
+
+char pyready=1;
+char pygood=1;
+PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey;
+PyObject *tpt_console_obj;
+void pycon_open(){
+ //initialise python console
+ Py_Initialize();
+ PyRun_SimpleString("print 'python present.'");
+ Py_InitModule("tpt", EmbMethods);
+
+ //change the path to find all the correct modules
+ PyRun_SimpleString("import sys\nsys.path.append('./tptPython.zip')\nsys.path.append('.')");
+ //load the console module and whatnot
+#ifdef PYEXT
+ PyRun_SimpleString(tpt_console_py);
+ printf("using external python console file.\n");
+ pname=PyString_FromString("tpt_console");//create string object
+ pmodule = PyImport_Import(pname);//import module
+ Py_DECREF(pname);//throw away string
+#else
+ tpt_console_obj = PyMarshal_ReadObjectFromString(tpt_console_pyc+8, sizeof(tpt_console_pyc)-8);
+ pmodule=PyImport_ExecCodeModule("tpt_console", tpt_console_obj);
+#endif
+
+ if (pmodule!=NULL)
+ {
+ pfunc=PyObject_GetAttrString(pmodule,"handle");//get the handler function
+ if (pfunc && PyCallable_Check(pfunc))//check if it's really a function
+ {
+ printf("python console ready to go.\n");
+ }
+ else
+ {
+ PyErr_Print();
+ printf("unable to find handle function, mangled console.py?\n");
+ pyready = 0;
+ pygood = 0;
+ }
+
+ pstep=PyObject_GetAttrString(pmodule,"step");//get the handler function
+ if (pstep && PyCallable_Check(pstep))//check if it's really a function
+ {
+ printf("step function found.\n");
+ }
+ else
+ {
+ printf("unable to find step function. ignoring.\n");
+ }
+
+ pkey=PyObject_GetAttrString(pmodule,"keypress");//get the handler function
+ if (pstep && PyCallable_Check(pkey))//check if it's really a function
+ {
+ printf("key function found.\n");
+ }
+ else
+ {
+ printf("unable to find key function. ignoring.\n");
+ }
+ }
+ else
+ {
+ //sys.stderr
+ PyErr_Print();
+ printf("unable to find console module, missing file or mangled console.py?\n");
+ pyready = 0;
+ pygood = 0;
+ }
+}
+void pycon_step(){
+ if (pyready==1 && pygood==1)
+ if (pstep!=NULL)
+ {
+ pargs=Py_BuildValue("()");
+ pvalue = PyObject_CallObject(pstep, pargs);
+ Py_DECREF(pargs);
+ pargs=NULL;
+ if (pvalue==NULL)
+ strcpy(console_error,"failed to execute step code.");
+ //Py_DECREF(pvalue);
+ //puts("a");
+ pvalue=NULL;
+ }
+}
+void pycon_close(){
+
+ PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.py'))\nexcept:\n pass");
+ PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyo'))\nexcept:\n pass");
+ PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyc'))\nexcept:\n pass");
+
+ Py_Finalize();//cleanup any python stuff.
+}
+int process_command_py(pixel *vid_buf, char *console, char *console_error)
+{
+ int y,x,nx,ny,i,j,k,m;
+ int do_next = 1;
+ char xcoord[10];
+ char ycoord[10];
+ char console2[15];
+ char console3[15];
+ char console4[15];
+ char console5[15];
+ //PyObject *pvalue,*pargs;
+ //sprintf(console_error, "%s", console);
+ if (console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
+ {
+ sscanf(console,"%14s %14s %14s %14s", console2, console3, console4, console5);//why didn't i know about this function?!
+ if (strcmp(console2, "quit")==0)
+ {
+ return -1;
+ } else {
+ //handle them command
+ pargs=Py_BuildValue("(s)",console);
+ pvalue = PyObject_CallObject(pfunc, pargs);
+ Py_DECREF(pargs);
+ pargs=NULL;
+ if (pvalue==NULL)
+ strcpy(console_error,"failed to execute code.");
+ pvalue=NULL;
+ }
+ }
+ return 1;
+}
+void pycon_keypress(char key, int modifier){
+ if (pyready==1 && pygood==1)
+ if (pkey!=NULL && sdl_key!=NULL)
+ {
+ pargs=Py_BuildValue("(c)",sdl_key);
+ pvalue = PyObject_CallObject(pkey, pargs);
+ Py_DECREF(pargs);
+ pargs=NULL;
+ if (pvalue==NULL)
+ strcpy(console_error,"failed to execute key code.");
+ pvalue=NULL;
+ }
+}
+
+/*
+ * PYTHON FUNCTIONS
+ * instructions on making a function callable from python:
+ * first you make a function that accepts (PyObject *self, PyObject *args) as arguments
+ * then you use PyArg_ParseTuple to parse the arguments, handle everything the function should do.
+ * register the function by adding a line to static PyMethodDef EmbMethods[] = {
+ * the line should look like this:
+ * {"PyFunctionname", Functionname, METH_VARARGS,"short help string"},
+ * for more information on the PyWhatever functions look here:
+ * http://docs.python.org/extending/extending.html
+ */
+
+//functions callable from python:
+
+static PyObject* emb_create(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int x,y,t;
+ char *name = "";
+ char *kwlist[] = {"x","y","t","name", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "II|Is:create",kwlist, &x,&y,&t,&name))
+ return NULL;
+ //
+ if (strcmp(name,"")!=0)
+ console_parse_type(name, &t, console_error);
+ return Py_BuildValue("i",create_part(-1,x,y,t));
+}
+
+static PyObject* emb_pause(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":unpause"))
+ return NULL;
+ //
+ sys_pause=1;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_unpause(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":pause"))
+ return NULL;
+ //
+ sys_pause=0;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_toggle_pause(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":toggle_pause"))
+ return NULL;
+ //
+ sys_pause=!sys_pause;
+ return Py_BuildValue("i",1);
+}
+
+//console_mode
+static PyObject* emb_toggle_console(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=!console_mode;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_open_console(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=1;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_close_console(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=0;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_log(PyObject *self, PyObject *args)
+{
+ char *buffer;
+ if (!PyArg_ParseTuple(args, "s:log",&buffer))
+ return NULL;
+ //
+ strcpy(console_error,buffer);
+ puts(buffer);
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_console_more(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":log"))
+ return NULL;
+ //
+ console_more=1;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_console_less(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":log"))
+ return NULL;
+ //
+ console_more=0;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_reset_pressure(PyObject *self, PyObject *args)
+{
+ int nx, ny;
+ if (!PyArg_ParseTuple(args, ":reset_pressure"))
+ return NULL;
+ //
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = 0;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_reset_velocity(PyObject *self, PyObject *args)
+{
+ int nx, ny;
+ if (!PyArg_ParseTuple(args, ":reset_velocity"))
+ return NULL;
+ //
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ vx[ny][nx] = 0;
+ vy[ny][nx] = 0;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_reset_sparks(PyObject *self, PyObject *args)
+{
+ int i;
+ if (!PyArg_ParseTuple(args, ":reset_sparks"))
+ return NULL;
+ //
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type==PT_SPRK)
+ {
+ parts[i].type = parts[i].ctype;
+ parts[i].life = 4;
+ }
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_life(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].life = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].life = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].life = life;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].life = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_type(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j=-1,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1 && j==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ console_parse_type(type, &life, console_error);
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].type = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].type = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].type = life;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].type = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_temp(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,j,x=-1,y=-1;
+ float newval;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type", kwlist, &newval, &name, &i, &x, &y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].temp = newval;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].temp = newval;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].temp = newval;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].temp = newval;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_tmp(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].tmp = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].tmp = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].tmp = life;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].tmp = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_x(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].x = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].x = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].x = life;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].x = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_y(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].y = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].y = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].y = life;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].y = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_ctype(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type, &life, &name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (!life)
+ console_parse_type(type, &life, console_error);
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].ctype = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].ctype = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].ctype = life;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].ctype = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_vx(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,j,x=-1,y=-1;
+ float life;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].vx = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].vx = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].vx = life;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].vx = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_vy(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,j,x=-1,y=-1;
+ float life;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].vy = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].vy = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
+ parts[i].vy = life;
+
+ }
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].vy = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_get_pmap(PyObject *self, PyObject *args)
+{
+ int x,y;
+ if (!PyArg_ParseTuple(args, "II:get_pmap",&x,&y))
+ return NULL;
+ //
+ if (x<0 || y<0 || x>=XRES || y>=YRES)
+ return Py_BuildValue("i",-1);
+
+ return Py_BuildValue("I",pmap[y][x]);
+}
+
+static PyObject* emb_get_prop(PyObject *self, PyObject *args)
+{
+ int i;
+ char *prop = "";
+ if (!PyArg_ParseTuple(args, "Is:get_pmap",&i,&prop))
+ return NULL;
+ //
+ if (parts[i].type)
+ {
+ if (strcmp(prop,"type")==0)
+ return Py_BuildValue("i",parts[i].type);
+ if (strcmp(prop,"life")==0)
+ return Py_BuildValue("i",parts[i].life);
+ if (strcmp(prop,"ctype")==0)
+ return Py_BuildValue("i",parts[i].ctype);
+ if (strcmp(prop,"temp")==0)
+ return Py_BuildValue("i",parts[i].temp);
+ if (strcmp(prop,"tmp")==0)
+ return Py_BuildValue("i",parts[i].tmp);
+ if (strcmp(prop,"vy")==0)
+ return Py_BuildValue("f",parts[i].vy);
+ if (strcmp(prop,"vx")==0)
+ return Py_BuildValue("f",parts[i].vx);
+ if (strcmp(prop,"x")==0)
+ return Py_BuildValue("i",parts[i].x);
+ if (strcmp(prop,"y")==0)
+ return Py_BuildValue("i",parts[i].y);
+ }
+
+ return Py_BuildValue("i",-1);
+}
+
+static PyObject* emb_draw_pixel(PyObject *self, PyObject *args)
+{
+ int x,y,r,g,b,a;
+ a=255;
+ if (!PyArg_ParseTuple(args, "IIIII|I:draw_pixel",&x,&y,&r,&g,&b,&a))
+ return NULL;
+
+ if (vid_buf!=NULL)
+ {
+ drawpixel(vid_buf,x,y,r,g,b,a);
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+
+}
+
+static PyObject* emb_draw_text(PyObject *self, PyObject *args)
+{
+ int x,y,r,g,b,a;
+ char *txt;
+ a=255;
+ if (!PyArg_ParseTuple(args, "IIsIII|I:draw_text",&x,&y,&txt,&r,&g,&b,&a))
+ return NULL;
+ if (vid_buf!=NULL)
+ {
+ drawtext(vid_buf,x,y,txt,r,g,b,a);
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+}
+
+static PyObject* emb_draw_rect(PyObject *self, PyObject *args)
+{
+ int x,y,w,h,r,g,b,a;
+ a=255;
+ if (!PyArg_ParseTuple(args, "IIIIIII|I:draw_rect",&x,&y,&w,&h,&r,&g,&b,&a))
+ return NULL;
+ if (vid_buf!=NULL)
+ {
+ drawrect(vid_buf,x,y,w,h,r,g,b,a);
+ //fillrect
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+}
+
+static PyObject* emb_draw_fillrect(PyObject *self, PyObject *args)
+{
+ int x,y,w,h,r,g,b,a;
+ a=255;
+ if (!PyArg_ParseTuple(args, "IIIIIII|I:draw_fillrect",&x,&y,&w,&h,&r,&g,&b,&a))
+ return NULL;
+ if (vid_buf!=NULL)
+ {
+ fillrect(vid_buf,x,y,w,h,r,g,b,a);
+ //fillrect
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+}
+
+static PyObject* emb_get_width(PyObject *self, PyObject *args)
+{
+ char *txt;
+ if (!PyArg_ParseTuple(args, "s:get_width",&txt))
+ return NULL;
+ return Py_BuildValue("i",textwidth(txt));
+}
+
+static PyObject* emb_get_mouse(PyObject *self, PyObject *args)
+{
+ int x,y,mask,b1,b2,b3;
+ if (!PyArg_ParseTuple(args, ":get_mouse"))
+ return NULL;
+ mask=SDL_GetMouseState(&x, &y);
+ b1=mask&SDL_BUTTON(1);
+ b2=mask&SDL_BUTTON(2);
+ b3=mask&SDL_BUTTON(3);
+ return Py_BuildValue("(ii(iii))",x,y,b1,b2,b3);
+}
+
+static PyObject* emb_get_name(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":get_name"))
+ return NULL;
+ if (svf_login)
+ return Py_BuildValue("s",svf_user);
+ else
+ return Py_BuildValue("s","");
+}
+
+static PyObject* emb_shortcuts_disable(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":shortcuts_disable"))
+ return NULL;
+ //
+ sys_shortcuts=0;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_shortcuts_enable(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":shortcuts_enable"))
+ return NULL;
+ //
+ sys_shortcuts=1;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_get_modifier(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":get_modifier"))
+ return NULL;
+ return Py_BuildValue("(iiiiii)",sdl_mod&KMOD_LCTRL,sdl_mod&KMOD_RCTRL,sdl_mod&KMOD_LALT,sdl_mod&KMOD_RALT,sdl_mod&KMOD_LSHIFT,sdl_mod&KMOD_RSHIFT);
+}
+
+static PyObject* emb_set_keyrepeat(PyObject *self, PyObject *args)
+{
+ int keydelay,keyinterval;
+ keydelay=SDL_DEFAULT_REPEAT_DELAY;
+ keyinterval=SDL_DEFAULT_REPEAT_INTERVAL;
+ if (!PyArg_ParseTuple(args, "|ii:set_keyrepeat",&keydelay,&keyinterval))
+ return NULL;
+ return Py_BuildValue("i",SDL_EnableKeyRepeat(keydelay,keyinterval));
+}
+
+//delete_part
+static PyObject* emb_delete(PyObject *self, PyObject *args)
+{
+ int x,y;
+ if (!PyArg_ParseTuple(args, "ii:delete",&x,&y))
+ return NULL;
+ delete_part(x,y);
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_pressure(PyObject *self, PyObject *args)
+{
+ int x,y,press;
+ if (!PyArg_ParseTuple(args, "iii:set_pressure",&x,&y,&press))
+ return NULL;
+ pv[y/CELL][x/CELL]=press;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_set_velocity(PyObject *self, PyObject *args)
+{
+ int x,y,xv,yv;
+ if (!PyArg_ParseTuple(args, "iiii:set_velocity",&x,&y,&xv,&yv))
+ return NULL;
+ vx[y/CELL][x/CELL]=xv;
+ vy[y/CELL][x/CELL]=yv;
+ return Py_BuildValue("i",1);
+}
+
+static PyObject* emb_disable_python(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":disable_python"))
+ return NULL;
+ pyready=0;
+ 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));
+}*/
+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."},
+ {"reset_pressure", (PyCFunction)emb_reset_pressure, METH_VARARGS, "resets all the pressure."},
+ {"reset_velocity", (PyCFunction)emb_reset_velocity, METH_VARARGS, "resets all the velocity."},
+ {"reset_sparks", (PyCFunction)emb_reset_sparks, METH_VARARGS, "resets all the sparks."},
+ {"set_life", (PyCFunction)emb_set_life, METH_VARARGS|METH_KEYWORDS, "sets life of a specified particle."},
+ {"set_type", (PyCFunction)emb_set_type, METH_VARARGS|METH_KEYWORDS, "sets type of a specified particle."},
+ {"set_temp", (PyCFunction)emb_set_temp, METH_VARARGS|METH_KEYWORDS, "sets temp of a specified particle."},
+ {"set_tmp", (PyCFunction)emb_set_tmp, METH_VARARGS|METH_KEYWORDS, "sets tmp of a specified particle."},
+ {"set_x", (PyCFunction)emb_set_x, METH_VARARGS|METH_KEYWORDS, "sets x of a specified particle."},
+ {"set_y", (PyCFunction)emb_set_y, METH_VARARGS|METH_KEYWORDS, "sets y of a specified particle."},
+ {"set_ctype", (PyCFunction)emb_set_ctype, METH_VARARGS|METH_KEYWORDS, "sets ctype of a specified particle."},
+ {"set_vx", (PyCFunction)emb_set_vx, METH_VARARGS|METH_KEYWORDS, "sets vx of a specified particle."},
+ {"set_vy", (PyCFunction)emb_set_vy, METH_VARARGS|METH_KEYWORDS, "sets vy of a specified particle."},
+ {"pause", (PyCFunction)emb_pause, METH_VARARGS, "pause the game."},
+ {"unpause", (PyCFunction)emb_unpause, METH_VARARGS, "unpause the game."},
+ {"pause_toggle", (PyCFunction)emb_toggle_pause, METH_VARARGS, "toggle game pause."},
+ {"console_open", (PyCFunction)emb_open_console, METH_VARARGS, "open the game console."},
+ {"console_close", (PyCFunction)emb_close_console, METH_VARARGS, "close the game console."},
+ {"console_toggle", (PyCFunction)emb_toggle_console, METH_VARARGS, "toggle the game console."},
+ {"console_more", (PyCFunction)emb_console_more, METH_VARARGS, "turns the more indicator on."},
+ {"console_less", (PyCFunction)emb_console_less, METH_VARARGS, "turns the more indicator off."},
+ {"get_pmap", (PyCFunction)emb_get_pmap, METH_VARARGS, "get the pmap value."},
+ {"get_prop", (PyCFunction)emb_get_prop, METH_VARARGS, "get some properties."},
+ {"draw_pixel", (PyCFunction)emb_draw_pixel, METH_VARARGS, "draw a pixel."},
+ {"draw_text", (PyCFunction)emb_draw_text, METH_VARARGS, "draw some text."},
+ {"draw_rect", (PyCFunction)emb_draw_rect, METH_VARARGS, "draw a rect."},
+ {"draw_fillrect", (PyCFunction)emb_draw_fillrect, METH_VARARGS, "draw a rect."},
+ {"get_width", (PyCFunction)emb_get_width, METH_VARARGS, "get string width."},
+ {"get_mouse", (PyCFunction)emb_get_mouse, METH_VARARGS, "get mouse status."},
+ {"get_name", (PyCFunction)emb_get_name, METH_VARARGS, "get name of logged in user"},
+ {"shortcuts_disable", (PyCFunction)emb_shortcuts_disable, METH_VARARGS, "disable keyboard shortcuts"},
+ {"shortcuts_enable", (PyCFunction)emb_shortcuts_enable, METH_VARARGS, "enable keyboard shortcuts"},
+ {"get_modifier", (PyCFunction)emb_get_modifier, METH_VARARGS, "get pressed modifier keys"},
+ {"set_keyrepeat", (PyCFunction)emb_set_keyrepeat, METH_VARARGS, "set key repeat rate."},
+ {"delete", (PyCFunction)emb_delete, METH_VARARGS, "delete a particle"},
+ {"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