]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu-div0test/nexuiz/checkbox.c
add map info dialog
[divverent/nexuiz.git] / data / qcsrc / menu-div0test / nexuiz / checkbox.c
1 #ifdef INTERFACE
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
9         ATTRIB(NexuizCheckBox, color, vector, SKINCOLOR_CHECKBOX_N)
10         ATTRIB(NexuizCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C)
11         ATTRIB(NexuizCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F)
12         ATTRIB(NexuizCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D)
13
14         ATTRIB(NexuizCheckBox, cvarName, string, string_null)
15         METHOD(NexuizCheckBox, loadCvars, void(entity))
16         METHOD(NexuizCheckBox, saveCvars, void(entity))
17
18         ATTRIB(NexuizCheckBox, disabledAlpha, float, SKINALPHA_DISABLED)
19 ENDCLASS(NexuizCheckBox)
20 entity makeNexuizCheckBox(float, string, string);
21 #endif
22
23 #ifdef IMPLEMENTATION
24 entity makeNexuizCheckBox(float isInverted, string theCvar, string theText)
25 {
26         entity me;
27         me = spawnNexuizCheckBox();
28         me.configureNexuizCheckBox(me, isInverted, theCvar, theText);
29         return me;
30 }
31 void configureNexuizCheckBoxNexuizCheckBox(entity me, float isInverted, string theCvar, string theText)
32 {
33         me.inverted = isInverted;
34         me.checked = 0;
35         if(theCvar)
36         {
37                 me.cvarName = theCvar;
38                 me.loadCvars(me);
39         }
40         me.configureCheckBox(me, theText, me.fontSize, me.image);
41 }
42 void setCheckedNexuizCheckBox(entity me, float val)
43 {
44         if(val != me.checked)
45         {
46                 me.checked = val;
47                 me.saveCvars(me);
48         }
49 }
50 void loadCvarsNexuizCheckBox(entity me)
51 {
52         me.checked = me.inverted - !!cvar(me.cvarName);
53 }
54 void saveCvarsNexuizCheckBox(entity me)
55 {
56         cvar_set(me.cvarName, ftos(fabs(me.inverted - me.checked)));
57 }
58 #endif