From: Holger Schemel Date: Mon, 13 Apr 2020 15:26:01 +0000 (+0200) Subject: fixed drawing global animations when switching screens without fading X-Git-Tag: 4.2.0.0~53 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=b844b9ff4b1c79c5789cdae0a90deacb88d0887a;p=rocksndiamonds.git fixed drawing global animations when switching screens without fading Before, when switching screens without fading (like leaving sub-menus with default settings for screen fading, or screen changes after pressing the "Escape" key), a single video frame was drawn without global animations, which could cause flickering of animations. With this fix, global animations will also be drawn for this video frame. --- diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 04cfc0e7..d271951e 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -1033,6 +1033,17 @@ void SDLFadeRectangle(int x, int y, int width, int height, time_current = SDL_GetTicks(); + if (fade_delay <= 0) + { + // immediately draw final target frame without delay + fade_mode &= (FADE_MODE_FADE | FADE_MODE_TRANSFORM); + fade_delay = 1; + time_current -= 1; + + // when fading without delay, also skip post delay + post_delay = 0; + } + if (fade_mode == FADE_MODE_MELT) { boolean done = FALSE; diff --git a/src/tools.c b/src/tools.c index 67bb1795..52fbded0 100644 --- a/src/tools.c +++ b/src/tools.c @@ -971,19 +971,13 @@ static void FadeExt(int fade_mask, int fade_mode, int fade_type) height = WIN_YSIZE; } - if (!setup.fade_screens || - fade_delay == 0 || - fading.fade_mode == FADE_MODE_NONE) - { - if (fade_mode == FADE_MODE_FADE_OUT) - return; - - BlitBitmap(backbuffer, window, x, y, width, height, x, y); - - redraw_mask &= ~fade_mask; + // when switching screens without fading, set fade delay to zero + if (!setup.fade_screens || fading.fade_mode == FADE_MODE_NONE) + fade_delay = 0; + // do not display black frame when fading out without fade delay + if (fade_mode == FADE_MODE_FADE_OUT && fade_delay == 0) return; - } FadeRectangle(x, y, width, height, fade_mode, fade_delay, post_delay, draw_border_function);