From: Holger Schemel Date: Tue, 14 Mar 2017 22:32:12 +0000 (+0100) Subject: added custom version string to default program configuration settings X-Git-Tag: 4.0.1.1~33 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=499ad3bb12d513266ddcebe41a84eee8237a7fb5;p=rocksndiamonds.git added custom version string to default program configuration settings --- diff --git a/src/config.c b/src/config.c index 608b066e..02083581 100644 --- a/src/config.c +++ b/src/config.c @@ -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; diff --git a/src/config.h b/src/config.h index ba401a52..12e19614 100644 --- a/src/config.h +++ b/src/config.h @@ -16,6 +16,7 @@ char *getSourceDateString(void); char *getProgramTitleString(void); +char *getProgramRealVersionString(void); char *getProgramVersionString(void); char *getProgramInitString(void); char *getWindowTitleString(void); diff --git a/src/files.c b/src/files.c index 3468df64..33b174de 100644 --- a/src/files.c +++ b/src/files.c @@ -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); diff --git a/src/libgame/system.c b/src/libgame/system.c index 4f27d60a..ed51e626 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -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; diff --git a/src/libgame/system.h b/src/libgame/system.h index 7de14d61..630dce85 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -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(); diff --git a/src/main.c b/src/main.c index 200b954c..1dd7a167 100644 --- a/src/main.c +++ b/src/main.c @@ -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); } diff --git a/src/screens.c b/src/screens.c index e8171d5e..d3bf2981 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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);