rnd-20070925-1-src
authorHolger Schemel <info@artsoft.org>
Tue, 25 Sep 2007 21:15:06 +0000 (23:15 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:56:24 +0000 (10:56 +0200)
12 files changed:
src/conftime.h
src/files.c
src/init.c
src/libgame/image.c
src/libgame/image.h
src/libgame/misc.c
src/libgame/setup.c
src/libgame/sound.c
src/libgame/system.c
src/libgame/system.h
src/libgame/text.c
src/screens.c

index 2b817800906ee6bd8a18ae0b872bd43ae2844037..798079ba44f5a798ca54931da4394a1fb6048e7d 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2007-09-18 02:08"
+#define COMPILE_DATE_STRING "2007-09-25 03:18"
index 48fb5865fa9e81004159d5fd03d9365cee25a5ef..e78c1cdb271102049a81b6c596a7bab2bcfbe854 100644 (file)
@@ -8013,8 +8013,9 @@ void SaveScore(int nr)
 #define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS    28
 #define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS      29
 #define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC       30
+#define SETUP_TOKEN_OVERRIDE_CLASSIC_ARTWORK   31
 
-#define NUM_GLOBAL_SETUP_TOKENS                        31
+#define NUM_GLOBAL_SETUP_TOKENS                        32
 
 /* editor setup */
 #define SETUP_TOKEN_EDITOR_EL_BOULDERDASH      0
@@ -8142,6 +8143,7 @@ static struct TokenInfo global_setup_tokens[] =
   { TYPE_SWITCH, &si.override_level_graphics, "override_level_graphics"        },
   { TYPE_SWITCH, &si.override_level_sounds,   "override_level_sounds"  },
   { TYPE_SWITCH, &si.override_level_music,    "override_level_music"   },
+  { TYPE_SWITCH, &si.override_classic_artwork,"override_classic_artwork"},
 };
 
 static boolean not_used = FALSE;
@@ -8296,6 +8298,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->override_level_graphics = FALSE;
   si->override_level_sounds = FALSE;
   si->override_level_music = FALSE;
+  si->override_classic_artwork = FALSE;
 
   si->editor.el_boulderdash            = TRUE;
   si->editor.el_emerald_mine           = TRUE;
@@ -8968,7 +8971,11 @@ void LoadMenuDesignSettings()
   InitMenuDesignSettings_Static();
   InitMenuDesignSettings_SpecialPreProcessing();
 
+#if 1
+  if (!GFX_OVERRIDE_ARTWORK(ARTWORK_TYPE_GRAPHICS))
+#else
   if (!SETUP_OVERRIDE_ARTWORK(setup, ARTWORK_TYPE_GRAPHICS))
+#endif
   {
     /* first look for special settings configured in level series config */
     filename_base = getCustomArtworkLevelConfigFilename(ARTWORK_TYPE_GRAPHICS);
index 512c2756d2bdb8478cc8d46a9ce99a7deaad5eca..4711b34394e3d88db8ca50e548abc47fdfcc3fbd 100644 (file)
@@ -587,6 +587,58 @@ void InitFontGraphicInfo()
               getFontBitmapID, getFontFromToken);
 }
 
