added support for main menu titles in level and graphics config file
authorHolger Schemel <info@artsoft.org>
Fri, 24 Nov 2017 20:21:19 +0000 (21:21 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 23 Mar 2018 22:21:16 +0000 (23:21 +0100)
src/init.c
src/libgame/setup.c
src/libgame/setup.h
src/libgame/system.h
src/screens.c

index b0043d4911cf53fc19117049ce321ed7fdebb3ad..ff9f0344a003542288b8b6a275214456a213a4a5 100644 (file)
@@ -5123,6 +5123,10 @@ static void InitArtworkConfig()
   {
     "name",
     "sort_priority",
+    "program_title",
+    "program_copyright",
+    "program_company",
+
     NULL
   };
   static char **ignore_image_tokens;
index f2f5984f702ce2947bfa4c77bc4a4b1ff9086f8b..bbfbe9c3d9063057f2d044e94e2401111705a550 100644 (file)
@@ -2236,27 +2236,30 @@ SetupFileHash *loadSetupFileHash(char *filename)
 #define LEVELINFO_TOKEN_NAME_SORTING           2
 #define LEVELINFO_TOKEN_AUTHOR                 3
 #define LEVELINFO_TOKEN_YEAR                   4
-#define LEVELINFO_TOKEN_IMPORTED_FROM          5
-#define LEVELINFO_TOKEN_IMPORTED_BY            6
-#define LEVELINFO_TOKEN_TESTED_BY              7
-#define LEVELINFO_TOKEN_LEVELS                 8
-#define LEVELINFO_TOKEN_FIRST_LEVEL            9
-#define LEVELINFO_TOKEN_SORT_PRIORITY          10
-#define LEVELINFO_TOKEN_LATEST_ENGINE          11
-#define LEVELINFO_TOKEN_LEVEL_GROUP            12
-#define LEVELINFO_TOKEN_READONLY               13
-#define LEVELINFO_TOKEN_GRAPHICS_SET_ECS       14
-#define LEVELINFO_TOKEN_GRAPHICS_SET_AGA       15
-#define LEVELINFO_TOKEN_GRAPHICS_SET           16
-#define LEVELINFO_TOKEN_SOUNDS_SET             17
-#define LEVELINFO_TOKEN_MUSIC_SET              18
-#define LEVELINFO_TOKEN_FILENAME               19
-#define LEVELINFO_TOKEN_FILETYPE               20
-#define LEVELINFO_TOKEN_SPECIAL_FLAGS          21
-#define LEVELINFO_TOKEN_HANDICAP               22
-#define LEVELINFO_TOKEN_SKIP_LEVELS            23
-
-#define NUM_LEVELINFO_TOKENS                   24
+#define LEVELINFO_TOKEN_PROGRAM_TITLE          5
+#define LEVELINFO_TOKEN_PROGRAM_COPYRIGHT      6
+#define LEVELINFO_TOKEN_PROGRAM_COMPANY                7
+#define LEVELINFO_TOKEN_IMPORTED_FROM          8
+#define LEVELINFO_TOKEN_IMPORTED_BY            9
+#define LEVELINFO_TOKEN_TESTED_BY              10
+#define LEVELINFO_TOKEN_LEVELS                 11
+#define LEVELINFO_TOKEN_FIRST_LEVEL            12
+#define LEVELINFO_TOKEN_SORT_PRIORITY          13
+#define LEVELINFO_TOKEN_LATEST_ENGINE          14
+#define LEVELINFO_TOKEN_LEVEL_GROUP            15
+#define LEVELINFO_TOKEN_READONLY               16
+#define LEVELINFO_TOKEN_GRAPHICS_SET_ECS       17
+#define LEVELINFO_TOKEN_GRAPHICS_SET_AGA       18
+#define LEVELINFO_TOKEN_GRAPHICS_SET           19
+#define LEVELINFO_TOKEN_SOUNDS_SET             20
+#define LEVELINFO_TOKEN_MUSIC_SET              21
+#define LEVELINFO_TOKEN_FILENAME               22
+#define LEVELINFO_TOKEN_FILETYPE               23
+#define LEVELINFO_TOKEN_SPECIAL_FLAGS          24
+#define LEVELINFO_TOKEN_HANDICAP               25
+#define LEVELINFO_TOKEN_SKIP_LEVELS            26
+
+#define NUM_LEVELINFO_TOKENS                   27
 
 static LevelDirTree ldi;
 
@@ -2268,6 +2271,9 @@ static struct TokenInfo levelinfo_tokens[] =
   { TYPE_STRING,       &ldi.name_sorting,      "name_sorting"          },
   { TYPE_STRING,       &ldi.author,            "author"                },
   { TYPE_STRING,       &ldi.year,              "year"                  },
+  { TYPE_STRING,       &ldi.program_title,     "program_title"         },
+  { TYPE_STRING,       &ldi.program_copyright, "program_copyright"     },
+  { TYPE_STRING,       &ldi.program_company,   "program_company"       },
   { TYPE_STRING,       &ldi.imported_from,     "imported_from"         },
   { TYPE_STRING,       &ldi.imported_by,       "imported_by"           },
   { TYPE_STRING,       &ldi.tested_by,         "tested_by"             },
@@ -2297,6 +2303,9 @@ static struct TokenInfo artworkinfo_tokens[] =
   { TYPE_STRING,       &ldi.name,              "name"                  },
   { TYPE_STRING,       &ldi.name_sorting,      "name_sorting"          },
   { TYPE_STRING,       &ldi.author,            "author"                },
+  { TYPE_STRING,       &ldi.program_title,     "program_title"         },
+  { TYPE_STRING,       &ldi.program_copyright, "program_copyright"     },
+  { TYPE_STRING,       &ldi.program_company,   "program_company"       },
   { TYPE_INTEGER,      &ldi.sort_priority,     "sort_priority"         },
   { TYPE_STRING,       &ldi.basepath,          "basepath"              },
   { TYPE_STRING,       &ldi.fullpath,          "fullpath"              },
@@ -2333,6 +2342,10 @@ static void setTreeInfoToDefaults(TreeInfo *ti, int type)
   ti->author = getStringCopy(ANONYMOUS_NAME);
   ti->year = NULL;
 
+  ti->program_title = NULL;
+  ti->program_copyright = NULL;
+  ti->program_company = NULL;
+
   ti->sort_priority = LEVELCLASS_UNDEFINED;    /* default: least priority */
   ti->latest_engine = FALSE;                   /* default: get from level */
   ti->parent_link = FALSE;
@@ -2406,6 +2419,10 @@ static void setTreeInfoToDefaultsFromParent(TreeInfo *ti, TreeInfo *parent)
   ti->author = getStringCopy(parent->author);
   ti->year = getStringCopy(parent->year);
 
+  ti->program_title = getStringCopy(parent->program_title);
+  ti->program_copyright = getStringCopy(parent->program_copyright);
+  ti->program_company = getStringCopy(parent->program_company);
+
   ti->sort_priority = parent->sort_priority;
   ti->latest_engine = parent->latest_engine;
   ti->parent_link = FALSE;
@@ -2471,6 +2488,11 @@ static TreeInfo *getTreeInfoCopy(TreeInfo *ti)
   ti_copy->name_sorting                = getStringCopy(ti->name_sorting);
   ti_copy->author              = getStringCopy(ti->author);
   ti_copy->year                        = getStringCopy(ti->year);
+
+  ti_copy->program_title       = getStringCopy(ti->program_title);
+  ti_copy->program_copyright   = getStringCopy(ti->program_copyright);
+  ti_copy->program_company     = getStringCopy(ti->program_company);
+
   ti_copy->imported_from       = getStringCopy(ti->imported_from);
   ti_copy->imported_by         = getStringCopy(ti->imported_by);
   ti_copy->tested_by           = getStringCopy(ti->tested_by);
@@ -2528,6 +2550,10 @@ void freeTreeInfo(TreeInfo *ti)
   checked_free(ti->author);
   checked_free(ti->year);
 
+  checked_free(ti->program_title);
+  checked_free(ti->program_copyright);
+  checked_free(ti->program_company);
+
   checked_free(ti->class_desc);
 
   checked_free(ti->infotext);
@@ -3620,6 +3646,14 @@ char *getArtworkIdentifierForUserLevelSet(int type)
          classic_artwork_set);
 }
 
