X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=84198618ee2a7baad4d783662277f6f49f6ad158;hb=fe3196f07cb50ffb788c0073b82f94c26f93cfbf;hp=e46b0a6dd34c564336ed8a5dd9b5fe761dddebe8;hpb=cb81cac37a6a681c0ee295918e5ef919fbef1e90;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index e46b0a6d..84198618 100644 --- a/src/tools.c +++ b/src/tools.c @@ -19,6 +19,7 @@ #include "cartoons.h" #include "network.h" #include "tape.h" +#include "screens.h" /* select level set with EMC X11 graphics before activating EM GFX debugging */ @@ -240,6 +241,11 @@ void DrawMaskedBorder_ALL() void DrawMaskedBorder(int redraw_mask) { + /* do not draw masked screen borders when displaying title screens */ + if (effectiveGameStatus() == GAME_MODE_TITLE || + effectiveGameStatus() == GAME_MODE_MESSAGE) + return; + if (redraw_mask & REDRAW_ALL) DrawMaskedBorder_ALL(); else @@ -274,7 +280,7 @@ void BackToFront() if (redraw_mask & REDRAW_TILES && game_status == GAME_MODE_PLAYING && - border.draw_masked[game_status]) + border.draw_masked[GAME_MODE_PLAYING]) redraw_mask |= REDRAW_FIELD; if (global.fps_slowdown && game_status == GAME_MODE_PLAYING) @@ -314,15 +320,16 @@ void BackToFront() SyncDisplay(); -#if 1 - DrawMaskedBorder(redraw_mask); -#endif + /* prevent drawing masked border to backbuffer when using playfield buffer */ + if (game_status != GAME_MODE_PLAYING || + redraw_mask & REDRAW_FROM_BACKBUFFER || + buffer == backbuffer) + DrawMaskedBorder(redraw_mask); + else + DrawMaskedBorder(redraw_mask & REDRAW_DOORS); if (redraw_mask & REDRAW_ALL) { -#if 0 - DrawMaskedBorder(REDRAW_ALL); -#endif BlitBitmap(backbuffer, window, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); redraw_mask = REDRAW_NONE; @@ -333,9 +340,6 @@ void BackToFront() if (game_status != GAME_MODE_PLAYING || redraw_mask & REDRAW_FROM_BACKBUFFER) { -#if 0 - DrawMaskedBorder(REDRAW_FIELD); -#endif BlitBitmap(backbuffer, window, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, REAL_SX, REAL_SY); } @@ -354,21 +358,23 @@ void BackToFront() ABS(ScreenMovPos) == ScrollStepSize || redraw_tiles > REDRAWTILES_THRESHOLD) { -#if 1 - if (border.draw_masked[GFX_SPECIAL_ARG_MAIN]) + if (border.draw_masked[GAME_MODE_PLAYING]) { - BlitBitmap(buffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY); + if (buffer != backbuffer) + { + /* copy playfield buffer to backbuffer to add masked border */ + BlitBitmap(buffer, backbuffer, fx, fy, SXSIZE, SYSIZE, SX, SY); + DrawMaskedBorder(REDRAW_FIELD); + } - DrawMaskedBorder(REDRAW_FIELD); BlitBitmap(backbuffer, window, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE, REAL_SX, REAL_SY); } else + { BlitBitmap(buffer, window, fx, fy, SXSIZE, SYSIZE, SX, SY); -#else - BlitBitmap(buffer, window, fx, fy, SXSIZE, SYSIZE, SX, SY); -#endif + } #if 0 #ifdef DEBUG @@ -392,28 +398,13 @@ void BackToFront() if (redraw_mask & REDRAW_DOORS) { if (redraw_mask & REDRAW_DOOR_1) - { -#if 0 - DrawMaskedBorder(REDRAW_DOOR_1); -#endif BlitBitmap(backbuffer, window, DX, DY, DXSIZE, DYSIZE, DX, DY); - } if (redraw_mask & REDRAW_DOOR_2) - { -#if 0 - DrawMaskedBorder(REDRAW_DOOR_2); -#endif BlitBitmap(backbuffer, window, VX, VY, VXSIZE, VYSIZE, VX, VY); - } if (redraw_mask & REDRAW_DOOR_3) - { -#if 0 - DrawMaskedBorder(REDRAW_DOOR_3); -#endif BlitBitmap(backbuffer, window, EX, EY, EXSIZE, EYSIZE, EX, EY); - } redraw_mask &= ~REDRAW_DOORS; } @@ -597,10 +588,16 @@ void FadeCrossSaveBackbuffer() BlitBitmap(backbuffer, bitmap_db_cross, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); } +void SetWindowBackgroundImageIfDefined(int graphic) +{ + if (graphic_info[graphic].bitmap) + SetWindowBackgroundBitmap(graphic_info[graphic].bitmap); +} + void SetMainBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) - SetMainBackgroundImage(graphic); + SetMainBackgroundBitmap(graphic_info[graphic].bitmap); } void SetMainBackgroundImage(int graphic) @@ -627,21 +624,46 @@ void SetPanelBackground() SetDoorBackgroundBitmap(bitmap_db_panel); } -void DrawBackground(int dst_x, int dst_y, int width, int height) +void DrawBackground(int x, int y, int width, int height) { -#if 1 - ClearRectangleOnBackground(drawto, dst_x, dst_y, width, height); + /* !!! "drawto" might still point to playfield buffer here (see below) !!! */ + /* (when entering hall of fame after playing) */ +#if 0 + ClearRectangleOnBackground(drawto, x, y, width, height); #else - ClearRectangleOnBackground(backbuffer, dst_x, dst_y, width, height); + ClearRectangleOnBackground(backbuffer, x, y, width, height); #endif redraw_mask |= REDRAW_FIELD; } +void DrawBackgroundForFont(int x, int y, int width, int height, int font_nr) +{ + struct FontBitmapInfo *font = getFontBitmapInfo(font_nr); + + if (font->bitmap == NULL) + return; + + DrawBackground(x, y, width, height); +} + +void DrawBackgroundForGraphic(int x, int y, int width, int height, int graphic) +{ + struct GraphicInfo *g = &graphic_info[graphic]; + + if (g->bitmap == NULL) + return; + + DrawBackground(x, y, width, height); +} + void ClearWindow() { + /* !!! "drawto" might still point to playfield buffer here (see above) !!! */ + /* (when entering hall of fame after playing) */ DrawBackground(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); + /* !!! maybe this should be done before clearing the background !!! */ if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING) { ClearRectangle(fieldbuffer, 0, 0, FXSIZE, FYSIZE); @@ -688,6 +710,39 @@ void SetBorderElement() } } +void FloodFillLevel(int from_x, int from_y, int fill_element, + short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY], + int max_fieldx, int max_fieldy) +{ + int i,x,y; + int old_element; + static int check[4][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } }; + static int safety = 0; + + /* check if starting field still has the desired content */ + if (field[from_x][from_y] == fill_element) + return; + + safety++; + + if (safety > max_fieldx * max_fieldy) + Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug."); + + old_element = field[from_x][from_y]; + field[from_x][from_y] = fill_element; + + for (i = 0; i < 4; i++) + { + x = from_x + check[i][0]; + y = from_y + check[i][1]; + + if (IN_FIELD(x, y, max_fieldx, max_fieldy) && field[x][y] == old_element) + FloodFillLevel(x, y, fill_element, field, max_fieldx, max_fieldy); + } + + safety--; +} + void SetRandomAnimationValue(int x, int y) { gfx.anim_random_frame = GfxRandom[x][y]; @@ -1355,13 +1410,17 @@ void DrawScreenField(int x, int y) boolean cut_mode = NO_CUTTING; if (element == EL_QUICKSAND_EMPTYING || + element == EL_QUICKSAND_FAST_EMPTYING || element == EL_MAGIC_WALL_EMPTYING || element == EL_BD_MAGIC_WALL_EMPTYING || + element == EL_DC_MAGIC_WALL_EMPTYING || element == EL_AMOEBA_DROPPING) cut_mode = CUT_ABOVE; else if (element == EL_QUICKSAND_FILLING || + element == EL_QUICKSAND_FAST_FILLING || element == EL_MAGIC_WALL_FILLING || - element == EL_BD_MAGIC_WALL_FILLING) + element == EL_BD_MAGIC_WALL_FILLING || + element == EL_DC_MAGIC_WALL_FILLING) cut_mode = CUT_BELOW; if (cut_mode == CUT_ABOVE) @@ -1403,8 +1462,10 @@ void DrawScreenField(int x, int y) content_old = Store[oldx][oldy]; if (element_old == EL_QUICKSAND_EMPTYING || + element_old == EL_QUICKSAND_FAST_EMPTYING || element_old == EL_MAGIC_WALL_EMPTYING || element_old == EL_BD_MAGIC_WALL_EMPTYING || + element_old == EL_DC_MAGIC_WALL_EMPTYING || element_old == EL_AMOEBA_DROPPING) cut_mode = CUT_ABOVE; @@ -1551,9 +1612,17 @@ void AnimateEnvelope(int envelope_nr, int anim_mode, int action) for (yy = 0; yy < ysize; yy++) for (xx = 0; xx < xsize; xx++) DrawEnvelopeBackground(envelope_nr, sx,sy, xx,yy, xsize, ysize, font_nr); +#if 1 + DrawTextBuffer(SX + sx + font_width, SY + sy + font_height, + level.envelope[envelope_nr].text, font_nr, max_xsize, + xsize - 2, ysize - 2, mask_mode, + level.envelope[envelope_nr].autowrap, + level.envelope[envelope_nr].centered); +#else DrawTextToTextArea(SX + sx + font_width, SY + sy + font_height, level.envelope[envelope_nr].text, font_nr, max_xsize, xsize - 2, ysize - 2, mask_mode); +#endif redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER; BackToFront(); @@ -1717,7 +1786,7 @@ static void DrawPreviewLevelExt(int from_x, int from_y) #define MICROLABEL_IMPORTED_BY_HEAD 6 #define MICROLABEL_IMPORTED_BY 7 -static int getMaxTextLength(struct MenuPosInfo *pos, int font_nr) +static int getMaxTextLength(struct TextPosInfo *pos, int font_nr) { int max_text_width = SXSIZE; int font_width = getFontWidth(font_nr); @@ -1734,7 +1803,7 @@ static int getMaxTextLength(struct MenuPosInfo *pos, int font_nr) static void DrawPreviewLevelLabelExt(int mode) { - struct MenuPosInfo *pos = &menu.main.text.level_info_2; + struct TextPosInfo *pos = &menu.main.text.level_info_2; char label_text[MAX_OUTPUT_LINESIZE + 1]; int max_len_label_text; int font_nr = FONT_TEXT_2; @@ -1751,6 +1820,11 @@ static void DrawPreviewLevelLabelExt(int mode) max_len_label_text = SXSIZE / getFontWidth(font_nr); #endif +#if 1 + if (pos->chars != -1) + max_len_label_text = pos->chars; +#endif + for (i = 0; i < max_len_label_text; i++) label_text[i] = ' '; label_text[max_len_label_text] = '\0'; @@ -1837,7 +1911,7 @@ void DrawPreviewLevel(boolean restart) if (leveldir_current->name) { - struct MenuPosInfo *pos = &menu.main.text.level_info_1; + struct TextPosInfo *pos = &menu.main.text.level_info_1; char label_text[MAX_OUTPUT_LINESIZE + 1]; int font_nr = FONT_TEXT_1; #if 1 @@ -1850,6 +1924,11 @@ void DrawPreviewLevel(boolean restart) int lxpos, lypos; #endif +#if 1 + if (pos->chars != -1) + max_len_label_text = pos->chars; +#endif + strncpy(label_text, leveldir_current->name, max_len_label_text); label_text[max_len_label_text] = '\0'; @@ -2462,7 +2541,11 @@ boolean Request(char *text, unsigned int req_state) if (max_word_len > MAX_REQUEST_LINE_FONT1_LEN) { max_request_line_len = MAX_REQUEST_LINE_FONT2_LEN; +#if 1 + font_nr = FONT_TEXT_1; +#else font_nr = FONT_LEVEL_NUMBER; +#endif break; } @@ -4429,19 +4512,19 @@ em_object_mapping_list[] = }, { Xexit, TRUE, FALSE, - EL_EXIT_CLOSED, -1, -1 + EL_EM_EXIT_CLOSED, -1, -1 }, { Xexit_1, TRUE, FALSE, - EL_EXIT_OPEN, -1, -1 + EL_EM_EXIT_OPEN, -1, -1 }, { Xexit_2, FALSE, FALSE, - EL_EXIT_OPEN, -1, -1 + EL_EM_EXIT_OPEN, -1, -1 }, { Xexit_3, FALSE, FALSE, - EL_EXIT_OPEN, -1, -1 + EL_EM_EXIT_OPEN, -1, -1 }, { Xdynamite, TRUE, FALSE, @@ -5350,10 +5433,14 @@ int get_next_element(int element) { case EL_QUICKSAND_FILLING: return EL_QUICKSAND_FULL; case EL_QUICKSAND_EMPTYING: return EL_QUICKSAND_EMPTY; + case EL_QUICKSAND_FAST_FILLING: return EL_QUICKSAND_FAST_FULL; + case EL_QUICKSAND_FAST_EMPTYING: return EL_QUICKSAND_FAST_EMPTY; case EL_MAGIC_WALL_FILLING: return EL_MAGIC_WALL_FULL; case EL_MAGIC_WALL_EMPTYING: return EL_MAGIC_WALL_ACTIVE; case EL_BD_MAGIC_WALL_FILLING: return EL_BD_MAGIC_WALL_FULL; case EL_BD_MAGIC_WALL_EMPTYING: return EL_BD_MAGIC_WALL_ACTIVE; + case EL_DC_MAGIC_WALL_FILLING: return EL_DC_MAGIC_WALL_FULL; + case EL_DC_MAGIC_WALL_EMPTYING: return EL_DC_MAGIC_WALL_ACTIVE; case EL_AMOEBA_DROPPING: return EL_AMOEBA_WET; default: return element; @@ -6171,9 +6258,26 @@ void PlayMenuMusic() if (music == MUS_UNDEFINED) return; + if (!setup.sound_music) + return; + PlayMusic(music); } +void PlaySoundActivating() +{ +#if 0 + PlaySound(SND_MENU_ITEM_ACTIVATING); +#endif +} + +void PlaySoundSelecting() +{ +#if 0 + PlaySound(SND_MENU_ITEM_SELECTING); +#endif +} + void ToggleFullscreenIfNeeded() { boolean change_fullscreen = (setup.fullscreen !=