rnd-20031122-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 22 Nov 2003 02:36:54 +0000 (03:36 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:44:39 +0000 (10:44 +0200)
src/conf_e2g.c
src/conftime.h
src/files.c
src/files.h
src/libgame/setup.c
src/libgame/setup.h
src/libgame/sound.c
src/libgame/system.h
src/main.c
src/main.h
src/screens.c

index e17b2fac5db6dc1180e757c8c526716e189a3ae2..34ea8a3f61955f6c32083aeb4726d603892a1358 100644 (file)
@@ -885,10 +885,18 @@ element_to_graphic[] =
     EL_AMOEBA_GROWING,                 -1, -1, FALSE,
     IMG_AMOEBA_GROWING
   },
+  {
+    EL_AMOEBA,                         ACTION_GROWING, -1, FALSE,
+    IMG_AMOEBA_GROWING
+  },
   {
     EL_AMOEBA_SHRINKING,               -1, -1, FALSE,
     IMG_AMOEBA_SHRINKING
   },
+  {
+    EL_AMOEBA,                         ACTION_SHRINKING, -1, FALSE,
+    IMG_AMOEBA_SHRINKING
+  },
   {
     EL_AMOEBA_WET,                     -1, -1, FALSE,
     IMG_AMOEBA_WET
@@ -897,6 +905,10 @@ element_to_graphic[] =
     EL_AMOEBA_DROPPING,                        -1, -1, FALSE,
     IMG_AMOEBA_DROPPING
   },
+  {
+    EL_AMOEBA,                         ACTION_DROPPING, -1, FALSE,
+    IMG_AMOEBA_DROPPING
+  },
   {
     EL_AMOEBA_DRY,                     -1, -1, FALSE,
     IMG_AMOEBA_DRY
index b4b0a87d72a1a189025af3b2c899e369af4fc442..a3595d1d9cf28c07f285961894fa496414e8b1c3 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-11-21 02:35]"
+#define COMPILE_DATE_STRING "[2003-11-22 03:36]"
index 779a6751d92524be848de4f240098914ca2394e6..51e2c44d680442c6a11069a22fbf5fae60b815f3 100644 (file)
@@ -2859,11 +2859,12 @@ static struct MusicFileInfo *get_music_file_info(char *basename)
   }
   token_to_value_ptr[] =
   {
-    { "title", &tmp_music_file_info.title      },
-    { "artist",        &tmp_music_file_info.artist     },
-    { "album", &tmp_music_file_info.album      },
-    { "year",  &tmp_music_file_info.year       },
-    { NULL,    NULL                            },
+    { "context",       &tmp_music_file_info.context    },
+    { "title",         &tmp_music_file_info.title      },
+    { "artist",                &tmp_music_file_info.artist     },
+    { "album",         &tmp_music_file_info.album      },
+    { "year",          &tmp_music_file_info.year       },
+    { NULL,            NULL                            },
   };
   int i;
 
@@ -2914,8 +2915,7 @@ static struct MusicFileInfo *get_music_file_info(char *basename)
   {
     char *value = getHashEntry(setup_file_hash, token_to_value_ptr[i].token);
 
-    if (value != NULL)
-      *token_to_value_ptr[i].value_ptr = getStringCopy(value);
+    *token_to_value_ptr[i].value_ptr = getStringCopy(value);  /* may be NULL */
   }
 
   new_music_file_info = checked_calloc(sizeof(struct MusicFileInfo));
@@ -3018,3 +3018,203 @@ void LoadMusicInfo()
     printf("::: title == '%s'\n", next->title);
 #endif
 }
