diff --git a/source/blood/src/blood.h b/source/blood/src/blood.h index 287c47863..01e93b5bb 100644 --- a/source/blood/src/blood.h +++ b/source/blood/src/blood.h @@ -87,7 +87,6 @@ struct GameInterface : ::GameInterface void UpdateScreenSize() override; bool GenerateSavePic() override; void FreeGameData() override; - bool validate_hud(int) override; void set_hud_layout(int size) override; void set_hud_scale(int size) override; FString statFPS() override; diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 99addcf4a..bd3a30efd 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -55,22 +55,10 @@ int32_t mouseyaxismode = -1; -// This is mainly here to account for the different implementation between Blood and the other games -// and to allow unified handling and the same value range in the CVAR code. -// Unlike EDuke's version, NBlood's was actually fine, it just had a too small value range to be chosen as the unified version. -bool GameInterface::validate_hud(int layout) -{ - return layout > 3 && layout != 8; // 8 is the status bar overlay which NBlood did not implement. -} - void GameInterface::set_hud_layout(int layout) { - static const uint8_t screen_size_vals[] = { 7, 7, 7, 7, 6, 5, 4, 3, 3, 2, 1, 0 }; - - if (validate_hud(layout)) - { - viewResizeView(screen_size_vals[layout]); - } + layout = clamp(7 - layout, 0, 7); // need to reverse the order because menu sliders always have low values to the left. + viewResizeView(layout); } void GameInterface::set_hud_scale(int scale) diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 4ff3f9ce3..ba328bd7b 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -104,9 +104,9 @@ struct GameInterface virtual int app_main() = 0; virtual void UpdateScreenSize() {} virtual void FreeGameData() {} - virtual bool validate_hud(int) = 0; + virtual bool validate_hud(int) { return true; } virtual void set_hud_layout(int size) = 0; - virtual void set_hud_scale(int size) = 0; + virtual void set_hud_scale(int size) {} virtual FString statFPS() { return "FPS display not available"; } virtual GameStats getStats() { return {}; } virtual void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) {} diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index d34a982d2..0e6ca2afb 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -92,6 +92,8 @@ CVAR(Bool, disableautoload, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALC //CVAR(Bool, autoloadbrightmaps, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) // hopefully this is an option for later //CVAR(Bool, autoloadlights, false, CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_GLOBALCONFIG) +extern int hud_size_max; + //========================================================================== // @@ -611,9 +613,9 @@ int RunGame() if (g_gameType & GAMEFLAG_BLOOD) { - UCVarValue v; - v.Bool = false; - mus_redbook.SetGenericRepDefault(v, CVAR_Bool); // Blood should default to CD Audio off - all other games must default to on. + mus_redbook.SetGenericRepDefault(false, CVAR_Bool); // Blood should default to CD Audio off - all other games must default to on. + hud_size.SetGenericRepDefault(6, CVAR_Int); // HUD is different for everything. + hud_size_max = 7; } G_ReadConfig(currentGame); diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp index 927f5b171..68edf8efa 100644 --- a/source/common/gamecvars.cpp +++ b/source/common/gamecvars.cpp @@ -160,10 +160,13 @@ CUSTOM_CVARD(Int, snd_speech, 5, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enables/disabl // This was particularly messy. EDuke and Rednukem had no consistent setting for this but a complex combination of 4 CVARs and lots of mod flags controlling the HUD layout // NBlood had this differently with an inverted scale of 0-7 with 0 having no HUD. // For consistency all frontends now use the same scale, with 0 being the smallest and 11 being the largest, which get converted to the internal settings by the set_hud_layout callback. + +int hud_size_max = 11; // 11 is for Duke Nukem and its offspring games. + CUSTOM_CVARD(Int, hud_size, 9, CVAR_ARCHIVE | CVAR_NOINITCALL, "Defines the HUD size and style") { if (self < 0) self = 0; - else if (self > 11) self = 11; + else if (self > hud_size_max) self = hud_size_max; else { if (gi->validate_hud(self)) diff --git a/wadsrc/static/engine/menudef.txt b/wadsrc/static/engine/menudef.txt index e782c9b42..56ef7549c 100644 --- a/wadsrc/static/engine/menudef.txt +++ b/wadsrc/static/engine/menudef.txt @@ -1197,11 +1197,16 @@ OptionMenu "HUDOptions" //protected { Title "$OPTMNU_HUD" - Slider "$DSPLYMNU_SCREENSIZE", "hud_size", 0.0, 11.0, 1.0, -1 - ifgame(duke, nam, ww2gi, redneck, redneckrides, fury) // Fixme: The scaling really needs to be taken out of the game code. + ifgame(duke, nam, ww2gi, redneck, redneckrides, fury) { + Slider "$DSPLYMNU_SCREENSIZE", "hud_size", 0.0, 11.0, 1.0, -1 Slider "$DSPLYMNU_SBSCALE", "hud_scale", 0.3, 1.0, 0.1, 2 } + ifgame(blood) + { + Slider "$DSPLYMNU_SCREENSIZE", "hud_size", 0.0, 7.0, 1.0, -1 + } + Option "$DSPLYMNU_LEVELSTATS", "hud_stats", "OnOff" ifgame(duke, nam, ww2gi, redneck, redneckrides, fury) {