improved and extended definitions for title screen transitions
authorHolger Schemel <info@artsoft.org>
Wed, 9 Dec 2015 20:26:49 +0000 (21:26 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 9 Dec 2015 20:26:49 +0000 (21:26 +0100)
build-scripts/create_element_defs.pl
src/conf_gfx.c
src/files.c
src/main.h
src/screens.c
src/tools.c

index 3c080a7a02e2262487675237673d40b0722eb067..c8a6cd0676a317130aa8b7a3b21454a0abec9bf1 100755 (executable)
@@ -2408,7 +2408,7 @@ sub print_image_config_vars
            $var =~ s/\.([A-Z]+)$/\[GFX_SPECIAL_ARG_$1\]/;
            $var =~ s/\.([A-Z]+)\./\[GFX_SPECIAL_ARG_$1\]./;
 
-           if ($var =~ /^(menu.(enter|leave)_screen)(.[a-z_]+)$/)
+           if ($var =~ /^(menu.(enter|leave|next)_screen)(.[a-z_]+)$/)
            {
                $var = $1 . "[GFX_SPECIAL_ARG_DEFAULT]" . $3;
            }
index 880d0632210ce7915b720bcf44138210940ff9ef..fa001bdba47c1ab1bb5869ef3cae26d11023ddf6 100644 (file)
@@ -6143,12 +6143,15 @@ struct ConfigInfo image_config[] =
   { "menu.enter_screen.fade_mode",             "fade"                  },
   { "menu.enter_screen.fade_delay",            "250"                   },
   { "menu.enter_screen.post_delay",            "125"                   },
-  { "menu.next_screen.fade_mode",              "crossfade"             },
-  { "menu.next_screen.fade_delay",             "250"                   },
-  { "menu.next_screen.post_delay",             "125"                   },
   { "menu.leave_screen.fade_mode",             "fade"                  },
   { "menu.leave_screen.fade_delay",            "250"                   },
   { "menu.leave_screen.post_delay",            "125"                   },
+  { "menu.next_screen.fade_mode",              "crossfade"             },
+  { "menu.next_screen.fade_delay",             "250"                   },
+  { "menu.next_screen.post_delay",             "125"                   },
+  { "menu.enter_screen.TITLE.fade_mode",       "fade"                  },
+  { "menu.enter_screen.TITLE.fade_delay",      "500"                   },
+  { "menu.enter_screen.TITLE.post_delay",      "250"                   },
   { "menu.enter_screen.SCORES.fade_mode",      ARG_DEFAULT             },
   { "menu.enter_screen.SCORES.fade_delay",     ARG_DEFAULT             },
   { "menu.enter_screen.SCORES.post_delay",     ARG_DEFAULT             },
@@ -6161,6 +6164,9 @@ struct ConfigInfo image_config[] =
   { "menu.enter_screen.PLAYING.fade_mode",     ARG_DEFAULT             },
   { "menu.enter_screen.PLAYING.fade_delay",    ARG_DEFAULT             },
   { "menu.enter_screen.PLAYING.post_delay",    ARG_DEFAULT             },
+  { "menu.leave_screen.TITLE.fade_mode",       "fade"                  },
+  { "menu.leave_screen.TITLE.fade_delay",      "500"                   },
+  { "menu.leave_screen.TITLE.post_delay",      "250"                   },
   { "menu.leave_screen.SCORES.fade_mode",      ARG_DEFAULT             },
   { "menu.leave_screen.SCORES.fade_delay",     ARG_DEFAULT             },
   { "menu.leave_screen.SCORES.post_delay",     ARG_DEFAULT             },
@@ -6173,6 +6179,12 @@ struct ConfigInfo image_config[] =
   { "menu.leave_screen.PLAYING.fade_mode",     ARG_DEFAULT             },
   { "menu.leave_screen.PLAYING.fade_delay",    ARG_DEFAULT             },
   { "menu.leave_screen.PLAYING.post_delay",    ARG_DEFAULT             },
+  { "menu.next_screen.TITLE.fade_mode",                "fade"                  },
+  { "menu.next_screen.TITLE.fade_delay",       "500"                   },
+  { "menu.next_screen.TITLE.post_delay",       "250"                   },
+  { "menu.next_screen.INFO.fade_mode",         ARG_DEFAULT             },
+  { "menu.next_screen.INFO.fade_delay",                ARG_DEFAULT             },
+  { "menu.next_screen.INFO.post_delay",                ARG_DEFAULT             },
 
   { "menu.draw_xoffset",                       "0"                     },
   { "menu.draw_yoffset",                       "0"                     },
index c357e2c7003fb45894f0603cf0b6b22fb4dfbff6..d1b60e47c704ccbaa6119f38035134a0c16404b9 100644 (file)
@@ -8778,8 +8778,12 @@ static void InitMenuDesignSettings_SpecialPreProcessing()
   /* (eg, init "menu.enter_screen.SCORES.xyz" from "menu.enter_screen.xyz") */
   for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
   {
+    if (i == GFX_SPECIAL_ARG_TITLE)    /* title values already initialized */
+      continue;
+
     menu.enter_screen[i] = menu.enter_screen[GFX_SPECIAL_ARG_DEFAULT];
     menu.leave_screen[i] = menu.leave_screen[GFX_SPECIAL_ARG_DEFAULT];
+    menu.next_screen[i]  = menu.next_screen[GFX_SPECIAL_ARG_DEFAULT];
   }
 
   /* special case: initialize "ARG_DEFAULT" values in static default config */
@@ -8790,8 +8794,10 @@ static void InitMenuDesignSettings_SpecialPreProcessing()
     viewport.playfield[i] = viewport.playfield[GFX_SPECIAL_ARG_DEFAULT];
     viewport.door_1[i]    = viewport.door_1[GFX_SPECIAL_ARG_DEFAULT];
 
-    if (i != GFX_SPECIAL_ARG_EDITOR)   /* editor value already initialized */
-      viewport.door_2[i] = viewport.door_2[GFX_SPECIAL_ARG_DEFAULT];
+    if (i == GFX_SPECIAL_ARG_EDITOR)   /* editor values already initialized */
+      continue;
+
+    viewport.door_2[i] = viewport.door_2[GFX_SPECIAL_ARG_DEFAULT];
   }
 }
 
