added options "played_header" and "played" to music file info
authorHolger Schemel <info@artsoft.org>
Thu, 1 Jun 2023 21:22:37 +0000 (23:22 +0200)
committerHolger Schemel <info@artsoft.org>
Thu, 1 Jun 2023 21:30:37 +0000 (23:30 +0200)
If option "played" is specified in the music file info, it overrides
a potentially detected level number to be displayed for this option.

The option "played_header" can be used to replace the text "played in"
with a different header text.

src/files.c
src/main.h
src/screens.c

index 47dfe11972294618b3aaa16a27516a5242f7e69d..c934db0fb414ce918421ed8913da260e8878b509 100644 (file)
@@ -12839,11 +12839,13 @@ static struct MusicFileInfo *get_music_file_info_ext(char *basename, int music,
     { "artist_header", &tmp_music_file_info.artist_header      },
     { "album_header",  &tmp_music_file_info.album_header       },
     { "year_header",   &tmp_music_file_info.year_header        },
+    { "played_header", &tmp_music_file_info.played_header      },
 
     { "title",         &tmp_music_file_info.title              },
     { "artist",                &tmp_music_file_info.artist             },
     { "album",         &tmp_music_file_info.album              },
     { "year",          &tmp_music_file_info.year               },
+    { "played",                &tmp_music_file_info.played             },
 
     { NULL,            NULL                                    },
   };
@@ -12957,11 +12959,13 @@ void LoadMusicInfo(void)
     checked_free(music_file_info->artist_header);
     checked_free(music_file_info->album_header);
     checked_free(music_file_info->year_header);
+    checked_free(music_file_info->played_header);
 
     checked_free(music_file_info->title);
     checked_free(music_file_info->artist);
     checked_free(music_file_info->album);
     checked_free(music_file_info->year);
+    checked_free(music_file_info->played);
 
     free(music_file_info);
 
index a107a65ee2e700868d69d4b549bdabb81bf7c04a..dc4ea9ace501012d47b92aaf669ec47fa15ee25c 100644 (file)
@@ -3779,11 +3779,13 @@ struct MusicFileInfo
   char *artist_header;
   char *album_header;
   char *year_header;
+  char *played_header;
 
   char *title;
   char *artist;
   char *album;
   char *year;
+  char *played;
 
   int music;
 
index a7e164399780cb99346e4c08178b97d35cd22ed3..d48ba4ecf99d7edfc588828899b5c149729b91dc 100644 (file)
@@ -3595,11 +3595,23 @@ void HandleInfoScreen_Music(int dx, int dy, int button)
       ystart += ystep_head;
     }
 
-    int music_level_nr = -1;
-    int i;
+    if (!strEqual(list->played, UNKNOWN_NAME))
+    {
+      if (!strEqual(list->played_header, UNKNOWN_NAME))
+       DrawTextSCentered(ystart, font_head, list->played_header);
+      else
+       DrawTextSCentered(ystart, font_head, "played in");
 
-    if (!list->is_sound)
+      ystart += ystep_head;
+
+      DrawTextFCentered(ystart, font_text, "%s", list->played);
+      ystart += ystep_head;
+    }
+    else if (!list->is_sound)
     {
+      int music_level_nr = -1;
+      int i;
+
       // check if this music is configured for a certain level
       for (i = leveldir_current->first_level;
           i <= leveldir_current->last_level; i++)
@@ -3616,7 +3628,11 @@ void HandleInfoScreen_Music(int dx, int dy, int button)
 
       if (music_level_nr != -1)
       {
-       DrawTextSCentered(ystart, font_head, "played in");
+       if (!strEqual(list->played_header, UNKNOWN_NAME))
+         DrawTextSCentered(ystart, font_head, list->played_header);
+       else
+         DrawTextSCentered(ystart, font_head, "played in");
+
        ystart += ystep_head;
 
        DrawTextFCentered(ystart, font_text, "level %03d", music_level_nr);