X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=d2645960674a93a8112d1c9b9db28fe0bf379cbe;hp=b37667c1f4d334223400ebbfe87ad8d65c08cbf4;hb=d4c11da68a7271553ca5591adfae54fd3b45011f;hpb=3dc317d10b44cc6b75db10ac194966ad8114d390 diff --git a/src/tools.c b/src/tools.c index b37667c1..d2645960 100644 --- a/src/tools.c +++ b/src/tools.c @@ -11,6 +11,8 @@ * tools.c * ***********************************************************/ +#include + #ifdef __FreeBSD__ #include #endif @@ -25,8 +27,6 @@ #include "cartoons.h" #include "network.h" -#include - #ifdef MSDOS extern boolean wait_for_vsync; #endif @@ -89,11 +89,13 @@ void BackToFront() this could mean that we have to wait for the graphics to complete, although we could go on doing calculations for the next frame */ - XSync(display,FALSE); + XSync(display, FALSE); + /* #ifdef MSDOS wait_for_vsync = TRUE; #endif + */ if (redraw_mask & REDRAW_ALL) { @@ -115,13 +117,15 @@ void BackToFront() if (setup.soft_scrolling) { - fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0); - fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0); + fx += (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); + fy += (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); } - XCopyArea(display,buffer,window,gc, - fx,fy, SXSIZE,SYSIZE, - SX,SY); + if (setup.soft_scrolling || + ABS(ScreenGfxPos) + ScrollStepSize == TILEX || + ABS(ScreenGfxPos) == ScrollStepSize || + redraw_tiles > REDRAWTILES_THRESHOLD) + XCopyArea(display, buffer, window, gc, fx, fy, SXSIZE, SYSIZE, SX, SY); } redraw_mask &= ~REDRAW_MAIN; } @@ -281,9 +285,39 @@ void ClearWindow() redraw_mask |= REDRAW_FIELD; } -void DrawText(int x, int y, char *text, int font, int col) +void DrawTextFCentered(int y, int font_type, char *format, ...) +{ + char buffer[FULL_SXSIZE / FONT3_XSIZE + 10]; + int font_xsize; + va_list ap; + + font_xsize = (font_type < FC_SPECIAL1 ? FONT2_XSIZE : + font_type < FC_SPECIAL2 ? FONT3_XSIZE : FONT4_XSIZE); + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + DrawText(SX + (SXSIZE - strlen(buffer) * font_xsize) / 2, SY + y, + buffer, FS_SMALL, font_type); +} + +void DrawTextF(int x, int y, int font_type, char *format, ...) { - DrawTextExt(drawto, gc, x, y, text, font, col); + char buffer[FULL_SXSIZE / FONT3_XSIZE + 10]; + va_list ap; + + va_start(ap, format); + vsprintf(buffer, format, ap); + va_end(ap); + + DrawText(SX + x, SY + y, buffer, FS_SMALL, font_type); +} + +void DrawText(int x, int y, char *text, int font_size, int font_type) +{ + DrawTextExt(drawto, gc, x, y, text, font_size, font_type); + if (x < DX) redraw_mask |= REDRAW_FIELD; else if (y < VY) @@ -291,23 +325,23 @@ void DrawText(int x, int y, char *text, int font, int col) } void DrawTextExt(Drawable d, GC gc, int x, int y, - char *text, int font, int font_color) + char *text, int font_size, int font_type) { int font_width, font_height, font_start; int font_pixmap; - if (font != FS_SMALL && font != FS_BIG) - font = FS_SMALL; - if (font_color < FC_RED || font_color > FC_SPECIAL2) - font_color = FC_RED; - - font_width = (font == FS_BIG ? FONT1_XSIZE : - font_color < FC_SPECIAL1 ? FONT2_XSIZE : - font_color < FC_SPECIAL2 ? FONT3_XSIZE : FONT4_XSIZE); - font_height = (font == FS_BIG ? FONT1_XSIZE : - font_color < FC_SPECIAL2 ? FONT2_XSIZE : FONT4_XSIZE); - font_pixmap = (font == FS_BIG ? PIX_BIGFONT : PIX_SMALLFONT); - font_start = (font_color * (font == FS_BIG ? FONT1_YSIZE : FONT2_YSIZE) * + if (font_size != FS_SMALL && font_size != FS_BIG) + font_size = FS_SMALL; + if (font_type < FC_RED || font_type > FC_SPECIAL2) + font_type = FC_RED; + + font_width = (font_size == FS_BIG ? FONT1_XSIZE : + font_type < FC_SPECIAL1 ? FONT2_XSIZE : + font_type < FC_SPECIAL2 ? FONT3_XSIZE : FONT4_XSIZE); + font_height = (font_size == FS_BIG ? FONT1_XSIZE : + font_type < FC_SPECIAL2 ? FONT2_XSIZE : FONT4_XSIZE); + font_pixmap = (font_size == FS_BIG ? PIX_BIGFONT : PIX_SMALLFONT); + font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE : FONT2_YSIZE) * FONT_LINES_PER_FONT); while(*text) @@ -797,6 +831,8 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, src_x = (graphic % HEROES_PER_LINE) * TILEX + cx; src_y = (graphic / HEROES_PER_LINE) * TILEY + cy; } + else /* big font graphics currently not allowed (and not needed) */ + return; dest_x = FX + x * TILEX + dx; dest_y = FY + y * TILEY + dy; @@ -1308,11 +1344,13 @@ boolean Request(char *text, unsigned int req_state) int mx, my, ty, result = -1; unsigned int old_door_state; +#ifndef MSDOS /* pause network game while waiting for request to answer */ if (options.network && game_status == PLAYING && req_state & REQUEST_WAIT_FOR) SendToServer_PausePlaying(); +#endif old_door_state = GetDoorState(); @@ -1514,11 +1552,13 @@ boolean Request(char *text, unsigned int req_state) } } +#ifndef MSDOS /* continue network game after request */ if (options.network && game_status == PLAYING && req_state & REQUEST_WAIT_FOR) SendToServer_ContinuePlaying(); +#endif return(result); } @@ -1561,11 +1601,11 @@ unsigned int GetDoorState() unsigned int MoveDoor(unsigned int door_state) { - static unsigned int door1 = DOOR_OPEN_1; - static unsigned int door2 = DOOR_CLOSE_2; - static long door_delay = 0; + static int door1 = DOOR_OPEN_1; + static int door2 = DOOR_CLOSE_2; + static unsigned long door_delay = 0; int x, start, stepsize = 2; - long door_delay_value = stepsize * 5; + unsigned long door_delay_value = stepsize * 5; if (door_state == DOOR_GET_STATE) return(door1 | door2);