mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 04:01:31 +00:00
Implemented mGrayCheck and isGrayed() in OptionMenuItem
This commit is contained in:
parent
cebf37b3fa
commit
f8653c36d0
1 changed files with 22 additions and 41 deletions
|
@ -36,12 +36,14 @@ class OptionMenuItem : MenuItemBase
|
||||||
{
|
{
|
||||||
String mLabel;
|
String mLabel;
|
||||||
bool mCentered;
|
bool mCentered;
|
||||||
|
CVar mGrayCheck;
|
||||||
|
|
||||||
protected void Init(String label, String command, bool center = false)
|
protected void Init(String label, String command, bool center = false, CVar graycheck = null)
|
||||||
{
|
{
|
||||||
Super.Init(0, 0, command);
|
Super.Init(0, 0, command);
|
||||||
mLabel = label;
|
mLabel = label;
|
||||||
mCentered = center;
|
mCentered = center;
|
||||||
|
mGrayCheck = graycheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawText(int x, int y, int color, String text, bool grayed = false)
|
protected void drawText(int x, int y, int color, String text, bool grayed = false)
|
||||||
|
@ -66,12 +68,16 @@ class OptionMenuItem : MenuItemBase
|
||||||
Menu.DrawOptionText(indent + CursorSpace(), y, color, text, grayed, localize);
|
Menu.DrawOptionText(indent + CursorSpace(), y, color, text, grayed, localize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CursorSpace()
|
int CursorSpace()
|
||||||
{
|
{
|
||||||
return (14 * CleanXfac_1);
|
return (14 * CleanXfac_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool IsGrayed()
|
||||||
|
{
|
||||||
|
return mGrayCheck != null && !mGrayCheck.GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
override bool Selectable()
|
override bool Selectable()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -85,7 +91,7 @@ class OptionMenuItem : MenuItemBase
|
||||||
}
|
}
|
||||||
|
|
||||||
override bool MouseEvent(int type, int x, int y)
|
override bool MouseEvent(int type, int x, int y)
|
||||||
{
|
{
|
||||||
if (Selectable() && type == Menu.MOUSE_Release)
|
if (Selectable() && type == Menu.MOUSE_Release)
|
||||||
{
|
{
|
||||||
return Menu.GetCurrentMenu().MenuEvent(Menu.MKEY_Enter, true);
|
return Menu.GetCurrentMenu().MenuEvent(Menu.MKEY_Enter, true);
|
||||||
|
@ -253,16 +259,14 @@ class OptionMenuItemOptionBase : OptionMenuItem
|
||||||
{
|
{
|
||||||
// command is a CVAR
|
// command is a CVAR
|
||||||
Name mValues; // Entry in OptionValues table
|
Name mValues; // Entry in OptionValues table
|
||||||
CVar mGrayCheck;
|
|
||||||
int mCenter;
|
int mCenter;
|
||||||
|
|
||||||
const OP_VALUES = 0x11001;
|
const OP_VALUES = 0x11001;
|
||||||
|
|
||||||
protected void Init(String label, Name command, Name values, CVar graycheck, int center)
|
protected void Init(String label, Name command, Name values, CVar graycheck, int center)
|
||||||
{
|
{
|
||||||
Super.Init(label, command);
|
Super.Init(label, command, false, graycheck);
|
||||||
mValues = values;
|
mValues = values;
|
||||||
mGrayCheck = graycheck;
|
|
||||||
mCenter = center;
|
mCenter = center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,11 +343,6 @@ class OptionMenuItemOptionBase : OptionMenuItem
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isGrayed()
|
|
||||||
{
|
|
||||||
return mGrayCheck != null && !mGrayCheck.GetInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
override bool Selectable()
|
override bool Selectable()
|
||||||
{
|
{
|
||||||
return !isGrayed();
|
return !isGrayed();
|
||||||
|
@ -699,18 +698,16 @@ 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', CVar graycheck = NULL)
|
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, false, graycheck);
|
||||||
mMin = min;
|
mMin = min;
|
||||||
mMax = max;
|
mMax = max;
|
||||||
mStep = step;
|
mStep = step;
|
||||||
mShowValue = showval;
|
mShowValue = showval;
|
||||||
mDrawX = 0;
|
mDrawX = 0;
|
||||||
mSliderShort = 0;
|
mSliderShort = 0;
|
||||||
mGrayCheck = graycheck;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual double GetSliderValue()
|
virtual double GetSliderValue()
|
||||||
|
@ -722,11 +719,6 @@ class OptionMenuSliderBase : OptionMenuItem
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool IsGrayed(void)
|
|
||||||
{
|
|
||||||
return mGrayCheck != NULL && !mGrayCheck.GetInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
override bool Selectable(void)
|
override bool Selectable(void)
|
||||||
{
|
{
|
||||||
return !IsGrayed();
|
return !IsGrayed();
|
||||||
|
@ -900,17 +892,15 @@ class OptionMenuItemSlider : OptionMenuSliderBase
|
||||||
class OptionMenuItemColorPicker : OptionMenuItem
|
class OptionMenuItemColorPicker : OptionMenuItem
|
||||||
{
|
{
|
||||||
CVar mCVar;
|
CVar mCVar;
|
||||||
CVar mGrayCheck;
|
|
||||||
|
|
||||||
const CPF_RESET = 0x20001;
|
const CPF_RESET = 0x20001;
|
||||||
|
|
||||||
OptionMenuItemColorPicker Init(String label, Name command, CVar graycheck = null)
|
OptionMenuItemColorPicker Init(String label, Name command, CVar graycheck = null)
|
||||||
{
|
{
|
||||||
Super.Init(label, command);
|
Super.Init(label, command, false, graycheck);
|
||||||
CVar cv = CVar.FindCVar(command);
|
CVar cv = CVar.FindCVar(command);
|
||||||
if (cv != null && cv.GetRealType() != CVar.CVAR_Color) cv = null;
|
if (cv != null && cv.GetRealType() != CVar.CVAR_Color) cv = null;
|
||||||
mCVar = cv;
|
mCVar = cv;
|
||||||
mGrayCheck = graycheck;
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,11 +956,6 @@ class OptionMenuItemColorPicker : OptionMenuItem
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool IsGrayed(void)
|
|
||||||
{
|
|
||||||
return mGrayCheck != NULL && !mGrayCheck.GetInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
override bool Selectable()
|
override bool Selectable()
|
||||||
{
|
{
|
||||||
return !isGrayed();
|
return !isGrayed();
|
||||||
|
@ -987,11 +972,12 @@ class OptionMenuItemColorPicker : OptionMenuItem
|
||||||
|
|
||||||
class OptionMenuFieldBase : OptionMenuItem
|
class OptionMenuFieldBase : OptionMenuItem
|
||||||
{
|
{
|
||||||
|
CVar mCVar;
|
||||||
|
|
||||||
void Init (String label, Name command, CVar graycheck = null)
|
void Init (String label, Name command, CVar graycheck = null)
|
||||||
{
|
{
|
||||||
Super.Init(label, command);
|
Super.Init(label, command, false, graycheck);
|
||||||
mCVar = CVar.FindCVar(mAction);
|
mCVar = CVar.FindCVar(mAction);
|
||||||
mGrayCheck = graycheck;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String GetCVarString()
|
String GetCVarString()
|
||||||
|
@ -1009,9 +995,8 @@ class OptionMenuFieldBase : OptionMenuItem
|
||||||
|
|
||||||
override int Draw (OptionMenuDescriptor d, int y, int indent, bool selected)
|
override int Draw (OptionMenuDescriptor d, int y, int indent, bool selected)
|
||||||
{
|
{
|
||||||
bool grayed = mGrayCheck != null && !mGrayCheck.GetInt();
|
drawLabel(indent, y, selected ? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, isGrayed());
|
||||||
drawLabel(indent, y, selected ? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, grayed);
|
drawValue(indent, y, OptionMenuSettings.mFontColorValue, Represent(), isGrayed(), false);
|
||||||
drawValue(indent, y, OptionMenuSettings.mFontColorValue, Represent(), grayed, false);
|
|
||||||
return indent;
|
return indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,11 +1021,8 @@ class OptionMenuFieldBase : OptionMenuItem
|
||||||
|
|
||||||
override bool Selectable()
|
override bool Selectable()
|
||||||
{
|
{
|
||||||
return mGrayCheck == null || mGrayCheck.GetInt() != 0;
|
return !isGrayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
CVar mCVar;
|
|
||||||
CVar mGrayCheck;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
@ -1142,7 +1124,6 @@ class OptionMenuItemNumberField : OptionMenuFieldBase
|
||||||
return String.format("%.3f", mCVar.GetFloat());
|
return String.format("%.3f", mCVar.GetFloat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override bool MenuEvent (int mkey, bool fromcontroller)
|
override bool MenuEvent (int mkey, bool fromcontroller)
|
||||||
{
|
{
|
||||||
if (mCVar)
|
if (mCVar)
|
||||||
|
@ -1188,9 +1169,9 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
|
||||||
String TextNegOne;
|
String TextNegOne;
|
||||||
int mClickVal;
|
int mClickVal;
|
||||||
|
|
||||||
OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "")
|
OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "", CVar graycheck = null)
|
||||||
{
|
{
|
||||||
Super.Init(label, command, min, max, step, 0);
|
Super.Init(label, command, min, max, step, 0, graycheck);
|
||||||
mCVar =CVar.FindCVar(command);
|
mCVar =CVar.FindCVar(command);
|
||||||
TextZero = zero;
|
TextZero = zero;
|
||||||
TextNEgOne = negone;
|
TextNEgOne = negone;
|
||||||
|
@ -1207,12 +1188,12 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
|
||||||
if ((Selection == 0 || Selection == -1) && mClickVal <= 0)
|
if ((Selection == 0 || Selection == -1) && mClickVal <= 0)
|
||||||
{
|
{
|
||||||
String text = Selection == 0? TextZero : Selection == -1? TextNegOne : "";
|
String text = Selection == 0? TextZero : Selection == -1? TextNegOne : "";
|
||||||
drawValue(indent, y, OptionMenuSettings.mFontColorValue, text);
|
drawValue(indent, y, OptionMenuSettings.mFontColorValue, text, isGrayed());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue