From b202cf7a127b0cadc15e7bf68a3fdf4a98e48896 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Oct 2022 16:37:12 +0200 Subject: [PATCH] - added option to show the level stats on the automap. --- source/core/gamecvars.cpp | 5 +- source/core/gamecvars.h | 1 - wadsrc/static/menudef.txt | 11 ++++- wadsrc/static/zscript/games/blood/ui/sbar.zs | 12 +++-- wadsrc/static/zscript/games/duke/ui/sbar.zs | 18 ++++--- .../static/zscript/games/exhumed/ui/sbar.zs | 11 +++-- wadsrc/static/zscript/games/sw/ui/sbar.zs | 14 +++--- wadsrc/static/zscript/statusbar.zs | 48 +++++++++++++------ 8 files changed, 79 insertions(+), 41 deletions(-) diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index f6946f366..6d75af339 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -179,7 +179,10 @@ CUSTOM_CVARD(Float, hud_statscale, 0.5, CVAR_ARCHIVE, "change the scale of the s } -CVARD(Bool, hud_stats, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable level statistics display") +CUSTOM_CVARD(Int, hud_stats, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable level statistics display") +{ + if (self < 0 || self > 3) self = 0; +} CVARD(Bool, hud_showmapname, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable map name display on load") CVARD(Bool, hud_position, false, CVAR_ARCHIVE, "aligns the status bar to the bottom/top") CVARD(Bool, hud_bgstretch, false, CVAR_ARCHIVE, "enable/disable background image stretching in wide resolutions") diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index 82136c02d..e2b705bd2 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -59,7 +59,6 @@ EXTERN_CVAR(Int, hud_size) EXTERN_CVAR(Float, hud_statscale) EXTERN_CVAR(Int, hud_custom) -EXTERN_CVAR(Bool, hud_stats) EXTERN_CVAR(Bool, hud_showmapname) EXTERN_CVAR(Bool, hud_position) EXTERN_CVAR(Bool, hud_bgstretch) diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 3075c8d3f..778b152ef 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1227,6 +1227,7 @@ OptionMenu "AutomapOptions" Option "$AUTOMAPMNU_FOLLOW", "am_followplayer", "OnOff" Slider "$AUTOMAPMNU_LINEALPHA", "am_linealpha", 0.1, 1.0, 0.1, 1 Slider "$AUTOMAPMNU_LINETHICKNESS", "am_linethickness", 1, 8, 1, 0 + StaticText "" // todo: //CVAR(Bool, am_textfont, false, CVAR_ARCHIVE) @@ -1293,6 +1294,14 @@ OptionValue CrosshairHealthTypes 2.0, "$OPTVAL_YES_ENHANCED" } +OptionValue HudStats +{ + 0.0, "$OPTVAL_OFF" + 1.0, "$OPTVAL_HUD" + 2.0, "$OPTVAL_AUTOMAP" + 3.0, "$OPTVAL_HUDANDMAP" +} + OptionMenu "HUDOptions" protected { Title "$OPTMNU_HUD" @@ -1300,7 +1309,7 @@ OptionMenu "HUDOptions" protected Slider "$DSPLYMNU_SCREENSIZE", "hud_size", 0.0, 9.0, 1.0, -1 Slider "$DSPLYMNU_SBSCALE", "hud_scalefactor", 0.36, 1.0, 0.04, 2 StaticText "" - Option "$DSPLYMNU_LEVELSTATS", "hud_stats", "OnOff" + Option "$DSPLYMNU_LEVELSTATS", "hud_stats", "HudStats" Slider "$DSPLYMNU_STATSCALE", "hud_statscale", 0.36, 1.0, 0.04, 2 StaticText "" diff --git a/wadsrc/static/zscript/games/blood/ui/sbar.zs b/wadsrc/static/zscript/games/blood/ui/sbar.zs index 15abea253..13244a890 100644 --- a/wadsrc/static/zscript/games/blood/ui/sbar.zs +++ b/wadsrc/static/zscript/games/blood/ui/sbar.zs @@ -139,24 +139,28 @@ class BloodStatusBar : RazeStatusBar stats.fontscale = 1.; stats.screenbottomspace = bottomy; - stats.statfont = SmallFont; stats.letterColor = TEXTCOLOR_DARKRED; stats.standardColor = TEXTCOLOR_DARKGRAY; + int y = -1; + int mask = 1; if (automapMode == am_full) { stats.statfont = SmallFont2; stats.spacing = 6; stats.altspacing = SmallFont.GetHeight() + 2; if (hud_size <= Hud_StbarOverlay) stats.screenbottomspace = 56; - PrintAutomapInfo(stats, false); + y = PrintAutomapInfo(stats, summary, false); + mask = 2; } - if (automapMode == am_off && hud_stats) + // Blood does not use am_overlay. + if (hud_stats & mask) { + stats.statfont = SmallFont; stats.completeColor = TEXTCOLOR_DARKGREEN; stats.spacing = SmallFont.GetHeight() + 2; - PrintLevelStats(stats, summary); + PrintLevelStats(stats, summary, y); } } diff --git a/wadsrc/static/zscript/games/duke/ui/sbar.zs b/wadsrc/static/zscript/games/duke/ui/sbar.zs index aafcdbc20..3825c7838 100644 --- a/wadsrc/static/zscript/games/duke/ui/sbar.zs +++ b/wadsrc/static/zscript/games/duke/ui/sbar.zs @@ -164,14 +164,9 @@ class DukeCommonStatusBar : RazeStatusBar StatsPrintInfo stats; stats.fontscale = Raze.isRR() ? 0.5 : 1.; stats.screenbottomspace = bottomy; - stats.statfont = SmallFont; - if (Raze.isNamWW2GI()) - { - // The stock font of these games is totally unusable for this. - stats.statfont = ConFont; - stats.spacing = ConFont.GetHeight() + 1; - } + int y = -1; + int mask = 1; if (automapMode == am_full) { stats.statfont = SmallFont2; @@ -182,13 +177,16 @@ class DukeCommonStatusBar : RazeStatusBar stats.standardColor = Font.TEXTCOLOR_UNTRANSLATED; stats.letterColor = Font.TEXTCOLOR_GOLD; - PrintAutomapInfo(stats, false); + y = PrintAutomapInfo(stats, info, false); + mask = 2; } - else if (hud_stats) + if (hud_stats & mask) { + stats.statfont = SmallFont; stats.letterColor = Font.TEXTCOLOR_ORANGE; if (Raze.isNamWW2GI()) { + stats.statfont = ConFont; stats.spacing = 8; stats.standardColor = Font.TEXTCOLOR_YELLOW; stats.completeColor = Font.TEXTCOLOR_FIRE; @@ -205,7 +203,7 @@ class DukeCommonStatusBar : RazeStatusBar stats.standardColor = stats.completeColor = Font.TEXTCOLOR_UNTRANSLATED; } - PrintLevelStats(stats, info); + PrintLevelStats(stats, info, y); } } diff --git a/wadsrc/static/zscript/games/exhumed/ui/sbar.zs b/wadsrc/static/zscript/games/exhumed/ui/sbar.zs index 133f38574..c0cc54e29 100644 --- a/wadsrc/static/zscript/games/exhumed/ui/sbar.zs +++ b/wadsrc/static/zscript/games/exhumed/ui/sbar.zs @@ -455,19 +455,22 @@ class ExhumedStatusBar : RazeStatusBar stats.fontscale = 1.; stats.altspacing = stats.spacing = SmallFont.GetHeight(); stats.screenbottomspace = bottomy; - stats.statfont = SmallFont; stats.letterColor = TEXTCOLOR_RED; stats.standardColor = TEXTCOLOR_UNTRANSLATED; + int y = -1; + int mask = 1; if (automapMode == am_full) { stats.statfont = Raze.PickSmallFont(); - PrintAutomapInfo(stats, true); + y = PrintAutomapInfo(stats, summary, true); + mask = 2; } - else if (automapMode == am_off && hud_stats) + if (hud_stats & mask) { + stats.statfont = SmallFont; stats.completeColor = TEXTCOLOR_DARKGREEN; - PrintLevelStats(stats, summary); + PrintLevelStats(stats, summary, y); } } diff --git a/wadsrc/static/zscript/games/sw/ui/sbar.zs b/wadsrc/static/zscript/games/sw/ui/sbar.zs index 88a1dd766..f3feb4f6b 100644 --- a/wadsrc/static/zscript/games/sw/ui/sbar.zs +++ b/wadsrc/static/zscript/games/sw/ui/sbar.zs @@ -892,10 +892,10 @@ class SWStatusBar : RazeStatusBar { StatsPrintInfo stats; stats.fontscale = 1; - stats.spacing = 7; stats.screenbottomspace = bottomy; - stats.statfont = SmallFont; + int y = -1; + int mask = 1; if (automapMode == am_full) { stats.letterColor = Font.TEXTCOLOR_SAPPHIRE; @@ -904,15 +904,17 @@ class SWStatusBar : RazeStatusBar stats.statfont = SmallFont2; stats.spacing = 6; stats.altspacing = SmallFont.GetHeight() + 1; - PrintAutomapInfo(stats, false); + y = PrintAutomapInfo(stats, info, false); + mask = 2; } - // JBF 20040124: display level stats in screen corner - else if (hud_stats && !(netgame /*|| numplayers > 1*/)) + if (hud_stats & mask) { + stats.statfont = SmallFont; + stats.spacing = 7; stats.letterColor = Font.TEXTCOLOR_RED; stats.standardColor = Font.TEXTCOLOR_TAN; stats.completeColor = Font.TEXTCOLOR_FIRE; - PrintLevelStats(stats, info); + PrintLevelStats(stats, info, y); } } diff --git a/wadsrc/static/zscript/statusbar.zs b/wadsrc/static/zscript/statusbar.zs index 7977b7a55..4085f00e2 100644 --- a/wadsrc/static/zscript/statusbar.zs +++ b/wadsrc/static/zscript/statusbar.zs @@ -43,24 +43,26 @@ class RazeStatusBar : StatusBarCore // //============================================================================ - void PrintLevelStats(StatsPrintInfo info, SummaryInfo stats) + void PrintLevelStats(StatsPrintInfo info, SummaryInfo stats, double y = -1) { - - double y; double scale = info.fontscale * hud_statscale; if (info.spacing <= 0) info.spacing = info.statfont.GetHeight() * info.fontscale; double spacing = info.spacing * hud_statscale; - if (hud_size == Hud_Nothing) + + if (y < 0) { - y = 198 - spacing; - } - else if (info.screenbottomspace < 0) - { - y = 200 - (RelTop - info.screenbottomspace) * hud_scalefactor - spacing; - } - else - { - y = 200 - info.screenbottomspace * hud_scalefactor - spacing; + if (hud_size == Hud_Nothing) + { + y = 198 - spacing; + } + else if (info.screenbottomspace < 0) + { + y = 200 - (RelTop - info.screenbottomspace) * hud_scalefactor - spacing; + } + else + { + y = 200 - info.screenbottomspace * hud_scalefactor - spacing; + } } double y1, y2, y3; @@ -109,7 +111,7 @@ class RazeStatusBar : StatusBarCore // //============================================================================ - void PrintAutomapInfo(StatsPrintInfo info, bool forcetextfont = false) + int PrintAutomapInfo(StatsPrintInfo info, SummaryInfo stats, bool forcetextfont = false) { let TEXTCOLOR_ESCAPESTR = "\034"; let lev = currentLevel; @@ -145,9 +147,19 @@ class RazeStatusBar : StatusBarCore double y; + double st_y = -1; if (am_nameontop) { y = spacing + 1; + if (info.screenbottomspace < 0) + { + st_y = (200 - RelTop) * hud_scalefactor - spacing; + } + else + { + st_y = 200 - info.screenbottomspace * hud_scalefactor - spacing; + } + } else if (info.screenbottomspace < 0) { @@ -163,8 +175,16 @@ class RazeStatusBar : StatusBarCore DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true); y -= spacing; if (volname.length() > 0) + { Screen.DrawText(myfont, Font.CR_UNTRANSLATED, 2 * hud_statscale, y, volname, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true); + y -= spacing; + } + if (!am_nameontop) + { + st_y = y; + } + return st_y; } //============================================================================