+
+void add_info_animation(int element, int action, int direction, int delay,
+                       int *num_list_entries)
+{
+  struct InfoAnimationInfo *new_list_entry;
+  (*num_list_entries)++;
+
+  info_animation_info =
+    checked_realloc(info_animation_info,
+                   *num_list_entries * sizeof(struct InfoAnimationInfo));
+  new_list_entry = &info_animation_info[*num_list_entries - 1];
+
+  new_list_entry->element = element;
+  new_list_entry->action = action;
+  new_list_entry->direction = direction;
+  new_list_entry->delay = delay;
+}
+
+void print_unknown_token(char *filename, char *token, int token_nr)
+{
+  if (token_nr == 0)
+  {
+    Error(ERR_RETURN_LINE, "-");
+    Error(ERR_RETURN, "warning: unknown token(s) found in config file:");
+    Error(ERR_RETURN, "- config file: '%s'", filename);
+  }
+
+  Error(ERR_RETURN, "- token: '%s'", token);
+}
+
+void print_unknown_token_end(int token_nr)
+{
+  if (token_nr > 0)
+    Error(ERR_RETURN_LINE, "-");
+}
+
+void LoadInfoAnimations()
+{
+  char *filename = getElementInfoFilename();
+  SetupFileList *setup_file_list, *list;
+  SetupFileHash *element_hash, *action_hash, *direction_hash;
+  int num_list_entries = 0;
+  int num_unknown_tokens = 0;
+  int i;
+
+  if ((setup_file_list = loadSetupFileList(filename)) == NULL)
+    return;
+
+  element_hash   = newSetupFileHash();
+  action_hash    = newSetupFileHash();
+  direction_hash = newSetupFileHash();
+
+  for (i=0; i < MAX_NUM_ELEMENTS; i++)
+    setHashEntry(element_hash, element_info[i].token_name, itoa(i));
+
+  for (i=0; i < NUM_ACTIONS; i++)
+    setHashEntry(action_hash, element_action_info[i].suffix,
+                itoa(element_action_info[i].value));
+
+  for (i=0; i < NUM_DIRECTIONS; i++)
+    setHashEntry(direction_hash, element_direction_info[i].suffix,
+                itoa(element_direction_info[i].value));
+
+  for (list = setup_file_list; list != NULL; list = list->next)
+  {
+    char *element_token, *action_token, *direction_token;
+    char *element_value, *action_value, *direction_value;
+    int delay = atoi(list->value);
+
+    if (strcmp(list->token, "end") == 0)
+    {
+      add_info_animation(-1, -1, -1, -1, &num_list_entries);
+
+      continue;
+    }
+
+    element_token = list->token;
+    element_value = getHashEntry(element_hash, element_token);
+
+    if (element_value != NULL)
+    {
+      /* element found */
+      add_info_animation(atoi(element_value), -1, -1,
+                        delay, &num_list_entries);
+
+      continue;
+    }
+
+    if (strchr(element_token, '.') == NULL)
+    {
+      /* no further suffixes found -- this is not an element */
+      print_unknown_token(filename, list->token, num_unknown_tokens++);
+
+      continue;
+    }
+
+    action_token = strchr(element_token, '.');
+    element_token = getStringCopy(element_token);
+    *strchr(element_token, '.') = '\0';
+
+    element_value = getHashEntry(element_hash, element_token);
+
+    if (element_value == NULL)
+    {
+      /* this is not an element */
+      print_unknown_token(filename, list->token, num_unknown_tokens++);
+      free(element_token);
+
+      continue;
+    }
+
+    action_value = getHashEntry(action_hash, action_token);
+
+    if (action_value != NULL)
+    {
+      /* action found */
+      add_info_animation(atoi(element_value), atoi(action_value), -1,
+                        delay, &num_list_entries);
+      free(element_token);
+
+      continue;
+    }
+
+    direction_token = action_token;
+    direction_value = getHashEntry(direction_hash, direction_token);
+
+    if (direction_value != NULL)
+    {
+      /* direction found */
+      add_info_animation(atoi(element_value), -1, atoi(direction_value),
+                        delay, &num_list_entries);
+      free(element_token);
+
+      continue;
+    }
+
+    if (strchr(action_token + 1, '.') == NULL)
+    {
+      /* no further suffixes found -- this is not an action or direction */
+      print_unknown_token(filename, list->token, num_unknown_tokens++);
+      free(element_token);
+
+      continue;
+    }
+
+    direction_token = strchr(action_token + 1, '.');
+    action_token = getStringCopy(action_token);
+    *strchr(action_token + 1, '.') = '\0';
+
+    action_value = getHashEntry(action_hash, action_token);
+
+    if (action_value == NULL)
+    {
+      /* this is not an action */
+      print_unknown_token(filename, list->token, num_unknown_tokens++);
+      free(element_token);
+      free(action_token);
+
+      continue;
+    }
+
+    direction_value = getHashEntry(direction_hash, direction_token);
+
+    if (direction_value != NULL)
+    {
+      /* direction found */
+      add_info_animation(atoi(element_value), atoi(action_value),
+                        atoi(direction_value),
+                        delay, &num_list_entries);
+      free(element_token);
+      free(action_token);
+
+      continue;
+    }
+
+    print_unknown_token(filename, list->token, num_unknown_tokens++);
+
+    free(element_token);
+    free(action_token);
+  }
+
+  print_unknown_token_end(num_unknown_tokens);
+
+  add_info_animation(-999, -999, -999, -999, &num_list_entries);
+
+  freeSetupFileList(setup_file_list);
+  freeSetupFileHash(element_hash);
+  freeSetupFileHash(action_hash);
+  freeSetupFileHash(direction_hash);
+
+#if 0
+  /* TEST ONLY */
+  for (i=0; i < num_list_entries; i++)
+    printf("::: %d, %d, %d => %d\n",
+          info_animation_info[i].element,
+          info_animation_info[i].action,
+          info_animation_info[i].direction,
+          info_animation_info[i].delay);
+#endif
+}
index 0da4cc2da6a76a3e0459469e4f920836d31886db..844503a00a5e8ba6d78c1bf51631c6fe616ae297 100644 (file)
@@ -42,5 +42,6 @@ void LoadCustomElementDescriptions();
 void LoadSpecialMenuDesignSettings();
 void LoadUserDefinedEditorElementList(int **, int *);
 void LoadMusicInfo();