@@ -8831,7 +8837,17 @@ static void InitMenuDesignSettings_SpecialPostProcessing()
 
 static void LoadMenuDesignSettingsFromFilename(char *filename)
 {
+  static struct TitleFadingInfo tfi;
   static struct TitleMessageInfo tmi;
+  static struct TokenInfo title_tokens[] =
+  {
+    { TYPE_INTEGER,    &tfi.fade_mode,         ".fade_mode"            },
+    { TYPE_INTEGER,    &tfi.fade_delay,        ".fade_delay"           },
+    { TYPE_INTEGER,    &tfi.post_delay,        ".post_delay"           },
+    { TYPE_INTEGER,    &tfi.auto_delay,        ".auto_delay"           },
+
+    { -1,              NULL,                   NULL                    }
+  };
   static struct TokenInfo titlemessage_tokens[] =
   {
     { TYPE_INTEGER,    &tmi.x,                 ".x"                    },
@@ -8855,12 +8871,34 @@ static void LoadMenuDesignSettingsFromFilename(char *filename)
     { -1,              NULL,                   NULL                    }
   };
   static struct
+  {
+    struct TitleFadingInfo *info;
+    char *text;
+  }
+  title_info[] =
+  {
+    /* initialize title screens from "next screen" definitions, if defined */
+    { &title_initial_default,          "menu.next_screen.TITLE"        },
+    { &title_default,                  "menu.next_screen.TITLE"        },
+
+    { NULL,                            NULL                            }
+  };
+  static struct
   {
     struct TitleMessageInfo *array;
     char *text;
   }
   titlemessage_arrays[] =
   {
+    /* initialize title messages from "next screen" definitions, if defined */
+    { titlemessage_initial,            "menu.next_screen.TITLE"        },
+    { titlemessage,                    "menu.next_screen.TITLE"        },
+
+    /* overwrite title messages with title definitions, if defined */
+    { titlemessage_initial,            "[title_initial]"               },
+    { titlemessage,                    "[title]"                       },
+
+    /* overwrite title messages with title message definitions, if defined */
     { titlemessage_initial,            "[titlemessage_initial]"        },
     { titlemessage,                    "[titlemessage]"                },
 
@@ -8934,12 +8972,18 @@ static void LoadMenuDesignSettingsFromFilename(char *filename)
     char *token_4 = "menu.leave_screen.fade_mode";
     char *token_5 = "menu.leave_screen.fade_delay";
     char *token_6 = "menu.leave_screen.post_delay";
+    char *token_7 = "menu.next_screen.fade_mode";
+    char *token_8 = "menu.next_screen.fade_delay";
+    char *token_9 = "menu.next_screen.post_delay";
     char *value_1 = getHashEntry(setup_file_hash, token_1);
     char *value_2 = getHashEntry(setup_file_hash, token_2);
     char *value_3 = getHashEntry(setup_file_hash, token_3);
     char *value_4 = getHashEntry(setup_file_hash, token_4);
     char *value_5 = getHashEntry(setup_file_hash, token_5);
     char *value_6 = getHashEntry(setup_file_hash, token_6);
+    char *value_7 = getHashEntry(setup_file_hash, token_7);
+    char *value_8 = getHashEntry(setup_file_hash, token_8);
+    char *value_9 = getHashEntry(setup_file_hash, token_9);
 
     if (value_1 != NULL)
       menu.enter_screen[i].fade_mode = get_token_parameter_value(token_1,
@@ -8959,6 +9003,15 @@ static void LoadMenuDesignSettingsFromFilename(char *filename)
     if (value_6 != NULL)
       menu.leave_screen[i].post_delay = get_token_parameter_value(token_6,
                                                                  value_6);
+    if (value_7 != NULL)
+      menu.next_screen[i].fade_mode = get_token_parameter_value(token_7,
+                                                               value_7);
+    if (value_8 != NULL)
+      menu.next_screen[i].fade_delay = get_token_parameter_value(token_8,
+                                                                value_8);
+    if (value_9 != NULL)
+      menu.next_screen[i].post_delay = get_token_parameter_value(token_9,
+                                                                value_9);
   }
 
   /* special case: initialize with default values that may be overwritten */
@@ -9041,6 +9094,33 @@ static void LoadMenuDesignSettingsFromFilename(char *filename)
                                                                 value_15);
   }
 
