From 2a0c4b9f32b7dda19d9d63fe979767a5c8f56e9b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 24 Oct 2010 07:31:39 +0000 Subject: [PATCH] - added a CVAR to decide when to show the map label (ExMy, MAPxx) on the automap HUD. Available settings are Never, Always and Only for hubs. - made all crosshair related CVARs game specific. They were all global to all supportesd games. SVN r2964 (trunk) --- src/g_shared/sbar.h | 1 + src/g_shared/shared_hud.cpp | 7 +++-- src/g_shared/shared_sbar.cpp | 51 +++++++++++++++++++++++++----------- wadsrc/static/menudef.txt | 8 ++++++ 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index 295e0e4e1..b2f6173bf 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -381,6 +381,7 @@ DBaseStatusBar *CreateCustomStatusBar(int script=0); // Crosshair stuff ---------------------------------------------------------- +void ST_FormatMapName(FString &mapname, const char *mapnamecolor = ""); void ST_LoadCrosshair(bool alwaysload=false); extern FTexture *CrosshairImage; diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index f82e866f6..d766d8902 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -833,10 +833,9 @@ void DrawHUD() } else { + FString mapname; char printstr[256]; int seconds; - cluster_info_t *thiscluster = FindClusterInfo (level.cluster); - bool hub = !!(thiscluster->flags&CLUSTER_HUB); int length=8*SmallFont->GetCharWidth('0'); int fonth=SmallFont->GetHeight()+1; int bottom=hudheight-1; @@ -865,8 +864,8 @@ void DrawHUD() } } - mysnprintf(printstr, countof(printstr), "%s: %s", level.mapname, level.LevelName.GetChars()); - screen->DrawText(SmallFont, hudcolor_titl, 1, hudheight-fonth-1, printstr, + ST_FormatMapName(mapname); + screen->DrawText(SmallFont, hudcolor_titl, 1, hudheight-fonth-1, mapname, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE); diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index beb459cda..75084ae38 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -95,12 +95,16 @@ CUSTOM_CVAR (Bool, st_scale, true, CVAR_ARCHIVE) } } -CVAR (Int, crosshair, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR (Bool, crosshairforce, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR (Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CVAR (Bool, crosshairhealth, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CVAR (Bool, crosshairscale, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -CVAR (Bool, crosshairgrow, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR (Int, crosshair, 0, CVAR_ARCHIVE) +CVAR (Bool, crosshairforce, false, CVAR_ARCHIVE) +CVAR (Color, crosshaircolor, 0xff0000, CVAR_ARCHIVE); +CVAR (Bool, crosshairhealth, true, CVAR_ARCHIVE); +CVAR (Bool, crosshairscale, false, CVAR_ARCHIVE); +CVAR (Bool, crosshairgrow, false, CVAR_ARCHIVE); +CUSTOM_CVAR(Int, am_showmaplabel, 2, CVAR_ARCHIVE) +{ + if (self < 0 || self > 2) self = 2; +} CVAR (Bool, idmypos, false, 0); @@ -118,6 +122,30 @@ BYTE DBaseStatusBar::DamageToAlpha[114] = 230, 231, 232, 233, 234, 235, 235, 236, 237 }; +//--------------------------------------------------------------------------- +// +// Format the map name, include the map label if wanted +// +//--------------------------------------------------------------------------- + +void ST_FormatMapName(FString &mapname, const char *mapnamecolor) +{ + cluster_info_t *cluster = FindClusterInfo (level.cluster); + bool ishub = (cluster != NULL && (cluster->flags & CLUSTER_HUB)); + + if (am_showmaplabel == 1 || (am_showmaplabel == 2 && !ishub)) + { + mapname << level.mapname << ": "; + } + mapname << mapnamecolor << level.LevelName; +} + +//--------------------------------------------------------------------------- +// +// Load crosshair definitions +// +//--------------------------------------------------------------------------- + void ST_LoadCrosshair(bool alwaysload) { int num = 0; @@ -1270,18 +1298,9 @@ void DBaseStatusBar::Draw (EHudState state) y -= 8; } } - cluster_info_t *cluster = FindClusterInfo (level.cluster); - if (cluster == NULL || !(cluster->flags & CLUSTER_HUB)) - { - mysnprintf (line, countof(line), "%s: ", level.mapname); - } - else - { - *line = 0; - } FString mapname; - mapname.Format("%s%c%c%s", line, TEXTCOLOR_ESCAPE, CR_GREY + 'A', level.LevelName.GetChars()); + ST_FormatMapName(mapname, TEXTCOLOR_GREY); screen->DrawText (SmallFont, highlight, (SCREENWIDTH - SmallFont->StringWidth (mapname)*CleanXfac)/2, y, mapname, DTA_CleanNoMove, true, TAG_DONE); diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index db8d4bd45..1f5cf9207 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -841,6 +841,13 @@ OptionValue OverlayTypes 2, "Overlay Only" } +OptionValue MaplabelTypes +{ + 0, "Never" + 1, "Always" + 2, "Not for hubs" +} + OptionMenu AutomapOptions { Title "AUTOMAP OPTIONS" @@ -858,6 +865,7 @@ OptionMenu AutomapOptions Option "Show time elapsed", "am_showtime", "OnOff" Option "Show total time elapsed", "am_showtotaltime", "OnOff" Option "Show secrets on map", "am_map_secrets", "SecretTypes" + Option "Show map label", "am_showmaplabel", "MaplabelTypes" Option "Draw map background", "am_drawmapback", "OnOff" Option "Show keys (cheat)", "am_showkeys", "OnOff" }