+void LoadInfoAnimations();
 
 #endif /* FILES_H */
index 3ba6745deb17c313c1d55f640b9f2d8bdd7e4571..446fb1e4470bfa326bb86856ffca8b1da4370127 100644 (file)
@@ -417,6 +417,18 @@ char *getEditorSetupFilename()
   return filename;
 }
 
+char *getElementInfoFilename()
+{
+  static char *filename = NULL;
+
+  if (filename != NULL)
+    free(filename);
+
+  filename = getPath2(getCurrentLevelDir(), ELEMENTINFO_FILENAME);
+
+  return filename;
+}
+
 static char *getCorrectedArtworkBasename(char *basename)
 {
   char *basename_corrected = basename;
index 9939437ab1c0cc962e2c108571027850a552c00d..85ec5db1b57f7ced3bd63a5de6272f59e147963c 100644 (file)
@@ -197,6 +197,7 @@ char *getTapeFilename(int);
 char *getScoreFilename(int);
 char *getSetupFilename(void);
 char *getEditorSetupFilename(void);
+char *getElementInfoFilename(void);
 char *getImageFilename(char *);
 char *getCustomImageFilename(char *);
 char *getCustomSoundFilename(char *);
index 261428116aa7166ec5bea8e6d9af4b88c07b6e59..8fb94919cff281bdc887a241aecf1225ab9f076c 100644 (file)
@@ -1934,7 +1934,7 @@ void LoadCustomMusic_NoConf(void)
     if (music_already_used)
       continue;
 
-#if 1
+#if 0
     if (FileIsSound(basename) || FileIsMusic(basename))
       printf("DEBUG: loading music '%s' ...\n", basename);
 #endif
index ec1b52501f66ab337091744ded186e06cbf49f80..3abbbd7602cb849b7946fe02a520ab6eadcaae9c 100644 (file)
 #define SETUP_FILENAME         "setup.conf"
 #define LEVELSETUP_FILENAME    "levelsetup.conf"
 #define EDITORSETUP_FILENAME   "editorsetup.conf"
+#define ELEMENTINFO_FILENAME   "elementinfo.conf"
 #define LEVELINFO_FILENAME     "levelinfo.conf"
 #define GRAPHICSINFO_FILENAME  "graphicsinfo.conf"
 #define SOUNDSINFO_FILENAME    "soundsinfo.conf"
 #define SETUP_FILENAME         "setup.cnf"
 #define LEVELSETUP_FILENAME    "lvlsetup.cnf"
 #define EDITORSETUP_FILENAME   "edsetup.conf"
+#define ELEMENTINFO_FILENAME   "eleminfo.conf"
 #define LEVELINFO_FILENAME     "lvlinfo.cnf"
 #define GRAPHICSINFO_FILENAME  "gfxinfo.cnf"
 #define SOUNDSINFO_FILENAME    "sndinfo.cnf"
index d9319c5c35757089f610a256b4550f0d8e99bcf3..4032019b6ca665d3f85d6ca5881538f538b58fa0 100644 (file)
@@ -105,6 +105,7 @@ struct GraphicInfo     *graphic_info = NULL;
 struct SoundInfo       *sound_info = NULL;
 struct MusicInfo       *music_info = NULL;
 struct MusicFileInfo   *music_file_info = NULL;
+struct InfoAnimationInfo *info_animation_info = NULL;
 
 
 /* ------------------------------------------------------------------------- */
@@ -3476,12 +3477,12 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1] =
     "-"
   },
   {
-    "nut_breaking",
+    "nut.breaking",
     "-",
     "-"
   },
   {
-    "diamond_breaking",
+    "diamond.breaking",
     "-",
     "-"
   },
