added custom version string to default program configuration settings
authorHolger Schemel <info@artsoft.org>
Tue, 14 Mar 2017 22:32:12 +0000 (23:32 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 11 Oct 2017 07:19:26 +0000 (09:19 +0200)
src/config.c
src/config.h
src/files.c
src/libgame/system.c
src/libgame/system.h
src/main.c
src/screens.c

index 608b066ed64f89aa3ed42b81a0e9a24a8965de0f..02083581813486a7a636c2fc1b397532434b7b91 100644 (file)
@@ -25,7 +25,7 @@ char *getProgramTitleString()
   return program.program_title;
 }
 
-char *getProgramVersionString()
+char *getProgramRealVersionString()
 {
   static char program_version_string[32];
 
@@ -36,6 +36,11 @@ char *getProgramVersionString()
   return program_version_string;
 }
 
+char *getProgramVersionString()
+{
+  return program.version_string;
+}
+
 char *getProgramInitString()
 {
   static char *program_init_string = NULL;
index ba401a52a93b3e9ce6806d58aed366525d1d1a4f..12e19614ed3d3c9659d933243865389e0d53338d 100644 (file)
@@ -16,6 +16,7 @@
 
 char *getSourceDateString(void);
 char *getProgramTitleString(void);
+char *getProgramRealVersionString(void);
 char *getProgramVersionString(void);
 char *getProgramInitString(void);
 char *getWindowTitleString(void);
index 3468df641ff8bcc26072cf1d47f51194a3ff84d6..33b174de4e367911d92531c65ecf778d6366eb30 100644 (file)
@@ -20,6 +20,7 @@
 #include "init.h"
 #include "tools.h"
 #include "tape.h"
+#include "config.h"
 
 #define ENABLE_UNUSED_CODE     0       /* currently unused functions */
 #define ENABLE_HISTORIC_CHUNKS 0       /* only for historic reference */
@@ -8061,24 +8062,25 @@ void SaveScore(int nr)
 
 /* internal setup */
 #define SETUP_TOKEN_INT_PROGRAM_TITLE          0
-#define SETUP_TOKEN_INT_PROGRAM_AUTHOR         1
-#define SETUP_TOKEN_INT_PROGRAM_EMAIL          2
-#define SETUP_TOKEN_INT_PROGRAM_WEBSITE                3
-#define SETUP_TOKEN_INT_PROGRAM_COPYRIGHT      4
-#define SETUP_TOKEN_INT_PROGRAM_COMPANY                5
-#define SETUP_TOKEN_INT_PROGRAM_ICON_FILE      6
-#define SETUP_TOKEN_INT_DEFAULT_GRAPHICS_SET   7
-#define SETUP_TOKEN_INT_DEFAULT_SOUNDS_SET     8
-#define SETUP_TOKEN_INT_DEFAULT_MUSIC_SET      9
-#define SETUP_TOKEN_INT_FALLBACK_GRAPHICS_FILE 10
-#define SETUP_TOKEN_INT_FALLBACK_SOUNDS_FILE   11
-#define SETUP_TOKEN_INT_FALLBACK_MUSIC_FILE    12
-#define SETUP_TOKEN_INT_DEFAULT_LEVEL_SERIES   13
-#define SETUP_TOKEN_INT_CHOOSE_FROM_TOP_LEVELDIR 14
-#define SETUP_TOKEN_INT_DEFAULT_WINDOW_WIDTH   15
-#define SETUP_TOKEN_INT_DEFAULT_WINDOW_HEIGHT  16
-
-#define NUM_INTERNAL_SETUP_TOKENS              17
+#define SETUP_TOKEN_INT_PROGRAM_VERSION                1
+#define SETUP_TOKEN_INT_PROGRAM_AUTHOR         2
+#define SETUP_TOKEN_INT_PROGRAM_EMAIL          3
+#define SETUP_TOKEN_INT_PROGRAM_WEBSITE                4
+#define SETUP_TOKEN_INT_PROGRAM_COPYRIGHT      5
+#define SETUP_TOKEN_INT_PROGRAM_COMPANY                6
+#define SETUP_TOKEN_INT_PROGRAM_ICON_FILE      7
+#define SETUP_TOKEN_INT_DEFAULT_GRAPHICS_SET   8
+#define SETUP_TOKEN_INT_DEFAULT_SOUNDS_SET     9
+#define SETUP_TOKEN_INT_DEFAULT_MUSIC_SET      10
+#define SETUP_TOKEN_INT_FALLBACK_GRAPHICS_FILE 11
+#define SETUP_TOKEN_INT_FALLBACK_SOUNDS_FILE   12
+#define SETUP_TOKEN_INT_FALLBACK_MUSIC_FILE    13
+#define SETUP_TOKEN_INT_DEFAULT_LEVEL_SERIES   14
+#define SETUP_TOKEN_INT_CHOOSE_FROM_TOP_LEVELDIR 15
+#define SETUP_TOKEN_INT_DEFAULT_WINDOW_WIDTH   16
+#define SETUP_TOKEN_INT_DEFAULT_WINDOW_HEIGHT  17
+
+#define NUM_INTERNAL_SETUP_TOKENS              18
 
 /* debug setup */
 #define SETUP_TOKEN_DEBUG_FRAME_DELAY_0                0
@@ -8255,6 +8257,7 @@ static struct TokenInfo system_setup_tokens[] =
 static struct TokenInfo internal_setup_tokens[] =
 {
   { TYPE_STRING, &sxi.program_title,           "program_title"         },
+  { TYPE_STRING, &sxi.program_version,         "program_version"       },
   { TYPE_STRING, &sxi.program_author,          "program_author"        },
   { TYPE_STRING, &sxi.program_email,           "program_email"         },
   { TYPE_STRING, &sxi.program_website,         "program_website"       },
@@ -8448,6 +8451,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si)
   si->system.audio_fragment_size = DEFAULT_AUDIO_FRAGMENT_SIZE;
 
   si->internal.program_title     = getStringCopy(PROGRAM_TITLE_STRING);
+  si->internal.program_version   = getStringCopy(getProgramRealVersionString());
   si->internal.program_author    = getStringCopy(PROGRAM_AUTHOR_STRING);
   si->internal.program_email     = getStringCopy(PROGRAM_EMAIL_STRING);
   si->internal.program_website   = getStringCopy(PROGRAM_WEBSITE_STRING);
index 4f27d60a614cd0fb0649814fe7538391d6168d3f..ed51e626a8f473747e4b9644c532f95e76b9b490 100644 (file)
@@ -68,7 +68,7 @@ int                   FrameCounter = 0;
 void InitProgramInfo(char *argv0, char *config_filename, char *userdata_subdir,
                     char *program_title, char *icon_title,
                     char *icon_filename, char *cookie_prefix,
-                    int program_version)
+                    char *program_version_string, int program_version)
 {
   program.command_basepath = getBasePath(argv0);
   program.command_basename = getBaseName(argv0);
@@ -92,6 +92,8 @@ void InitProgramInfo(char *argv0, char *config_filename, char *userdata_subdir,
   program.version_build = VERSION_BUILD(program_version);
   program.version_ident = program_version;
 
+  program.version_string = program_version_string;
+
   program.log_filename[LOG_OUT_ID] = getLogFilename(LOG_OUT_BASENAME);
   program.log_filename[LOG_ERR_ID] = getLogFilename(LOG_ERR_BASENAME);
   program.log_file[LOG_OUT_ID] = program.log_file_default[LOG_OUT_ID] = stdout;
index 7de14d613cd23ede44694e0cbe7b7e47a384d67b..630dce8573face1ad389ca539d2aa4d72fedb1f6 100644 (file)
@@ -779,6 +779,8 @@ struct ProgramInfo
   int version_build;
   int version_ident;
 
+  char *version_string;
+
   char *(*window_title_function)(void);
   void (*exit_message_function)(char *, va_list);
   void (*exit_function)(int);
@@ -1065,6 +1067,7 @@ struct SetupSystemInfo
 struct SetupInternalInfo
 {
   char *program_title;
+  char *program_version;
   char *program_author;
   char *program_email;
   char *program_website;
@@ -1448,7 +1451,7 @@ extern int                        FrameCounter;
 /* function definitions */
 
 void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
-                    int);
+                    char *, int);
 
 void InitScoresInfo();
 void SetWindowTitle();
index 200b954c67c733e704169bf4ec70d77402d5b87b..1dd7a167c16985f3605f9af9d1c4e2cb87679b4c 100644 (file)
@@ -5738,13 +5738,20 @@ static void print_usage()
 
 static void print_version()
 {
-  Print("%s %d.%d.%d.%d%s\n",
-       PROGRAM_TITLE_STRING,
-       PROGRAM_VERSION_MAJOR,
-       PROGRAM_VERSION_MINOR,
-       PROGRAM_VERSION_PATCH,
-       PROGRAM_VERSION_BUILD,
-       PROGRAM_VERSION_EXTRA);
+  Print("%s", getProgramInitString());
+
+  if (!strEqual(getProgramVersionString(), getProgramRealVersionString()))
+  {
+    Print(" (%s %d.%d.%d.%d%s)",
+         PROGRAM_TITLE_STRING,
+         PROGRAM_VERSION_MAJOR,
+         PROGRAM_VERSION_MINOR,
+         PROGRAM_VERSION_PATCH,
+         PROGRAM_VERSION_BUILD,
+         PROGRAM_VERSION_EXTRA);
+  }
+
+  Print("\n");
 
   if (options.debug)
   {
@@ -5780,6 +5787,7 @@ static void InitProgramConfig(char *command_filename)
 {
   char *program_title = PROGRAM_TITLE_STRING;
   char *program_icon_file = PROGRAM_ICON_FILENAME;
+  char *program_version = getProgramRealVersionString();
   char *config_filename = getProgramConfigFilename(command_filename);
   char *userdata_basename = getBaseNameNoSuffix(command_filename);
   char *userdata_subdir;
@@ -5805,6 +5813,11 @@ static void InitProgramConfig(char *command_filename)
       strlen(setup.internal.program_title) > 0)
     program_title = getStringCopy(setup.internal.program_title);
 
+  // set program version from potentially redefined program version
+  if (setup.internal.program_version != NULL &&
+      strlen(setup.internal.program_version) > 0)
+    program_version = getStringCopy(setup.internal.program_version);
+
   // set program icon file from potentially redefined program icon file
   if (setup.internal.program_icon_file != NULL &&
       strlen(setup.internal.program_icon_file) > 0)
@@ -5833,6 +5846,7 @@ static void InitProgramConfig(char *command_filename)
                  program_title,
                  program_icon_file,
                  COOKIE_PREFIX,
+                 program_version,
                  GAME_VERSION_ACTUAL);
 }
 
index e8171d5e1360c4772678403d7ce9bd641f1c5acb..d3bf2981968faff2cdada0f4d8895adeed22a252 100644 (file)
@@ -3312,6 +3312,13 @@ void DrawInfoScreen_Version()
   DrawTextF(xstart1, ystart2, font_header, "Version");
   DrawTextF(xstart2, ystart2, font_text, getProgramVersionString());
 
+  if (!strEqual(getProgramVersionString(), getProgramRealVersionString()))
+  {
+    ystart2 += ystep;
+    DrawTextF(xstart1, ystart2, font_header, "Version (real)");
+    DrawTextF(xstart2, ystart2, font_text, getProgramRealVersionString());
+  }
+
   ystart2 += ystep;
   DrawTextF(xstart1, ystart2, font_header, "Platform");
   DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);