+  /* special case: initialize with default values that may be overwritten */
+  /* (e.g., init "[title].fade_mode" from "menu.next_screen.TITLE.fade_mode") */
+  for (i = 0; title_info[i].info != NULL; i++)
+  {
+    struct TitleFadingInfo *info = title_info[i].info;
+    char *base_token = title_info[i].text;
+
+    for (j = 0; title_tokens[j].type != -1; j++)
+    {
+      char *token = getStringCat2(base_token, title_tokens[j].text);
+      char *value = getHashEntry(setup_file_hash, token);
+
+      if (value != NULL)
+      {
+       int parameter_value = get_token_parameter_value(token, value);
+
+       tfi = *info;
+
+       *(boolean *)title_tokens[j].value = (boolean)parameter_value;
+
+       *info = tfi;
+      }
+
+      free(token);
+    }
+  }
+
   /* special case: initialize with default values that may be overwritten */
   /* (e.g., init "titlemessage_1.fade_mode" from "[titlemessage].fade_mode") */
   for (i = 0; titlemessage_arrays[i].array != NULL; i++)
index a8edcee71ea33d8c76b534843b1bb39e487c7aa7..f2e9357031a3e330907ce4ee55d63893ff60548b 100644 (file)
@@ -2176,7 +2176,7 @@ struct MenuInfo
   struct TitleFadingInfo leave_menu;
   struct TitleFadingInfo enter_screen[NUM_SPECIAL_GFX_ARGS];
   struct TitleFadingInfo leave_screen[NUM_SPECIAL_GFX_ARGS];
