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 */
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;
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);
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 :
SDL_Flip(surface_screen);
}
- SDL_FreeSurface(surface_screen_copy);
- SDL_FreeSurface(surface_black);
-
redraw_mask = REDRAW_NONE;
}