- 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.
This commit is contained in:
Christoph Oelckers 2017-03-30 11:30:09 +02:00
parent f95c29ad28
commit a3ef711d1d
5 changed files with 70 additions and 11 deletions

View file

@ -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();
}

View file

@ -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;

View file

@ -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";

View file

@ -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"
}

View file

@ -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;
}
}