3 #include "../item/checkbox.qc"
4 CLASS(XonoticCheckBox, CheckBox)
5 METHOD(XonoticCheckBox, configureXonoticCheckBox, void(entity, float, float, 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(float, string, string);
26 entity makeXonoticCheckBoxEx(float, float, string, string);
30 entity makeXonoticCheckBox(float isInverted, string theCvar, string theText)
38 else if(isInverted < -1)
43 else if(isInverted == 1)
53 return makeXonoticCheckBoxEx(y, n, theCvar, theText);
55 entity makeXonoticCheckBoxEx(float theYesValue, float theNoValue, string theCvar, string theText)
58 me = NEW(XonoticCheckBox);
59 me.configureXonoticCheckBox(me, theYesValue, theNoValue, theCvar, theText);
62 void XonoticCheckBox_configureXonoticCheckBox(entity me, float theYesValue, float theNoValue, string theCvar, string theText)
64 me.yesValue = theYesValue;
65 me.noValue = theNoValue;
69 me.cvarName = theCvar;
70 me.tooltip = getZonedTooltipForIdentifier(theCvar);
73 me.configureCheckBox(me, theText, me.fontSize, me.image);
75 void XonoticCheckBox_setChecked(entity me, float val)
83 void XonoticCheckBox_loadCvars(entity me)
90 m = (me.yesValue + me.noValue) * 0.5;
91 d = (cvar(me.cvarName) - m) / (me.yesValue - m);
94 void XonoticCheckBox_saveCvars(entity me)
100 cvar_set(me.cvarName, ftos(me.yesValue));
102 cvar_set(me.cvarName, ftos(me.noValue));
104 CheckSendCvars(me, me.cvarName);