From: Holger Schemel Date: Sun, 2 Nov 2014 00:48:09 +0000 (+0100) Subject: fixed redraw/fade bugs when redefining the playfield size or position X-Git-Tag: 4.0.0.0-rc1~318 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f7165d318c089b77d0a91a77afc44cb8866dc1cc;p=rocksndiamonds.git fixed redraw/fade bugs when redefining the playfield size or position --- diff --git a/ChangeLog b/ChangeLog index cd522a5d..96408bca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2014-11-02 * fixed bug with not updating default bitmap pointer for scaled images + * fixed redraw/fade bugs when redefining the playfield size or position 2014-10-27 * fixed some smaller issues with loading custom artwork diff --git a/src/conftime.h b/src/conftime.h index 545fff3a..eabe26b1 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-10-27 21:31" +#define COMPILE_DATE_STRING "2014-11-02 01:32" diff --git a/src/editor.c b/src/editor.c index 781a3efd..728ff1d7 100644 --- a/src/editor.c +++ b/src/editor.c @@ -7368,11 +7368,6 @@ static boolean playfield_area_changed = FALSE; void DrawLevelEd() { - int old_sx = SX; - int old_sy = SY; - int old_sxsize = SXSIZE; - int old_sysize = SYSIZE; - StopAnimation(); CloseDoor(DOOR_CLOSE_ALL); @@ -7385,13 +7380,7 @@ void DrawLevelEd() /* needed if different viewport properties defined for editor */ ChangeViewportPropertiesIfNeeded(); - if (old_sx != SX || - old_sy != SY || - old_sxsize != SXSIZE || - old_sysize != SYSIZE) - playfield_area_changed = TRUE; - else - playfield_area_changed = FALSE; + playfield_area_changed = DrawingAreaChanged(); OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY); @@ -7431,7 +7420,7 @@ void DrawLevelEd() BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, DOOR_GFX_PAGEX8, 236, EXSIZE, EYSIZE, EX, EY); - redraw_mask |= REDRAW_ALL; + // redraw_mask |= REDRAW_ALL; FreeLevelEditorGadgets(); CreateLevelEditorGadgets(); @@ -11389,7 +11378,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) /* needed before playing if editor playfield area has different size */ ClearRectangle(drawto, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); - redraw_mask = REDRAW_ALL; + // redraw_mask = REDRAW_ALL; level_editor_test_game = TRUE; diff --git a/src/game.c b/src/game.c index 0fa3035d..7b63ee75 100644 --- a/src/game.c +++ b/src/game.c @@ -3909,6 +3909,14 @@ void InitGame() FadeIn(REDRAW_FIELD); +#if 1 + // full screen redraw is required at this point in the following cases: + // - special editor door undrawn when game was started from level editor + // - drawing area (playfield) was changed and has to be removed completely + redraw_mask = REDRAW_ALL; + BackToFront(); +#endif + if (!game.restart_level) { /* copy default game door content to main double buffer */ diff --git a/src/libgame/system.c b/src/libgame/system.c index 25edb0ef..eec5d192 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -170,6 +170,8 @@ void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize, gfx.field_save_buffer = field_save_buffer; + gfx.drawing_area_changed = FALSE; + SetDrawDeactivationMask(REDRAW_NONE); /* do not deactivate drawing */ SetDrawBackgroundMask(REDRAW_NONE); /* deactivate masked drawing */ } @@ -463,6 +465,16 @@ boolean DrawingOnBackground(int x, int y) CheckDrawingArea(x, y, 1, 1, gfx.draw_background_mask)); } +boolean DrawingAreaChanged() +{ + int drawing_area_changed = gfx.drawing_area_changed; + + // reset flag for change of drawing area after querying it + gfx.drawing_area_changed = FALSE; + + return drawing_area_changed; +} + static boolean InClippedRectangle(Bitmap *bitmap, int *x, int *y, int *width, int *height, boolean is_dest) { diff --git a/src/libgame/system.h b/src/libgame/system.h index 04d97974..f7259356 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -788,6 +788,8 @@ struct GfxInfo int draw_deactivation_mask; int draw_background_mask; + boolean drawing_area_changed; + Bitmap *field_save_buffer; Bitmap *background_bitmap; @@ -1303,6 +1305,7 @@ void ClearRectangle(Bitmap *, int, int, int, int); void ClearRectangleOnBackground(Bitmap *, int, int, int, int); void BlitBitmapMasked(Bitmap *, Bitmap *, int, int, int, int, int, int); boolean DrawingOnBackground(int, int); +boolean DrawingAreaChanged(); void BlitBitmapOnBackground(Bitmap *, Bitmap *, int, int, int, int, int, int); void DrawSimpleBlackLine(Bitmap *, int, int, int, int); void DrawSimpleWhiteLine(Bitmap *, int, int, int, int); diff --git a/src/screens.c b/src/screens.c index 469239d1..ca4e669a 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1309,9 +1309,6 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) KeyboardAutoRepeatOn(); ActivateJoystick(); - SetDrawDeactivationMask(REDRAW_NONE); - SetDrawBackgroundMask(REDRAW_FIELD); - audio.sound_deactivated = FALSE; GetPlayerConfig(); @@ -1373,6 +1370,10 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) LoadLevel(level_nr); LoadScore(level_nr); + // set this after "ChangeViewportPropertiesIfNeeded()" (which may reset it) + SetDrawDeactivationMask(REDRAW_NONE); + SetDrawBackgroundMask(REDRAW_FIELD); + SetMainBackgroundImage(IMG_BACKGROUND_MAIN); if (fade_mask == REDRAW_ALL) @@ -3228,6 +3229,8 @@ void HandleTypeName(int newxpos, Key key) static void DrawChooseTree(TreeInfo **ti_ptr) { + int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD); + UnmapAllGadgets(); FreeScreenGadgets(); @@ -3235,14 +3238,14 @@ static void DrawChooseTree(TreeInfo **ti_ptr) CloseDoor(DOOR_CLOSE_2); - FadeOut(REDRAW_FIELD); + FadeOut(fade_mask); ClearField(); HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr); MapScreenTreeGadgets(*ti_ptr); - FadeIn(REDRAW_FIELD); + FadeIn(fade_mask); InitAnimation(); } @@ -3744,6 +3747,8 @@ void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button) void DrawHallOfFame(int highlight_position) { + int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD); + UnmapAllGadgets(); FadeSoundsAndMusic(); @@ -3762,7 +3767,7 @@ void DrawHallOfFame(int highlight_position) FadeSetEnterScreen(); - FadeOut(REDRAW_FIELD); + FadeOut(fade_mask); InitAnimation(); @@ -3771,7 +3776,7 @@ void DrawHallOfFame(int highlight_position) HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE); - FadeIn(REDRAW_FIELD); + FadeIn(fade_mask); } static void drawHallOfFameList(int first_entry, int highlight_position) @@ -5289,6 +5294,7 @@ static void drawSetupInfoList(struct TokenInfo *setup_info, static void DrawSetupScreen_Generic() { + int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD); boolean redraw_all = FALSE; char *title_string = NULL; int i; @@ -5303,7 +5309,7 @@ static void DrawSetupScreen_Generic() if (redraw_mask & REDRAW_ALL) redraw_all = TRUE; - FadeOut(REDRAW_FIELD); + FadeOut(fade_mask); ClearField(); @@ -5390,9 +5396,9 @@ static void DrawSetupScreen_Generic() MapScreenGadgets(max_setup_info); if (redraw_all) - redraw_mask = REDRAW_ALL; + redraw_mask = fade_mask = REDRAW_ALL; - FadeIn(redraw_mask); + FadeIn(fade_mask); InitAnimation(); } diff --git a/src/tools.c b/src/tools.c index 861d6b7a..ad2b3b32 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4365,8 +4365,6 @@ void DrawSpecialEditorDoor() int vy = VY - outer_border; int exsize = EXSIZE + 2 * outer_border; - CloseDoor(DOOR_CLOSE_2); - /* draw bigger level editor toolbox window */ BlitBitmap(gfx1->bitmap, drawto, gfx1->src_x, gfx1->src_y, top_border_width, top_border_height, ex, ey - top_border_height); @@ -8000,6 +7998,7 @@ void ChangeViewportPropertiesIfNeeded() boolean init_video_buffer = FALSE; boolean init_gadgets_and_toons = FALSE; boolean init_em_graphics = FALSE; + boolean drawing_area_changed = FALSE; if (viewport.window.width != WIN_XSIZE || viewport.window.height != WIN_YSIZE) @@ -8058,6 +8057,19 @@ void ChangeViewportPropertiesIfNeeded() init_em_graphics = TRUE; } + if (new_sx != SX || + new_sy != SY || + new_sxsize != SXSIZE || + new_sysize != SYSIZE || + new_real_sx != REAL_SX || + new_real_sy != REAL_SY || + new_full_sxsize != FULL_SXSIZE || + new_full_sysize != FULL_SYSIZE) + { + if (!init_video_buffer) + drawing_area_changed = TRUE; + } + SX = new_sx; SY = new_sy; DX = new_dx; @@ -8098,6 +8110,11 @@ void ChangeViewportPropertiesIfNeeded() SCR_FIELDX = new_scr_fieldx; SCR_FIELDY = new_scr_fieldy; + + gfx.drawing_area_changed = drawing_area_changed; + + SetDrawDeactivationMask(REDRAW_NONE); + SetDrawBackgroundMask(REDRAW_FIELD); } if (init_video_buffer) @@ -8105,9 +8122,6 @@ void ChangeViewportPropertiesIfNeeded() // printf("::: init_video_buffer\n"); InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); - - SetDrawDeactivationMask(REDRAW_NONE); - SetDrawBackgroundMask(REDRAW_FIELD); } if (init_gadgets_and_toons)