fixed fading complete screen if playfield viewport has changed
authorHolger Schemel <info@artsoft.org>
Fri, 3 Nov 2017 13:39:54 +0000 (14:39 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 23 Mar 2018 22:21:15 +0000 (23:21 +0100)
src/editor.c
src/game.c
src/screens.c
src/tools.c
src/tools.h

index fb40606..5f9b2b9 100644 (file)
@@ -8264,7 +8264,7 @@ void DrawLevelEd()
 
   FadeSoundsAndMusic();
 
-  if (CheckIfGlobalBorderHasChanged())
+  if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
     fade_mask = REDRAW_ALL;
 
   FadeOut(fade_mask);
index 76f3489..1de51be 100644 (file)
@@ -3298,7 +3298,7 @@ void InitGame()
   else
     FadeSetEnterScreen();
 
-  if (CheckIfGlobalBorderHasChanged())
+  if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
     fade_mask = REDRAW_ALL;
 
   FadeLevelSoundsAndMusic();
index 7513842..9c02fc9 100644 (file)
@@ -1486,7 +1486,7 @@ void DrawMainMenu()
   if (redraw_mask & REDRAW_ALL)
     fade_mask = REDRAW_ALL;
 
-  if (CheckIfGlobalBorderHasChanged())
+  if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
     fade_mask = REDRAW_ALL;
 
   FadeOut(fade_mask);
@@ -2186,7 +2186,7 @@ static void DrawInfoScreen_Main()
   if (redraw_mask & REDRAW_ALL)
     fade_mask = REDRAW_ALL;
 
-  if (CheckIfGlobalBorderHasChanged())
+  if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
     fade_mask = REDRAW_ALL;
 
   UnmapAllGadgets();
@@ -3838,7 +3838,7 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
 {
   int fade_mask = REDRAW_FIELD;
 
-  if (CheckIfGlobalBorderHasChanged())
+  if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
     fade_mask = REDRAW_ALL;
 
   if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY))
@@ -4357,7 +4357,7 @@ void DrawHallOfFame(int highlight_position)
 {
   int fade_mask = REDRAW_FIELD;
 
-  if (CheckIfGlobalBorderHasChanged())
+  if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
     fade_mask = REDRAW_ALL;
 
   UnmapAllGadgets();
@@ -6010,7 +6010,7 @@ static void DrawSetupScreen_Generic()
   char *title_string = NULL;
   int i;
 
-  if (CheckIfGlobalBorderHasChanged())
+  if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
     fade_mask = REDRAW_ALL;
 
   UnmapAllGadgets();
index b87d720..2838908 100644 (file)
@@ -8973,6 +8973,31 @@ void ResetFontStatus()
   SetFontStatus(-1);
 }
 
+boolean CheckIfPlayfieldViewportHasChanged()
+{
+  // if game status has not changed, playfield viewport has not changed either
+  if (game_status == game_status_last)
+    return FALSE;
+
+  // check if playfield viewport has changed with current game status
+  struct RectWithBorder *vp_playfield = &viewport.playfield[game_status];
+  int new_real_sx      = vp_playfield->x;
+  int new_real_sy      = vp_playfield->y;
+  int new_full_sxsize  = vp_playfield->width;
+  int new_full_sysize  = vp_playfield->height;
+
+  return (new_real_sx != REAL_SX ||
+         new_real_sy != REAL_SY ||
+         new_full_sxsize != FULL_SXSIZE ||
+         new_full_sysize != FULL_SYSIZE);
+}
+
+boolean CheckIfGlobalBorderOrPlayfieldViewportHasChanged()
+{
+  return (CheckIfGlobalBorderHasChanged() ||
+         CheckIfPlayfieldViewportHasChanged());
+}
+
 void ChangeViewportPropertiesIfNeeded()
 {
   boolean use_mini_tilesize = (level.game_engine_type == GAME_ENGINE_TYPE_MM ?
index 794cc08..2efb705 100644 (file)
@@ -276,4 +276,7 @@ void ResetFontStatus();
 void ToggleFullscreenOrChangeWindowScalingIfNeeded();
 void ChangeViewportPropertiesIfNeeded();
 
+boolean CheckIfPlayfieldViewportHasChanged();
+boolean CheckIfGlobalBorderOrPlayfieldViewportHasChanged();
+
 #endif /* TOOLS_H */