X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=16cb3984075fd88b48bec40c43a3f39ead5e8d48;hb=b461a474a18f36ff4bd5f1805ea01de11dd5a5fc;hp=7a99fd61f9a41ef90f119071d87464235575708c;hpb=b583d4fa28df35b6974bd075d3de65a841454556;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 7a99fd61..16cb3984 100644 --- a/src/tools.c +++ b/src/tools.c @@ -279,7 +279,7 @@ void BackToFront() info1[0] = '\0'; sprintf(text, "%.1f fps%s", global.frames_per_second, info1); - DrawTextExt(window, SX, SY, text, FS_SMALL, FC_YELLOW); + DrawTextExt(window, SX, SY, text, FS_SMALL, FC_YELLOW, FONT_OPAQUE); } FlushDisplay(); @@ -362,9 +362,32 @@ void FadeToFront() BackToFront(); } +void SetMainBackgroundImage(int graphic) +{ + SetMainBackgroundBitmap(graphic == IMG_NONE ? NULL : + new_graphic_info[graphic].bitmap ? + new_graphic_info[graphic].bitmap : + new_graphic_info[IMG_BACKGROUND_DEFAULT].bitmap); +} + +void SetDoorBackgroundImage(int graphic) +{ + SetDoorBackgroundBitmap(graphic == IMG_NONE ? NULL : + new_graphic_info[graphic].bitmap ? + new_graphic_info[graphic].bitmap : + new_graphic_info[IMG_BACKGROUND_DEFAULT].bitmap); +} + +void DrawBackground(int dest_x, int dest_y, int width, int height) +{ + ClearRectangleOnBackground(backbuffer, dest_x, dest_y, width, height); + + redraw_mask |= REDRAW_FIELD; +} + void ClearWindow() { - ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); + DrawBackground(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); if (setup.soft_scrolling && game_status == PLAYING) { @@ -379,8 +402,6 @@ void ClearWindow() ClearRectangle(window, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); SetDrawtoField(DRAW_DIRECT); } - - redraw_mask |= REDRAW_FIELD; } static int getGraphicAnimationPhase(int frames, int delay, int mode) @@ -657,9 +678,10 @@ void DrawPlayer(struct PlayerInfo *player) { int px = SCREENX(next_jx), py = SCREENY(next_jy); - if (element == EL_SOKOBAN_FIELD_EMPTY || - Feld[next_jx][next_jy] == EL_SOKOBAN_FIELD_FULL) - DrawGraphicShiftedThruMask(px, py, sxx, syy, GFX_SOKOBAN_OBJEKT, 0, + if ((sxx || syy) && + (element == EL_SOKOBAN_FIELD_EMPTY || + Feld[next_jx][next_jy] == EL_SOKOBAN_FIELD_FULL)) + DrawGraphicShiftedThruMask(px, py, sxx, syy, IMG_SOKOBAN_OBJECT, 0, NO_CUTTING); else { @@ -669,9 +691,7 @@ void DrawPlayer(struct PlayerInfo *player) int frame = 0; #endif - if ((element == EL_ROCK || - element == EL_BD_ROCK || - element == EL_SP_ZONK) && sxx) + if ((sxx || syy) && IS_PUSHABLE(element)) { graphic = el_dir_act2img(element, player->MovDir, GFX_ACTION_MOVING); #if 1 @@ -725,7 +745,7 @@ void DrawPlayer(struct PlayerInfo *player) #endif if (game.emulation == EMU_SUPAPLEX) - DrawGraphic(sx, sy, GFX_SP_DISK_RED, 0); + DrawGraphic(sx, sy, IMG_SP_DISK_RED, 0); else DrawGraphicThruMask(sx, sy, graphic, frame); } @@ -1306,6 +1326,12 @@ inline static int getGfxAction(int x, int y) gfx_action = GfxAction[x][y]; #endif +#if DEBUG + if (gfx_action < 0) + printf("getGfxAction: THIS SHOULD NEVER HAPPEN: GfxAction[%d][%d] == %d\n", + x, y, gfx_action); +#endif + return gfx_action; } @@ -1313,11 +1339,23 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, int cut_mode, int mask_mode) { int ux = LEVELX(x), uy = LEVELY(y); - int move_dir = MovDir[ux][uy]; - int move_pos = getFramePosition(ux, uy); - int gfx_action = getGfxAction(ux, uy); - int graphic = el_dir_act2img(element, move_dir, gfx_action); - int frame = getGraphicAnimationFrame(graphic, move_pos); + int graphic; + int frame; + + if (IN_LEV_FIELD(ux, uy)) + { + int move_dir = MovDir[ux][uy]; + int move_pos = getFramePosition(ux, uy); + int gfx_action = getGfxAction(ux, uy); + + graphic = el_dir_act2img(element, move_dir, gfx_action); + frame = getGraphicAnimationFrame(graphic, move_pos); + } + else + { + graphic = el2img(element); + frame = getGraphicAnimationFrame(graphic, 0); + } if (element == EL_WALL_GROWING) { @@ -1717,12 +1755,7 @@ void DrawMicroElement(int xpos, int ypos, int element) { Bitmap *src_bitmap; int src_x, src_y; - int graphic; - - if (element == EL_EMPTY) - return; - - graphic = el2img(element); + int graphic = el2img(element); getMicroGraphicSource(graphic, &src_bitmap, &src_x, &src_y); BlitBitmap(src_bitmap, drawto, src_x, src_y, MICRO_TILEX, MICRO_TILEY, @@ -1733,6 +1766,7 @@ void DrawLevel() { int x,y; + SetDrawBackgroundMask(REDRAW_NONE); ClearWindow(); for(x=BX1; x<=BX2; x++) @@ -1757,7 +1791,7 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) { int x, y; - ClearRectangle(drawto, xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE); + DrawBackground(xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE); if (lev_fieldx < STD_LEV_FIELDX) xpos += (STD_LEV_FIELDX - lev_fieldx) / 2 * MICRO_TILEX; @@ -1776,7 +1810,8 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) if (lx >= 0 && lx < lev_fieldx && ly >= 0 && ly < lev_fieldy) DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, Ur[lx][ly]); - else if (lx >= -1 && lx < lev_fieldx+1 && ly >= -1 && ly < lev_fieldy+1) + else if (lx >= -1 && lx < lev_fieldx+1 && ly >= -1 && ly < lev_fieldy+1 + && BorderElement != EL_EMPTY) DrawMicroElement(xpos + x * MICRO_TILEX, ypos + y * MICRO_TILEY, BorderElement); } @@ -1798,7 +1833,7 @@ static void DrawMicroLevelLabelExt(int mode) { char label_text[MAX_MICROLABEL_SIZE + 1]; - ClearRectangle(drawto, SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE); + DrawBackground(SX, MICROLABEL_YPOS, SXSIZE, FONT4_YSIZE); strncpy(label_text, (mode == MICROLABEL_LEVEL_NAME ? level.name : mode == MICROLABEL_CREATED_BY ? "created by" : @@ -1950,8 +1985,10 @@ boolean Request(char *text, unsigned int req_state) DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1); + SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1); + /* clear door drawing field */ - ClearRectangle(drawto, DX, DY, DXSIZE, DYSIZE); + DrawBackground(DX, DY, DXSIZE, DYSIZE); /* write text for request */ for(ty=0; ty < MAX_REQUEST_LINES; ty++) @@ -1979,8 +2016,8 @@ boolean Request(char *text, unsigned int req_state) strncpy(text_line, text, tl); text_line[tl] = 0; - DrawTextExt(drawto, DX + 50 - (tl * 14)/2, DY + 8 + ty * 16, - text_line, FS_SMALL, FC_YELLOW); + DrawText(DX + 50 - (tl * 14)/2, DY + 8 + ty * 16, + text_line, FS_SMALL, FC_YELLOW); text += tl + (tc == ' ' ? 1 : 0); } @@ -2014,7 +2051,11 @@ boolean Request(char *text, unsigned int req_state) #endif if (!(req_state & REQUEST_WAIT_FOR)) - return(FALSE); + { + SetDrawBackgroundMask(REDRAW_FIELD); + + return FALSE; + } if (game_status != MAINMENU) InitAnimation(); @@ -2023,6 +2064,8 @@ boolean Request(char *text, unsigned int req_state) request_gadget_id = -1; + SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1); + while(result < 0) { if (PendingEvent()) @@ -2158,6 +2201,8 @@ boolean Request(char *text, unsigned int req_state) RemapAllGadgets(); + SetDrawBackgroundMask(REDRAW_FIELD); + #if defined(PLATFORM_UNIX) /* continue network game after request */ if (options.network && @@ -2166,7 +2211,7 @@ boolean Request(char *text, unsigned int req_state) SendToServer_ContinuePlaying(); #endif - return(result); + return result; } unsigned int OpenDoor(unsigned int door_state) @@ -2244,10 +2289,17 @@ unsigned int MoveDoor(unsigned int door_state) { stepsize = 20; door_delay_value = 0; + StopSound(SND_MENU_DOOR_OPENING); StopSound(SND_MENU_DOOR_CLOSING); } + if (global.autoplay_leveldir) + { + door_state |= DOOR_NO_DELAY; + door_state &= ~DOOR_CLOSE_ALL; + } + if (door_state & DOOR_ACTION) { if (!(door_state & DOOR_NO_DELAY)) @@ -2263,10 +2315,11 @@ unsigned int MoveDoor(unsigned int door_state) for(x=start; x<=DXSIZE; x+=stepsize) { - Bitmap *bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap; + Bitmap *bitmap = new_graphic_info[IMG_GLOBAL_DOOR].bitmap; GC gc = bitmap->stored_clip_gc; - WaitUntilDelayReached(&door_delay, door_delay_value); + if (!(door_state & DOOR_NO_DELAY)) + WaitUntilDelayReached(&door_delay, door_delay_value); if (door_state & DOOR_ACTION_1) { @@ -2368,8 +2421,12 @@ unsigned int MoveDoor(unsigned int door_state) void DrawSpecialEditorDoor() { /* draw bigger toolbox window */ - BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, drawto, - DOOR_GFX_PAGEX7, 0, 108, 56, EX - 4, EY - 12); + BlitBitmap(new_graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, + DOOR_GFX_PAGEX7, 0, EXSIZE + 8, 8, + EX - 4, EY - 12); + BlitBitmap(new_graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, + EX - 4, VY - 4, EXSIZE + 8, EYSIZE - VYSIZE + 4, + EX - 4, EY - 4); redraw_mask |= REDRAW_ALL; } @@ -2377,8 +2434,9 @@ void DrawSpecialEditorDoor() void UndrawSpecialEditorDoor() { /* draw normal tape recorder window */ - BlitBitmap(new_graphic_info[IMG_MENU_BACK].bitmap, drawto, - 562, 344, 108, 56, EX - 4, EY - 12); + BlitBitmap(new_graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, + EX - 4, EY - 12, EXSIZE + 8, EYSIZE - VYSIZE + 12, + EX - 4, EY - 12); redraw_mask |= REDRAW_ALL; } @@ -2506,7 +2564,7 @@ void CreateToolButtons() for (i=0; i