From fb7306526f0d6e2fe58c12ec7daad098f97b709f Mon Sep 17 00:00:00 2001 From: Ian C Date: Thu, 12 May 2005 23:40:12 +0000 Subject: Fixed ledit --- ledit.c | 155 +++++++++++++++++++++++++++------------------------------------- 1 file changed, 66 insertions(+), 89 deletions(-) diff --git a/ledit.c b/ledit.c index 1a5c26c..6297dff 100644 --- a/ledit.c +++ b/ledit.c @@ -42,26 +42,28 @@ static char rcs_id[]="$Id$"; #define RND(x) (rand()%(x)) XSizeHints size_hints; -int black,white; +ulong black,white; Display *disp; Window window; Colormap cm; XFontStruct *font; -XFuncControl Key(); -XFuncControl Mouse(); -XFuncControl Motion(); -XFuncControl Process(); +XFuncControl Key(Window w, XPressRelease mode, XEvent *e); +XFuncControl Mouse(Window w, XPressRelease mode, int b, int x, int y); +XFuncControl Motion(Window w, int x, int y); +XFuncControl Process(void); +void ReadFile(void); +void WriteFile(void); -XCallBack key[2]={{0,Key},{0,NULL}}; -XCallBack mouse[2]={{0,Mouse},{0,NULL}}; -XCallBack motion[2]={{0,Motion},{0,NULL}}; +XWindowKeyCallback key[2]={{0,Key},{0,NULL}}; +XWindowButtonCallback mouse[2]={{0,Mouse},{0,NULL}}; +XWindowMoveCallBack motion[2]={{0,Motion},{0,NULL}}; #define NOCOL 7 -char *colnames[NOCOL]= +const char *colnames[NOCOL]= {"black","white","red","yellow","blue","green","cyan"}; -int pix[NOCOL]; +ulong pix[NOCOL]; #define BLACK pix[0] #define WHITE pix[1] @@ -113,10 +115,7 @@ int mx,my; int gx=0,gy=0; -int main(argc,argv) -int argc; -char *argv[]; - +int main(int argc, char *argv[]) { unsigned long evmask; @@ -141,15 +140,15 @@ char *argv[]; &size_hints,&black,&white); if (argc>1) - { + { fname=argv[1]; ReadFile(); - } + } else - { + { fprintf(stderr,"Must supply a level file\n"); exit(1); - } + } if (argc>2) CONST=atoi(argv[2]); @@ -164,19 +163,15 @@ char *argv[]; } -XFuncControl Key(w,m,e) -Window w; -int m; -XEvent *e; - +XFuncControl Key(Window w,XPressRelease m, XEvent *e) { KeySym k; if (m==XPRESS) return; - switch(k=XLookupKeysym(e,ShiftMapIndex)) - { + switch(k=XLookupKeysym((XKeyEvent*)e,ShiftMapIndex)) + { case XK_G: /* Set centre */ case XK_g: gx=STOMX(e->xkey.x); @@ -192,20 +187,20 @@ XEvent *e; case XK_C: /* Create poly */ case XK_c: if (noxkey.x); obj[no].o.y=STOMY(e->xkey.y); cur=no++; - } + } break; case XK_O: /* Set origin */ case XK_o: if (no) - { + { obj[cur].o.x=STOMX(e->xkey.x); obj[cur].o.y=STOMY(e->xkey.y); - } + } break; case XK_D: /* Delete poly */ @@ -257,17 +252,13 @@ XEvent *e; default: break; - } + } - return(XFUNCCONT); + return XFUNCCONT; } -XFuncControl Mouse(w,m,b,x,y) -Window w; -int m; -int b,x,y; - +XFuncControl Mouse(Window w, XPressRelease m, int b, int x, int y) { int mapx,mapy; @@ -275,10 +266,10 @@ int b,x,y; return (XFUNCCONT); switch(b) - { + { case 1: /* Add point */ if (obj[cur].no