@@ -3496,12 +3497,12 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1] =
     "-"
   },
   {
-    "amoeba_growing",
+    "amoeba.growing",
     "-",
     "-"
   },
   {
-    "amoeba_shrinking",
+    "amoeba.shrinking",
     "-",
     "-"
   },
@@ -3640,6 +3641,11 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1] =
     "-",
     "-"
   },
+  {
+    "amoeba",
+    "amoeba",
+    "-"
+  },
   {
     "[default]",
     "default",
index 3bbb26522d686210c7f47d135fd364e3e35a7e82..ebcfb39d5958df074aab0b037b0df0477e0746a8 100644 (file)
 #define EL_DYNABOMB_PLAYER_4                   (EL_FIRST_DUMMY + 17)
 #define EL_SHIELD_NORMAL_ACTIVE                        (EL_FIRST_DUMMY + 18)
 #define EL_SHIELD_DEADLY_ACTIVE                        (EL_FIRST_DUMMY + 19)
-#define EL_DEFAULT                             (EL_FIRST_DUMMY + 20)
-#define EL_BD_DEFAULT                          (EL_FIRST_DUMMY + 21)
-#define EL_SP_DEFAULT                          (EL_FIRST_DUMMY + 22)
-#define EL_SB_DEFAULT                          (EL_FIRST_DUMMY + 23)
+#define EL_AMOEBA                              (EL_FIRST_DUMMY + 20)
+#define EL_DEFAULT                             (EL_FIRST_DUMMY + 21)
+#define EL_BD_DEFAULT                          (EL_FIRST_DUMMY + 22)
+#define EL_SP_DEFAULT                          (EL_FIRST_DUMMY + 23)
+#define EL_SB_DEFAULT                          (EL_FIRST_DUMMY + 24)
 
-#define MAX_NUM_ELEMENTS                       (EL_FIRST_DUMMY + 24)
+#define MAX_NUM_ELEMENTS                       (EL_FIRST_DUMMY + 25)
 
 
 /* values for graphics/sounds action types */
@@ -1514,6 +1515,15 @@ struct SpecialSuffixInfo
   int value;
 };
 
+struct InfoAnimationInfo
+{
+  int element;
+  int action;
+  int direction;
+
+  int delay;
+};
+
 
 #if 0
 extern GC                      tile_clip_gc;
@@ -1608,6 +1618,7 @@ extern struct GraphicInfo      *graphic_info;
 extern struct SoundInfo               *sound_info;
 extern struct MusicInfo               *music_info;
 extern struct MusicFileInfo    *music_file_info;
+extern struct InfoAnimationInfo *info_animation_info;
 extern struct ConfigInfo       image_config[];
 extern struct ConfigInfo       sound_config[];
 extern struct ConfigInfo       music_config[];
index a6b259d9eb7a065b4a04917fdaaef5143a98d09c..328f6893317dc40b33d415870aa333ac140633d5 100644 (file)
@@ -516,6 +516,7 @@ static long helpscreen_state;
 static int helpscreen_step[MAX_HELPSCREEN_ELS];
 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
 
+#if 0
 static int helpscreen_action[] =
 {
   IMG_PLAYER_1_MOVING_DOWN,            16,
@@ -725,6 +726,8 @@ static int helpscreen_action[] =
 
   HA_END
 };
+#endif
+
 static char *helpscreen_eltext[][2] =
 {
  {"THE HERO:",                         "(Is _this_ guy good old Rockford?)"},
@@ -792,6 +795,7 @@ static char *helpscreen_eltext[][2] =
 };
 static int num_helpscreen_els = sizeof(helpscreen_eltext) / (2*sizeof(char *));
 
+#if 0
 static char *helpscreen_music[][3] =
 {
   { "Alchemy",                 "Ian Boddy",            "Drive" },
@@ -802,73 +806,98 @@ static char *helpscreen_music[][3] =
   { "Voyager",                 "The Alan Parsons Project","Pyramid" },
   { "Twilight Painter",                "Tangerine Dream",      "Heartbreakers" }
 };
+#endif
+
 static int num_helpscreen_music = 7;
 static int helpscreen_musicpos;
 
