diff options
author | Simon Howard | 2013-09-20 23:50:44 +0000 |
---|---|---|
committer | Simon Howard | 2013-09-20 23:50:44 +0000 |
commit | 5af0b0450d5e7ae30ec6cef585f1f5c4ef4dddce (patch) | |
tree | ac7c18a973944e298611b8ba3a9321812fe6c7a3 | |
parent | f1d79f495d4ad394c87d7fc11132c120736658fa (diff) | |
download | chocolate-doom-5af0b0450d5e7ae30ec6cef585f1f5c4ef4dddce.tar.gz chocolate-doom-5af0b0450d5e7ae30ec6cef585f1f5c4ef4dddce.tar.bz2 chocolate-doom-5af0b0450d5e7ae30ec6cef585f1f5c4ef4dddce.zip |
Set setup tool title so that it it shows the name of the correct game
being configured, not just always "Chocolate Doom".
Subversion-branch: /branches/v2-branch
Subversion-revision: 2669
-rw-r--r-- | src/m_misc.c | 55 | ||||
-rw-r--r-- | src/m_misc.h | 1 | ||||
-rw-r--r-- | src/setup/mainmenu.c | 19 | ||||
-rw-r--r-- | src/setup/mode.c | 7 | ||||
-rw-r--r-- | src/setup/mode.h | 1 |
5 files changed, 82 insertions, 1 deletions
diff --git a/src/m_misc.c b/src/m_misc.c index 47aea8b9..f3e11c36 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -296,6 +296,61 @@ char *M_StrCaseStr(char *haystack, char *needle) return NULL; } +// +// String replace function. +// Returns a Z_Malloc()ed string. +// + +char *M_StringReplace(char *haystack, char *needle, char *replacement) +{ + char *result, *p, *dst; + size_t needle_len = strlen(needle); + int n; + + // Count number of occurrences of 'p': + + for (p = haystack, n = 0;; ++n) + { + p = strstr(p, needle); + + if (p == NULL) + { + break; + } + + p += needle_len; + } + + // Construct new string. + + result = Z_Malloc(strlen(haystack) + + (strlen(replacement) - needle_len) * n + + 1, + PU_STATIC, NULL); + + dst = result; + p = haystack; + + while (*p != '\0') + { + if (!strncmp(p, needle, needle_len)) + { + strcpy(dst, replacement); + dst += strlen(replacement); + p += needle_len; + } + else + { + *dst = *p; + ++dst; + ++p; + } + } + *dst = '\0'; + + return result; +} + #ifdef _WIN32 char *M_OEMToUTF8(const char *oem) diff --git a/src/m_misc.h b/src/m_misc.h index ac5b5164..e96e2383 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -43,6 +43,7 @@ boolean M_StrToInt(const char *str, int *result); void M_ExtractFileBase(char *path, char *dest); void M_ForceUppercase(char *text); char *M_StrCaseStr(char *haystack, char *needle); +char *M_StringReplace(char *haystack, char *needle, char *replacement); char *M_OEMToUTF8(const char *ansi); #endif diff --git a/src/setup/mainmenu.c b/src/setup/mainmenu.c index 74e77fd5..8e5ebdad 100644 --- a/src/setup/mainmenu.c +++ b/src/setup/mainmenu.c @@ -31,6 +31,8 @@ #include "m_argv.h" #include "m_config.h" #include "m_controls.h" +#include "m_misc.h" +#include "z_zone.h" #include "setup_icon.c" #include "mode.h" @@ -316,6 +318,20 @@ static void SetIcon(void) free(mask); } +static void SetWindowTitle(void) +{ + char *title; + + title = M_StringReplace(PACKAGE_NAME " Setup ver " PACKAGE_VERSION, + "Doom", + GetGameTitle()); + + + TXT_SetDesktopTitle(title); + + Z_Free(title); +} + // Initialize the textscreen library. static void InitTextscreen(void) @@ -328,8 +344,8 @@ static void InitTextscreen(void) exit(-1); } - TXT_SetDesktopTitle(PACKAGE_NAME " Setup ver " PACKAGE_VERSION); SetIcon(); + SetWindowTitle(); } // Restart the textscreen library. Used when the video_driver variable @@ -354,6 +370,7 @@ static void RunGUI(void) static void MissionSet(void) { + SetWindowTitle(); InitConfig(); MainMenu(); } diff --git a/src/setup/mode.c b/src/setup/mode.c index 88924ad8..f5387750 100644 --- a/src/setup/mode.c +++ b/src/setup/mode.c @@ -112,6 +112,7 @@ static int screenblocks = 9; static int detailLevel = 0; static char *savedir = NULL; static char *executable = NULL; +static char *game_title = "Doom"; static char *back_flat = "F_PAVE01"; static int comport = 0; static char *nickname = NULL; @@ -223,6 +224,7 @@ static void SetMission(mission_config_t *config) iwads = D_FindAllIWADs(config->mask); gamemission = config->mission; SetExecutable(config); + game_title = config->label; M_SetConfigFilenames(config->config_file, config->extra_config_file); } @@ -374,6 +376,11 @@ char *GetExecutableName(void) return executable; } +char *GetGameTitle(void) +{ + return game_title; +} + iwad_t **GetIwads(void) { return iwads; diff --git a/src/setup/mode.h b/src/setup/mode.h index 44046c38..2495775d 100644 --- a/src/setup/mode.h +++ b/src/setup/mode.h @@ -31,6 +31,7 @@ extern GameMission_t gamemission; void SetupMission(GameSelectCallback callback); void InitBindings(void); char *GetExecutableName(void); +char *GetGameTitle(void); iwad_t **GetIwads(void); #endif /* #ifndef SETUP_MODE_H */ |