2 CLASS(NexuizCheckBox) EXTENDS(CheckBox)
3 METHOD(NexuizCheckBox, configureNexuizCheckBox, void(entity, float, string, string))
4 METHOD(NexuizCheckBox, setChecked, void(entity, float))
5 ATTRIB(NexuizCheckBox, fontSize, float, SKINFONTSIZE_NORMAL)
6 ATTRIB(NexuizCheckBox, image, string, SKINGFX_CHECKBOX)
7 ATTRIB(NexuizCheckBox, inverted, float, 0)
8 // can be: 0 (off = 0, on = 1)
10 // 1+a (off = a, on = -a)
11 // -1-a (off = -a, on = a)
13 ATTRIB(NexuizCheckBox, color, vector, SKINCOLOR_CHECKBOX_N)
14 ATTRIB(NexuizCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C)
15 ATTRIB(NexuizCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F)
16 ATTRIB(NexuizCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D)
18 ATTRIB(NexuizCheckBox, cvarName, string, string_null)
19 METHOD(NexuizCheckBox, loadCvars, void(entity))
20 METHOD(NexuizCheckBox, saveCvars, void(entity))
22 ATTRIB(NexuizCheckBox, disabledAlpha, float, SKINALPHA_DISABLED)
23 ENDCLASS(NexuizCheckBox)
24 entity makeNexuizCheckBox(float, string, string);
28 entity makeNexuizCheckBox(float isInverted, string theCvar, string theText)
31 me = spawnNexuizCheckBox();
32 me.configureNexuizCheckBox(me, isInverted, theCvar, theText);
35 void configureNexuizCheckBoxNexuizCheckBox(entity me, float isInverted, string theCvar, string theText)
37 me.inverted = isInverted;
41 me.cvarName = theCvar;
44 me.configureCheckBox(me, theText, me.fontSize, me.image);
46 void setCheckedNexuizCheckBox(entity me, float val)
54 void loadCvarsNexuizCheckBox(entity me)
57 me.checked = cvar(me.cvarName);
58 else if(me.inverted == 1)
59 me.checked = !cvar(me.cvarName);
60 else if(me.inverted > 1)
61 me.checked = (cvar(me.cvarName) < 0);
62 else if(me.inverted < -1)
63 me.checked = (cvar(me.cvarName) > 0);
65 void saveCvarsNexuizCheckBox(entity me)
68 cvar_set(me.cvarName, me.checked ? "1" : "0");
69 else if(me.inverted == 1)
70 cvar_set(me.cvarName, me.checked ? "0" : "1");
71 else if(me.inverted > 1)
74 cvar_set(me.cvarName, ftos(-(me.inverted - 1)));
76 cvar_set(me.cvarName, ftos(+(me.inverted - 1)));
78 else if(me.inverted < -1)
81 cvar_set(me.cvarName, ftos(-(me.inverted + 1)));
83 cvar_set(me.cvarName, ftos(+(me.inverted + 1)));