]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu-div0test/nexuiz/radiobutton.c
fix selection bugs when enabling/disabling the checkboxes
[divverent/nexuiz.git] / data / qcsrc / menu-div0test / nexuiz / radiobutton.c
1 #ifdef INTERFACE
2 CLASS(NexuizRadioButton) EXTENDS(RadioButton)
3         METHOD(NexuizRadioButton, configureNexuizRadioButton, void(entity, float, string, string, string))
4         METHOD(NexuizRadioButton, setChecked, void(entity, float))
5         ATTRIB(NexuizRadioButton, fontSize, float, SKINFONTSIZE_NORMAL)
6         ATTRIB(NexuizRadioButton, image, string, SKINGFX_RADIOBUTTON)
7
8         ATTRIB(NexuizRadioButton, cvarName, string, string_null)
9         ATTRIB(NexuizRadioButton, cvarValue, string, string_null)
10         METHOD(NexuizRadioButton, loadCvars, void(entity))
11         METHOD(NexuizRadioButton, saveCvars, void(entity))
12 ENDCLASS(NexuizRadioButton)
13 entity makeNexuizRadioButton(float, string, string, string);
14 #endif
15
16 #ifdef IMPLEMENTATION
17 entity makeNexuizRadioButton(float theGroup, string theCvar, string theValue, string theText)
18 {
19         entity me;
20         me = spawnNexuizRadioButton();
21         me.configureNexuizRadioButton(me, theGroup, theCvar, theValue, theText);
22         return me;
23 }
24 void configureNexuizRadioButtonNexuizRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText)
25 {
26         if(theCvar)
27         {
28                 me.cvarName = theCvar;
29                 me.cvarValue = theValue;
30                 me.loadCvars(me);
31         }
32         me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
33 }
34 void setCheckedNexuizRadioButton(entity me, float val)
35 {
36         if(val != me.checked)
37         {
38                 me.checked = val;
39                 me.saveCvars(me);
40         }
41 }
42 void loadCvarsNexuizRadioButton(entity me)
43 {
44         me.checked = (cvar_string(me.cvarName) == me.cvarValue);
45 }
46 void saveCvarsNexuizRadioButton(entity me)
47 {
48         if(me.checked)
49                 cvar_set(me.cvarName, me.cvarValue);
50 }
51 #endif