rnd-20060430-2-src
authorHolger Schemel <info@artsoft.org>
Sun, 30 Apr 2006 13:07:57 +0000 (15:07 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:51:38 +0000 (10:51 +0200)
* fixed bug that forced re-defining menu settings in each config file
* added the possibility to define up to five title screens for each
  level set that are displayed after loading using (cross)fading in/out
  (this was added to display the various start images of the EMC sets)

ChangeLog
src/conftime.h
src/files.c
src/libgame/misc.c
src/tools.c

index e3694fcab1564ab5d8adbde68c49dd35be928338..280d27d8caa3c93036830f7c4402f05ed2824b86 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-04-30
+       * fixed bug that forced re-defining menu settings in each config file
+
+2006-04-29
+       * added the possibility to define up to five title screens for each
+         level set that are displayed after loading using (cross)fading in/out
+         (this was added to display the various start images of the EMC sets)
+
 2006-04-28
        * added "CE score gets zero [of]" to custom element trigger conditions
        * added setup option to display element token name in level editor
index f421ea5d71c872f5e0ecc70acb7233b283e1f264..0224c2c59bf2017bbf870b65afc0b358a642d39d 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-04-30 04:12]"
+#define COMPILE_DATE_STRING "[2006-04-30 15:04]"
index e6baec2532cc26d4636cb68c21a7e129e3f62798..a762cdb9f571c81cfec01d585089598f008561a5 100644 (file)
@@ -5547,10 +5547,49 @@ void LoadCustomElementDescriptions()
   freeSetupFileHash(setup_file_hash);
 }
 
-void LoadSpecialMenuDesignSettings()
+static void LoadSpecialMenuDesignSettingsFromFilename(char *filename)
 {
-  char *filename = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS);
   SetupFileHash *setup_file_hash;
+  int i;
+
+#if 0
+  printf("LoadSpecialMenuDesignSettings from file '%s' ...\n", filename);
+#endif
+
+  if ((setup_file_hash = loadSetupFileHash(filename)) == NULL)
+    return;
+
+  /* special case: initialize with default values that may be overwritten */
+  for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)
+  {
+    char *value_x = getHashEntry(setup_file_hash, "menu.draw_xoffset");
+    char *value_y = getHashEntry(setup_file_hash, "menu.draw_yoffset");
+    char *list_size = getHashEntry(setup_file_hash, "menu.list_size");
+
+    if (value_x != NULL)
+      menu.draw_xoffset[i] = get_integer_from_string(value_x);
+    if (value_y != NULL)
+      menu.draw_yoffset[i] = get_integer_from_string(value_y);
+    if (list_size != NULL)
+      menu.list_size[i] = get_integer_from_string(list_size);
+  }
+
+  /* read (and overwrite with) values that may be specified in config file */
+  for (i = 0; image_config_vars[i].token != NULL; i++)
+  {
+    char *value = getHashEntry(setup_file_hash, image_config_vars[i].token);
+
+    if (value != NULL)
+      *image_config_vars[i].value =
+       get_auto_parameter_value(image_config_vars[i].token, value);
+  }
+
+  freeSetupFileHash(setup_file_hash);
+}
+
+void LoadSpecialMenuDesignSettings_NEW()
+{
+  char *filename_base = UNDEFINED_FILENAME, *filename_local;
   int i, j;
 
   /* always start with reliable default values from default config */
@@ -5561,6 +5600,43 @@ void LoadSpecialMenuDesignSettings()
          get_auto_parameter_value(image_config_vars[i].token,
                                   image_config[j].value);
 
+#if 0
+  if (!SETUP_OVERRIDE_ARTWORK(setup, ARTWORK_TYPE_GRAPHICS))
+  {
+    /* first look for special settings configured in level series config */
+    filename_base = getCustomArtworkLevelConfigFilename(ARTWORK_TYPE_GRAPHICS);
+
+    if (fileExists(filename_base))
+      LoadSpecialMenuDesignSettingsFromFilename(filename_base);
+  }
+
+  filename_local = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS);
+
+  if (filename_local != NULL && !strEqual(filename_base, filename_local))
+    LoadSpecialMenuDesignSettingsFromFilename(filename_local);
+
+#else
+
+  filename_local = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS);
+
+  LoadSpecialMenuDesignSettingsFromFilename(filename_local);
+#endif
+}
+
+void LoadSpecialMenuDesignSettings()
+{
+  char *filename = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS);
+  SetupFileHash *setup_file_hash;
+  int i, j;
+
+  /* always start with reliable default values from default config */
+  for (i = 0; image_config_vars[i].token != NULL; i++)
+    for (j = 0; image_config[j].token != NULL; j++)
+      if (strEqual(image_config_vars[i].token, image_config[j].token))
+        *image_config_vars[i].value =
+          get_auto_parameter_value(image_config_vars[i].token,
+                                   image_config[j].value);
+
   if ((setup_file_hash = loadSetupFileHash(filename)) == NULL)
     return;
 
@@ -5586,7 +5662,7 @@ void LoadSpecialMenuDesignSettings()
 
     if (value != NULL)
       *image_config_vars[i].value =
-       get_auto_parameter_value(image_config_vars[i].token, value);
+        get_auto_parameter_value(image_config_vars[i].token, value);
   }
 
   freeSetupFileHash(setup_file_hash);