+static void CheckArtworkConfigForCustomElements(char *filename)
+{
+  SetupFileHash *setup_file_hash;
+  boolean redefined_ce_found = FALSE;
+
+  if ((setup_file_hash = loadSetupFileHash(filename)) != NULL)
+  {
+    BEGIN_HASH_ITERATION(setup_file_hash, itr)
+    {
+      char *token = HASH_ITERATION_TOKEN(itr);
+
+      if (strPrefix(token, "custom_"))
+       redefined_ce_found = TRUE;
+    }
+    END_HASH_ITERATION(setup_file_hash, itr)
+
+    freeSetupFileHash(setup_file_hash);
+  }
+
+  printf("::: redefined_ce_found == %d [%s]\n", redefined_ce_found, filename);
+}
+
+static void CheckCustomElementGraphicInfo()
+{
+  struct PropertyMapping *property_mapping = getImageListPropertyMapping();
+  int num_property_mappings = getImageListPropertyMappingSize();
+  boolean redefined_ce_found = FALSE;
+  int i;
+
+  /* check normal element/graphic mapping from static configuration */
+  for (i = 0; element_to_graphic[i].element > -1; i++)
+  {
+    int element = element_to_graphic[i].element;
+    int graphic = element_to_graphic[i].graphic;
+
+    if (IS_CUSTOM_ELEMENT(element))
+      if (getImageListEntryFromImageID(graphic)->redefined)
+       redefined_ce_found = TRUE;
+  }
+
+  /* check normal element/graphic mapping from dynamic configuration */
+  for (i = 0; i < num_property_mappings; i++)
+  {
+    int element = property_mapping[i].base_index;
+
+    if (IS_CUSTOM_ELEMENT(element))
+      redefined_ce_found = TRUE;
+  }
+
+  printf("::: redefined_ce_found == %d\n", redefined_ce_found);
+}
+
 void InitElementGraphicInfo()
 {
   struct PropertyMapping *property_mapping = getImageListPropertyMapping();
@@ -5422,6 +5474,7 @@ void InitGfx()
   InitGfxDoor1Info(DX, DY, DXSIZE, DYSIZE);
   InitGfxDoor2Info(VX, VY, VXSIZE, VYSIZE);
   InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
+  InitGfxCustomArtworkInfo();
 
   bitmap_font_initial = LoadCustomImage(filename_font_initial);
 
@@ -5663,7 +5716,11 @@ static char *getNewArtworkIdentifier(int type)
   static boolean last_has_level_artwork_set[3] = { FALSE, FALSE, FALSE };
   static boolean initialized[3] = { FALSE, FALSE, FALSE };
   TreeInfo *artwork_first_node = ARTWORK_FIRST_NODE(artwork, type);
+#if 1
+  boolean setup_override_artwork = GFX_OVERRIDE_ARTWORK(type);
+#else
   boolean setup_override_artwork = SETUP_OVERRIDE_ARTWORK(setup, type);
+#endif
   char *setup_artwork_set = SETUP_ARTWORK_SET(setup, type);
   char *leveldir_identifier = leveldir_current->identifier;
 #if 1
@@ -5780,6 +5837,44 @@ void ReloadCustomArtwork(int force_reload)
   boolean force_reload_mus = (force_reload & (1 << ARTWORK_TYPE_MUSIC));
   boolean reload_needed;
 
+#if 1
+  gfx.draw_init_text = FALSE;
+
+  gfx.override_level_graphics = FALSE;
+  gfx.override_level_sounds   = FALSE;
+  gfx.override_level_music    = FALSE;
+
+#if 0
+  LoadImageConfig();
+#endif
+#if 0
+  CheckCustomElementGraphicInfo();
+#endif
+
+#if 1
+  {
+    char *filename_base, *filename_local;
+
+    /* first look for special artwork configured in level series config */
+    filename_base = getCustomArtworkLevelConfigFilename(ARTWORK_TYPE_GRAPHICS);
+
+    if (fileExists(filename_base))
+      CheckArtworkConfigForCustomElements(filename_base);
+
+    filename_local = getCustomArtworkConfigFilename(ARTWORK_TYPE_GRAPHICS);
+
+    if (filename_local != NULL && !strEqual(filename_base, filename_local))
+      CheckArtworkConfigForCustomElements(filename_local);
+  }
+#endif
+
+  gfx.override_level_graphics = setup.override_level_graphics;
+  gfx.override_level_sounds   = setup.override_level_sounds;
+  gfx.override_level_music    = setup.override_level_music;
+
+  gfx.draw_init_text = TRUE;
+#endif
+
   force_reload_gfx |= AdjustGraphicsForEMC();
 
   gfx_new_identifier = getNewArtworkIdentifier(ARTWORK_TYPE_GRAPHICS);
index 85a73a54f2a29322acb80ce9e4b9fab4f779ebd7..c9712c81799556e6a02d9efd1bca6464e0fa1cc7 100644 (file)
@@ -1026,6 +1026,11 @@ void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries,
   image_info->free_artwork = FreeImage;
 }
 
