added using new screen fading option ".auto_delay_unit"
[rocksndiamonds.git] / src / screens.c
index 8defaee40fbeab0288b2a3822b699e9121630c00..fc7602749d33b7d3091c04e18d8c6f03ae1f7cf5 100644 (file)
@@ -988,6 +988,7 @@ static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci)
   ti.fade_delay = tmi.fade_delay;
   ti.post_delay = tmi.post_delay;
   ti.auto_delay = tmi.auto_delay;
+  ti.auto_delay_unit = tmi.auto_delay_unit;
 
   return ti;
 }
@@ -1704,6 +1705,25 @@ static void gotoTopLevelDir(void)
   }
 }
 
+static unsigned int getAutoDelayCounter(struct TitleFadingInfo *fi)
+{
+  boolean use_frame_counter = (fi->auto_delay_unit == AUTO_DELAY_UNIT_FRAMES);
+
+  return (use_frame_counter ? video.frame_counter : Counter());
+}
+
+static boolean TitleAutoDelayReached(unsigned int *counter_var,
+                                    struct TitleFadingInfo *fi)
+{
+  return DelayReachedExt(counter_var, fi->auto_delay, getAutoDelayCounter(fi));
+}
+
+static void ResetTitleAutoDelay(unsigned int *counter_var,
+                               struct TitleFadingInfo *fi)
+{
+  *counter_var = getAutoDelayCounter(fi);
+}
+
 void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 {
   static unsigned int title_delay = 0;
@@ -1778,12 +1798,12 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
     FadeIn(REDRAW_ALL);
 
-    DelayReached(&title_delay, 0);     // reset delay counter
+    ResetTitleAutoDelay(&title_delay, &fading);
 
     return;
   }
 
-  if (fading.auto_delay > 0 && DelayReached(&title_delay, fading.auto_delay))
+  if (fading.auto_delay > 0 && TitleAutoDelayReached(&title_delay, &fading))
     button = MB_MENU_CHOICE;
 
   if (button == MB_MENU_LEAVE)
@@ -1841,7 +1861,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
       FadeIn(REDRAW_ALL);
 
-      DelayReached(&title_delay, 0);   // reset delay counter
+      ResetTitleAutoDelay(&title_delay, &fading);
     }
     else
     {
@@ -1906,7 +1926,7 @@ static void HandleMainMenu_SelectLevel(int step, int direction,
 
   if (new_level_nr != old_level_nr)
   {
-    struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
+    struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
 
     PlaySound(SND_MENU_ITEM_SELECTING);
 
@@ -1927,9 +1947,8 @@ static void HandleMainMenu_SelectLevel(int step, int direction,
 
     UpdateScreenMenuGadgets(SCREEN_MASK_MAIN_HAS_SOLUTION, hasSolutionTape());
 
-    // needed because DrawPreviewLevelInitial() takes some time
-    BackToFront();
-    // SyncDisplay();
+    // force redraw of playfield area (may be reset at this point)
+    redraw_mask |= REDRAW_FIELD;
   }
 }
 
@@ -1939,7 +1958,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
   static boolean button_pressed_last = FALSE;
   boolean button_pressed = FALSE;
   int pos = choice;
-  int i;
+  int i = 0;   // needed to prevent compiler warning due to bad code below
 
   if (button == MB_MENU_INITIALIZE)
   {
@@ -4531,7 +4550,7 @@ void DrawChooseLevelNr(void)
   for (i = leveldir_current->first_level; i <= leveldir_current->last_level;i++)
   {
     TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_LEVEL_NR);
-    char identifier[32], name[32];
+    char identifier[32], name[64];
     int value = i;
 
     // temporarily load level info to get level name
@@ -4706,7 +4725,8 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
 
     FadeSound(SND_BACKGROUND_SCORES);
 
-    if (game_status_last_screen == GAME_MODE_PLAYING &&
+    if (button == MB_MENU_CHOICE &&
+       game_status_last_screen == GAME_MODE_PLAYING &&
        setup.auto_play_next_level && setup.increment_levels &&
        level_nr < leveldir_current->last_level &&
        !network_playing)
@@ -6165,6 +6185,17 @@ static struct
   { &setup.touch.grid_ysize[1],                execSetupChooseGridYSize_1      },
   { &setup.touch.grid_ysize[1],                &grid_size_text[1][1]           },
 
+  { &setup.internal.menu_game,         execSetupGame                   },
+  { &setup.internal.menu_editor,       execSetupEditor                 },
+  { &setup.internal.menu_graphics,     execSetupGraphics               },
+  { &setup.internal.menu_sound,                execSetupSound                  },
+  { &setup.internal.menu_artwork,      execSetupArtwork                },
+  { &setup.internal.menu_input,                execSetupInput                  },
+  { &setup.internal.menu_touch,                execSetupTouch                  },
+  { &setup.internal.menu_shortcuts,    execSetupShortcuts              },
+  { &setup.internal.menu_exit,         execExitSetup                   },
+  { &setup.internal.menu_save_and_exit,        execSaveAndExitSetup            },
+
   { NULL,                              NULL                            }
 };
 
@@ -8487,16 +8518,8 @@ static void CreateScreenMenubuttons(void)
 
     menubutton_info[i].get_gadget_position(&x, &y, id);
 
-    if (menubutton_info[i].screen_mask == SCREEN_MASK_MAIN_HAS_SOLUTION)
-    {
-      width  = graphic_info[menubutton_info[i].gfx_pressed].width;
-      height = graphic_info[menubutton_info[i].gfx_pressed].height;
-    }
-    else
-    {
-      width = SC_MENUBUTTON_XSIZE;
-      height = SC_MENUBUTTON_YSIZE;
-    }
+    width  = graphic_info[menubutton_info[i].gfx_pressed].width;
+    height = graphic_info[menubutton_info[i].gfx_pressed].height;
 
     gfx_unpressed = menubutton_info[i].gfx_unpressed;
     gfx_pressed   = menubutton_info[i].gfx_pressed;