-#if 0
-void OLD_DrawHelpScreenElAction(int start)
+#if 1
+void DrawHelpScreenElAction(int start)
 {
   int i = 0, j = 0;
-  int frame, graphic;
-  int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
+  int xstart = mSX + 16;
+  int ystart = mSY + 64 + 2 * 32;
+  int ystep = TILEY + 4;
+  int element, action, direction;
+  int graphic;
+  int delay;
+  int sync_frame;
 
-  while(helpscreen_action[j] != HA_END)
+  while (info_animation_info[j].element != -999)
   {
-    if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
+    if (i >= start + MAX_HELPSCREEN_ELS || i >= num_helpscreen_els)
       break;
-    else if (i<start || helpscreen_delay[i-start])
+    else if (i < start)
     {
-      if (i>=start && helpscreen_delay[i-start])
-       helpscreen_delay[i-start]--;
-
-      while(helpscreen_action[j] != HA_NEXT)
+      while (info_animation_info[j].element != -1)
        j++;
+
       j++;
       i++;
+
       continue;
     }
 
-    j += 3*helpscreen_step[i-start];
-    graphic = helpscreen_action[j++];
+    j += helpscreen_step[i - start];
+
+    element = info_animation_info[j].element;
+    action = info_animation_info[j].action;
+    direction = info_animation_info[j].direction;
+
+    if (action != -1 && direction != -1)
+      graphic = el_act_dir2img(element, action, direction);
+    else if (action != -1)
+      graphic = el_act2img(element, action);
+    else if (direction != -1)
+      graphic = el_act2img(element, direction);
+    else
+      graphic = el2img(element);
+
+    delay = info_animation_info[j++].delay;
+
+    if (delay == -1)
+      delay = 1000000;
 
-    if (helpscreen_frame[i-start])
+    if (helpscreen_frame[i - start] == 0)
     {
-      frame = helpscreen_action[j++] - helpscreen_frame[i-start];
-      helpscreen_frame[i-start]--;
+      sync_frame = 0;
+      helpscreen_frame[i - start] = delay - 1;
     }
     else
     {
-      frame = 0;
-      helpscreen_frame[i-start] = helpscreen_action[j++]-1;
+      sync_frame = delay - helpscreen_frame[i - start];
+      helpscreen_frame[i - start]--;
     }
 
-    helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
-
-    if (helpscreen_action[j] == HA_NEXT)
+    if (info_animation_info[j].element == -1)
     {
-      if (!helpscreen_frame[i-start])
-       helpscreen_step[i-start] = 0;
+      if (!helpscreen_frame[i - start])
+       helpscreen_step[i - start] = 0;
     }
     else
     {
-      if (!helpscreen_frame[i-start])
-       helpscreen_step[i-start]++;
-      while(helpscreen_action[j] != HA_NEXT)
+      if (!helpscreen_frame[i - start])
+       helpscreen_step[i - start]++;
+      while(info_animation_info[j].element != -1)
        j++;
     }
+
     j++;
 
-    DrawOldGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame);
+    ClearRectangleOnBackground(drawto, xstart, ystart + (i - start) * ystep,
+                              TILEX, TILEY);
+    DrawGraphicAnimationExt(drawto, xstart, ystart + (i - start) * ystep,
+                           graphic, sync_frame, USE_MASKING);
+
     i++;
   }
 
-  for(i=2;i<16;i++)
-  {
-    MarkTileDirty(0,i);
-    MarkTileDirty(1,i);
-  }
+  redraw_mask |= REDRAW_FIELD;
+
+  FrameCounter++;
 }
-#endif
+
+#else
 
 void DrawHelpScreenElAction(int start)
 {
@@ -953,6 +982,7 @@ void DrawHelpScreenElAction(int start)
 
   FrameCounter++;
 }
+#endif
 
 void DrawHelpScreenElText(int start)
 {
@@ -1095,8 +1125,14 @@ void DrawHelpScreen()
   helpscreen_musicpos = 0;
   helpscreen_state = 0;
 
+  LoadInfoAnimations();
   LoadMusicInfo();
 
+  num_helpscreen_els = 0;
+  for (i=0; info_animation_info[i].element != -999; i++)
+    if (info_animation_info[i].element == -1)
+      num_helpscreen_els++;
+
   num_helpscreen_music = 0;
   for (list = music_file_info; list != NULL; list = list->next)
     num_helpscreen_music++;