diff --git a/src/mn_internal.h b/src/mn_internal.h index 4be467a4..fe618d98 100644 --- a/src/mn_internal.h +++ b/src/mn_internal.h @@ -80,7 +80,6 @@ void MN_BackSecondary(void); // [FG] alternative text for missing menu graphics lumps void MN_DrawTitle(int x, int y, const char *patch, const char *alttext); void MN_DrawStringCR(int cx, int cy, byte *cr1, byte *cr2, const char *ch); -int MN_StringWidth(const char *string); int MN_StringHeight(const char *string); void MN_General(int choice); diff --git a/src/mn_menu.h b/src/mn_menu.h index a702ba67..1310f447 100644 --- a/src/mn_menu.h +++ b/src/mn_menu.h @@ -100,6 +100,7 @@ void MN_InitMenuStrings(void); boolean MN_StartsWithMapIdentifier(char *str); +int MN_StringWidth(const char *string); int MN_GetPixelWidth(const char *ch); void MN_DrawString(int cx, int cy, int color, const char *ch); diff --git a/src/st_widgets.c b/src/st_widgets.c index fd91ebdf..d5619cbb 100644 --- a/src/st_widgets.c +++ b/src/st_widgets.c @@ -34,6 +34,7 @@ #include "m_config.h" #include "m_input.h" #include "m_misc.h" +#include "mn_menu.h" #include "p_mobj.h" #include "p_spec.h" #include "r_main.h" @@ -132,7 +133,7 @@ static void UpdateMessage(sbe_widget_t *widget, player_t *player) } } -static char announce_string[HU_MAXLINELENGTH]; +static char announce_string[HU_MAXLINELENGTH], author_string[HU_MAXLINELENGTH]; static void UpdateAnnounceMessage(sbe_widget_t *widget, player_t *player) { @@ -162,6 +163,7 @@ static void UpdateAnnounceMessage(sbe_widget_t *widget, player_t *player) } else if (player->secretmessage) { + author_string[0] = '\0'; state = announce_secret; widget->duration_left = widget->duration; M_snprintf(string, sizeof(string), GOLD_S "%s" ORIG_S, @@ -172,6 +174,10 @@ static void UpdateAnnounceMessage(sbe_widget_t *widget, player_t *player) if (widget->duration_left > 0) { ST_AddLine(widget, string); + if (author_string[0]) + { + ST_AddLine(widget, author_string); + } --widget->duration_left; } else @@ -645,16 +651,23 @@ void ST_ResetTitle(void) '0' + hudcolor_titl, string); announce_string[0] = '\0'; + author_string[0] = '\0'; if (hud_map_announce && leveltime == 0) { if (gamemapinfo && gamemapinfo->author) { M_snprintf(announce_string, sizeof(announce_string), "%s by %s", string, gamemapinfo->author); + if (MN_StringWidth(announce_string) > SCREENWIDTH) + { + M_StringCopy(announce_string, string, sizeof(announce_string)); + M_snprintf(author_string, sizeof(author_string), "by %s", + gamemapinfo->author); + } } else { - M_snprintf(announce_string, sizeof(announce_string), "%s", string); + M_StringCopy(announce_string, string, sizeof(announce_string)); } } }