Add graycheck to colorpicker

This commit is contained in:
jekyllgrim 2023-12-30 03:11:56 +03:00 committed by Christoph Oelckers
parent 4273af8004
commit cebf37b3fa

View file

@ -900,22 +900,24 @@ class OptionMenuItemSlider : OptionMenuSliderBase
class OptionMenuItemColorPicker : OptionMenuItem
{
CVar mCVar;
CVar mGrayCheck;
const CPF_RESET = 0x20001;
OptionMenuItemColorPicker Init(String label, Name command)
OptionMenuItemColorPicker Init(String label, Name command, CVar graycheck = null)
{
Super.Init(label, command);
CVar cv = CVar.FindCVar(command);
if (cv != null && cv.GetRealType() != CVar.CVAR_Color) cv = null;
mCVar = cv;
mGrayCheck = graycheck;
return self;
}
//=============================================================================
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());
if (mCVar != null)
{
@ -963,6 +965,16 @@ class OptionMenuItemColorPicker : OptionMenuItem
}
return false;
}
virtual bool IsGrayed(void)
{
return mGrayCheck != NULL && !mGrayCheck.GetInt();
}
override bool Selectable()
{
return !isGrayed();
}
}
//=============================================================================