-  struct TitleFadingInfo next_screen;
+  struct TitleFadingInfo next_screen[NUM_SPECIAL_GFX_ARGS];
 
   int sound[NUM_SPECIAL_GFX_ARGS];
   int music[NUM_SPECIAL_GFX_ARGS];
index 4461c4b7995531a78b0545d2333b0b5f4ae0c4ce..1f94c7850526b018393acae400a9c0b37980e86c 100644 (file)
@@ -1552,9 +1552,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
   static int last_sound = -1, last_music = -1;
   boolean return_to_main_menu = FALSE;
   struct TitleControlInfo *tci;
-  struct TitleFadingInfo fading_default;
-  struct TitleFadingInfo fading_last = fading;
-  struct TitleFadingInfo fading_next;
   int sound, music;
 
   if (button == MB_MENU_INITIALIZE)
@@ -1566,6 +1563,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
     last_sound = SND_UNDEFINED;
     last_music = MUS_UNDEFINED;
 
+    FadeSetEnterScreen();
+
     if (game_status_last_screen == GAME_MODE_INFO)
     {
       if (num_title_screens == 0)
@@ -1584,6 +1583,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
     /* only required to update logic for redrawing global border */
     ClearField();
 
+    /* title screens may have different window size */
     ChangeViewportPropertiesIfNeeded();
 
     if (tci->is_image)
@@ -1591,17 +1591,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
     else
       DrawTitleScreenMessage(tci->local_nr, tci->initial);
 
-    fading_default = (tci->initial ? title_initial_default : title_default);
-
-    fading = fading_next = getTitleFading(tci);
-
-    if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) &&
-       fading_next.fade_mode & FADE_TYPE_TRANSFORM)
-    {
-      fading.fade_mode = FADE_MODE_FADE;
-      fading.fade_delay = fading_default.fade_delay;
-    }
-
     sound = getTitleSound(tci);
     music = getTitleMusic(tci);
 
@@ -1617,8 +1606,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
 
     FadeIn(REDRAW_ALL);
 
-    fading = fading_next;
-
     DelayReached(&title_delay, 0);     /* reset delay counter */
 
     return;
@@ -1658,6 +1645,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
       if (music == MUS_UNDEFINED || music != last_music)
        FadeMusic();
 
+      fading = getTitleFading(tci);
+
       FadeOut(REDRAW_ALL);
 
       if (tci->is_image)
@@ -1665,8 +1654,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
       else
        DrawTitleScreenMessage(tci->local_nr, tci->initial);
 
-      fading_next = getTitleFading(tci);
-
       sound = getTitleSound(tci);
       music = getTitleMusic(tci);
 
@@ -1678,15 +1665,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
       last_sound = sound;
       last_music = music;
 
-      /* last screen already faded out, next screen has no animation */
-      if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) &&
-         fading_next.fade_mode == FADE_MODE_NONE)
-       fading = fading_next;
-
       FadeIn(REDRAW_ALL);
 
-      fading = fading_next;
-
       DelayReached(&title_delay, 0);   /* reset delay counter */
     }
     else
@@ -2203,6 +2183,11 @@ static void DrawInfoScreen_Main()
   PlayMenuSound();
   PlayMenuMusic();
 
+#if 1
+  // needed after returning from title screens with different window size
+  OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+#endif
+
   DrawMaskedBorder(fade_mask);
 
   FadeIn(fade_mask);
index cda45dea6bed338ecc11510ab8c54e3a09f9052e..5c1f6549daee1d533f5e27333abf84f8d79e97cb 100644 (file)
@@ -649,7 +649,7 @@ void FadeSetEnterScreen()
 
 void FadeSetNextScreen()
 {
-  fading = menu.next_screen;
+  fading = menu.next_screen[game_status];
 
   // (do not overwrite fade mode set by FadeSetEnterScreen)
   // FadeSetLeaveNext(fading, TRUE);   /* (keep same fade mode) */