3 #include "../item/checkbox.qc"
4 CLASS(XonoticCheckBox, CheckBox)
5 METHOD(XonoticCheckBox, configureXonoticCheckBox, void(entity, float, float, string, string, string));
6 METHOD(XonoticCheckBox, setChecked, void(entity, float));
7 ATTRIB(XonoticCheckBox, fontSize, float, SKINFONTSIZE_NORMAL)
8 ATTRIB(XonoticCheckBox, image, string, SKINGFX_CHECKBOX)
9 ATTRIB(XonoticCheckBox, yesValue, float, 1)
10 ATTRIB(XonoticCheckBox, noValue, float, 0)
12 ATTRIB(XonoticCheckBox, color, vector, SKINCOLOR_CHECKBOX_N)
13 ATTRIB(XonoticCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C)
14 ATTRIB(XonoticCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F)
15 ATTRIB(XonoticCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D)
17 ATTRIB(XonoticCheckBox, cvarName, string, string_null)
18 METHOD(XonoticCheckBox, loadCvars, void(entity));
19 METHOD(XonoticCheckBox, saveCvars, void(entity));
20 ATTRIB(XonoticCheckBox, sendCvars, float, 0)
22 ATTRIB(XonoticCheckBox, alpha, float, SKINALPHA_TEXT)
23 ATTRIB(XonoticCheckBox, disabledAlpha, float, SKINALPHA_DISABLED)
24 ENDCLASS(XonoticCheckBox)
25 entity makeXonoticCheckBox_T(float, string, string, string);
26 entity makeXonoticCheckBox(float, string, string);
27 entity makeXonoticCheckBoxEx_T(float, float, string, string, string);
28 entity makeXonoticCheckBoxEx(float, float, string, string);
32 entity makeXonoticCheckBox_T(float isInverted, string theCvar, string theText, string theTooltip)
40 else if(isInverted < -1)
45 else if(isInverted == 1)
55 return makeXonoticCheckBoxEx_T(y, n, theCvar, theText, theTooltip);
57 entity makeXonoticCheckBox(float isInverted, string theCvar, string theText)
59 return makeXonoticCheckBox_T(isInverted, theCvar, theText, string_null);
62 entity makeXonoticCheckBoxEx_T(float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip)
65 me = NEW(XonoticCheckBox);
66 me.configureXonoticCheckBox(me, theYesValue, theNoValue, theCvar, theText, theTooltip);
69 entity makeXonoticCheckBoxEx(float theYesValue, float theNoValue, string theCvar, string theText)
71 return makeXonoticCheckBoxEx_T(theYesValue, theNoValue, theCvar, theText, string_null);
74 void XonoticCheckBox_configureXonoticCheckBox(entity me, float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip)
76 me.yesValue = theYesValue;
77 me.noValue = theNoValue;
79 me.cvarName = (theCvar) ? theCvar : string_null;
81 setZonedTooltip(me, theTooltip, theCvar);
82 me.configureCheckBox(me, theText, me.fontSize, me.image);
84 void XonoticCheckBox_setChecked(entity me, float val)
92 void XonoticCheckBox_loadCvars(entity me)
99 m = (me.yesValue + me.noValue) * 0.5;
100 d = (cvar(me.cvarName) - m) / (me.yesValue - m);
101 me.checked = (d > 0);
103 void XonoticCheckBox_saveCvars(entity me)
109 cvar_set(me.cvarName, ftos(me.yesValue));
111 cvar_set(me.cvarName, ftos(me.noValue));
113 CheckSendCvars(me, me.cvarName);