#ifdef INTERFACE CLASS(VoretCheckBox) EXTENDS(CheckBox) METHOD(VoretCheckBox, configureVoretCheckBox, void(entity, float, float, string, string)) METHOD(VoretCheckBox, setChecked, void(entity, float)) ATTRIB(VoretCheckBox, fontSize, float, SKINFONTSIZE_NORMAL) ATTRIB(VoretCheckBox, image, string, SKINGFX_CHECKBOX) ATTRIB(VoretCheckBox, yesValue, float, 1) ATTRIB(VoretCheckBox, noValue, float, 0) ATTRIB(VoretCheckBox, color, vector, SKINCOLOR_CHECKBOX_N) ATTRIB(VoretCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C) ATTRIB(VoretCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F) ATTRIB(VoretCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D) ATTRIB(VoretCheckBox, cvarName, string, string_null) METHOD(VoretCheckBox, loadCvars, void(entity)) METHOD(VoretCheckBox, saveCvars, void(entity)) ATTRIB(VoretCheckBox, alpha, float, SKINALPHA_TEXT) ATTRIB(VoretCheckBox, disabledAlpha, float, SKINALPHA_DISABLED) ENDCLASS(VoretCheckBox) entity makeVoretCheckBox(float, string, string); entity makeVoretCheckBoxEx(float, float, string, string); #endif #ifdef IMPLEMENTATION entity makeVoretCheckBox(float isInverted, string theCvar, string theText) { float y, n; if(isInverted > 1) { n = isInverted - 1; y = -n; } else if(isInverted < -1) { n = isInverted + 1; y = -n; } else if(isInverted == 1) { n = 1; y = 0; } else { n = 0; y = 1; } return makeVoretCheckBoxEx(y, n, theCvar, theText); } entity makeVoretCheckBoxEx(float theYesValue, float theNoValue, string theCvar, string theText) { entity me; me = spawnVoretCheckBox(); me.configureVoretCheckBox(me, theYesValue, theNoValue, theCvar, theText); return me; } void configureVoretCheckBoxVoretCheckBox(entity me, float theYesValue, float theNoValue, string theCvar, string theText) { me.yesValue = theYesValue; me.noValue = theNoValue; me.checked = 0; if(theCvar) { me.cvarName = theCvar; me.tooltip = getZonedTooltipForIdentifier(theCvar); me.loadCvars(me); } me.configureCheckBox(me, theText, me.fontSize, me.image); } void setCheckedVoretCheckBox(entity me, float val) { if(val != me.checked) { me.checked = val; me.saveCvars(me); } } void loadCvarsVoretCheckBox(entity me) { float m, d; if not(me.cvarName) return; m = (me.yesValue + me.noValue) * 0.5; d = (cvar(me.cvarName) - m) / (me.yesValue - m); me.checked = (d > 0); } void saveCvarsVoretCheckBox(entity me) { if not(me.cvarName) return; if(me.checked) cvar_set(me.cvarName, ftos(me.yesValue)); else cvar_set(me.cvarName, ftos(me.noValue)); } #endif