+TreeInfo *getArtworkTreeInfoForUserLevelSet(int type)
+{
+  char *artwork_set = getArtworkIdentifierForUserLevelSet(type);
+  TreeInfo *artwork_first_node = ARTWORK_FIRST_NODE(artwork, type);
+
+  return getTreeInfoFromIdentifier(artwork_first_node, artwork_set);
+}
+
 boolean checkIfCustomArtworkExistsForCurrentLevelSet()
 {
   char *graphics_set =
index fab964386587ce5dfc177f54799fdb571035e674..ff12637afcd4418e27a8c1ec6851a13b87e322f4 100644 (file)
@@ -314,6 +314,7 @@ void LoadArtworkInfo(void);
 void LoadLevelArtworkInfo(void);
 
 char *getArtworkIdentifierForUserLevelSet(int);
+TreeInfo *getArtworkTreeInfoForUserLevelSet(int);
 boolean checkIfCustomArtworkExistsForCurrentLevelSet();
 void AddUserLevelSetToLevelInfo(char *);
 boolean UpdateUserLevelSet(char *, char *, char *, int);
index 7f6f17caae790a13cd330a0f8790752a065679b8..d11f71b4bf56962f43c34efe73da8c9cd0230bf4 100644 (file)
@@ -1200,6 +1200,11 @@ struct TreeInfo
   char *name_sorting;  /* optional sorting name for correct name sorting */
   char *author;                /* level or artwork author name */
   char *year;          /* optional year of creation for levels or artwork */
+
+  char *program_title;    /* optional alternative text for program title */
+  char *program_copyright; /* optional alternative text for program copyright */
+  char *program_company;   /* optional alternative text for program company */
+
   char *imported_from; /* optional comment for imported levels or artwork */
   char *imported_by;   /* optional comment for imported levels or artwork */
   char *tested_by;     /* optional comment to name people who tested a set */
index 58a2ecba14946dcfb4b470592fb5177e42dfbd67..8c8119d6c7004edc373e086b348255877d5c6e03 100644 (file)
@@ -581,6 +581,9 @@ static char *main_text_level_year           = NULL;
 static char *main_text_level_imported_from     = NULL;
 static char *main_text_level_imported_by       = NULL;
 static char *main_text_level_tested_by         = NULL;
+static char *main_text_title_1                 = NULL;
+static char *main_text_title_2                 = NULL;
+static char *main_text_title_3                 = NULL;
 
 struct MainControlInfo
 {
@@ -730,19 +733,19 @@ static struct MainControlInfo main_controls[] =
   {
     MAIN_CONTROL_TITLE_1,
     NULL,                              -1,
-    &menu.main.text.title_1,           &setup.internal.program_title,
+    &menu.main.text.title_1,           &main_text_title_1,
     NULL,                              NULL,
   },
   {
     MAIN_CONTROL_TITLE_2,
     NULL,                              -1,
-    &menu.main.text.title_2,           &setup.internal.program_copyright,
+    &menu.main.text.title_2,           &main_text_title_2,
     NULL,                              NULL,
   },
   {
     MAIN_CONTROL_TITLE_3,
     NULL,                              -1,
-    &menu.main.text.title_3,           &setup.internal.program_company,
+    &menu.main.text.title_3,           &main_text_title_3,
     NULL,                              NULL,
   },
 
@@ -996,6 +999,8 @@ static boolean visibleTextPos(struct TextPosInfo *pos)
 
 static void InitializeMainControls()
 {
+  TreeInfo *graphics_current =
+    getArtworkTreeInfoForUserLevelSet(ARTWORK_TYPE_GRAPHICS);
   boolean local_team_mode = (!options.network && setup.team_mode);
   int i;
 
@@ -1014,6 +1019,22 @@ static void InitializeMainControls()
   main_text_level_imported_by  = leveldir_current->imported_by;
   main_text_level_tested_by    = leveldir_current->tested_by;
 
+  main_text_title_1 = (leveldir_current->program_title ?
+                      leveldir_current->program_title :
+                      graphics_current->program_title ?
+                      graphics_current->program_title :
+                      setup.internal.program_title);
+  main_text_title_2 = (leveldir_current->program_copyright ?
+                      leveldir_current->program_copyright :
+                      graphics_current->program_copyright ?
+                      graphics_current->program_copyright :
+                      setup.internal.program_copyright);
+  main_text_title_3 = (leveldir_current->program_company ?
+                      leveldir_current->program_company :
+                      graphics_current->program_company ?
+                      graphics_current->program_company :
+                      setup.internal.program_company);
+
   /* set main control screen positions to dynamically determined values */
   for (i = 0; main_controls[i].nr != -1; i++)
   {