fixed and enhanced screen fading and global border handling
[rocksndiamonds.git] / src / screens.c
index 6ee974e01917746dfe3407a7e7e9d49ae11ea5d4..99dedcefa3c9d446f5538bf5e8b5aa5b73700da4 100644 (file)
@@ -1417,19 +1417,32 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading)
   /* needed if last screen (level choice) changed graphics, sounds or music */
   ReloadCustomArtwork(0);
 
+#if 1
+  /* needed if different viewport properties defined for menues */
+  ChangeViewportPropertiesIfNeeded();
+#endif
+
   if (redraw_mask & REDRAW_ALL)
     fade_mask = REDRAW_ALL;
 
+  if (CheckIfRedrawGlobalBorderIsNeeded())
+    fade_mask = REDRAW_ALL;
+
   FadeOut(fade_mask);
 
+#if 0
   /* needed if different viewport properties defined for menues */
   ChangeViewportPropertiesIfNeeded();
+#endif
 
   /* needed if last screen was the editor screen */
   UndrawSpecialEditorDoor();
 
   SetDrawtoField(DRAW_BACKBUFFER);
 
+  /* reset drawing area change flag */
+  DrawingAreaChanged();
+
   if (CheckTitleScreen(levelset_has_changed))
   {
     game_status = GAME_MODE_TITLE;
@@ -1452,8 +1465,10 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading)
 
   SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
 
+#if 1
   if (fade_mask == REDRAW_ALL)
     RedrawGlobalBorder();
+#endif
 
   ClearField();
 
@@ -1487,6 +1502,11 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading)
 
   DrawMaskedBorder(REDRAW_ALL);
 
+#if 0
+  if (redraw_mask & REDRAW_ALL)
+    fade_mask = REDRAW_ALL;
+#endif
+
   FadeIn(fade_mask);
   FadeSetEnterMenu();
 
@@ -1884,6 +1904,11 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       {
        game_status = GAME_MODE_SCORES;
 
+#if 1
+       /* required before door position may be changed in next step */
+       CloseDoor(DOOR_CLOSE_ALL);
+#endif
+
        ChangeViewportPropertiesIfNeeded();
 
        DrawHallOfFame(-1);
@@ -2122,6 +2147,9 @@ static void DrawInfoScreen_Main(int fade_mask, boolean do_fading)
 {
   int i;
 
+  if (CheckIfRedrawGlobalBorderIsNeeded())
+    fade_mask = REDRAW_ALL;
+
   UnmapAllGadgets();
 
   FreeScreenGadgets();
@@ -2178,10 +2206,10 @@ static void changeSetupValue(int, int, int);
 void HandleMenuScreen(int mx, int my, int dx, int dy, int button,
                      int mode, int num_page_entries, int max_page_entries)
 {
-  static int game_status_last;
-  static int num_page_entries_last[NUM_SPECIAL_GFX_ARGS];
+  static int num_page_entries_all_last[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
   static int choice_stores[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
   static int first_entry_stores[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES];
+  int *num_page_entries_last = num_page_entries_all_last[game_status];
   int *choice_store = choice_stores[game_status];
   int *first_entry_store = first_entry_stores[game_status];
   int choice = choice_store[mode];             /* starts with 0 */
@@ -2198,18 +2226,15 @@ void HandleMenuScreen(int mx, int my, int dx, int dy, int button,
     // check if number of menu page entries has changed (may happen by change
     // of custom artwork definition value for 'list_size' for this menu screen)
     // (in this case, the last menu position most probably has to be corrected)
-    if (game_status != game_status_last &&
-       num_page_entries != num_page_entries_last[game_status])
+    if (num_page_entries != num_page_entries_last[mode])
     {
-      for (i = 0; i < MAX_MENU_MODES; i++)
-       choice_store[i] = first_entry_store[i] = 0;
+      choice_store[mode] = first_entry_store[mode] = 0;
 
       choice = first_entry = 0;
       y = y_old = 0;
-    }
 
-    game_status_last = game_status;
-    num_page_entries_last[game_status] = num_page_entries;
+      num_page_entries_last[mode] = num_page_entries;
+    }
 
     /* advance to first valid menu entry */
     while (choice < num_page_entries &&
@@ -5289,6 +5314,7 @@ static struct TokenInfo setup_info_game[] =
 #endif
   { TYPE_ENTER_LIST, execSetupChooseSnapshotMode,"Game Engine Snapshot Mode:" },
   { TYPE_STRING,       &snapshot_mode_text,    ""                      },
+  { TYPE_SWITCH,       &setup.show_snapshot_buttons,"Show Snapshot Buttons:" },
   { TYPE_EMPTY,                NULL,                   ""                      },
   { TYPE_LEAVE_MENU,   execSetupMain,          "Back"                  },
 
@@ -5733,6 +5759,9 @@ static void DrawSetupScreen_Generic()
   char *title_string = NULL;
   int i;
 
+  if (CheckIfRedrawGlobalBorderIsNeeded())
+    fade_mask = REDRAW_ALL;
+
   UnmapAllGadgets();
 
   FreeScreenGadgets();