+void LoadImageConfig()
+{
+  LoadArtworkConfig(image_info);
+}
+
 void ReloadCustomImages()
 {
 #if 0
index 89f4f7c41d36ac7029fc9d39d05e6d792d18ad3b..879c96159dbb32e461419d3566791577697e4955 100644 (file)
@@ -89,6 +89,7 @@ struct PropertyMapping *getImageListPropertyMapping();
 void InitImageList(struct ConfigInfo *, int, struct ConfigTypeInfo *,
                   char **, char **, char **, char **, char **);
 
+void LoadImageConfig();
 void ReloadCustomImages();
 void CreateImageWithSmallImages(int, int);
 void ScaleImage(int, int);
index 3d63cc5c07316f7fa039ed938144e705552ffc75..8ff6a458b32682b374d43d994572d03a4eb8177b 100644 (file)
@@ -2662,7 +2662,11 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info)
     artwork_info->num_property_mapping_entries = 0;
   }
 
+#if 1
+  if (!GFX_OVERRIDE_ARTWORK(artwork_info->type))
+#else
   if (!SETUP_OVERRIDE_ARTWORK(setup, artwork_info->type))
+#endif
   {
     /* first look for special artwork configured in level series config */
     filename_base = getCustomArtworkLevelConfigFilename(artwork_info->type);
index df6e2f8a0bc8ebad3299240c2bf449f3786e8307..e8e99a382d2f1b109083b7e94705d0b2e1db2da3 100644 (file)
@@ -518,7 +518,7 @@ char *getLevelSetTitleMessageFilename(int nr, boolean initial)
 
   basename = getLevelSetTitleMessageBasename(nr, initial);
 
-  if (!setup.override_level_graphics)
+  if (!gfx.override_level_graphics)
   {
     /* 1st try: look for special artwork in current level series directory */
     filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
@@ -615,7 +615,7 @@ char *getCustomImageFilename(char *basename)
 
   basename = getCorrectedArtworkBasename(basename);
 
-  if (!setup.override_level_graphics)
+  if (!gfx.override_level_graphics)
   {
     /* 1st try: look for special artwork in current level series directory */
     filename = getPath3(getCurrentLevelDir(), GRAPHICS_DIRECTORY, basename);
@@ -688,7 +688,7 @@ char *getCustomSoundFilename(char *basename)
 
   basename = getCorrectedArtworkBasename(basename);
 
-  if (!setup.override_level_sounds)
+  if (!gfx.override_level_sounds)
   {
     /* 1st try: look for special artwork in current level series directory */
     filename = getPath3(getCurrentLevelDir(), SOUNDS_DIRECTORY, basename);
@@ -756,7 +756,7 @@ char *getCustomMusicFilename(char *basename)
 
   basename = getCorrectedArtworkBasename(basename);
 
-  if (!setup.override_level_music)
+  if (!gfx.override_level_music)
   {
     /* 1st try: look for special artwork in current level series directory */
     filename = getPath3(getCurrentLevelDir(), MUSIC_DIRECTORY, basename);
@@ -850,7 +850,7 @@ char *getCustomMusicDirectory(void)
 
   checked_free(directory);
 
-  if (!setup.override_level_music)
+  if (!gfx.override_level_music)
   {
     /* 1st try: look for special artwork in current level series directory */
     directory = getPath2(getCurrentLevelDir(), MUSIC_DIRECTORY);
index b80cccab57ca3636078e1d8af1e23fb376d2f97e..d620dd93d0614b38ac5dfff9244d3abb518d5f7b 100644 (file)
@@ -474,8 +474,8 @@ static void WriteReloadInfoToPipe(char *set_identifier, int type)
   unsigned long str_size4 = strlen(ti->basepath) + 1;
   unsigned long str_size5 = strlen(ti->fullpath) + 1;
   boolean override_level_artwork = (type == SND_CTRL_RELOAD_SOUNDS ?
-                                   setup.override_level_sounds :
-                                   setup.override_level_music);
+                                   gfx.override_level_sounds :
+                                   gfx.override_level_music);
 
   if (IS_CHILD_PROCESS())
     return;
@@ -534,8 +534,8 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
   unsigned long str_size1, str_size2, str_size3, str_size4, str_size5;
   static char *set_identifier = NULL;
   boolean *override_level_artwork = (snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS ?
-                                    &setup.override_level_sounds :
-                                    &setup.override_level_music);
+                                    &gfx.override_level_sounds :
+                                    &gfx.override_level_music);
 
   checked_free(set_identifier);
 
index 9ed186f1e8143312974f1a4ea0c9807a50030d00..ed856965d6ab7f6fce783f97c8c7414b78426072 100644 (file)
@@ -201,6 +201,15 @@ void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void))
   gfx.draw_busy_anim_function = draw_busy_anim_function;
 }
 
+void InitGfxCustomArtworkInfo()
+{
+  gfx.override_level_graphics = FALSE;
+  gfx.override_level_sounds = FALSE;
+  gfx.override_level_music = FALSE;
+
+  gfx.draw_init_text = TRUE;
+}
+
 void SetDrawDeactivationMask(int draw_deactivation_mask)
 {
   gfx.draw_deactivation_mask = draw_deactivation_mask;
index 59522dc6269213db49fdb4c50794527b0cd36d5e..a340b21844dc3dd12707617ac90ae1ab9473d8d0 100644 (file)
                                 (setup).override_level_sounds :        \
                                 (setup).override_level_music)
 
+#define GFX_OVERRIDE_ARTWORK(type)                                     \
+                               ((type) == ARTWORK_TYPE_GRAPHICS ?      \
+                                gfx.override_level_graphics :          \
+                                (type) == ARTWORK_TYPE_SOUNDS ?        \
+                                gfx.override_level_sounds :            \
+                                gfx.override_level_music)
+
 #define ARTWORK_FIRST_NODE(artwork, type)                              \
                                ((type) == ARTWORK_TYPE_GRAPHICS ?      \
                                 (artwork).gfx_first :                  \
@@ -725,6 +732,12 @@ struct GfxInfo
   Bitmap *background_bitmap;
   int background_bitmap_mask;
 
+  boolean override_level_graphics;
+  boolean override_level_sounds;
+  boolean override_level_music;
+
+  boolean draw_init_text;
+
   int num_fonts;
   struct FontBitmapInfo *font_bitmap_info;
   int (*select_font_function)(int);
@@ -858,7 +871,7 @@ struct SetupInfo
   boolean override_level_graphics;
   boolean override_level_sounds;
   boolean override_level_music;
-#if 0
+#if 1
   boolean override_classic_artwork;
 #endif
 
@@ -1134,6 +1147,7 @@ void InitGfxDoor1Info(int, int, int, int);
 void InitGfxDoor2Info(int, int, int, int);
 void InitGfxScrollbufferInfo(int, int);
 void InitGfxDrawBusyAnimFunction(void (*draw_busy_anim_function)(void));
+void InitGfxCustomArtworkInfo();
 void SetDrawDeactivationMask(int);
 void SetDrawBackgroundMask(int);
 void SetWindowBackgroundBitmap(Bitmap *);
index f5e9c0666d504c6b5917b5f96c303626506caf4b..f0cdb01adaecedd75fb3325b440ba40dd840b1dd 100644 (file)
@@ -203,6 +203,7 @@ void DrawInitTextExt(char *text, int ypos, int font_nr, boolean force)
     return;
 
   if (window != NULL &&
+      gfx.draw_init_text &&
       gfx.num_fonts > 0 &&
       gfx.font_bitmap_info[font_nr].bitmap != NULL)
   {
index 7ec7fac55947037fcbafe46592a9b580848a2bfe..0ed0b384c0200e3e9277a895e5f9e2afa88fdc2d 100644 (file)
@@ -4203,6 +4203,7 @@ static struct TokenInfo setup_info_artwork[] =
   { TYPE_YES_NO, &setup.override_level_graphics,"Override Level Graphics:" },
   { TYPE_YES_NO, &setup.override_level_sounds, "Override Level Sounds:"   },
   { TYPE_YES_NO, &setup.override_level_music,  "Override Level Music:"    },
+  { TYPE_YES_NO, &setup.override_classic_artwork,"Override Classic Artwork:" },
 #else
   { TYPE_STRING,       NULL,                   "Override Level Artwork:"},
   { TYPE_YES_NO,       &setup.override_level_graphics, "Graphics:"     },