mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-17 17:11:19 +00:00
Add grayed-out support to sliders
This commit is contained in:
parent
e2e176e0be
commit
f467e4bc33
1 changed files with 26 additions and 13 deletions
|
@ -699,8 +699,9 @@ class OptionMenuSliderBase : OptionMenuItem
|
||||||
int mShowValue;
|
int mShowValue;
|
||||||
int mDrawX;
|
int mDrawX;
|
||||||
int mSliderShort;
|
int mSliderShort;
|
||||||
|
CVar mGrayCheck;
|
||||||
|
|
||||||
protected void Init(String label, double min, double max, double step, int showval, Name command = 'none')
|
protected void Init(String label, double min, double max, double step, int showval, Name command = 'none', CVar graycheck = NULL)
|
||||||
{
|
{
|
||||||
Super.Init(label, command);
|
Super.Init(label, command);
|
||||||
mMin = min;
|
mMin = min;
|
||||||
|
@ -709,6 +710,7 @@ class OptionMenuSliderBase : OptionMenuItem
|
||||||
mShowValue = showval;
|
mShowValue = showval;
|
||||||
mDrawX = 0;
|
mDrawX = 0;
|
||||||
mSliderShort = 0;
|
mSliderShort = 0;
|
||||||
|
mGrayCheck = graycheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual double GetSliderValue()
|
virtual double GetSliderValue()
|
||||||
|
@ -720,18 +722,29 @@ class OptionMenuSliderBase : OptionMenuItem
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsGrayed(void)
|
||||||
|
{
|
||||||
|
return mGrayCheck != NULL && !mGrayCheck.GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
override bool Selectable(void)
|
||||||
|
{
|
||||||
|
return !IsGrayed();
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
// Draw a slider. Set fracdigits negative to not display the current value numerically.
|
// Draw a slider. Set fracdigits negative to not display the current value numerically.
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
private void DrawSliderElement (int color, int x, int y, String str)
|
private void DrawSliderElement (int color, int x, int y, String str, bool grayed = false)
|
||||||
{
|
{
|
||||||
screen.DrawText (ConFont, color, x, y, str, DTA_CellX, 16 * CleanXfac_1, DTA_CellY, 16 * CleanYfac_1);
|
int overlay = grayed? Color(96, 48, 0, 0) : 0;
|
||||||
|
screen.DrawText (ConFont, color, x, y, str, DTA_CellX, 16 * CleanXfac_1, DTA_CellY, 16 * CleanYfac_1, DTA_ColorOverlay, overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected 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, bool grayed = false)
|
||||||
{
|
{
|
||||||
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;
|
||||||
|
@ -753,21 +766,21 @@ class OptionMenuSliderBase : OptionMenuItem
|
||||||
|
|
||||||
if (!mSliderShort)
|
if (!mSliderShort)
|
||||||
{
|
{
|
||||||
DrawSliderElement(Font.CR_WHITE, x, cy, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12");
|
DrawSliderElement(Font.CR_WHITE, x, cy, "\x10\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x12", grayed);
|
||||||
DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 78) / range)) * 2 * CleanXfac_1), cy, "\x13");
|
DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 78) / range)) * 2 * CleanXfac_1), cy, "\x13", grayed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// On 320x200 we need a shorter slider
|
// On 320x200 we need a shorter slider
|
||||||
DrawSliderElement(Font.CR_WHITE, x, cy, "\x10\x11\x11\x11\x11\x11\x12");
|
DrawSliderElement(Font.CR_WHITE, x, cy, "\x10\x11\x11\x11\x11\x11\x12", grayed);
|
||||||
DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 38) / range)) * 2 * CleanXfac_1), cy, "\x13");
|
DrawSliderElement(Font.FindFontColor(gameinfo.mSliderColor), x + int((5 + ((ccur * 38) / range)) * 2 * CleanXfac_1), cy, "\x13", grayed);
|
||||||
right -= 5*8*CleanXfac;
|
right -= 5*8*CleanXfac;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fracdigits >= 0 && right + maxlen <= screen.GetWidth())
|
if (fracdigits >= 0 && right + maxlen <= screen.GetWidth())
|
||||||
{
|
{
|
||||||
textbuf = String.format(formater, cur);
|
textbuf = String.format(formater, cur);
|
||||||
drawText(right, y, Font.CR_DARKGRAY, textbuf);
|
drawText(right, y, Font.CR_DARKGRAY, textbuf, grayed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,9 +788,9 @@ class OptionMenuSliderBase : OptionMenuItem
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
|
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
|
||||||
{
|
{
|
||||||
drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor);
|
drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, IsGrayed());
|
||||||
mDrawX = indent + CursorSpace();
|
mDrawX = indent + CursorSpace();
|
||||||
DrawSlider (mDrawX, y, mMin, mMax, GetSliderValue(), mShowValue, indent);
|
DrawSlider (mDrawX, y, mMin, mMax, GetSliderValue(), mShowValue, indent, IsGrayed());
|
||||||
return indent;
|
return indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -850,9 +863,9 @@ class OptionMenuItemSlider : OptionMenuSliderBase
|
||||||
{
|
{
|
||||||
CVar mCVar;
|
CVar mCVar;
|
||||||
|
|
||||||
OptionMenuItemSlider Init(String label, Name command, double min, double max, double step, int showval = 1)
|
OptionMenuItemSlider Init(String label, Name command, double min, double max, double step, int showval = 1, CVar graycheck = NULL)
|
||||||
{
|
{
|
||||||
Super.Init(label, min, max, step, showval, command);
|
Super.Init(label, min, max, step, showval, command, graycheck);
|
||||||
mCVar =CVar.FindCVar(command);
|
mCVar =CVar.FindCVar(command);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue