| version 1.3 | | version 1.4 |
|---|
| | |
| /* | | /* |
| * static char *rcsid_xutil_c = | | * static char *rcsid_xutil_c = |
| * "$Id: xutil.c,v 1.3 2001/12/28 08:56:32 mwedel Exp $"; | | * "$Id: xutil.c,v 1.4 2002/01/15 07:33:02 mwedel Exp $"; |
| */ | | */ |
| /* | | /* |
| Crossfire client, a client program for the crossfire program. | | Crossfire client, a client program for the crossfire program. |
| | |
| "White", /* 1 */ | | "White", /* 1 */ |
| "Navy", /* 2 */ | | "Navy", /* 2 */ |
| "Red", /* 3 */ | | "Red", /* 3 */ |
| "Orange", /* 4 */ | | "Chocolate", /* 4 was Orange, but impossible to read on DarkSeaGreen */ |
| "DodgerBlue", /* 5 */ | | "DodgerBlue", /* 5 */ |
| "DarkOrange2", /* 6 */ | | "DarkOrange2", /* 6 */ |
| "SeaGreen", /* 7 */ | | "SeaGreen", /* 7 */ |
| | |
| */ | | */ |
| | | |
| pixmaps[0].mask=None; | | pixmaps[0].mask=None; |
| pixmaps[0].bitmap=XCreateBitmapFromData(display, | | pixmaps[0].bitmap=XCreateBitmapFromData(display,DefaultRootWindow(display), |
| RootWindow(display, screen_num), (const char*)question_bits, image_size,image_size); | | question_bits,question_width,question_height); |
| | | |
| /* In xpm mode, XCopyArea is used from this data, so we need to copy | | /* In xpm mode, XCopyArea is used from this data, so we need to copy |
| * the image into an pixmap of appropriate depth. | | * the image into an pixmap of appropriate depth. |
| * Note that while are image created is the image size, since we know | | |
| * that are filler image is currently only 24x24, we only copy that much | | |
| * data. | | |
| */ | | */ |
| pixmaps[0].pixmap=XCreatePixmap(display, win_root, image_size, image_size, | | pixmaps[0].pixmap=XCreatePixmap(display, win_root, image_size, image_size, |
| DefaultDepth(display,DefaultScreen(display))); | | DefaultDepth(display,DefaultScreen(display))); |
| XCopyPlane(display, pixmaps[0].bitmap, pixmaps[0].pixmap, gc_game, | | XCopyPlane(display, pixmaps[0].bitmap, pixmaps[0].pixmap, gc_game, |
| 0,0,24,24,0,0,1); | | 0,0,image_size,image_size,0,0,1); |
| | | |
| pixmaps[0].bg = 0; | | pixmaps[0].bg = 0; |
| pixmaps[0].fg = 1; | | pixmaps[0].fg = 1; |
| | |
| char buf[MAX_BUF]; | | char buf[MAX_BUF]; |
| | | |
| facetoname[pnum] = strdup_local(facepath); | | facetoname[pnum] = strdup_local(facepath); |
| sprintf(buf,"askface %d", pnum); | | cs_print_string(csocket.fd, "askface %d", pnum); |
| cs_write_string(csocket.fd, buf, strlen(buf)); | | |
| /* Need to make sure we have the directory */ | | /* Need to make sure we have the directory */ |
| sprintf(buf,"%s/%c%c", facecachedir, facename[0], facename[1]); | | sprintf(buf,"%s/%c%c", facecachedir, facename[0], facename[1]); |
| if (access(buf,R_OK)) make_path_to_dir(buf); | | if (access(buf,R_OK)) make_path_to_dir(buf); |
| | |
| #ifndef GDK_XUTIL | | #ifndef GDK_XUTIL |
| Pixmap pixmap, mask; | | Pixmap pixmap, mask; |
| #endif | | #endif |
| | | unsigned long w,h; |
| | | |
| /* Check private cache first */ | | /* Check private cache first */ |
| sprintf(buf,"%s/.crossfire/gfx/%s", getenv("HOME"), face); | | sprintf(buf,"%s/.crossfire/gfx/%s.png", getenv("HOME"), face); |
| if (display_mode == Png_Display) | | |
| strcat(buf,".png"); | | |
| | | |
| if ((fd=open(buf, O_RDONLY))!=-1) { | | if ((fd=open(buf, O_RDONLY))!=-1) { |
| len=read(fd, data, 65535); | | len=read(fd, data, 65535); |
| | |
| /* To prevent having a directory with 2000 images, we do a simple | | /* To prevent having a directory with 2000 images, we do a simple |
| * split on the first 2 characters. | | * split on the first 2 characters. |
| */ | | */ |
| sprintf(buf,"%s/%c%c/%s", facecachedir, face[0], face[1],face); | | sprintf(buf,"%s/%c%c/%s.png", facecachedir, face[0], face[1],face); |
| if (display_mode == Png_Display) | | |
| strcat(buf,".png"); | | |
| | | |
| if ((fd=open(buf, O_RDONLY))==-1) { | | if ((fd=open(buf, O_RDONLY))==-1) { |
| requestface(pnum, face, buf); | | requestface(pnum, face, buf); |
| | |
| #endif | | #endif |
| } | | } |
| } | | } |
| if (display_mode==Png_Display) { | | |
| unsigned long w,h; | | |
| | | |
| /* Fail on this read, we will request a new copy */ | | /* Fail on this read, we will request a new copy */ |
| if (png_to_xpixmap(display, win_game, data, len, | | if (png_to_xpixmap(display, win_game, data, len, |
| | |
| pixmaps[pnum].pixmap = pixmap; | | pixmaps[pnum].pixmap = pixmap; |
| pixmaps[pnum].mask = mask; | | pixmaps[pnum].mask = mask; |
| } | | } |
| | | |
| } else if (display_mode==Pix_Display) { | | |
| pixmaps[pnum].bitmap = XCreateBitmapFromData(display, | | |
| RootWindow(display,DefaultScreen(display)), | | |
| (char*)data,24,24); | | |
| pixmaps[pnum].fg = (data[24] << 24) + (data[25] << 16) + (data[26] << 8) + | | |
| data[27]; | | |
| pixmaps[pnum].bg = (data[28] << 24) + (data[29] << 16 )+ (data[30] << 8 )+ | | |
| data[31]; | | |
| } | | |
| } | | } |
| | | |
| | | |
| | |
| /* This parses a keypress. It should only be called when in Playing | | /* This parses a keypress. It should only be called when in Playing |
| * mode. | | * mode. |
| */ | | */ |
| void parse_key(char key, KeyCode keycode, KeySym keysym) | | void parse_key(char key, KeyCode keycode, KeySym keysym, int repeated) |
| { | | { |
| Key_Entry *keyentry, *first_match=NULL; | | Key_Entry *keyentry, *first_match=NULL; |
| int present_flags=0; | | int present_flags=0; |
| | |
| run_dir(first_match->direction); | | run_dir(first_match->direction); |
| sprintf(buf,"run %s", first_match->command); | | sprintf(buf,"run %s", first_match->command); |
| } | | } |
| else { | | else if (!repeated) { |
| strcpy(buf,first_match->command); | | strcpy(buf,first_match->command); |
| extended_command(first_match->command); | | extended_command(first_match->command); |
| } | | } |
| | | else |
| | | sprintf(buf,"move %s (ignored)", first_match->command); |
| if (cpl.echo_bindings) draw_info(buf,NDI_BLACK); | | if (cpl.echo_bindings) draw_info(buf,NDI_BLACK); |
| } | | } |
| else { | | else { |
| | |
| unsigned long y; | | unsigned long y; |
| #endif | | #endif |
| | | |
| if ((display_mode != Png_Display) || (image_file[0] == 0)) return 0; | | if (image_file[0] == 0) return 0; |
| | | |
| if (!cache_images) { | | if (!cache_images) { |
| cache_images=1; /* we want face commands from server */ | | cache_images=1; /* we want face commands from server */ |
| | |
| } | | } |
| } | | } |
| | | |
| cs_write_string( csocket.fd, "mapredraw", 9); | | cs_print_string(csocket.fd, "mapredraw"); |
| | | |
| return; | | return; |
| } | | } |
| | | |