Skip to content

Commit

Permalink
Add graycheck to colorpicker
Browse files Browse the repository at this point in the history
  • Loading branch information
jekyllgrim authored and coelckers committed Dec 30, 2023
1 parent 4273af8 commit cebf37b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -963,6 +965,16 @@ class OptionMenuItemColorPicker : OptionMenuItem
}
return false;
}

virtual bool IsGrayed(void)
{
return mGrayCheck != NULL && !mGrayCheck.GetInt();
}

override bool Selectable()
{
return !isGrayed();
}
}

//=============================================================================
Expand Down

0 comments on commit cebf37b

Please sign in to comment.