index 154f83438daa3a83370cb8464b97b2778d64e855..2cf6bd84e8b7a8f7b335a0f76e238ce4e223dabb 100644 (file)
@@ -2067,6 +2067,10 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info,
   if (filename == NULL)
     return;
 
+#if 0
+  printf("LoadArtworkConfigFromFilename '%s' ...\n", filename);
+#endif
+
   if ((setup_file_hash = loadSetupFileHash(filename)) == NULL)
     return;
 
@@ -2433,10 +2437,6 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
   char *filename_base = UNDEFINED_FILENAME, *filename_local;
   int i, j;
 
-#if 0
-  printf("GOT CUSTOM ARTWORK CONFIG FILE '%s'\n", filename);
-#endif
-
   DrawInitText("Loading artwork config:", 120, FC_GREEN);
   DrawInitText(ARTWORKINFO_FILENAME(artwork_info->type), 150, FC_YELLOW);
 
index 6f2c96e21840bccbc7aefb193e3f0d710fe6b253..1533897305dbb533bbc73b222a6d7acca7c3a92a 100644 (file)
@@ -420,49 +420,59 @@ void FadeToFront()
 
 static void FadeExt(Bitmap *bitmap_cross, int fade_ms, int fade_mode)
 {
+  static boolean initialization_needed = TRUE;
+  static SDL_Surface *surface_screen_copy = NULL;
+  static SDL_Surface *surface_black = NULL;
   SDL_Surface *surface_screen = backbuffer->surface;
-  SDL_Surface *surface_screen_copy = NULL;
-  SDL_Surface *surface_black = NULL;
   SDL_Surface *surface_cross;          /* initialized later */
   boolean fade_reverse;                        /* initialized later */
-  unsigned int flags = SDL_SRCALPHA;
   unsigned int time_last, time_current;
   float alpha;
   int alpha_final;
 
-  /* use same surface type as screen surface */
-  if ((surface_screen->flags & SDL_HWSURFACE))
-    flags |= SDL_HWSURFACE;
-  else
-    flags |= SDL_SWSURFACE;
-
-  /* create surface for copy of screen buffer */
-  if ((surface_screen_copy =
-       SDL_CreateRGBSurface(flags,
-                           surface_screen->w,
-                           surface_screen->h,
-                           surface_screen->format->BitsPerPixel,
-                           surface_screen->format->Rmask,
-                           surface_screen->format->Gmask,
-                           surface_screen->format->Bmask,
-                           surface_screen->format->Amask)) == NULL)
-    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
-
-  SDL_BlitSurface(surface_screen, NULL, surface_screen_copy, NULL);
+  if (initialization_needed)
+  {
+    unsigned int flags = SDL_SRCALPHA;
 
-  /* create black surface for fading from/to black */
-  if ((surface_black =
-       SDL_CreateRGBSurface(flags,
-                           surface_screen->w,
-                           surface_screen->h,
-                           surface_screen->format->BitsPerPixel,
-                           surface_screen->format->Rmask,
-                           surface_screen->format->Gmask,
-                           surface_screen->format->Bmask,
-                           surface_screen->format->Amask)) == NULL)
-    Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError());
+    /* use same surface type as screen surface */
+    if ((surface_screen->flags & SDL_HWSURFACE))
+      flags |= SDL_HWSURFACE;
+    else
+      flags |= SDL_SWSURFACE;
+
+    /* create surface for temporary copy of screen buffer */
+    if ((surface_screen_copy =
+        SDL_CreateRGBSurface(flags,
+                             surface_screen->w,
+                             surface_screen->h,
+                             surface_screen->format->BitsPerPixel,
+                             surface_screen->format->Rmask,
+                             surface_screen->format->Gmask,
+                             surface_screen->format->Bmask,
+                             surface_screen->format->Amask)) == NULL)
+      Error(ERR_EXIT, "SDL_CreateRGBSurface(   ) failed: %s", SDL_GetError());
+
+    /* create black surface for fading from/to black */
+    if ((surface_black =
+        SDL_CreateRGBSurface(flags,
+                             surface_screen->w,
+                             surface_screen->h,
+                             surface_screen->format->BitsPerPixel,
+                             surface_screen->format->Rmask,
+                             surface_screen->format->Gmask,
+                             surface_screen->format->Bmask,
+                             surface_screen->format->Amask)) == NULL)
+      Error(ERR_EXIT, "SDL_CreateRGBSurface(   ) failed: %s", SDL_GetError());
+
+    /* completely fill the surface with black color pixels */
+    SDL_FillRect(surface_black, NULL,
+                SDL_MapRGB(surface_screen->format, 0, 0, 0));
+
+    initialization_needed = FALSE;
+  }
 
-  SDL_FillRect(surface_black, NULL, SDL_MapRGB(surface_screen->format, 0,0,0));
+  /* copy the current screen backbuffer to the temporary screen copy buffer */
+  SDL_BlitSurface(surface_screen, NULL, surface_screen_copy, NULL);
 
   fade_reverse = (fade_mode == FADE_MODE_FADE_IN ? TRUE : FALSE);
   surface_cross = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_cross->surface :
@@ -489,9 +499,6 @@ static void FadeExt(Bitmap *bitmap_cross, int fade_ms, int fade_mode)
     SDL_Flip(surface_screen);
   }
 
-  SDL_FreeSurface(surface_screen_copy);
-  SDL_FreeSurface(surface_black);
-
   redraw_mask = REDRAW_NONE;
 }