added using new screen fading option ".auto_delay_unit"
authorHolger Schemel <info@artsoft.org>
Sat, 25 May 2019 09:10:56 +0000 (11:10 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 25 May 2019 10:23:58 +0000 (12:23 +0200)
src/screens.c

index 933be2a19ef4977b993f2ceb1bcaf86c3d6e9b41..fc7602749d33b7d3091c04e18d8c6f03ae1f7cf5 100644 (file)
@@ -1705,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;
@@ -1779,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)
@@ -1842,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
     {