summaryrefslogtreecommitdiff
path: root/src/interface.c
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-04-23 12:41:08 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-04-25 11:07:55 (GMT)
commit7b82eae82e770410feeed841b7e2c05c7e20d9da (patch)
tree5f933f239676718957966dc3b62b96720f68de14 /src/interface.c
parentaef09292ee83479571524e4900c903af03efe7e5 (diff)
downloadpowder-7b82eae82e770410feeed841b7e2c05c7e20d9da.zip
powder-7b82eae82e770410feeed841b7e2c05c7e20d9da.tar.gz
Jacksonmj: Move console functions into seperate file
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c75
1 files changed, 1 insertions, 74 deletions
diff --git a/src/interface.c b/src/interface.c
index d8672cb..b31a107 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -14,9 +14,8 @@
#include <powder.h>
#include <interface.h>
#include <misc.h>
+#include <console.h>
-
-//char pyready=1;
SDLMod sdl_mod;
int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
@@ -4204,78 +4203,6 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
return NULL;
}
-//takes a a string and compares it to element names, and puts it value into element.
-int console_parse_type(char *txt, int *element, char *err)
-{
- int i = -1;
- // alternative names for some elements
- if (strcasecmp(txt,"C4")==0) i = PT_PLEX;
- else if (strcasecmp(txt,"C5")==0) i = PT_C5;
- else if (strcasecmp(txt,"NONE")==0) i = PT_NONE;
- if (i>=0)
- {
- *element = i;
- strcpy(err,"");
- return 1;
- }
- for (i=1; i<PT_NUM; i++) {
- if (strcasecmp(txt,ptypes[i].name)==0)
- {
- *element = i;
- strcpy(err,"");
- return 1;
- }
- }
- strcpy(err, "Particle type not recognised");
- return 0;
-}
-//takes a string of coords "x,y" and puts the values into x and y.
-int console_parse_coords(char *txt, int *x, int *y, char *err)
-{
- // TODO: use regex?
- int nx = -1, ny = -1;
- if (sscanf(txt,"%d,%d",&nx,&ny)!=2 || nx<0 || nx>=XRES || ny<0 || ny>=YRES)
- {
- strcpy(err,"Invalid coordinates");
- return 0;
- }
- *x = nx;
- *y = ny;
- return 1;
-}
-//takes a string of either coords or a particle number, and puts the particle number into *which
-int console_parse_partref(char *txt, int *which, char *err)
-{
- int i = -1, nx, ny;
- strcpy(err,"");
- // TODO: use regex?
- if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err))
- {
- i = pmap[ny][nx];
- if (!i || (i>>8)>=NPART)
- i = -1;
- else
- i = i>>8;
- }
- else if (txt)
- {
- char *num = (char*)malloc(strlen(txt)+3);
- i = atoi(txt);
- sprintf(num,"%d",i);
- if (!txt || strcmp(txt,num)!=0)
- i = -1;
- free(num);
- }
- if (i>=0 && i<NPART && parts[i].type)
- {
- *which = i;
- strcpy(err,"");
- return 1;
- }
- if (strcmp(err,"")==0) strcpy(err,"Particle does not exist");
- return 0;
-}
-
void decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy)
{
int i,ss,hh,vv,cr=127,cg=0,cb=0,b = 0,mx,my,bq = 0,j, lb=0,lx=0,ly=0,lm=0;