mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-30 16:00:55 +00:00
- 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:
parent
f95c29ad28
commit
a3ef711d1d
5 changed files with 70 additions and 11 deletions
|
@ -376,6 +376,8 @@ void FGameConfigFile::DoGlobalSetup ()
|
||||||
if (var != NULL) var->ResetToDefault();
|
if (var != NULL) var->ResetToDefault();
|
||||||
var = FindCVar("con_scaletext", NULL);
|
var = FindCVar("con_scaletext", NULL);
|
||||||
if (var != NULL) var->ResetToDefault();
|
if (var != NULL) var->ResetToDefault();
|
||||||
|
var = FindCVar("uiscale", NULL);
|
||||||
|
if (var != NULL) var->ResetToDefault();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
#include "textures.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)
|
if (self < 0)
|
||||||
{
|
{
|
||||||
|
@ -82,9 +82,9 @@ int GetUIScale(int altval)
|
||||||
if (altval > 0) scaleval = altval;
|
if (altval > 0) scaleval = altval;
|
||||||
else if (uiscale == 0)
|
else if (uiscale == 0)
|
||||||
{
|
{
|
||||||
// Default should try to scale to 640x480
|
// Default should try to scale to 640x400
|
||||||
int vscale = screen->GetHeight() / 640;
|
int vscale = screen->GetHeight() / 400;
|
||||||
int hscale = screen->GetWidth() / 480;
|
int hscale = screen->GetWidth() / 640;
|
||||||
scaleval = clamp(vscale, 1, hscale);
|
scaleval = clamp(vscale, 1, hscale);
|
||||||
}
|
}
|
||||||
else scaleval = uiscale;
|
else scaleval = uiscale;
|
||||||
|
|
|
@ -1853,6 +1853,7 @@ HUDMNU_HEXENFLASHES = "Hexen weapon flashes";
|
||||||
HUDMNU_POISONFLASHES = "Poison damage flashes";
|
HUDMNU_POISONFLASHES = "Poison damage flashes";
|
||||||
HUDMNU_ICEFLASHES = "Ice death flashes";
|
HUDMNU_ICEFLASHES = "Ice death flashes";
|
||||||
HUDMNU_HAZARDFLASHES = "Poison Buildup flashes";
|
HUDMNU_HAZARDFLASHES = "Poison Buildup flashes";
|
||||||
|
HUDMNU_SCALEOPT = "Scaling Options";
|
||||||
|
|
||||||
// Scaling options
|
// Scaling options
|
||||||
SCALEMNU_TITLE = "Scaling Options";
|
SCALEMNU_TITLE = "Scaling Options";
|
||||||
|
@ -1863,6 +1864,9 @@ SCALEMNU_STATBAR = "Status bar";
|
||||||
SCALEMNU_HUD = "Fullscreen HUD";
|
SCALEMNU_HUD = "Fullscreen HUD";
|
||||||
SCALEMNU_ALTHUD = "Alternative HUD";
|
SCALEMNU_ALTHUD = "Alternative HUD";
|
||||||
SCALEMNU_HUDASPECT = "HUD preserves aspect ratio";
|
SCALEMNU_HUDASPECT = "HUD preserves aspect ratio";
|
||||||
|
SCALEMNU_USEUI = "Use default scale";
|
||||||
|
SCALEMNU_USEFS = "Scale to fullscreen";
|
||||||
|
SCALEMNU_ADAPT = "Adapt to screen size";
|
||||||
|
|
||||||
// AltHUD Options
|
// AltHUD Options
|
||||||
ALTHUDMNU_TITLE = "Alternative HUD";
|
ALTHUDMNU_TITLE = "Alternative HUD";
|
||||||
|
|
|
@ -852,15 +852,15 @@ OptionMenu "HUDOptions"
|
||||||
OptionMenu "ScalingOptions"
|
OptionMenu "ScalingOptions"
|
||||||
{
|
{
|
||||||
Title "$SCALEMNU_TITLE"
|
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 " "
|
StaticText " "
|
||||||
// These will need a new control type.
|
// These will need a new control type.
|
||||||
StaticText "$SCALEMNU_OVERRIDE", 1
|
StaticText "$SCALEMNU_OVERRIDE", 1
|
||||||
Option "$SCALEMNU_MESSAGES", "con_scaletext", "OnOff"
|
ScaleSlider "$SCALEMNU_MESSAGES", "con_scaletext", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI"
|
||||||
Option "$SCALEMNU_CONSOLE", "con_scale", "OnOff"
|
ScaleSlider "$SCALEMNU_CONSOLE", "con_scale", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI"
|
||||||
Option "$SCALEMNU_STATBAR", "st_scale", "OnOff"
|
ScaleSlider "$SCALEMNU_STATBAR", "st_scale", -1.0, 8.0, 1.0, "$SCALEMNU_USEUI", "$SCALEMNU_USEFS"
|
||||||
Option "$SCALEMNU_HUD", "hud_scale", "OnOff"
|
ScaleSlider "$SCALEMNU_HUD", "hud_scale", -1.0, 8.0, 1.0, "$SCALEMNU_USEUI", "$SCALEMNU_USEFS"
|
||||||
Option "$SCALEMNU_ALTHUD", "hud_althudscale", "OnOff"
|
ScaleSlider "$SCALEMNU_ALTHUD", "hud_althudscale", 0.0, 8.0, 1.0, "$SCALEMNU_USEUI"
|
||||||
StaticText " "
|
StaticText " "
|
||||||
Option "$SCALEMNU_HUDASPECT", "hud_aspectscale", "OnOff"
|
Option "$SCALEMNU_HUDASPECT", "hud_aspectscale", "OnOff"
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 formater = String.format("%%.%df", fracdigits); // The format function cannot do the '%.*f' syntax.
|
||||||
String textbuf;
|
String textbuf;
|
||||||
|
@ -1211,3 +1211,56 @@ class OptionMenuItemNumberField : OptionMenuFieldBase
|
||||||
float mStep;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue