4 #include "../item/checkbox.qc"
5 CLASS(XonoticCheckBox, CheckBox)
6 METHOD(XonoticCheckBox, configureXonoticCheckBox, void(entity, float, float, string, string, string));
7 METHOD(XonoticCheckBox, setChecked, void(entity, float));
8 ATTRIB(XonoticCheckBox, fontSize, float, SKINFONTSIZE_NORMAL)
9 ATTRIB(XonoticCheckBox, image, string, SKINGFX_CHECKBOX)
10 ATTRIB(XonoticCheckBox, yesValue, float, 1)
11 ATTRIB(XonoticCheckBox, noValue, float, 0)
13 ATTRIB(XonoticCheckBox, color, vector, SKINCOLOR_CHECKBOX_N)
14 ATTRIB(XonoticCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C)
15 ATTRIB(XonoticCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F)
16 ATTRIB(XonoticCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D)
18 ATTRIB(XonoticCheckBox, cvarName, string, string_null)
19 METHOD(XonoticCheckBox, loadCvars, void(entity));
20 METHOD(XonoticCheckBox, saveCvars, void(entity));
21 ATTRIB(XonoticCheckBox, sendCvars, float, 0)
23 ATTRIB(XonoticCheckBox, alpha, float, SKINALPHA_TEXT)
24 ATTRIB(XonoticCheckBox, disabledAlpha, float, SKINALPHA_DISABLED)
25 ENDCLASS(XonoticCheckBox)
26 entity makeXonoticCheckBox_T(float, string, string, string);
27 entity makeXonoticCheckBox(float, string, string);
28 entity makeXonoticCheckBoxEx_T(float, float, string, string, string);
29 entity makeXonoticCheckBoxEx(float, float, string, string);
33 entity makeXonoticCheckBox_T(float isInverted, string theCvar, string theText, string theTooltip)
41 else if(isInverted < -1)
46 else if(isInverted == 1)
56 return makeXonoticCheckBoxEx_T(y, n, theCvar, theText, theTooltip);
58 entity makeXonoticCheckBox(float isInverted, string theCvar, string theText)
60 return makeXonoticCheckBox_T(isInverted, theCvar, theText, string_null);
63 entity makeXonoticCheckBoxEx_T(float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip)
66 me = NEW(XonoticCheckBox);
67 me.configureXonoticCheckBox(me, theYesValue, theNoValue, theCvar, theText, theTooltip);
70 entity makeXonoticCheckBoxEx(float theYesValue, float theNoValue, string theCvar, string theText)
72 return makeXonoticCheckBoxEx_T(theYesValue, theNoValue, theCvar, theText, string_null);
75 void XonoticCheckBox_configureXonoticCheckBox(entity me, float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip)
77 me.yesValue = theYesValue;
78 me.noValue = theNoValue;
80 me.cvarName = (theCvar) ? theCvar : string_null;
82 setZonedTooltip(me, theTooltip, theCvar);
83 me.configureCheckBox(me, theText, me.fontSize, me.image);
85 void XonoticCheckBox_setChecked(entity me, float val)
93 void XonoticCheckBox_loadCvars(entity me)
100 m = (me.yesValue + me.noValue) * 0.5;
101 d = (cvar(me.cvarName) - m) / (me.yesValue - m);
102 me.checked = (d > 0);
104 void XonoticCheckBox_saveCvars(entity me)
110 cvar_set(me.cvarName, ftos(me.yesValue));
112 cvar_set(me.cvarName, ftos(me.noValue));
114 CheckSendCvars(me, me.cvarName);