From a3ef711d1d684a370518d5f5f274cadab7440cee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 30 Mar 2017 11:30:09 +0200 Subject: [PATCH] - added a special slider type for the scaling options that prints a descriptive text instead of the slider for the special settings. - fixed the adaptive scale calculation in GetUIScale which had the coordinates mixed up. --- src/gameconfigfile.cpp | 2 + src/v_draw.cpp | 8 +-- wadsrc/static/language.enu | 4 ++ wadsrc/static/menudef.txt | 12 ++-- .../static/zscript/menu/optionmenuitems.txt | 55 ++++++++++++++++++- 5 files changed, 70 insertions(+), 11 deletions(-) diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index ffeba90f2..b3fc0b712 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -376,6 +376,8 @@ void FGameConfigFile::DoGlobalSetup () if (var != NULL) var->ResetToDefault(); var = FindCVar("con_scaletext", NULL); if (var != NULL) var->ResetToDefault(); + var = FindCVar("uiscale", NULL); + if (var != NULL) var->ResetToDefault(); } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 78b0dd7f3..2a1248f90 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -63,7 +63,7 @@ #include "g_levellocals.h" #include "textures.h" -CUSTOM_CVAR(Int, uiscale, 2, CVAR_ARCHIVE | CVAR_NOINITCALL) +CUSTOM_CVAR(Int, uiscale, 0, CVAR_ARCHIVE | CVAR_NOINITCALL) { if (self < 0) { @@ -82,9 +82,9 @@ int GetUIScale(int altval) if (altval > 0) scaleval = altval; else if (uiscale == 0) { - // Default should try to scale to 640x480 - int vscale = screen->GetHeight() / 640; - int hscale = screen->GetWidth() / 480; + // Default should try to scale to 640x400 + int vscale = screen->GetHeight() / 400; + int hscale = screen->GetWidth() / 640; scaleval = clamp(vscale, 1, hscale); } else scaleval = uiscale; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index de32e0253..550a94634 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1853,6 +1853,7 @@ HUDMNU_HEXENFLASHES = "Hexen weapon flashes"; HUDMNU_POISONFLASHES = "Poison damage flashes"; HUDMNU_ICEFLASHES = "Ice death flashes"; HUDMNU_HAZARDFLASHES = "Poison Buildup flashes"; +HUDMNU_SCALEOPT = "Scaling Options"; // Scaling options SCALEMNU_TITLE = "Scaling Options"; @@ -1863,6 +1864,9 @@ SCALEMNU_STATBAR = "Status bar"; SCALEMNU_HUD = "Fullscreen HUD"; SCALEMNU_ALTHUD = "Alternative HUD"; SCALEMNU_HUDASPECT = "HUD preserves aspect ratio"; +SCALEMNU_USEUI = "Use default scale"; +SCALEMNU_USEFS = "Scale to fullscreen"; +SCALEMNU_ADAPT = "Adapt to screen size"; // AltHUD Options ALTHUDMNU_TITLE = "Alternative HUD"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 37b2a0175..3c9c88759 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -852,15 +852,15 @@ OptionMenu "HUDOptions" OptionMenu "ScalingOptions" { Title "$SCALEMNU_TITLE" - Slider "$HUDMNU_UISCALE", "uiscale", 0.0, 8.0, 1.0, 0 + ScaleSlider "$HUDMNU_UISCALE", "uiscale", 0.0, 8.0, 1.0, "$SCALEMNU_ADAPT" StaticText " " // These will need a new control type. StaticText "$SCALEMNU_OVERRIDE", 1 - Option "$SCALEMNU_MESSAGES", "con_scaletext", "OnOff" - Option "$SCALEMNU_CONSOLE", "con_scale", "OnOff" - Option "$SCALEMNU_STATBAR", "st_scale", "OnOff" - Option "$SCALEMNU_HUD", "hud_scale", "OnOff" - Option "$SCALEMNU_ALTHUD", "hud_althudscale", "OnOff" + ScaleSlider "$SCALEMNU_MESSAGES", "con_scaletext", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI" + ScaleSlider "$SCALEMNU_CONSOLE", "con_scale", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI" + ScaleSlider "$SCALEMNU_STATBAR", "st_scale", -1.0, 8.0, 1.0, "$SCALEMNU_USEUI", "$SCALEMNU_USEFS" + ScaleSlider "$SCALEMNU_HUD", "hud_scale", -1.0, 8.0, 1.0, "$SCALEMNU_USEUI", "$SCALEMNU_USEFS" + ScaleSlider "$SCALEMNU_ALTHUD", "hud_althudscale", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI" StaticText " " Option "$SCALEMNU_HUDASPECT", "hud_aspectscale", "OnOff" } diff --git a/wadsrc/static/zscript/menu/optionmenuitems.txt b/wadsrc/static/zscript/menu/optionmenuitems.txt index 01771a372..dd4385dbb 100644 --- a/wadsrc/static/zscript/menu/optionmenuitems.txt +++ b/wadsrc/static/zscript/menu/optionmenuitems.txt @@ -666,7 +666,7 @@ class OptionMenuSliderBase : OptionMenuItem // //============================================================================= - private void DrawSlider (int x, int y, double min, double max, double cur, int fracdigits, int indent) + protected void DrawSlider (int x, int y, double min, double max, double cur, int fracdigits, int indent) { String formater = String.format("%%.%df", fracdigits); // The format function cannot do the '%.*f' syntax. String textbuf; @@ -1211,3 +1211,56 @@ class OptionMenuItemNumberField : OptionMenuFieldBase float mStep; } +//============================================================================= +// +// A special slider that displays plain text for special settings related +// to scaling. +// +//============================================================================= + +class OptionMenuItemScaleSlider : OptionMenuItemSlider +{ + String TextZero; + String TextNegOne; + + OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "") + { + Super.Init(label, command, min, max, step, 0); + mCVar =CVar.FindCVar(command); + TextZero = zero; + TextNEgOne = negone; + return self; + } + + //============================================================================= + override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) + { + drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); + + int Selection = GetSliderValue(); + if (Selection == 0 || Selection == -1) + { + String text = Selection == 0? TextZero : Selection == -1? TextNegOne : ""; + screen.DrawText (SmallFont, OptionMenuSettings.mFontColorValue, indent + CursorSpace(), y, text, DTA_CleanNoMove_1, true); + } + else + { + mDrawX = indent + CursorSpace(); + DrawSlider (mDrawX, y, mMin, mMax, GetSliderValue(), mShowValue, indent); + } + return indent; + } + + override bool MouseEvent(int type, int x, int y) + { + int value = GetSliderValue(); + if (value > 0) return Super.MouseEvent(type, x, y); + if (type == Menu.MOUSE_Release) + { + return Menu.GetCurrentMenu().MenuEvent(Menu.MKEY_Enter, true); + } + return false; + } + +} +